solana: move fee transfer; uptick 0.0.1-alpha.3

This commit is contained in:
A5 Pickle 2024-01-18 10:50:53 -06:00
parent f3477691bc
commit aa4ea707a3
No known key found for this signature in database
GPG Key ID: DD6C727938DE8E65
4 changed files with 23 additions and 23 deletions

4
solana/Cargo.lock generated
View File

@ -2377,7 +2377,7 @@ dependencies = [
[[package]] [[package]]
name = "wormhole-cctp-solana" name = "wormhole-cctp-solana"
version = "0.0.1-alpha.2" version = "0.0.1-alpha.3"
dependencies = [ dependencies = [
"anchor-lang", "anchor-lang",
"anchor-spl", "anchor-spl",
@ -2393,7 +2393,7 @@ dependencies = [
[[package]] [[package]]
name = "wormhole-circle-integration-solana" name = "wormhole-circle-integration-solana"
version = "0.0.1-alpha.2" version = "0.0.1-alpha.3"
dependencies = [ dependencies = [
"anchor-lang", "anchor-lang",
"anchor-spl", "anchor-spl",

View File

@ -7,7 +7,7 @@ resolver = "2"
[workspace.package] [workspace.package]
edition = "2021" edition = "2021"
version = "0.0.1-alpha.2" version = "0.0.1-alpha.3"
authors = ["Wormhole Contributors"] authors = ["Wormhole Contributors"]
license = "Apache-2.0" license = "Apache-2.0"
homepage = "https://wormhole.com" homepage = "https://wormhole.com"

View File

@ -1,5 +1,5 @@
use crate::{cctp, messages::Deposit, wormhole::core_bridge_program}; 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. /// Arguments used to burn Circle-supported tokens and publish a Wormhole Core Bridge message.
#[derive(Debug, AnchorSerialize, AnchorDeserialize, Clone)] #[derive(Debug, AnchorSerialize, AnchorDeserialize, Clone)]
@ -88,24 +88,7 @@ pub fn burn_and_publish<'info>(
}, },
)?; )?;
// Pay Wormhole message fee. // Publish message via Core Bridge. This includes paying the 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.
core_bridge_program::cpi::post_message( core_bridge_program::cpi::post_message(
wormhole_ctx, wormhole_ctx,
core_bridge_program::cpi::PostMessageArgs { core_bridge_program::cpi::PostMessageArgs {

View File

@ -1,5 +1,5 @@
use crate::wormhole::core_bridge_program::Commitment; use crate::wormhole::core_bridge_program::Commitment;
use anchor_lang::prelude::*; use anchor_lang::{prelude::*, system_program};
#[derive(Accounts)] #[derive(Accounts)]
pub struct PostMessage<'info> { pub struct PostMessage<'info> {
@ -47,6 +47,23 @@ pub fn post_message<'info>(
ctx: CpiContext<'_, '_, '_, 'info, PostMessage<'info>>, ctx: CpiContext<'_, '_, '_, 'info, PostMessage<'info>>,
args: PostMessageArgs, args: PostMessageArgs,
) -> Result<()> { ) -> 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; const IX_SELECTOR: u8 = 1;
solana_program::program::invoke_signed( solana_program::program::invoke_signed(