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

983/remove assetsconfig from other pallets #1001

Merged
merged 87 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from 83 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
1c1cd94
use AssetInfoProvider in ceres-launchpad
HaidarJbeily7 Apr 9, 2024
510175d
use AssetInfoProvider in ceres-token-locker
HaidarJbeily7 Apr 9, 2024
e7ab0c5
use AssetInfoProvider in demeter-farming-platform
HaidarJbeily7 Apr 9, 2024
1ac7a93
use AssetInfoProvider in eth-bridge
HaidarJbeily7 Apr 9, 2024
de429bc
use AssetInfoProvider in hermes-governance-platform
HaidarJbeily7 Apr 9, 2024
e3a5e56
use AssetInfoProvider in liquidity-proxy
HaidarJbeily7 Apr 9, 2024
39c0a89
use AssetInfoProvider in multicollateral-bonding-curve-pool
HaidarJbeily7 Apr 9, 2024
b94622a
use AssetInfoProvider in pool-xyk
HaidarJbeily7 Apr 9, 2024
88a3446
use AssetInfoProvider in pswap-distribution
HaidarJbeily7 Apr 9, 2024
99e1559
use AssetInfoProvider in technical
HaidarJbeily7 Apr 9, 2024
af58b0a
resolve ambiguous associated type `AssetInfoProvider` in pswap-distri…
HaidarJbeily7 Apr 9, 2024
41199a9
use AssetInfoProvider in trading-pair
HaidarJbeily7 Apr 9, 2024
36494d9
use AssetInfoProvider in vested-rewards
HaidarJbeily7 Apr 9, 2024
97d1bcf
update mocks for trustless-bridge, bridge-proxy, eth-app
HaidarJbeily7 Apr 9, 2024
33d9cfb
update mock for kensetsu
HaidarJbeily7 Apr 9, 2024
05e7758
update all impl of Config's pallets with the new AssetInfoProvider type
HaidarJbeily7 Apr 9, 2024
831afc2
remove resolved `TODO` comments
HaidarJbeily7 Apr 9, 2024
2b8ab34
Merge branch 'master' into 395-tech-debt-use-assetinfoprovider-instea…
HaidarJbeily7 Apr 9, 2024
65895ad
Merge branch 'master' into 395-tech-debt-use-assetinfoprovider-instea…
HaidarJbeily7 Apr 12, 2024
082f307
update comments on AssetInfoProvider to be consistent
HaidarJbeily7 Apr 12, 2024
377d19b
avoid panic with unwrap() on get_asset_owner impl -> asset pallet
HaidarJbeily7 Apr 12, 2024
6b289da
use AssetInfoProvider in pool-xyk.action_*
HaidarJbeily7 Apr 12, 2024
0207492
Merge branch 'master' into 395-tech-debt-use-assetinfoprovider-instea…
HaidarJbeily7 Apr 12, 2024
50866a9
Merge branch 'master' into 395-tech-debt-use-assetinfoprovider-instea…
HaidarJbeily7 Apr 15, 2024
b0e7287
remove asset config from ceres-governance-platform, ceres-liquidity-l…
HaidarJbeily7 Apr 21, 2024
af432a3
remove asset config from multicollateral-bonding-curve-pool
HaidarJbeily7 Apr 21, 2024
b9f7d8e
fix issues in pool-xyk
HaidarJbeily7 Apr 22, 2024
d408eae
remove asset config from ceres-token-locker
HaidarJbeily7 Apr 22, 2024
84a85a6
remove asset config from ceres-launchpad
HaidarJbeily7 Apr 22, 2024
cf401f3
remove asset config from demeter-farming-platform
HaidarJbeily7 Apr 22, 2024
fbf367e
fix issues in demeter-farming-platform
HaidarJbeily7 Apr 22, 2024
c2bd0bb
remove asset config from vested-rewards
HaidarJbeily7 Apr 22, 2024
5514494
remove asset config from farming
HaidarJbeily7 Apr 22, 2024
ecfc085
remove asset config from rewards
HaidarJbeily7 Apr 22, 2024
c38b623
remove asset config from faucet
HaidarJbeily7 Apr 22, 2024
f81fced
remove asset config from kensetsu
HaidarJbeily7 Apr 22, 2024
e1b5726
remove asset config from bridge-proxy
HaidarJbeily7 Apr 22, 2024
af8021c
remove asset config from qa-tools
HaidarJbeily7 Apr 22, 2024
7c903bc
remove asset config from order-book
HaidarJbeily7 Apr 22, 2024
014b707
remove asset config from xst
HaidarJbeily7 Apr 22, 2024
25255b2
update all mocks
HaidarJbeily7 Apr 22, 2024
fc0605e
fix benchmarking in farming, kensetsu and pool-xyk
HaidarJbeily7 Apr 22, 2024
005bfec
fix benchmarking in order-book and pswap-distribution
HaidarJbeily7 Apr 22, 2024
1514624
add into for asset id compatibility
HaidarJbeily7 Apr 23, 2024
a28e6cd
Fix issues in liquidity proxy
HaidarJbeily7 Apr 23, 2024
18b9b15
remove currencies::Config + tokens::Config from common::Config
HaidarJbeily7 Apr 23, 2024
13131ff
fix benchmarking in xst
HaidarJbeily7 Apr 23, 2024
86d8aa6
fix clippy issue
HaidarJbeily7 Apr 23, 2024
7490968
Merge branch 'master' into 983/remove-assetsconfig-from-other-pallets
HaidarJbeily7 Apr 23, 2024
f2da93d
fix clippy issue
HaidarJbeily7 Apr 23, 2024
0d47486
revert tokens dependancy in common
HaidarJbeily7 Apr 23, 2024
537198c
remove unused imports
HaidarJbeily7 Apr 23, 2024
f22b921
Merge branch 'master' into 983/remove-assetsconfig-from-other-pallets
HaidarJbeily7 Apr 25, 2024
ea9eb65
remove asset config from apollo-platform
HaidarJbeily7 Apr 26, 2024
86d656e
remove asset config from ceres-staking
HaidarJbeily7 Apr 26, 2024
323e0eb
remove asset config from ceres-staking
HaidarJbeily7 Apr 26, 2024
5f6aab6
kensetsu remove assets from std
HaidarJbeily7 Apr 26, 2024
34e314e
edit cargo.toml: update assets to dev deps
HaidarJbeily7 Apr 26, 2024
940184d
remove asset config from dex-api
HaidarJbeily7 Apr 26, 2024
91d857a
remove asset config from dex-manager
HaidarJbeily7 Apr 26, 2024
f6f2e92
remove asset config from hermes-governance-platform
HaidarJbeily7 Apr 26, 2024
3fb9470
update Cargo.toml in iroha-migration
HaidarJbeily7 Apr 26, 2024
a9e1e90
remove asset config from xor-fee
HaidarJbeily7 Apr 26, 2024
4299e4e
remove asset config from referrals
HaidarJbeily7 Apr 26, 2024
bed52f4
remove asset config from trading-pair
HaidarJbeily7 Apr 26, 2024
94b3f3d
remove assets config from pswap-distribution
HaidarJbeily7 Apr 26, 2024
5524792
fixes
HaidarJbeily7 Apr 26, 2024
47d1a4f
Merge branch 'master' of me.github.com:sora-xor/sora2-network into 98…
HaidarJbeily7 Apr 26, 2024
e38fdcf
remove useless converstion
HaidarJbeily7 Apr 26, 2024
115f68b
remove useless converstion
HaidarJbeily7 Apr 26, 2024
f747edb
Merge branch 'master' into 983/remove-assetsconfig-from-other-pallets
HaidarJbeily7 Apr 26, 2024
6dd693e
Merge branch 'master' into 983/remove-assetsconfig-from-other-pallets
HaidarJbeily7 May 3, 2024
c6cfbd4
Merge remote-tracking branch 'origin/master' into 983/remove-assetsco…
HaidarJbeily7 May 7, 2024
de4440f
fix failed build
HaidarJbeily7 May 7, 2024
2d0e7fc
Merge branch 'master' into 983/remove-assetsconfig-from-other-pallets
HaidarJbeily7 May 7, 2024
824ca84
Merge remote-tracking branch 'origin/master' into 983/remove-assetsco…
HaidarJbeily7 May 8, 2024
109e2b7
Merge branch '983/remove-assetsconfig-from-other-pallets' of me.githu…
HaidarJbeily7 May 8, 2024
e6d7db7
Merge branch 'master' into 983/remove-assetsconfig-from-other-pallets
HaidarJbeily7 May 13, 2024
dce45a5
remove unused code
HaidarJbeily7 May 14, 2024
d8acbe0
Merge remote-tracking branch 'origin/master' into 983/remove-assetsco…
HaidarJbeily7 May 14, 2024
3a126c8
align with the requested changes
HaidarJbeily7 May 20, 2024
645167c
align with the requested changes
HaidarJbeily7 May 20, 2024
51461a8
Merge remote-tracking branch 'origin/master' into 983/remove-assetsco…
HaidarJbeily7 May 20, 2024
d7ca1bd
fixes
HaidarJbeily7 May 20, 2024
e67f6a6
Merge branch 'master' into 983/remove-assetsconfig-from-other-pallets
HaidarJbeily7 May 20, 2024
f706f70
fix
HaidarJbeily7 May 20, 2024
187b1fa
fix clippy issues
HaidarJbeily7 May 20, 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
2 changes: 2 additions & 0 deletions common/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ macro_rules! mock_common_config {
impl common::Config for $runtime {
type DEXId = DEXId;
type LstId = LiquiditySourceType;
type MultiCurrency = currencies::Pallet<$runtime>;
type AssetManager = assets::Pallet<$runtime>;
}
};
}
Expand Down
282 changes: 278 additions & 4 deletions common/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,24 @@

