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

Feature: unified syntax, stable Rust #906

Draft
wants to merge 51 commits into
base: rc/v3.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
b81eaa1
upgrade to framework version 0.49.0-alpha.3
andrei-marinica Apr 13, 2024
5323ab2
fixes after upgrade to 0.49.0-alpha.3
andrei-marinica Apr 13, 2024
1f7d912
send calls migration, new proxy for pair in router and build
mihaicalinluca Apr 16, 2024
e2b6ce7
reverted upgrade function back to no arguments + removed old proxies …
mihaicalinluca Apr 16, 2024
c519cca
fixed router upgrade_pair
andrei-marinica Apr 17, 2024
2061fae
new pair proxy cleanup
andrei-marinica Apr 17, 2024
aa1c768
energy-factory
mihaicalinluca Apr 17, 2024
5bc6820
more energy-factory proxy migration
mihaicalinluca Apr 17, 2024
2482c62
Merge pull request #892 from multiversx/send-migration
andrei-marinica Apr 17, 2024
40390e8
small cleanup
mihaicalinluca Apr 17, 2024
5f81d8b
pair proxy
mihaicalinluca Apr 17, 2024
4708c52
clippy
mihaicalinluca Apr 17, 2024
d76f6ef
price-provider, fees-collector and pause
mihaicalinluca Apr 18, 2024
399d509
the remaining proxies and build
mihaicalinluca Apr 18, 2024
3e70ead
initial impl and swap call to pair sc
mihaicalinluca Apr 22, 2024
16f3c31
update to latest wasm, proxy gen and progress on interact
mihaicalinluca Apr 23, 2024
a9bcc26
design change, reorg and progress for farm with locked rewards and pair
mihaicalinluca Apr 24, 2024
b0d1236
small integration test, cleanup, more endpoints
mihaicalinluca Apr 24, 2024
dfbd57b
energy-factory views
mihaicalinluca Apr 25, 2024
7f2b02b
farm staking proxy interaction and small fixes
mihaicalinluca Apr 25, 2024
6a6ceac
reorg traits as modules
mihaicalinluca Apr 29, 2024
e38a2f4
Merge pull request #893 from multiversx/proxy-migration
andrei-marinica May 10, 2024
66c1461
Merge pull request #896 from multiversx/interactor
andrei-marinica May 10, 2024
eba7872
upgrade to framework version 0.49.0
andrei-marinica May 10, 2024
d30b4e0
fixes after upgrade to 0.49.0
andrei-marinica May 10, 2024
801c753
replaced deprecated call with unified syntax
andrei-marinica May 10, 2024
79a8175
cleanup, fmt
andrei-marinica May 10, 2024
422cb1f
upgrade to framework version 0.50.0
andrei-marinica May 10, 2024
fa90933
Merge pull request #907 from multiversx/upgrade-50
andrei-marinica May 10, 2024
5fa59c6
removed feature: trait_alias
andrei-marinica May 10, 2024
bb0f339
removed feature: exact_size_is_empty
andrei-marinica May 10, 2024
28d2b99
removed feature: int_roundings
andrei-marinica May 10, 2024
6ffe047
removed feature: associated_type_defaults
andrei-marinica May 10, 2024
acc527e
warning fix
andrei-marinica May 10, 2024
3a75566
proxy regen and sc-config proxy paths fix
mihaicalinluca May 10, 2024
2c5a2d9
merge rc/v3.0
mihaicalinluca May 10, 2024
95eeb39
Add energy_factory_proxy::SimpleLockEnergyProxy
CostinCarabas May 10, 2024
2822dd6
Merge pull request #908 from multiversx/stable-dex
andrei-marinica May 10, 2024
f7f47b9
Merge branch 'rc/v3.0' into feat/unified
psorinionut May 30, 2024
827c2ff
further framework upgrade fixes
psorinionut May 30, 2024
7e7104f
test fixes
psorinionut May 30, 2024
d973c34
clippy fix
psorinionut May 30, 2024
0c4b9ab
clippy fix
psorinionut May 30, 2024
ddce980
framework upgrade 0.50.3
psorinionut May 30, 2024
32e1753
Merge pull request #922 from multiversx/framework-upgrade-0.50.3
psorinionut May 30, 2024
2729ddf
Merge pull request #909 from multiversx/energy-factory-proxy
psorinionut May 30, 2024
ee2d464
commented integration test
psorinionut May 30, 2024
1cccc07
Interactors code updates
psorinionut Jun 4, 2024
b56e76d
small test fix
mihaicalinluca Jul 4, 2024
633bc30
ignore integration tests
mihaicalinluca Jul 4, 2024
e6843bd
Merge pull request #931 from multiversx/test-fix
mihaicalinluca Jul 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
531 changes: 433 additions & 98 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ members = [

"pause-all",
"pause-all/meta",

"dex/interactor"
]
2 changes: 1 addition & 1 deletion common/common_errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ edition = "2021"
path = "src/lib.rs"

