From a9418f595152be961c5132a6d25edadac98c8b72 Mon Sep 17 00:00:00 2001 From: Chewing Glass Date: Tue, 16 Jan 2024 09:29:51 -0500 Subject: [PATCH] fix: Do not require initialized token account if no mobile burn --- .../src/instructions/onboard_mobile_hotspot_v0.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/programs/helium-entity-manager/src/instructions/onboard_mobile_hotspot_v0.rs b/programs/helium-entity-manager/src/instructions/onboard_mobile_hotspot_v0.rs index d875894cb..4d554589e 100644 --- a/programs/helium-entity-manager/src/instructions/onboard_mobile_hotspot_v0.rs +++ b/programs/helium-entity-manager/src/instructions/onboard_mobile_hotspot_v0.rs @@ -5,7 +5,7 @@ use std::str::FromStr; use anchor_spl::{ associated_token::AssociatedToken, - token::{burn, Burn, Mint, Token, TokenAccount}, + token::{burn, Burn, Mint, Token}, }; use data_credits::{ cpi::{ @@ -63,12 +63,9 @@ pub struct OnboardMobileHotspotV0<'info> { /// CHECK: Only loaded if location is being asserted #[account(mut)] pub dc_burner: UncheckedAccount<'info>, - #[account( - mut, - associated_token::authority = payer, - associated_token::mint = dnt_mint - )] - pub dnt_burner: Account<'info, TokenAccount>, + /// CHECK: Checked by spl token when the burn command is issued (which it may not be) + #[account(mut)] + pub dnt_burner: UncheckedAccount<'info>, #[account( has_one = sub_dao, @@ -248,7 +245,9 @@ pub fn handler<'info>( .unwrap() .checked_div(mobile_price) .unwrap(); - burn(ctx.accounts.mobile_burn_ctx(), mobile_fee)?; + if mobile_fee > 0 { + burn(ctx.accounts.mobile_burn_ctx(), mobile_fee)?; + } Ok(()) }