Skip to content

Commit

Permalink
Merge pull request #597 from galacticcouncil/latest_registry
Browse files Browse the repository at this point in the history
feat: use latest asset registry
  • Loading branch information
Roznovjak authored Feb 11, 2023
2 parents 3a7672d + fc7b0b4 commit 5818ee3
Show file tree
Hide file tree
Showing 32 changed files with 318 additions and 221 deletions.
128 changes: 48 additions & 80 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "runtime-integration-tests"
version = "0.8.8"
version = "0.9.0"
description = "Integration tests"
authors = ["GalacticCouncil"]
edition = "2021"
Expand All @@ -10,13 +10,13 @@ repository = "https://github.com/galacticcouncil/Basilisk-node"

[dependencies]
# Warehouse dependencies
pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", rev = "654b06312c800c4fbdd052e5b3a83ca15efed63a", default-features = false}
pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", rev = "654b06312c800c4fbdd052e5b3a83ca15efed63a", default-features = false}
pallet-nft = { git = "https://github.com/galacticcouncil/warehouse", rev = "654b06312c800c4fbdd052e5b3a83ca15efed63a", default-features = false }
pallet-currencies = { git = "https://github.com/galacticcouncil/warehouse", rev = "654b06312c800c4fbdd052e5b3a83ca15efed63a", default-features = false }
pallet-route-executor = { git = "https://github.com/galacticcouncil/warehouse", rev = "654b06312c800c4fbdd052e5b3a83ca15efed63a", default-features = false }
pallet-asset-registry = { git = "https://github.com/galacticcouncil/warehouse", rev = "fcebd285141ce9ed15136f6102fa6396605d96af", default-features = false }
hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "654b06312c800c4fbdd052e5b3a83ca15efed63a", default-features = false }
pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", rev = "ea6e89e2348ca349337bc4269a5637f4e9c3c9b1", default-features = false}
pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", rev = "ea6e89e2348ca349337bc4269a5637f4e9c3c9b1", default-features = false}
pallet-nft = { git = "https://github.com/galacticcouncil/warehouse", rev = "ea6e89e2348ca349337bc4269a5637f4e9c3c9b1", default-features = false }
pallet-currencies = { git = "https://github.com/galacticcouncil/warehouse", rev = "ea6e89e2348ca349337bc4269a5637f4e9c3c9b1", default-features = false }
pallet-route-executor = { git = "https://github.com/galacticcouncil/warehouse", rev = "ea6e89e2348ca349337bc4269a5637f4e9c3c9b1", default-features = false }
pallet-asset-registry = { git = "https://github.com/galacticcouncil/warehouse", rev = "ea6e89e2348ca349337bc4269a5637f4e9c3c9b1", default-features = false }
hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "ea6e89e2348ca349337bc4269a5637f4e9c3c9b1", default-features = false }

