solana/token_bridge: prevent self attestations
Change-Id: Iac42e8dcc9f04c1035334ec021c7d4ab11857227
This commit is contained in:
parent
78547e23e6
commit
0d97a2e5a3
|
@ -26,6 +26,7 @@ use bridge::{
|
|||
},
|
||||
types::ConsistencyLevel,
|
||||
vaa::SerializePayload,
|
||||
CHAIN_ID_SOLANA,
|
||||
};
|
||||
use primitive_types::U256;
|
||||
use solana_program::{
|
||||
|
@ -141,7 +142,7 @@ pub fn attest_token(
|
|||
// Create Asset Metadata
|
||||
let mut payload = PayloadAssetMeta {
|
||||
token_address: accs.mint.info().key.to_bytes(),
|
||||
token_chain: 1,
|
||||
token_chain: CHAIN_ID_SOLANA,
|
||||
decimals: accs.mint.decimals,
|
||||
symbol: "".to_string(),
|
||||
name: "".to_string(),
|
||||
|
|
|
@ -13,8 +13,12 @@ use crate::{
|
|||
},
|
||||
messages::PayloadAssetMeta,
|
||||
types::*,
|
||||
TokenBridgeError::InvalidChain,
|
||||
};
|
||||
use bridge::{
|
||||
vaa::ClaimableVAA,
|
||||
CHAIN_ID_SOLANA,
|
||||
};
|
||||
use bridge::vaa::ClaimableVAA;
|
||||
use solana_program::{
|
||||
account_info::AccountInfo,
|
||||
program::invoke_signed,
|
||||
|
@ -101,6 +105,11 @@ pub fn create_wrapped(
|
|||
) -> Result<()> {
|
||||
use bstr::ByteSlice;
|
||||
|
||||
// Do not process attestations sourced from the current chain.
|
||||
if accs.vaa.token_chain == CHAIN_ID_SOLANA {
|
||||
return Err(InvalidChain.into());
|
||||
}
|
||||
|
||||
let derivation_data: WrappedDerivationData = (&*accs).into();
|
||||
accs.mint
|
||||
.verify_derivation(ctx.program_id, &derivation_data)?;
|
||||
|
|
|
@ -29,6 +29,7 @@ use bridge::{
|
|||
},
|
||||
types::ConsistencyLevel,
|
||||
vaa::SerializePayload,
|
||||
CHAIN_ID_SOLANA,
|
||||
};
|
||||
use primitive_types::U256;
|
||||
use solana_program::{
|
||||
|
@ -192,7 +193,7 @@ pub fn transfer_native(
|
|||
let payload = PayloadTransfer {
|
||||
amount: U256::from(amount),
|
||||
token_address: accs.mint.info().key.to_bytes(),
|
||||
token_chain: 1,
|
||||
token_chain: CHAIN_ID_SOLANA,
|
||||
to: data.target_address,
|
||||
to_chain: data.target_chain,
|
||||
fee: U256::from(fee),
|
||||
|
|
Loading…
Reference in New Issue