diff --git a/.gitignore b/.gitignore index f5782f3..79641f6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ **/target test-ledger .history -config.json \ No newline at end of file +config.json + +.idea \ No newline at end of file diff --git a/solana-geyser-plugin-scaffold/src/fb_serializers/update_types.rs b/solana-geyser-plugin-scaffold/src/fb_serializers/update_types.rs index de945a8..31d7a09 100644 --- a/solana-geyser-plugin-scaffold/src/fb_serializers/update_types.rs +++ b/solana-geyser-plugin-scaffold/src/fb_serializers/update_types.rs @@ -7,6 +7,12 @@ use solana_sdk::signature::Signature; const BPF_LOADER_WRITE_INSTRUCTION_FIRST_BYTE: u8 = 0; const BPF_UPGRADEABLE_LOADER_WRITE_INSTRUCTION_FIRST_BYTE: u8 = 1; +const NFT_KEYS: &[&str] = &[ + "BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY", + "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", +]; + pub struct AccountUpdate { /// The account's public key pub key: Pubkey, @@ -85,6 +91,14 @@ impl AccountUpdate { } } } + + pub fn is_nft_account(&self) -> bool { + if NFT_KEYS.contains(&self.key.to_string().as_str()) { + return true; + } + + NFT_KEYS.contains(&self.owner.to_string().as_str()) + } } pub struct TransactionUpdate { @@ -145,6 +159,17 @@ impl TransactionUpdate { false } + + pub fn is_nft_transaction(&self) -> bool { + let account_keys = self.transaction.message().account_keys(); + for account_key in account_keys.iter() { + if NFT_KEYS.contains(&account_key.to_string().as_str()) { + return true; + } + } + + false + } } pub struct BlockUpdate<'a> { diff --git a/solana-geyser-plugin-scaffold/src/geyser_plugin_hook.rs b/solana-geyser-plugin-scaffold/src/geyser_plugin_hook.rs index ac9c6c8..ffd376b 100644 --- a/solana-geyser-plugin-scaffold/src/geyser_plugin_hook.rs +++ b/solana-geyser-plugin-scaffold/src/geyser_plugin_hook.rs @@ -126,7 +126,10 @@ impl GeyserPlugin for GeyserPluginHook { || GeyserPluginError::AccountsUpdateError { msg: UNINIT.into() }, |inner| { let acc_update = &AccountUpdate::from_account(account, slot, is_startup)?; - // TODO: add filter by accounts from config + + if !acc_update.is_nft_account() { + return Ok(()); + } let data = serialize_account(acc_update); @@ -204,7 +207,9 @@ impl GeyserPlugin for GeyserPluginHook { return Ok(()); } - // TODO: add filter by programs from config + if !tx_update.is_nft_transaction() { + return Ok(()); + } let data = serialize_transaction(&tx_update)?;