Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade 0.43.2 #769

Merged
merged 12 commits into from
Sep 5, 2023
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[workspace]
resolver = "2"

members = [
"dex",
"dex/farm",
Expand Down
2 changes: 1 addition & 1 deletion common/common_errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ edition = "2021"
[lib]
path = "src/lib.rs"
[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]
2 changes: 1 addition & 1 deletion common/common_structs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
[lib]
path = "src/lib.rs"
[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.mergeable]
Expand Down
2 changes: 1 addition & 1 deletion common/modules/farm/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ path = "../../pausable"
path = "../../permissions_module"

[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]
4 changes: 2 additions & 2 deletions common/modules/farm/contexts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ path = "../../pausable"
path = "../../permissions_module"

[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.multiversx-sc-modules]
version = "=0.39.4"
version = "=0.43.2"
1 change: 1 addition & 0 deletions common/modules/farm/contexts/src/claim_rewards_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ multiversx_sc::derive_imports!();

use common_errors::{ERROR_BAD_PAYMENTS, ERROR_EMPTY_PAYMENTS};
use common_structs::PaymentAttributesPair;
use multiversx_sc::api::BlockchainApi;
use multiversx_sc::contract_base::BlockchainWrapper;

pub struct ClaimRewardsContext<M, T>
Expand Down
1 change: 1 addition & 0 deletions common/modules/farm/contexts/src/exit_farm_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ multiversx_sc::derive_imports!();

use common_errors::ERROR_BAD_PAYMENTS;
use common_structs::PaymentAttributesPair;
use multiversx_sc::api::BlockchainApi;
use multiversx_sc::contract_base::BlockchainWrapper;

pub struct ExitFarmContext<M, T>
Expand Down
2 changes: 1 addition & 1 deletion common/modules/farm/events/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ path = "../../../common_structs"
path = "../contexts"

[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]
6 changes: 3 additions & 3 deletions common/modules/farm/farm_base_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ path = "../../../traits/mergeable"
path = "../../../traits/fixed-supply-token"

[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.multiversx-sc-modules]
version = "=0.39.4"
version = "=0.43.2"
[dev-dependencies.multiversx-sc-scenario]
version = "=0.39.4"
version = "=0.43.2"
6 changes: 1 addition & 5 deletions common/modules/farm/farm_base_impl/src/base_farm_init.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
multiversx_sc::imports!();

use common_errors::{ERROR_NOT_AN_ESDT, ERROR_SAME_TOKEN_IDS, ERROR_ZERO_AMOUNT};
use common_errors::{ERROR_NOT_AN_ESDT, ERROR_ZERO_AMOUNT};
use pausable::State;
use permissions_module::Permissions;

Expand Down Expand Up @@ -30,10 +30,6 @@ pub trait BaseFarmInitModule:
);
require!(division_safety_constant != 0u64, ERROR_ZERO_AMOUNT);

let farm_token = self.farm_token().get_token_id();
require!(reward_token_id != farm_token, ERROR_SAME_TOKEN_IDS);
require!(farming_token_id != farm_token, ERROR_SAME_TOKEN_IDS);

self.state().set(State::Inactive);
self.division_safety_constant()
.set_if_empty(&division_safety_constant);
Expand Down
4 changes: 2 additions & 2 deletions common/modules/farm/farm_token/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ path = "../../pausable"
path = "../../permissions_module"