use crate::prelude::{ManagementMode, QuoteAmount, SwapAmount, SwapOutcome};
use crate::{
Fixed, LiquiditySourceFilter, LiquiditySourceId, LiquiditySourceType, Oracle, PriceVariant,
PswapRemintInfo, RewardReason,
Amount, AssetId32, AssetName, AssetSymbol, BalancePrecision, ContentSource, Description, Fixed,
LiquiditySourceFilter, LiquiditySourceId, LiquiditySourceType, Oracle, PredefinedAssetId,
PriceVariant, PswapRemintInfo, RewardReason,
};
use frame_support::dispatch::DispatchResult;

use frame_support::dispatch::{DispatchResult, DispatchResultWithPostInfo};
use frame_support::pallet_prelude::MaybeSerializeDeserialize;
use frame_support::sp_runtime::traits::BadOrigin;
use frame_support::sp_runtime::DispatchError;
use frame_support::weights::Weight;
use frame_support::Parameter;
use frame_system::pallet_prelude::OriginFor;
use frame_system::RawOrigin;
use orml_traits::{
MultiCurrency, MultiCurrencyExtended, MultiLockableCurrency, MultiReservableCurrency,
};
use sp_core::{Get, H256};
use sp_runtime::traits::Member;
//FIXME maybe try info or try from is better than From and Option.
//use sp_std::convert::TryInto;
use crate::alt::DiscreteQuotation;
Expand Down Expand Up @@ -522,9 +530,34 @@ pub trait LiquidityRegistry<