[dependencies.multiversx-sc]
version = "=0.48.1"
version = "=0.50.3"
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 @@ -8,7 +8,7 @@ edition = "2021"
path = "src/lib.rs"

[dependencies.multiversx-sc]
version = "=0.48.1"
version = "=0.50.3"
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 @@ -23,5 +23,5 @@ path = "../../pausable"
path = "../../permissions_module"

[dependencies.multiversx-sc]
version = "=0.48.1"
version = "=0.50.3"
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 @@ -35,8 +35,8 @@ path = "../../pausable"
path = "../../permissions_module"

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

[dependencies.multiversx-sc-modules]
version = "=0.48.1"
version = "=0.50.3"
1 change: 0 additions & 1 deletion common/modules/farm/contexts/src/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![no_std]
#![feature(trait_alias)]

pub mod claim_rewards_context;
pub mod enter_farm_context;
Expand Down
11 changes: 9 additions & 2 deletions common/modules/farm/contexts/src/storage_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ multiversx_sc::derive_imports!();

use pausable::State;

pub trait FarmContracTraitBounds =
config::ConfigModule + rewards::RewardsModule + farm_token::FarmTokenModule;
pub trait FarmContracTraitBounds:
config::ConfigModule + rewards::RewardsModule + farm_token::FarmTokenModule
{
}

impl<T> FarmContracTraitBounds for T where
T: config::ConfigModule + rewards::RewardsModule + farm_token::FarmTokenModule
{
}

pub struct StorageCache<'a, C: FarmContracTraitBounds> {
sc_ref: &'a C,
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 @@ -14,5 +14,5 @@ path = "../../../common_structs"
path = "../contexts"

[dependencies.multiversx-sc]
version = "=0.48.1"
version = "=0.50.3"
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 @@ -50,11 +50,11 @@ path = "../../../traits/mergeable"
path = "../../../traits/fixed-supply-token"

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

[dependencies.multiversx-sc-modules]
version = "=0.48.1"
version = "=0.50.3"

[dev-dependencies.multiversx-sc-scenario]
version = "=0.48.1"
version = "=0.50.3"
22 changes: 18 additions & 4 deletions common/modules/farm/farm_base_impl/src/base_traits_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,31 @@ use common_structs::{FarmToken, FarmTokenAttributes, Nonce};
use config::ConfigModule;
use contexts::storage_cache::StorageCache;
use core::marker::PhantomData;
use farm_token::FarmTokenModule;
use fixed_supply_token::FixedSupplyToken;
use mergeable::Mergeable;
use multiversx_sc_modules::transfer_role_proxy::PaymentsVec;
use rewards::RewardsModule;

pub trait AllBaseFarmImplTraits =
pub trait AllBaseFarmImplTraits:
rewards::RewardsModule
+ config::ConfigModule
+ farm_token::FarmTokenModule
+ permissions_module::PermissionsModule
+ pausable::PausableModule
+ multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule
{
}

impl<T> AllBaseFarmImplTraits for T where
T: rewards::RewardsModule
+ config::ConfigModule
+ farm_token::FarmTokenModule
+ permissions_module::PermissionsModule
+ pausable::PausableModule
+ multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule;
+ multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule
{
}