pallet-xyk = { path = "../pallets/xyk",default-features = false}
pallet-duster= { path = "../pallets/duster",default-features = false}
Expand Down Expand Up @@ -108,7 +108,7 @@ parachain-runtime-mock = { path = "parachain-runtime-mock", default-features = f
[dev-dependencies]
xcm-emulator = { git = "https://github.com/shaunxw/xcm-simulator", rev = "0460d04c798028e7bef82c907082e11753ed173b" }
hex-literal = "0.3.1"
pallet-relaychain-info = { git = "https://github.com/galacticcouncil/warehouse", rev = "654b06312c800c4fbdd052e5b3a83ca15efed63a" }
pallet-relaychain-info = { git = "https://github.com/galacticcouncil/warehouse", rev = "ea6e89e2348ca349337bc4269a5637f4e9c3c9b1" }
pretty_assertions = "1.2.1"
sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
test-case = "2.2.1"
Expand Down
20 changes: 10 additions & 10 deletions integration-tests/parachain-runtime-mock/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "parachain-runtime-mock"
version = "0.1.7"
version = "0.2.0"
description = "A mock runtime for a parachain"
authors = ["GalacticCouncil"]
edition = "2021"
Expand All @@ -14,14 +14,14 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
scale-info = { version = "2.1", default-features = false, features = ["derive"] }

# Warehouse dependencies
pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", rev = "654b06312c800c4fbdd052e5b3a83ca15efed63a", default-features = false}
pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", rev = "654b06312c800c4fbdd052e5b3a83ca15efed63a", default-features = false}
pallet-nft = { git = "https://github.com/galacticcouncil/warehouse", rev = "654b06312c800c4fbdd052e5b3a83ca15efed63a", default-features = false }
pallet-currencies = { git = "https://github.com/galacticcouncil/warehouse", rev = "654b06312c800c4fbdd052e5b3a83ca15efed63a", default-features = false }
pallet-route-executor = { git = "https://github.com/galacticcouncil/warehouse", rev = "654b06312c800c4fbdd052e5b3a83ca15efed63a", default-features = false }
pallet-asset-registry = { git = "https://github.com/galacticcouncil/warehouse", rev = "fcebd285141ce9ed15136f6102fa6396605d96af", default-features = false }
hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "654b06312c800c4fbdd052e5b3a83ca15efed63a", default-features = false }
hydradx-adapters = { git = "https://github.com/galacticcouncil/warehouse", rev = "654b06312c800c4fbdd052e5b3a83ca15efed63a", default-features = false }
pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", rev = "ea6e89e2348ca349337bc4269a5637f4e9c3c9b1", default-features = false}
pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", rev = "ea6e89e2348ca349337bc4269a5637f4e9c3c9b1", default-features = false}
pallet-nft = { git = "https://github.com/galacticcouncil/warehouse", rev = "ea6e89e2348ca349337bc4269a5637f4e9c3c9b1", default-features = false }
pallet-currencies = { git = "https://github.com/galacticcouncil/warehouse", rev = "ea6e89e2348ca349337bc4269a5637f4e9c3c9b1", default-features = false }
pallet-route-executor = { git = "https://github.com/galacticcouncil/warehouse", rev = "ea6e89e2348ca349337bc4269a5637f4e9c3c9b1", default-features = false }
pallet-asset-registry = { git = "https://github.com/galacticcouncil/warehouse", rev = "ea6e89e2348ca349337bc4269a5637f4e9c3c9b1", default-features = false }
hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "ea6e89e2348ca349337bc4269a5637f4e9c3c9b1", default-features = false }
hydradx-adapters = { git = "https://github.com/galacticcouncil/warehouse", rev = "ea6e89e2348ca349337bc4269a5637f4e9c3c9b1", default-features = false }

pallet-xyk = { path = "../../pallets/xyk",default-features = false}
pallet-duster= { path = "../../pallets/duster",default-features = false}
Expand Down Expand Up @@ -110,7 +110,7 @@ kusama-runtime = { git = "https://github.com/paritytech/polkadot", branch = "rel
[dev-dependencies]
xcm-emulator = { git = "https://github.com/shaunxw/xcm-simulator", rev = "0460d04c798028e7bef82c907082e11753ed173b" }
hex-literal = "0.3.1"
pallet-relaychain-info = { git = "https://github.com/galacticcouncil/warehouse", branch = "polkadot-v0.9.29" }
pallet-relaychain-info = { git = "https://github.com/galacticcouncil/warehouse", rev = "ea6e89e2348ca349337bc4269a5637f4e9c3c9b1" }
pretty_assertions = "1.2.1"
sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" }
test-case = "2.2.1"
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/parachain-runtime-mock/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ parameter_types! {
pub SelfLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(ParachainInfo::parachain_id().into())));
pub const BaseXcmWeight: XcmWeight = 100_000_000;
pub const MaxAssetsForTransfer: usize = 2;

