diff --git a/solana/Cargo.lock b/solana/Cargo.lock index bb48e4a..685b0ba 100644 --- a/solana/Cargo.lock +++ b/solana/Cargo.lock @@ -2377,7 +2377,7 @@ dependencies = [ [[package]] name = "wormhole-cctp-solana" -version = "0.0.1-alpha.2" +version = "0.0.1-alpha.3" dependencies = [ "anchor-lang", "anchor-spl", @@ -2393,7 +2393,7 @@ dependencies = [ [[package]] name = "wormhole-circle-integration-solana" -version = "0.0.1-alpha.2" +version = "0.0.1-alpha.3" dependencies = [ "anchor-lang", "anchor-spl", diff --git a/solana/Cargo.toml b/solana/Cargo.toml index d6f063b..1740ec7 100644 --- a/solana/Cargo.toml +++ b/solana/Cargo.toml @@ -7,7 +7,7 @@ resolver = "2" [workspace.package] edition = "2021" -version = "0.0.1-alpha.2" +version = "0.0.1-alpha.3" authors = ["Wormhole Contributors"] license = "Apache-2.0" homepage = "https://wormhole.com" diff --git a/solana/modules/wormhole-cctp/src/cpi/burn_and_publish.rs b/solana/modules/wormhole-cctp/src/cpi/burn_and_publish.rs index 27b1566..ce94c39 100644 --- a/solana/modules/wormhole-cctp/src/cpi/burn_and_publish.rs +++ b/solana/modules/wormhole-cctp/src/cpi/burn_and_publish.rs @@ -1,5 +1,5 @@ use crate::{cctp, messages::Deposit, wormhole::core_bridge_program}; -use anchor_lang::{prelude::*, system_program}; +use anchor_lang::prelude::*; /// Arguments used to burn Circle-supported tokens and publish a Wormhole Core Bridge message. #[derive(Debug, AnchorSerialize, AnchorDeserialize, Clone)] @@ -88,24 +88,7 @@ pub fn burn_and_publish<'info>( }, )?; - // Pay Wormhole message fee. - { - let mut data: &[_] = &wormhole_ctx.accounts.config.try_borrow_data()?; - let config = wormhole_core_bridge_solana::state::Config::deserialize(&mut data)?; - - system_program::transfer( - CpiContext::new( - wormhole_ctx.accounts.system_program.to_account_info(), - system_program::Transfer { - from: wormhole_ctx.accounts.payer.to_account_info(), - to: wormhole_ctx.accounts.fee_collector.to_account_info(), - }, - ), - config.fee_lamports, - )?; - } - - // Publish message via Core Bridge. + // Publish message via Core Bridge. This includes paying the message fee. core_bridge_program::cpi::post_message( wormhole_ctx, core_bridge_program::cpi::PostMessageArgs { diff --git a/solana/modules/wormhole-cctp/src/wormhole/core_bridge_program/cpi/post_message.rs b/solana/modules/wormhole-cctp/src/wormhole/core_bridge_program/cpi/post_message.rs index 2edbf32..65d1460 100644 --- a/solana/modules/wormhole-cctp/src/wormhole/core_bridge_program/cpi/post_message.rs +++ b/solana/modules/wormhole-cctp/src/wormhole/core_bridge_program/cpi/post_message.rs @@ -1,5 +1,5 @@ use crate::wormhole::core_bridge_program::Commitment; -use anchor_lang::prelude::*; +use anchor_lang::{prelude::*, system_program}; #[derive(Accounts)] pub struct PostMessage<'info> { @@ -47,6 +47,23 @@ pub fn post_message<'info>( ctx: CpiContext<'_, '_, '_, 'info, PostMessage<'info>>, args: PostMessageArgs, ) -> Result<()> { + // Pay Wormhole message fee. + { + let mut data: &[_] = &ctx.accounts.config.try_borrow_data()?; + let config = wormhole_core_bridge_solana::state::Config::deserialize(&mut data)?; + + system_program::transfer( + CpiContext::new( + ctx.accounts.system_program.to_account_info(), + system_program::Transfer { + from: ctx.accounts.payer.to_account_info(), + to: ctx.accounts.fee_collector.to_account_info(), + }, + ), + config.fee_lamports, + )?; + } + const IX_SELECTOR: u8 = 1; solana_program::program::invoke_signed(