Skip to content

Commit

Permalink
Merge pull request #697 from ElrondNetwork/old-farms-exit-amount-comp
Browse files Browse the repository at this point in the history
exit amount compatibility for old farms
  • Loading branch information
claudiulataretu authored Jan 4, 2023
2 parents 825424c + 4fe1c6d commit 1a883b2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions locked-asset/simple-lock/src/proxy_farm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,15 @@ pub trait ProxyFarmModule:
) -> ExitFarmThroughProxyResultType<Self::Api> {
let payment: EsdtTokenPayment<Self::Api> = self.call_value().single_esdt();
let farm_proxy_token_attributes: FarmProxyTokenAttributes<Self::Api> =
self.validate_payment_and_get_farm_proxy_token_attributes(&payment);
match &opt_exit_amount {
OptionalValue::Some(exit_amount) => {
self.validate_payment_and_get_farm_proxy_token_attributes(&payment, exit_amount)
}
OptionalValue::None => self.validate_payment_and_get_farm_proxy_token_attributes(
&payment,
&payment.amount,
),
};

let farm_address = self.try_get_farm_address(
&farm_proxy_token_attributes.farming_token_id,
Expand Down Expand Up @@ -284,7 +292,7 @@ pub trait ProxyFarmModule:
fn farm_claim_rewards_locked_token(&self) -> FarmClaimRewardsThroughProxyResultType<Self::Api> {
let payment: EsdtTokenPayment<Self::Api> = self.call_value().single_esdt();
let mut farm_proxy_token_attributes: FarmProxyTokenAttributes<Self::Api> =
self.validate_payment_and_get_farm_proxy_token_attributes(&payment);
self.validate_payment_and_get_farm_proxy_token_attributes(&payment, &payment.amount);

let farm_address = self.try_get_farm_address(
&farm_proxy_token_attributes.farming_token_id,
Expand Down Expand Up @@ -342,6 +350,7 @@ pub trait ProxyFarmModule:
fn validate_payment_and_get_farm_proxy_token_attributes(
&self,
payment: &EsdtTokenPayment<Self::Api>,
exit_amount: &BigUint,
) -> FarmProxyTokenAttributes<Self::Api> {
require!(payment.amount > 0, NO_PAYMENT_ERR_MSG);

Expand All @@ -351,7 +360,7 @@ pub trait ProxyFarmModule:
let farm_proxy_token_attributes: FarmProxyTokenAttributes<Self::Api> =
farm_proxy_token_mapper.get_token_attributes(payment.token_nonce);

farm_proxy_token_mapper.nft_burn(payment.token_nonce, &payment.amount);
farm_proxy_token_mapper.nft_burn(payment.token_nonce, exit_amount);

farm_proxy_token_attributes
}
Expand Down

0 comments on commit 1a883b2

Please sign in to comment.