|
|
@@ -16,7 +16,10 @@ use crate::{
|
|
|
messages::PayloadTransfer,
|
|
|
types::*,
|
|
|
TokenBridgeError,
|
|
|
- TokenBridgeError::WrongAccountOwner,
|
|
|
+ TokenBridgeError::{
|
|
|
+ InvalidFee,
|
|
|
+ WrongAccountOwner,
|
|
|
+ },
|
|
|
};
|
|
|
use bridge::{
|
|
|
accounts::Bridge,
|
|
|
@@ -134,6 +137,11 @@ pub fn transfer_native(
|
|
|
return Err(TokenBridgeError::InvalidMint.into());
|
|
|
}
|
|
|
|
|
|
+ // Fee must be less than amount
|
|
|
+ if data.fee > data.amount {
|
|
|
+ return Err(InvalidFee.into());
|
|
|
+ }
|
|
|
+
|
|
|
// Verify that the token is not a wrapped token
|
|
|
if let COption::Some(mint_authority) = accs.mint.mint_authority {
|
|
|
if mint_authority == MintSigner::key(None, ctx.program_id) {
|
|
|
@@ -292,6 +300,11 @@ pub fn transfer_wrapped(
|
|
|
return Err(TokenBridgeError::InvalidMint.into());
|
|
|
}
|
|
|
|
|
|
+ // Fee must be less than amount
|
|
|
+ if data.fee > data.amount {
|
|
|
+ return Err(InvalidFee.into());
|
|
|
+ }
|
|
|
+
|
|
|
// Verify that meta is correct
|
|
|
let derivation_data: WrappedMetaDerivationData = (&*accs).into();
|
|
|
accs.wrapped_meta
|