refactor: remove bs58 dependency and use solana_sdk program ID constants

- Remove standalone bs58 dependency and rely on the solana_sdk re-export
- Switch system and token program IDs to the idiomatic spl_token / solana_sdk constants
- Use pubkey! and LazyLock for cleaner program ID initialization
- Alias solana_entry::Entry as SolanaEntry to avoid a naming conflict with gRPC types
- Remove unused FromStr imports and some redundant logic
This commit is contained in:
Estereg
2026-03-08 16:47:09 +00:00
parent 8469b7eec5
commit dad231a26b
4 changed files with 8 additions and 11 deletions
-1
View File
@@ -24,7 +24,6 @@ serde-big-array = "0.5.1"
futures = "0.3.32"
bincode = "1.3"
anyhow = "1.0.102"
bs58 = "0.5.1"
yellowstone-grpc-client = { version = "10.2.0" }
yellowstone-grpc-proto = { version = "10.1.1" }
tokio = { version = "1.50.0", features = ["full", "rt-multi-thread"]}
+5 -7
View File
@@ -2,7 +2,7 @@ use borsh::{BorshDeserialize, BorshSerialize};
use crossbeam_queue::ArrayQueue;
use serde::{Deserialize, Serialize};
use solana_sdk::{pubkey::Pubkey, signature::Signature};
use std::{borrow::Cow, fmt, str::FromStr, sync::Arc};
use std::{borrow::Cow, fmt, sync::Arc};
use crate::streaming::event_parser::DexEvent;
@@ -169,8 +169,6 @@ impl fmt::Display for EventType {
}
}
#[derive(
Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize, BorshSerialize, BorshDeserialize,
)]
@@ -243,11 +241,11 @@ impl EventMetadata {
}
static SOL_MINT: std::sync::LazyLock<Pubkey> =
std::sync::LazyLock::new(|| Pubkey::from_str("So11111111111111111111111111111111111111111").unwrap());
std::sync::LazyLock::new(spl_token::native_mint::id);
static SYSTEM_PROGRAMS: std::sync::LazyLock<[Pubkey; 3]> = std::sync::LazyLock::new(|| [
Pubkey::from_str("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA").unwrap(),
Pubkey::from_str("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb").unwrap(),
Pubkey::from_str("11111111111111111111111111111111").unwrap(),
spl_token::id(),
spl_token_2022::id(),
solana_sdk::pubkey!("11111111111111111111111111111111"),
]);
/// Trait abstracting over different inner-instruction types for swap data extraction
@@ -85,7 +85,7 @@ impl EventParser {
let recent_blockhash = if message.recent_blockhash.is_empty() {
None
} else {
Some(bs58::encode(&message.recent_blockhash).into_string())
Some(solana_sdk::bs58::encode(&message.recent_blockhash).into_string())
};
Self::parse_instruction_events_from_grpc_transaction(
protocols,
+2 -2
View File
@@ -12,7 +12,7 @@ use crate::streaming::event_parser::{Protocol, DexEvent};
use crate::streaming::grpc::MetricsManager;
use crate::streaming::shred::pool::factory;
use log::error;
use solana_entry::entry::Entry;
use solana_entry::entry::Entry as SolanaEntry;
use super::ShredStreamGrpc;
@@ -49,7 +49,7 @@ impl ShredStreamGrpc {
while let Some(message) = stream.next().await {
match message {
Ok(msg) => {
if let Ok(entries) = bincode::deserialize::<Vec<Entry>>(&msg.entries) {
if let Ok(entries) = bincode::deserialize::<Vec<SolanaEntry>>(&msg.entries) {
for entry in entries {
for (tx_index, transaction) in entry.transactions.iter().enumerate() {
let transaction_with_slot =