[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.multiversx-sc-modules]
version = "=0.39.4"
version = "=0.43.2"
2 changes: 1 addition & 1 deletion common/modules/farm/farm_token/src/farm_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub trait FarmTokenModule:
) {
self.require_caller_has_owner_or_admin_permissions();

let payment_amount = self.call_value().egld_value();
let payment_amount = self.call_value().egld_value().clone_value();
self.farm_token().issue_and_set_all_roles(
EsdtTokenType::Meta,
payment_amount,
Expand Down
4 changes: 2 additions & 2 deletions common/modules/farm/farm_token_merge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ path = "../../token_merge_helper"
path = "../farm_token"

[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.multiversx-sc-modules]
version = "=0.39.4"
version = "=0.43.2"
4 changes: 2 additions & 2 deletions common/modules/farm/rewards/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ path = "../../pausable"
path = "../../permissions_module"

[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.multiversx-sc-modules]
version = "=0.39.4"
version = "=0.43.2"
2 changes: 1 addition & 1 deletion common/modules/legacy_token_decode_module/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
[lib]
path = "src/lib.rs"
[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.common_structs]
Expand Down
2 changes: 1 addition & 1 deletion common/modules/locking_module/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
[lib]
path = "src/lib.rs"
[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.simple-lock]
Expand Down
2 changes: 1 addition & 1 deletion common/modules/math/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ edition = "2021"
[lib]
path = "src/lib.rs"
[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]
2 changes: 1 addition & 1 deletion common/modules/pausable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ path = "src/pausable.rs"
path = "../permissions_module"

[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]
2 changes: 1 addition & 1 deletion common/modules/permissions_module/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ bitflags = "1.3.2"
path = "../../common_errors"

[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]
2 changes: 1 addition & 1 deletion common/modules/sc_whitelist_module/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ path = "src/sc_whitelist_module.rs"
path = "../../common_errors"

[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]
2 changes: 1 addition & 1 deletion common/modules/token_merge_helper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ path = "src/lib.rs"
path = "../../common_errors"

[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]
2 changes: 1 addition & 1 deletion common/modules/token_send/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ path = "../../common_structs"
path = "../../common_errors"

[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]
2 changes: 1 addition & 1 deletion common/modules/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
[lib]
path = "src/lib.rs"
[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.common_structs]
Expand Down
2 changes: 1 addition & 1 deletion common/modules/utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub trait UtilsModule {
let payments = self.call_value().all_esdt_transfers();
require!(!payments.is_empty(), ERR_EMPTY_PAYMENTS);

payments
payments.clone_value()
}

fn pop_first_payment(
Expand Down
2 changes: 1 addition & 1 deletion common/traits/fixed-supply-token/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ edition = "2021"
[lib]
path = "src/lib.rs"
[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
2 changes: 1 addition & 1 deletion common/traits/mergeable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ edition = "2021"
[lib]
path = "src/lib.rs"
[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]
2 changes: 1 addition & 1 deletion common/traits/unwrappable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ edition = "2021"
[lib]
path = "src/lib.rs"
[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]
6 changes: 3 additions & 3 deletions dex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ version = "0.0.0"
edition = "2021"
publish = false
[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]

[dev-dependencies]
num-bigint = "0.4.2"

[dev-dependencies.multiversx-sc-modules]
version = "=0.39.4"
version = "=0.43.2"

[dev-dependencies.multiversx-sc-scenario]
version = "=0.39.4"
version = "=0.43.2"

[dev-dependencies.config]
path = "../common/modules/farm/config"
Expand Down
6 changes: 3 additions & 3 deletions dex/farm-with-locked-rewards/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ path = "../../locked-asset/energy-factory"
path = "../../energy-integration/common-modules/energy-query"

[dependencies.multiversx-sc]
version = "=0.39.4"
version = "=0.43.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.multiversx-sc-modules]
version = "=0.39.4"
version = "=0.43.2"

[dev-dependencies]
num-bigint = "0.4.2"

[dev-dependencies.multiversx-sc-scenario]
version = "=0.39.4"
version = "=0.43.2"

[dev-dependencies.simple-lock]
path = "../../locked-asset/simple-lock"
2 changes: 1 addition & 1 deletion dex/farm-with-locked-rewards/meta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ publish = false
path = ".."

[dependencies.multiversx-sc-meta]
version = "0.39.4"
version = "0.43.2"
2 changes: 1 addition & 1 deletion dex/farm-with-locked-rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub trait Farm:
let caller = self.blockchain().get_caller();
let orig_caller = self.get_orig_caller_from_opt(&caller, opt_orig_caller);

let payments = self.call_value().all_esdt_transfers();
let payments = self.call_value().all_esdt_transfers().clone_value();
let base_claim_rewards_result =
self.claim_rewards_base::<NoMintWrapper<Self>>(orig_caller.clone(), payments);
let output_farm_token_payment = base_claim_rewards_result.new_farm_token.payment.clone();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(deprecated)]

use common_structs::FarmTokenAttributes;
use config::ConfigModule;
use multiversx_sc::{
Expand All @@ -7,7 +9,7 @@ use multiversx_sc::{
};
use multiversx_sc_scenario::{
managed_address, managed_biguint, managed_token_id, rust_biguint,
whitebox::{BlockchainStateWrapper, ContractObjWrapper},
whitebox_legacy::{BlockchainStateWrapper, ContractObjWrapper},
DebugApi,
};

Expand All @@ -25,6 +27,7 @@ use multiversx_sc_modules::pause::PauseModule;
use pausable::{PausableModule, State};
use sc_whitelist_module::SCWhitelistModule;
use simple_lock::locked_token::LockedTokenModule;
use week_timekeeping::Epoch;

pub static REWARD_TOKEN_ID: &[u8] = b"MEX-123456";
pub static LOCKED_REWARD_TOKEN_ID: &[u8] = b"LOCKED-123456";
Expand All @@ -46,6 +49,14 @@ pub const EPOCHS_IN_YEAR: u64 = 360;
pub static LOCK_OPTIONS: &[u64] = &[EPOCHS_IN_YEAR, 2 * EPOCHS_IN_YEAR, 4 * EPOCHS_IN_YEAR];
pub static PENALTY_PERCENTAGES: &[u64] = &[4_000, 6_000, 8_000];

pub struct RawFarmTokenAttributes {
pub reward_per_share_bytes: Vec<u8>,
pub entering_epoch: Epoch,
pub compounded_reward_bytes: Vec<u8>,
pub current_farm_amount_bytes: Vec<u8>,
pub original_owner_bytes: [u8; 32],
}

pub struct FarmSetup<FarmObjBuilder, EnergyFactoryBuilder>
where
FarmObjBuilder: 'static + Copy + Fn() -> farm_with_locked_rewards::ContractObj<DebugApi>,
Expand Down Expand Up @@ -300,12 +311,50 @@ where
attributes: FarmTokenAttributes<DebugApi>,
) -> u64 {
let mut result = 0;

let raw_attributes = RawFarmTokenAttributes {
reward_per_share_bytes: attributes
.reward_per_share
.to_bytes_be()
.as_slice()
.to_vec(),
entering_epoch: attributes.entering_epoch,
compounded_reward_bytes: attributes
.compounded_reward
.to_bytes_be()
.as_slice()
.to_vec(),
current_farm_amount_bytes: attributes
.current_farm_amount
.to_bytes_be()
.as_slice()
.to_vec(),
original_owner_bytes: attributes.original_owner.to_byte_array(),
};

self.b_mock
.execute_query(&self.farm_wrapper, |sc| {
let attributes_managed = FarmTokenAttributes {
reward_per_share: multiversx_sc::types::BigUint::<DebugApi>::from_bytes_be(
&raw_attributes.reward_per_share_bytes,
),
entering_epoch: raw_attributes.entering_epoch,
compounded_reward: multiversx_sc::types::BigUint::<DebugApi>::from_bytes_be(
&raw_attributes.compounded_reward_bytes,
),
current_farm_amount: multiversx_sc::types::BigUint::<DebugApi>::from_bytes_be(
&raw_attributes.current_farm_amount_bytes,
),
original_owner:
multiversx_sc::types::ManagedAddress::<DebugApi>::new_from_bytes(
&raw_attributes.original_owner_bytes,
),
};

let result_managed = sc.calculate_rewards_for_given_position(
managed_address!(user),
managed_biguint!(farm_token_amount),
attributes,
attributes_managed,
);
result = result_managed.to_u64().unwrap();
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(deprecated)]

use common_structs::FarmTokenAttributes;
use multiversx_sc_scenario::{managed_address, managed_biguint, rust_biguint, DebugApi};
use simple_lock::locked_token::LockedTokenAttributes;
Expand Down
2 changes: 1 addition & 1 deletion dex/farm-with-locked-rewards/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ default-features = false
path = ".."

[dependencies.multiversx-sc-wasm-adapter]
version = "=0.39.4"
version = "=0.43.2"
Loading