Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hopefully fix solana #469

Merged
merged 2 commits into from
Apr 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions solana/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,15 @@ impl SolanaNetwork for SolanaRpc {
type Error = SolanaRpcError;

async fn payer_balance(&self, payer: &PublicKeyBinary) -> Result<u64, Self::Error> {
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)
}
Expand Down Expand Up @@ -226,20 +230,26 @@ impl BurnProgramCache {
dc_mint: Pubkey,
dnt_mint: Pubkey,
) -> Result<Self, SolanaRpcError> {
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();
Expand Down