Skip to content

Commit

Permalink
Merge pull request #701 from galacticcouncil/refactor/registry-traits
Browse files Browse the repository at this point in the history
refactor: registry traits consolidation
  • Loading branch information
martinfridrich authored Nov 22, 2023
2 parents 5a03cf0 + bf2e99c commit f88cc0b
Show file tree
Hide file tree
Showing 48 changed files with 1,435 additions and 403 deletions.
19 changes: 9 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 22 additions & 8 deletions integration-tests/src/bonds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::polkadot_test_net::*;
use frame_support::storage::with_transaction;
use frame_support::{assert_noop, assert_ok};
use frame_system::RawOrigin;
use hydradx_traits::CreateRegistry;
use hydradx_traits::registry::{AssetKind, Create};
use orml_traits::MultiCurrency;
use sp_runtime::{DispatchResult, TransactionOutcome};
use xcm_emulator::TestExt;
Expand Down Expand Up @@ -65,10 +65,15 @@ fn issue_bonds_should_work_when_issued_for_share_asset() {
let maturity = NOW + MONTH;

let name = b"SHARED".to_vec();
let share_asset_id = AssetRegistry::create_asset(
&name,
pallet_asset_registry::AssetType::PoolShare(HDX, DOT).into(),
1_000,
let share_asset_id = AssetRegistry::register_insufficient_asset(
None,
Some(&name),
AssetKind::XYK,
Some(1_000),
None,
None,
None,
None,
)
.unwrap();
assert_ok!(Currencies::deposit(share_asset_id, &ALICE.into(), amount,));
Expand Down Expand Up @@ -119,9 +124,18 @@ fn issue_bonds_should_not_work_when_issued_for_bond_asset() {
let maturity = NOW + MONTH;

let name = b"BOND".to_vec();
let underlying_asset_id =
AssetRegistry::create_asset(&name, pallet_asset_registry::AssetType::<AssetId>::Bond.into(), 1_000)
.unwrap();
let underlying_asset_id = AssetRegistry::register_insufficient_asset(
None,
Some(&name),
AssetKind::Bond,
Some(1_000),
None,
None,
None,
None,
)
.unwrap();

assert_ok!(Currencies::deposit(underlying_asset_id, &ALICE.into(), amount,));

// Act & Assert
Expand Down
22 changes: 14 additions & 8 deletions integration-tests/src/dca.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ use hydradx_runtime::{
AssetRegistry, Balances, Currencies, Omnipool, Router, Runtime, RuntimeEvent, RuntimeOrigin, Stableswap, Tokens,
Treasury, DCA,
};
use hydradx_traits::registry::{AssetKind, Create};
use hydradx_traits::router::{PoolType, Trade};
use hydradx_traits::{
registry::{AssetKind, Create},
Registry,
};
use orml_traits::MultiCurrency;
use orml_traits::MultiReservableCurrency;
use pallet_dca::types::{Order, Schedule};
Expand Down Expand Up @@ -2314,7 +2311,7 @@ pub fn init_stableswap() -> Result<(AssetId, AssetId, AssetId), DispatchError> {
None,
Some(name.as_ref()),
AssetKind::Token,
Some(1u128),
1u128,
Some(b"xDUM".as_ref()),
Some(18u8),
None,
Expand All @@ -2335,7 +2332,7 @@ pub fn init_stableswap() -> Result<(AssetId, AssetId, AssetId), DispatchError> {
None,
Some(b"pool".as_ref()),
AssetKind::Token,
Some(1u128),
1u128,
None,
None,
None,
Expand Down Expand Up @@ -2372,7 +2369,7 @@ pub fn init_stableswap_with_three_assets_having_different_decimals(
None,
Some(name.as_ref()),
AssetKind::Token,
Some(1u128),
1u128,
Some(b"xDUM".as_ref()),
Some(decimals_for_each_asset[idx as usize]),
None,
Expand All @@ -2395,7 +2392,16 @@ pub fn init_stableswap_with_three_assets_having_different_decimals(
initial.push(AssetAmount::new(asset_id, initial_liquidity));
added_liquidity.push(AssetAmount::new(asset_id, liquidity_added));
}
let pool_id = AssetRegistry::create_asset(&b"pool".to_vec(), 1u128)?;
let pool_id = AssetRegistry::register_insufficient_asset(
None,
Some(&b"pool".to_vec()),
AssetKind::Token,
Some(1u128),
None,
None,
None,
None,
)?;

let amplification = 100u16;
let fee = Permill::from_percent(1);
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2314,7 +2314,7 @@ pub fn init_stableswap() -> Result<(AssetId, AssetId, AssetId), DispatchError> {
None,
Some(name.as_ref()),
AssetKind::Token,
Some(1u128),
1u128,
Some(b"xDUM".as_ref()),
Some(18u8),
None,
Expand Down Expand Up @@ -2342,7 +2342,7 @@ pub fn init_stableswap() -> Result<(AssetId, AssetId, AssetId), DispatchError> {
None,
Some(b"pool".as_ref()),
AssetKind::Token,
Some(1u128),
1u128,
None,
None,
None,
Expand Down
2 changes: 1 addition & 1 deletion pallets/asset-registry/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ benchmarks! {
let _ = Pallet::<T>::register(RawOrigin::Root.into(), Some(asset_id), Some(name), AssetType::Token, Some(ed), Some(symbol), Some(decimals), Some(location), Some(xcm_rate_limit), is_sufficient);

let new_name= vec![98u8; T::StringLimit::get() as usize];
let new_type = AssetType::PoolShare(T::AssetId::from(10u8),T::AssetId::from(20u8));
let new_type = AssetType::XYK;
let new_ed = 1_000_000_u128;
let new_xcm_rate_limit = 1_000_u128;
let new_is_sufficient = false;
Expand Down
Loading

0 comments on commit f88cc0b

Please sign in to comment.