From a7334ed0f916e8265a6f5955bd4fe837fc1dedb5 Mon Sep 17 00:00:00 2001 From: Noah Prince <83885631+ChewingGlass@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:31:00 -0500 Subject: [PATCH] fix: Do not require initialized token account if no mobile burn (#542) --- .../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(()) }