pub const SequentialIdOffset: u32 = 1_000_000;
}
parameter_type_with_key! {
pub ExistentialDeposits: |_currency_id: AssetId| -> Balance {
Expand Down Expand Up @@ -276,6 +276,7 @@ impl pallet_asset_registry::Config for ParachainRuntime {
type Balance = Balance;
type AssetNativeLocation = AssetLocation;
type StringLimit = RegistryStringLimit;
type SequentialIdStartAt = SequentialIdOffset;
type NativeAssetId = ParachainNativeCurrencyId;
type WeightInfo = ();
}
Expand Down
12 changes: 6 additions & 6 deletions integration-tests/src/kusama_test_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ pub fn basilisk_ext() -> sp_io::TestExternalities {
.unwrap();

pallet_asset_registry::GenesisConfig::<Runtime> {
asset_names: vec![
(b"KSM".to_vec(), 1_000_000u128),
(b"aUSD".to_vec(), 1_000u128),
(b"MOVR".to_vec(), 1_000u128),
(b"NEW_BOOTSRAPPED_TOKEN".to_vec(), 1_000u128),
registered_assets: vec![
(b"KSM".to_vec(), 1_000_000u128, Some(1)),
(b"aUSD".to_vec(), 1_000u128, Some(2)),
(b"MOVR".to_vec(), 1_000u128, Some(3)),
(b"NEW_BOOTSRAPPED_TOKEN".to_vec(), 1_000u128, Some(4)),
],
native_asset_name: b"BSX".to_vec(),
native_existential_deposit: existential_deposit,
Expand Down Expand Up @@ -268,7 +268,7 @@ pub fn other_parachain_ext() -> sp_io::TestExternalities {
.unwrap();

pallet_asset_registry::GenesisConfig::<ParachainRuntime> {
asset_names: vec![(b"AUSD".to_vec(), 1_000_000u128)],
registered_assets: vec![(b"AUSD".to_vec(), 1_000_000u128, Some(1))],
native_asset_name: b"BSX".to_vec(),
native_existential_deposit: existential_deposit,
}
Expand Down
26 changes: 1 addition & 25 deletions integration-tests/src/nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use xcm_emulator::TestExt;
const ALLOW: bool = true;
const NOT_ALLOW: bool = false;
const RESERVED_COLLECTION_ID: CollectionId = 0;
const RESTRICTED_COLLECTION_TYPE: CollectionType = CollectionType::HydraHeads;
const RESTRICTED_COLLECTION_TYPE: CollectionType = CollectionType::LiquidityMining;

fn create_nft_collection(account_id: AccountId, collection_id: CollectionId, collection_type: CollectionType) {
Basilisk::execute_with(|| {
Expand All @@ -42,9 +42,6 @@ fn mint_nft(account_id: AccountId, collection_id: CollectionId, item_id: ItemId)

#[test_case(CollectionType::Marketplace, ALLOW ; "marketplace collection")]
#[test_case(CollectionType::LiquidityMining, NOT_ALLOW ; "liquidity mining collection")]
#[test_case(CollectionType::Redeemable, NOT_ALLOW ; "redeemable collection")]
#[test_case(CollectionType::Auction, NOT_ALLOW ; "auction collection")]
#[test_case(CollectionType::HydraHeads, NOT_ALLOW ; "hydra heads collection")]
fn test_nft_permission_for_collection_creation(collection_type: CollectionType, is_allowed: bool) {
assert_eq!(
is_allowed,
Expand All @@ -54,9 +51,6 @@ fn test_nft_permission_for_collection_creation(collection_type: CollectionType,

#[test_case(CollectionType::Marketplace, ALLOW ; "marketplace collection")]
#[test_case(CollectionType::LiquidityMining, NOT_ALLOW ; "liquidity mining collection")]
#[test_case(CollectionType::Redeemable, NOT_ALLOW ; "redeemable collection")]
#[test_case(CollectionType::Auction, NOT_ALLOW ; "auction collection")]
#[test_case(CollectionType::HydraHeads, NOT_ALLOW ; "hydra heads collection")]
fn test_nft_permission_for_minting(collection_type: CollectionType, is_allowed: bool) {
assert_eq!(
is_allowed,
Expand All @@ -66,9 +60,6 @@ fn test_nft_permission_for_minting(collection_type: CollectionType, is_allowed:

#[test_case(CollectionType::Marketplace, ALLOW ; "marketplace collection")]
#[test_case(CollectionType::LiquidityMining, ALLOW ; "liquidity mining collection")]
#[test_case(CollectionType::Redeemable, NOT_ALLOW ; "redeemable collection")]
#[test_case(CollectionType::Auction, NOT_ALLOW ; "auction collection")]
#[test_case(CollectionType::HydraHeads, NOT_ALLOW ; "hydra heads collection")]
fn test_nft_permission_for_transfer(collection_type: CollectionType, is_allowed: bool) {
assert_eq!(
is_allowed,
Expand All @@ -78,9 +69,6 @@ fn test_nft_permission_for_transfer(collection_type: CollectionType, is_allowed:

#[test_case(CollectionType::Marketplace, ALLOW ; "marketplace collection")]
#[test_case(CollectionType::LiquidityMining, NOT_ALLOW ; "liquidity mining collection")]
#[test_case(CollectionType::Redeemable, NOT_ALLOW ; "redeemable collection")]
#[test_case(CollectionType::Auction, NOT_ALLOW ; "auction collection")]
#[test_case(CollectionType::HydraHeads, NOT_ALLOW ; "hydra heads collection")]
fn test_nft_permission_for_burning(collection_type: CollectionType, is_allowed: bool) {
assert_eq!(
is_allowed,
Expand All @@ -90,9 +78,6 @@ fn test_nft_permission_for_burning(collection_type: CollectionType, is_allowed:

#[test_case(CollectionType::Marketplace, ALLOW ; "marketplace collection")]
#[test_case(CollectionType::LiquidityMining, NOT_ALLOW ; "liquidity mining collection")]
#[test_case(CollectionType::Redeemable, NOT_ALLOW ; "redeemable collection")]
#[test_case(CollectionType::Auction, NOT_ALLOW ; "auction collection")]
#[test_case(CollectionType::HydraHeads, NOT_ALLOW ; "hydra heads collection")]
fn test_nft_permission_for_collection_destroying(collection_type: CollectionType, is_allowed: bool) {
assert_eq!(
is_allowed,
Expand All @@ -102,9 +87,6 @@ fn test_nft_permission_for_collection_destroying(collection_type: CollectionType

#[test_case(CollectionType::Marketplace, ALLOW ; "marketplace collection")]
#[test_case(CollectionType::LiquidityMining, NOT_ALLOW ; "liquidity mining collection")]
#[test_case(CollectionType::Redeemable, NOT_ALLOW ; "redeemable collection")]
#[test_case(CollectionType::Auction, NOT_ALLOW ; "auction collection")]
#[test_case(CollectionType::HydraHeads, NOT_ALLOW ; "hydra heads collection")]
fn test_nft_permission_for_deposit(collection_type: CollectionType, is_allowed: bool) {
assert_eq!(
is_allowed,
Expand All @@ -116,9 +98,6 @@ fn test_nft_permission_for_deposit(collection_type: CollectionType, is_allowed:

#[test_case(CollectionType::Marketplace; "marketplace collection")]
#[test_case(CollectionType::LiquidityMining; "liquidity mining collection")]
#[test_case(CollectionType::Redeemable; "redeemable collection")]
#[test_case(CollectionType::Auction; "auction collection")]
#[test_case(CollectionType::HydraHeads; "hydra heads collection")]
fn deposit_for_create_typed_collection_should_be_zero(collection_type: CollectionType) {
// Arrange
TestNet::reset();
Expand Down Expand Up @@ -226,9 +205,6 @@ fn transfer_should_ignore_permissions() {

#[test_case(CollectionType::Marketplace; "marketplace collection")]
#[test_case(CollectionType::LiquidityMining; "liquidity mining collection")]
#[test_case(CollectionType::Redeemable; "redeemable collection")]
#[test_case(CollectionType::Auction; "auction collection")]
#[test_case(CollectionType::HydraHeads; "hydra heads collection")]
fn create_typed_collection_should_ignore_permissions_and_reserved_ids(collection_type: CollectionType) {
// Arrange
TestNet::reset();
Expand Down
24 changes: 24 additions & 0 deletions integration-tests/src/xyk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,27 @@ fn pool_should_be_created_when_it_was_destroyed_previously() {
));
});
}

#[test]
fn share_asset_id_should_be_offset() {
TestNet::reset();

Basilisk::execute_with(|| {
//arrange
assert_ok!(XYK::create_pool(
Origin::signed(ALICE.into()),
KSM,
100 * UNITS,
AUSD,
200 * UNITS,
));

let share_token = XYK::get_share_token(AssetPair {
asset_in: KSM,
asset_out: AUSD,
});
let offset = <basilisk_runtime::Runtime as pallet_asset_registry::Config>::SequentialIdStartAt::get();
//assert
assert!(share_token >= offset);
});
}
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "basilisk"
version = "8.1.3"
version = "8.1.4"
description = "Basilisk node"
authors = ["GalacticCouncil"]
edition = "2021"
Expand Down
23 changes: 16 additions & 7 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ pub fn testnet_parachain_config() -> Result<ChainSpec, String> {
//technical committee
vec![hex!["30035c21ba9eda780130f2029a80c3e962f56588bc04c36be95a225cb536fb55"].into()],
vec![],
vec![(b"KSM".to_vec(), 1_000u128), (b"KUSD".to_vec(), 1_000u128)],
vec![
(b"KSM".to_vec(), 1_000u128, Some(1u32)),
(b"KUSD".to_vec(), 1_000u128, Some(2u32)),
],
vec![(1, Price::from_float(0.0000212)), (2, Price::from_float(0.000806))],
vec![hex!["30035c21ba9eda780130f2029a80c3e962f56588bc04c36be95a225cb536fb55"].into()],
)
Expand Down Expand Up @@ -308,7 +311,10 @@ pub fn parachain_development_config() -> Result<ChainSpec, String> {
get_account_id_from_seed::<sr25519::Public>("Eve"),
],
get_vesting_config_for_test(),
vec![(b"KSM".to_vec(), 1_000u128), (b"KUSD".to_vec(), 1_000u128)],
vec![
(b"KSM".to_vec(), 1_000u128, Some(1u32)),
(b"KUSD".to_vec(), 1_000u128, Some(2u32)),
],
vec![(1, Price::from_float(0.0000212)), (2, Price::from_float(0.000806))],
vec![get_account_id_from_seed::<sr25519::Public>("Alice")],
)
Expand Down Expand Up @@ -602,7 +608,10 @@ pub fn local_parachain_config() -> Result<ChainSpec, String> {
get_account_id_from_seed::<sr25519::Public>("Eve"),
],
get_vesting_config_for_test(),
vec![(b"KSM".to_vec(), 1_000u128), (b"KUSD".to_vec(), 1_000u128)],
vec![
(b"KSM".to_vec(), 1_000u128, Some(1u32)),
(b"KUSD".to_vec(), 1_000u128, Some(2u32)),
],
vec![(1, Price::from_float(0.0000212)), (2, Price::from_float(0.000806))],
vec![get_account_id_from_seed::<sr25519::Public>("Alice")],
)
Expand Down Expand Up @@ -676,7 +685,7 @@ fn parachain_genesis(
// of this.
aura: Default::default(),
asset_registry: AssetRegistryConfig {
asset_names: vec![],
registered_assets: vec![],
native_asset_name: TOKEN_SYMBOL.as_bytes().to_vec(),
native_existential_deposit: NATIVE_EXISTENTIAL_DEPOSIT,
},
Expand Down Expand Up @@ -733,8 +742,8 @@ fn testnet_parachain_genesis(
council_members: Vec<AccountId>,
tech_committee_members: Vec<AccountId>,
vesting_list: Vec<(AccountId, BlockNumber, BlockNumber, u32, Balance)>,
registered_assets: Vec<(Vec<u8>, Balance)>, // (Asset name, Existential deposit)
accepted_assets: Vec<(AssetId, Price)>, // (Asset id, Fallback price) - asset which fee can be paid with
registered_assets: Vec<(Vec<u8>, Balance, Option<AssetId>)>, // (Asset name, Existential deposit, Chosen asset id)
accepted_assets: Vec<(AssetId, Price)>, // (Asset id, Fallback price) - asset which fee can be paid with
elections: Vec<AccountId>,
) -> GenesisConfig {
GenesisConfig {
Expand Down Expand Up @@ -773,7 +782,7 @@ fn testnet_parachain_genesis(
// of this.
aura: Default::default(),
asset_registry: AssetRegistryConfig {
asset_names: registered_assets.clone(),
registered_assets: registered_assets.clone(),
native_asset_name: TOKEN_SYMBOL.as_bytes().to_vec(),
native_existential_deposit: NATIVE_EXISTENTIAL_DEPOSIT,
},
Expand Down
Loading

0 comments on commit 5818ee3

Please sign in to comment.