Require meta in complete transfer wrapped
Change-Id: Ie5a5af23c39db7e0d29f7311ea1df385f20decef
This commit is contained in:
parent
c04fe95859
commit
0702ee300f
|
@ -8,7 +8,9 @@ use crate::{
|
|||
EndpointDerivationData,
|
||||
MintSigner,
|
||||
WrappedDerivationData,
|
||||
WrappedMetaDerivationData,
|
||||
WrappedMint,
|
||||
WrappedTokenMeta,
|
||||
},
|
||||
messages::PayloadTransfer,
|
||||
types::*,
|
||||
|
@ -171,6 +173,7 @@ pub struct CompleteWrapped<'b> {
|
|||
pub to: Mut<Data<'b, SplAccount, { AccountState::Initialized }>>,
|
||||
pub to_fees: Mut<Data<'b, SplAccount, { AccountState::Initialized }>>,
|
||||
pub mint: Mut<WrappedMint<'b, { AccountState::Initialized }>>,
|
||||
pub wrapped_meta: WrappedTokenMeta<'b, { AccountState::Initialized }>,
|
||||
|
||||
pub mint_authority: MintSigner<'b>,
|
||||
}
|
||||
|
@ -210,9 +213,17 @@ pub fn complete_wrapped(
|
|||
.verify_derivation(ctx.program_id, &derivation_data)?;
|
||||
|
||||
// Verify mint
|
||||
let derivation_data: WrappedDerivationData = (&*accs).into();
|
||||
accs.mint
|
||||
.verify_derivation(ctx.program_id, &derivation_data)?;
|
||||
accs.wrapped_meta.verify_derivation(
|
||||
ctx.program_id,
|
||||
&WrappedMetaDerivationData {
|
||||
mint_key: *accs.mint.info().key,
|
||||
},
|
||||
)?;
|
||||
if accs.wrapped_meta.token_address != accs.vaa.token_address
|
||||
|| accs.wrapped_meta.chain != accs.vaa.token_chain
|
||||
{
|
||||
return Err(InvalidMint.into());
|
||||
}
|
||||
|
||||
// Verify mints
|
||||
if *accs.mint.info().key != accs.to.mint {
|
||||
|
|
|
@ -176,6 +176,10 @@ pub fn complete_wrapped(
|
|||
},
|
||||
&program_id,
|
||||
);
|
||||
let meta_key = WrappedTokenMeta::<'_, { AccountState::Uninitialized }>::key(
|
||||
&WrappedMetaDerivationData { mint_key },
|
||||
&program_id,
|
||||
);
|
||||
let mint_authority_key = MintSigner::key(None, &program_id);
|
||||
|
||||
Ok(Instruction {
|
||||
|
@ -193,6 +197,7 @@ pub fn complete_wrapped(
|
|||
AccountMeta::new(to, false)
|
||||
},
|
||||
AccountMeta::new(mint_key, false),
|
||||
AccountMeta::new_readonly(meta_key, false),
|
||||
AccountMeta::new_readonly(mint_authority_key, false),
|
||||
// Dependencies
|
||||
AccountMeta::new_readonly(solana_program::sysvar::rent::id(), false),
|
||||
|
|
Loading…
Reference in New Issue