From c6143d76fa98da72b87b41321fd4023209e2d7ff Mon Sep 17 00:00:00 2001 From: Matthew Plant Date: Tue, 18 Apr 2023 20:00:30 -0400 Subject: [PATCH 1/2] Hopefully fix solana --- solana/src/lib.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/solana/src/lib.rs b/solana/src/lib.rs index 890942958..807142360 100644 --- a/solana/src/lib.rs +++ b/solana/src/lib.rs @@ -102,11 +102,18 @@ impl SolanaNetwork for SolanaRpc { type Error = SolanaRpcError; async fn payer_balance(&self, payer: &PublicKeyBinary) -> Result { + tracing::debug!("Fetching balance for payer: {payer}"); let ddc_key = delegated_data_credits(&self.program_cache.sub_dao, payer); - let account_data = self.provider.get_account_data(&ddc_key).await?; - let mut account_data = account_data.as_ref(); - let ddc = DelegatedDataCreditsV0::try_deserialize(&mut account_data)?; - let account_data = self.provider.get_account_data(&ddc.escrow_account).await?; + tracing::debug!("DDC key: {ddc_key}"); + let (escrow_account, _) = Pubkey::find_program_address( + &[ + "escrow_dc_account".as_bytes(), + &ddc_key.to_bytes(), + ], + &data_credits::ID, + ); + tracing::debug!("escrow_account: {escrow_account}"); + let account_data = self.provider.get_account_data(&escrow_account).await?; let account_layout = spl_token::state::Account::unpack(account_data.as_slice())?; Ok(account_layout.amount) } @@ -226,20 +233,26 @@ impl BurnProgramCache { dc_mint: Pubkey, dnt_mint: Pubkey, ) -> Result { + tracing::debug!("dc_mint = {dc_mint}"); + tracing::debug!("dnt_mint = {dnt_mint}"); let (account_payer, _) = Pubkey::find_program_address(&["account_payer".as_bytes()], &data_credits::ID); + tracing::debug!("account_payer = {account_payer}"); let (data_credits, _) = Pubkey::find_program_address(&["dc".as_bytes(), dc_mint.as_ref()], &data_credits::ID); + tracing::debug!("data_credits = {data_credits}"); let (sub_dao, _) = Pubkey::find_program_address( &["sub_dao".as_bytes(), dnt_mint.as_ref()], &helium_sub_daos::ID, ); + tracing::debug!("sub_dao = {sub_dao}"); let (dao, dc_burn_authority) = { let account_data = provider.get_account_data(&sub_dao).await?; let mut account_data = account_data.as_ref(); let sub_dao = SubDaoV0::try_deserialize(&mut account_data)?; (sub_dao.dao, sub_dao.dc_burn_authority) }; + tracing::debug!("dao = {dao}"); let registrar = { let account_data = provider.get_account_data(&dao).await?; let mut account_data = account_data.as_ref(); From 3d5bb04c51edbc71c997ce0e0cd717ab0ded5a90 Mon Sep 17 00:00:00 2001 From: Matthew Plant Date: Tue, 18 Apr 2023 20:03:58 -0400 Subject: [PATCH 2/2] Fmt --- solana/src/lib.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/solana/src/lib.rs b/solana/src/lib.rs index 807142360..663c8de31 100644 --- a/solana/src/lib.rs +++ b/solana/src/lib.rs @@ -106,10 +106,7 @@ impl SolanaNetwork for SolanaRpc { let ddc_key = delegated_data_credits(&self.program_cache.sub_dao, payer); tracing::debug!("DDC key: {ddc_key}"); let (escrow_account, _) = Pubkey::find_program_address( - &[ - "escrow_dc_account".as_bytes(), - &ddc_key.to_bytes(), - ], + &["escrow_dc_account".as_bytes(), &ddc_key.to_bytes()], &data_credits::ID, ); tracing::debug!("escrow_account: {escrow_account}");