-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove program_transformers dependency on plerkle (#144)
* program_transformers: remove plerkle * refactor: use deserializers from plerkle_serialization * fix: integration tests use plerkle_serialization deserializers * fix: handle parsing compiled inner and inner instructions * refactor: switch to account and transaction info taking ownership to allow for converting from plerkle to program transformer strcuts with TryFrom * refactor: address cr and reference published crates for plerkle_serialization and blockbuster --------- Co-authored-by: Kyle Espinola <[email protected]>
- Loading branch information
Showing
17 changed files
with
614 additions
and
543 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
pub mod account_updates; | ||
pub mod ack; | ||
pub mod backfiller; | ||
pub mod config; | ||
pub mod database; | ||
pub mod error; | ||
pub mod metrics; | ||
pub mod plerkle; | ||
pub mod stream; | ||
pub mod tasks; | ||
pub mod transaction_notifications; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
use { | ||
plerkle_serialization::deserializer::*, | ||
program_transformers::{error::ProgramTransformerError, AccountInfo, TransactionInfo}, | ||
}; | ||
|
||
pub fn into_program_transformer_err(e: PlerkleDeserializerError) -> ProgramTransformerError { | ||
ProgramTransformerError::DeserializationError(e.to_string()) | ||
} | ||
|
||
#[derive(thiserror::Error, Clone, Debug)] | ||
pub enum PlerkleDeserializerError { | ||
#[error("Not found")] | ||
NotFound, | ||
#[error("Solana error: {0}")] | ||
Solana(#[from] SolanaDeserializerError), | ||
} | ||
|
||
pub struct PlerkleAccountInfo<'a>(pub plerkle_serialization::AccountInfo<'a>); | ||
|
||
impl<'a> TryFrom<PlerkleAccountInfo<'a>> for AccountInfo { | ||
type Error = PlerkleDeserializerError; | ||
|
||
fn try_from(value: PlerkleAccountInfo) -> Result<Self, Self::Error> { | ||
let account_info = value.0; | ||
|
||
Ok(Self { | ||
slot: account_info.slot(), | ||
pubkey: account_info | ||
.pubkey() | ||
.ok_or(PlerkleDeserializerError::NotFound)? | ||
.try_into()?, | ||
owner: account_info | ||
.owner() | ||
.ok_or(PlerkleDeserializerError::NotFound)? | ||
.try_into()?, | ||
data: PlerkleOptionalU8Vector(account_info.data()).try_into()?, | ||
}) | ||
} | ||
} | ||
|
||
pub struct PlerkleTransactionInfo<'a>(pub plerkle_serialization::TransactionInfo<'a>); | ||
|
||
impl<'a> TryFrom<PlerkleTransactionInfo<'a>> for TransactionInfo { | ||
type Error = PlerkleDeserializerError; | ||
|
||
fn try_from(value: PlerkleTransactionInfo<'a>) -> Result<Self, Self::Error> { | ||
let tx_info = value.0; | ||
|
||
let slot = tx_info.slot(); | ||
let signature = PlerkleOptionalStr(tx_info.signature()).try_into()?; | ||
let account_keys = PlerkleOptionalPubkeyVector(tx_info.account_keys()).try_into()?; | ||
let message_instructions = PlerkleCompiledInstructionVector( | ||
tx_info | ||
.outer_instructions() | ||
.ok_or(PlerkleDeserializerError::NotFound)?, | ||
) | ||
.try_into()?; | ||
let compiled = tx_info.compiled_inner_instructions(); | ||
let inner = tx_info.inner_instructions(); | ||
let meta_inner_instructions = if let Some(c) = compiled { | ||
PlerkleCompiledInnerInstructionVector(c).try_into() | ||
} else { | ||
PlerkleInnerInstructionsVector(inner.ok_or(PlerkleDeserializerError::NotFound)?) | ||
.try_into() | ||
}?; | ||
|
||
Ok(Self { | ||
slot, | ||
signature, | ||
account_keys, | ||
message_instructions, | ||
meta_inner_instructions, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.