pub type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
pub type DexIdOf<T> = <T as Config>::DEXId;
pub type AssetIdOf<T> = <<T as Config>::AssetManager as AssetManager<
T,
AssetSymbol,
AssetName,
BalancePrecision,
ContentSource,
Description,
>>::AssetId;
pub type CurrencyIdOf<T> = <<T as Config>::MultiCurrency as MultiCurrency<
<T as frame_system::Config>::AccountId,
>>::CurrencyId;
pub type AmountOf<T> = <<T as Config>::MultiCurrency as MultiCurrencyExtended<
<T as frame_system::Config>::AccountId,
>>::Amount;

pub type GetBaseAssetIdOf<T> = <<T as Config>::AssetManager as AssetManager<
T,
AssetSymbol,
AssetName,
BalancePrecision,
ContentSource,
Description,
>>::GetBaseAssetId;

pub type BalanceOf<T> = <<T as Config>::MultiCurrency as MultiCurrency<AccountIdOf<T>>>::Balance;

/// Common DEX trait. Used for DEX-related pallets.
pub trait Config: frame_system::Config + currencies::Config {
pub trait Config: frame_system::Config {
/// DEX identifier.
type DEXId: Parameter
+ MaybeSerializeDeserialize
Expand All @@ -538,6 +571,7 @@ pub trait Config: frame_system::Config + currencies::Config {
+ Eq
+ PartialEq
+ MaxEncodedLen;

type LstId: Clone
+ Copy
+ Encode
Expand All @@ -546,6 +580,24 @@ pub trait Config: frame_system::Config + currencies::Config {
+ PartialEq
+ MaxEncodedLen
+ From<crate::primitives::LiquiditySourceType>;

type AssetManager: AssetManager<
Self,
AssetSymbol,
AssetName,
BalancePrecision,
ContentSource,
Description,
>;

/// Currency to transfer, reserve/unreserve, lock/unlock assets
type MultiCurrency: MultiLockableCurrency<
Self::AccountId,
Moment = Self::BlockNumber,
CurrencyId = AssetIdOf<Self>,
Balance = Balance,
> + MultiReservableCurrency<Self::AccountId, CurrencyId = AssetIdOf<Self>, Balance = Balance>
+ MultiCurrencyExtended<Self::AccountId, Amount = Amount>;
}

/// Definition of a pending atomic swap action. It contains the following three phrases:
Expand Down Expand Up @@ -1097,6 +1149,228 @@ impl<AssetId, AccountId, AssetSymbol, AssetName, BalancePrecision, ContentSource
}
}

pub trait AssetManager<
T: Config,
AssetSymbol,
AssetName,
BalancePrecision,
ContentSource,
Description,
>
{
type AssetId: Parameter
+ Member
+ Copy
+ MaybeSerializeDeserialize
+ Ord
+ Default
+ From<AssetId32<PredefinedAssetId>>
+ From<H256>
+ Into<H256>
+ Into<CurrencyIdOf<T>>
+ MaxEncodedLen;

type GetBaseAssetId: Get<Self::AssetId>;

#[allow(clippy::too_many_arguments)]
fn register_from(
account_id: &T::AccountId,
symbol: AssetSymbol,
name: AssetName,
precision: BalancePrecision,
initial_supply: Balance,
is_mintable: bool,
opt_content_src: Option<ContentSource>,
opt_desc: Option<Description>,
) -> Result<Self::AssetId, DispatchError>;
Fixed Show fixed Hide fixed

fn update_balance(
origin: OriginFor<T>,
who: T::AccountId,
currency_id: CurrencyIdOf<T>,
amount: AmountOf<T>,
) -> DispatchResult;

fn gen_asset_id_from_any(value: &impl Encode) -> Self::AssetId;

#[allow(clippy::too_many_arguments)]
fn register_asset_id(
account_id: T::AccountId,
asset_id: Self::AssetId,
symbol: AssetSymbol,
name: AssetName,
precision: BalancePrecision,
initial_supply: Balance,
is_mintable: bool,
opt_content_src: Option<ContentSource>,
opt_desc: Option<Description>,
) -> DispatchResult;
Fixed Show fixed Hide fixed

fn burn_from(
asset_id: &Self::AssetId,
issuer: &T::AccountId,
from: &T::AccountId,
amount: Balance,
) -> DispatchResult;

fn transfer_from(
asset_id: &Self::AssetId,
from: &T::AccountId,
to: &T::AccountId,
amount: Balance,
) -> DispatchResult;

fn mint_to(
asset_id: &Self::AssetId,
issuer: &T::AccountId,
to: &T::AccountId,
amount: Balance,
) -> DispatchResult;

fn mint_unchecked(
asset_id: &Self::AssetId,
to: &T::AccountId,
amount: Balance,
) -> DispatchResult;

fn burn(
origin: OriginFor<T>,
asset_id: Self::AssetId,
amount: Balance,
) -> DispatchResultWithPostInfo;

fn mint(
origin: OriginFor<T>,
asset_id: Self::AssetId,
to: T::AccountId,
amount: Balance,
) -> DispatchResultWithPostInfo;

#[allow(clippy::too_many_arguments)]
fn register(
origin: OriginFor<T>,
symbol: AssetSymbol,
name: AssetName,
initial_supply: Balance,
is_mintable: bool,
is_indivisible: bool,
opt_content_src: Option<ContentSource>,
opt_desc: Option<Description>,
) -> DispatchResultWithPostInfo;
Fixed Show fixed Hide fixed
}

impl<T: Config, AssetSymbol, AssetName, BalancePrecision, ContentSource, Description>
AssetManager<T, AssetSymbol, AssetName, BalancePrecision, ContentSource, Description> for ()
{
type AssetId = AssetId32<PredefinedAssetId>;
type GetBaseAssetId = ();

fn register_from(
_account_id: &T::AccountId,
_symbol: AssetSymbol,
_name: AssetName,
_precision: BalancePrecision,
_initial_supply: Balance,
_is_mintable: bool,
_opt_content_src: Option<ContentSource>,
_opt_desc: Option<Description>,
) -> Result<Self::AssetId, DispatchError> {
unimplemented!()
}

fn update_balance(
_origin: OriginFor<T>,
_who: T::AccountId,
_currency_id: CurrencyIdOf<T>,
_amount: AmountOf<T>,
) -> DispatchResult {
unimplemented!()
}

fn gen_asset_id_from_any(_value: &impl Encode) -> Self::AssetId {
unimplemented!()
}

fn register_asset_id(
_account_id: T::AccountId,
_asset_id: Self::AssetId,
_symbol: AssetSymbol,
_name: AssetName,
_precision: BalancePrecision,
_initial_supply: Balance,
_is_mintable: bool,
_opt_content_src: Option<ContentSource>,
_opt_desc: Option<Description>,
) -> DispatchResult {
unimplemented!()
}

fn burn_from(
_asset_id: &Self::AssetId,
_issuer: &<T as frame_system::Config>::AccountId,
_from: &<T as frame_system::Config>::AccountId,
_amount: Balance,
) -> DispatchResult {
unimplemented!()
}

fn transfer_from(
_asset_id: &Self::AssetId,
_from: &<T as frame_system::Config>::AccountId,
_to: &<T as frame_system::Config>::AccountId,
_amount: Balance,
) -> DispatchResult {
unimplemented!()
}

fn mint_to(
_asset_id: &Self::AssetId,
_issuer: &<T as frame_system::Config>::AccountId,
_to: &<T as frame_system::Config>::AccountId,
_amount: Balance,
) -> DispatchResult {
unimplemented!()
}

fn mint_unchecked(
_asset_id: &Self::AssetId,
_to: &T::AccountId,
_amount: Balance,
) -> DispatchResult {
unimplemented!()
}

fn burn(
_origin: OriginFor<T>,
_asset_id: Self::AssetId,
_amount: Balance,
) -> DispatchResultWithPostInfo {
unimplemented!()
}

fn mint(
_origin: OriginFor<T>,
_asset_id: Self::AssetId,
_to: <T as frame_system::Config>::AccountId,
_amount: Balance,
) -> DispatchResultWithPostInfo {
unimplemented!()
}

fn register(
_origin: OriginFor<T>,
_symbol: AssetSymbol,
_name: AssetName,
_initial_supply: Balance,
_is_mintable: bool,
_is_indivisible: bool,
_opt_content_src: Option<ContentSource>,
_opt_desc: Option<Description>,
) -> DispatchResultWithPostInfo {
unimplemented!()
}
}

pub trait SyntheticInfoProvider<AssetId> {
fn is_synthetic(asset_id: &AssetId) -> bool;

Expand Down
1 change: 0 additions & 1 deletion pallets/apollo-platform/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ codec = { package = "parity-scale-codec", version = "3", default-features = fals
scale-info = { version = "2", default-features = false, features = ["derive"] }
frame-support = { git = "https://github.com/sora-xor/substrate.git", branch = "polkadot-v0.9.38", default-features = false }
frame-system = { git = "https://github.com/sora-xor/substrate.git", branch = "polkadot-v0.9.38", default-features = false }
assets = { path = "../assets", default-features = false }
common = { path = "../../common", default-features = false }
sp-io = { git = "https://github.com/sora-xor/substrate.git", branch = "polkadot-v0.9.38", default-features = false }
sp-std = { git = "https://github.com/sora-xor/substrate.git", branch = "polkadot-v0.9.38", default-features = false }
Expand Down
Loading
Loading