pub trait FarmContract {
type FarmSc: AllBaseFarmImplTraits;
Expand All @@ -30,8 +43,7 @@ pub trait FarmContract {
+ FixedSupplyToken<<Self::FarmSc as ContractBase>::Api>
+ FarmToken<<Self::FarmSc as ContractBase>::Api>
+ From<FarmTokenAttributes<<Self::FarmSc as ContractBase>::Api>>
+ Into<FarmTokenAttributes<<Self::FarmSc as ContractBase>::Api>> =
FarmTokenAttributes<<Self::FarmSc as ContractBase>::Api>;
+ Into<FarmTokenAttributes<<Self::FarmSc as ContractBase>::Api>>;

#[inline]
fn mint_rewards(
Expand Down Expand Up @@ -259,4 +271,6 @@ where
T: AllBaseFarmImplTraits,
{
type FarmSc = T;

type AttributesType = FarmTokenAttributes<<Self::FarmSc as ContractBase>::Api>;
}
3 changes: 0 additions & 3 deletions common/modules/farm/farm_base_impl/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#![no_std]
#![allow(clippy::too_many_arguments)]
#![feature(exact_size_is_empty)]
#![feature(trait_alias)]
#![feature(associated_type_defaults)]

multiversx_sc::imports!();
multiversx_sc::derive_imports!();
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 @@ -26,8 +26,8 @@ path = "../../pausable"
path = "../../permissions_module"

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

[dependencies.multiversx-sc-modules]
version = "=0.48.1"
version = "=0.50.3"
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 @@ -23,11 +23,11 @@ path = "../../token_merge_helper"
path = "../farm_token"

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

[dependencies.multiversx-sc-modules]
version = "=0.48.1"
version = "=0.50.3"

[workspace]
members = ["."]
4 changes: 2 additions & 2 deletions common/modules/farm/rewards/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ path = "../../pausable"
path = "../../permissions_module"

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

[dependencies.multiversx-sc-modules]
version = "=0.48.1"
version = "=0.50.3"
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 @@ -8,7 +8,7 @@ edition = "2018"
path = "src/lib.rs"

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

[dependencies.common_structs]
Expand Down
8 changes: 1 addition & 7 deletions common/modules/locking_module/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,5 @@ edition = "2021"
path = "src/lib.rs"

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

[dependencies.simple-lock]
path = "../../../locked-asset/simple-lock"

[dependencies.energy-factory]
path = "../../../locked-asset/energy-factory"
89 changes: 89 additions & 0 deletions common/modules/locking_module/src/energy_factory_lock_proxy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
use multiversx_sc::proxy_imports::*;

pub struct SimpleLockEnergyProxy;

impl<Env, From, To, Gas> TxProxyTrait<Env, From, To, Gas> for SimpleLockEnergyProxy
where
Env: TxEnv,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
type TxProxyMethods = SimpleLockEnergyProxyMethods<Env, From, To, Gas>;

fn proxy_methods(self, tx: Tx<Env, From, To, (), Gas, (), ()>) -> Self::TxProxyMethods {
SimpleLockEnergyProxyMethods { wrapped_tx: tx }
}
}

pub struct SimpleLockEnergyProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
wrapped_tx: Tx<Env, From, To, (), Gas, (), ()>,
}

#[rustfmt::skip]
impl<Env, From, To, Gas> SimpleLockEnergyProxyMethods<Env, From, To, Gas>
where
Env: TxEnv,
Env::Api: VMApi,
From: TxFrom<Env>,
To: TxTo<Env>,
Gas: TxGas<Env>,
{
/// Locks a whitelisted token until `unlock_epoch` and receive meta ESDT LOCKED tokens
/// on a 1:1 ratio. Accepted input tokens:
/// - base asset token
/// - old factory token -> extends all periods to the provided option
/// - previously locked token -> extends period to the provided option
///
/// Arguments:
/// - lock_epochs - Number of epochs for which the tokens are locked for.
/// Caller may only choose from the available options,
/// which can be seen by querying getLockOptions
/// - opt_destination - OPTIONAL: destination address for the LOCKED tokens. Default is caller.
///
/// Output payment: LOCKED tokens
pub fn lock_tokens_endpoint<
Arg0: ProxyArg<u64>,
Arg1: ProxyArg<OptionalValue<ManagedAddress<Env::Api>>>,
>(
self,
lock_epochs: Arg0,
opt_destination: Arg1,
) -> TxProxyCall<Env, From, To, Gas, EsdtTokenPayment<Env::Api>> {
self.wrapped_tx
.raw_call("lockTokens")
.argument(&lock_epochs)
.argument(&opt_destination)
.original_result()
}

pub fn lock_virtual<
Arg0: ProxyArg<TokenIdentifier<Env::Api>>,
Arg1: ProxyArg<BigUint<Env::Api>>,
Arg2: ProxyArg<u64>,
Arg3: ProxyArg<ManagedAddress<Env::Api>>,
Arg4: ProxyArg<ManagedAddress<Env::Api>>,
>(
self,
token_id: Arg0,
amount: Arg1,
lock_epochs: Arg2,
dest_address: Arg3,
energy_address: Arg4,
) -> TxProxyCall<Env, From, To, Gas, EsdtTokenPayment<Env::Api>> {
self.wrapped_tx
.raw_call("lockVirtual")
.argument(&token_id)
.argument(&amount)
.argument(&lock_epochs)
.argument(&dest_address)
.argument(&energy_address)
.original_result()
}
}
1 change: 1 addition & 0 deletions common/modules/locking_module/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![no_std]

mod energy_factory_lock_proxy;
pub mod lock_with_energy_module;
pub mod locking_module;
21 changes: 8 additions & 13 deletions common/modules/locking_module/src/lock_with_energy_module.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
multiversx_sc::imports!();
use crate::energy_factory_lock_proxy;

use energy_factory::virtual_lock::ProxyTrait as _;
multiversx_sc::imports!();

#[multiversx_sc::module]
pub trait LockWithEnergyModule {
Expand Down Expand Up @@ -29,21 +29,16 @@ pub trait LockWithEnergyModule {
energy_address: ManagedAddress,
) -> EsdtTokenPayment {
let lock_epochs = self.lock_epochs().get();
let mut proxy_instance = self.get_locking_sc_proxy_instance();
let locking_sc_address = self.locking_sc_address().get();

proxy_instance
self.tx()
.to(locking_sc_address)
.typed(energy_factory_lock_proxy::SimpleLockEnergyProxy)
.lock_virtual(token_id, amount, lock_epochs, dest_address, energy_address)
.execute_on_dest_context()
.returns(ReturnsResult)
.sync_call()
}

fn get_locking_sc_proxy_instance(&self) -> energy_factory::Proxy<Self::Api> {
let locking_sc_address = self.locking_sc_address().get();
self.locking_sc_proxy_obj(locking_sc_address)
}

#[proxy]
fn locking_sc_proxy_obj(&self, sc_address: ManagedAddress) -> energy_factory::Proxy<Self::Api>;

#[view(getLockingScAddress)]
#[storage_mapper("lockingScAddress")]
fn locking_sc_address(&self) -> SingleValueMapper<ManagedAddress>;
Expand Down
22 changes: 11 additions & 11 deletions common/modules/locking_module/src/locking_module.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::energy_factory_lock_proxy;

multiversx_sc::imports!();

#[multiversx_sc::module]
Expand Down Expand Up @@ -45,22 +47,20 @@ pub trait LockingModule {
amount: BigUint,
) -> EgldOrEsdtTokenPayment<Self::Api> {
let unlock_epoch = self.unlock_epoch().get();
let mut proxy_instance = self.get_locking_sc_proxy_instance();
let locking_sc_address = self.locking_sc_address().get();

proxy_instance
let tokens = self
.tx()
.to(locking_sc_address)
.typed(energy_factory_lock_proxy::SimpleLockEnergyProxy)
.lock_tokens_endpoint(unlock_epoch, opt_dest)
.with_egld_or_single_esdt_transfer((token_id, 0, amount))
.execute_on_dest_context()
}
.egld_or_single_esdt(&token_id, 0, &amount)
.returns(ReturnsResult)
.sync_call();

fn get_locking_sc_proxy_instance(&self) -> simple_lock::Proxy<Self::Api> {
let locking_sc_address = self.locking_sc_address().get();
self.locking_sc_proxy_obj(locking_sc_address)
EgldOrEsdtTokenPayment::from(tokens)
}

#[proxy]
fn locking_sc_proxy_obj(&self, sc_address: ManagedAddress) -> simple_lock::Proxy<Self::Api>;

#[view(getLockingScAddress)]
#[storage_mapper("lockingScAddress")]
fn locking_sc_address(&self) -> SingleValueMapper<ManagedAddress>;
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 @@ -8,5 +8,5 @@ edition = "2021"
path = "src/lib.rs"

[dependencies.multiversx-sc]
version = "=0.48.1"
version = "=0.50.3"
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 @@ -11,5 +11,5 @@ path = "src/pausable.rs"
path = "../permissions_module"

[dependencies.multiversx-sc]
version = "=0.48.1"
version = "=0.50.3"
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 @@ -17,5 +17,5 @@ bitflags = "2.4.1"
path = "../../common_errors"

[dependencies.multiversx-sc]
version = "=0.48.1"
version = "=0.50.3"
features = ["esdt-token-payment-legacy-decode"]
Loading
Loading