From 70239ee10c68c55622fcfc0bf9520cfba74c42b7 Mon Sep 17 00:00:00 2001 From: dhruvja Date: Sun, 8 Dec 2024 14:09:57 +0530 Subject: [PATCH] check for uninitialized acc before calling the hook --- .../programs/solana-ibc/src/transfer/mod.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/solana/solana-ibc/programs/solana-ibc/src/transfer/mod.rs b/solana/solana-ibc/programs/solana-ibc/src/transfer/mod.rs index 65a54b1e..8fdac501 100644 --- a/solana/solana-ibc/programs/solana-ibc/src/transfer/mod.rs +++ b/solana/solana-ibc/programs/solana-ibc/src/transfer/mod.rs @@ -165,9 +165,22 @@ impl ibc::Module for IbcStorage<'_, '_> { if success { let store = self.borrow(); let accounts = &store.accounts.remaining_accounts; - let result = call_bridge_escrow(accounts, &maybe_ft_packet.data); - if let Err(status) = result { - ack = status.into(); + // Check if any account is not initialized and return the uninitialized account + if let Some(uninitialized_account) = + accounts.iter().find(|account| account.lamports() == 0) + { + let status = ibc::TokenTransferError::Other(format!( + "Account {} not initialized", + uninitialized_account.key + )) + .into(); + ack = ibc::AcknowledgementStatus::error(status).into(); + } else { + let result = + call_bridge_escrow(accounts, &maybe_ft_packet.data); + if let Err(status) = result { + ack = status.into(); + } } }