diff --git a/solana/modules/token_bridge/program/src/api/attest.rs b/solana/modules/token_bridge/program/src/api/attest.rs index dfad8218..8c8c6e64 100644 --- a/solana/modules/token_bridge/program/src/api/attest.rs +++ b/solana/modules/token_bridge/program/src/api/attest.rs @@ -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(), diff --git a/solana/modules/token_bridge/program/src/api/create_wrapped.rs b/solana/modules/token_bridge/program/src/api/create_wrapped.rs index dee1a403..0bd37f7b 100644 --- a/solana/modules/token_bridge/program/src/api/create_wrapped.rs +++ b/solana/modules/token_bridge/program/src/api/create_wrapped.rs @@ -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)?; diff --git a/solana/modules/token_bridge/program/src/api/transfer.rs b/solana/modules/token_bridge/program/src/api/transfer.rs index 63ca428a..c74a4dfc 100644 --- a/solana/modules/token_bridge/program/src/api/transfer.rs +++ b/solana/modules/token_bridge/program/src/api/transfer.rs @@ -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),