From d2426613a21cdd696b134bea04b855e85e53d83d Mon Sep 17 00:00:00 2001 From: zktony Date: Sun, 28 Apr 2024 18:22:45 +0530 Subject: [PATCH 1/8] feature:Added new create_parachain_ext --- pallets/rewards/src/lib.rs | 6 ------ pallets/thea-executor/src/lib.rs | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/pallets/rewards/src/lib.rs b/pallets/rewards/src/lib.rs index 2b52c908c..a68895a8a 100644 --- a/pallets/rewards/src/lib.rs +++ b/pallets/rewards/src/lib.rs @@ -431,12 +431,6 @@ impl Pallet { .saturating_sub(user_reward_info.claim_amount), ); - //ensure the claimable amount is greater than min claimable amount - ensure!( - rewards_claimable.saturated_into::() > MIN_REWARDS_CLAIMABLE_AMOUNT, - Error::::AmountToLowToRedeem - ); - //remove lock T::NativeCurrency::remove_lock(user_reward_info.lock_id, &user); diff --git a/pallets/thea-executor/src/lib.rs b/pallets/thea-executor/src/lib.rs index 1222714c0..04d889fd7 100644 --- a/pallets/thea-executor/src/lib.rs +++ b/pallets/thea-executor/src/lib.rs @@ -25,6 +25,8 @@ extern crate core; use frame_support::pallet_prelude::Weight; +use frame_support::traits::fungibles::Create; +use sp_runtime::traits::One; pub use pallet::*; #[cfg(feature = "runtime-benchmarks")] @@ -470,6 +472,19 @@ pub mod pallet { Ok(()) } + + #[pallet::call_index(7)] + #[pallet::weight(< T as Config >::TheaExecWeightInfo::claim_deposit(1))] + #[transactional] + pub fn create_parachain_asset(origin: OriginFor, asset: AssetId, decimal: u8) -> DispatchResult { + T::GovernanceOrigin::ensure_origin(origin)?; + let asset_id = Self::generate_asset_id_for_parachain(asset); + Self::resolve_create(asset_id.into(), Self::thea_account(), 1u128)?; + let metadata = AssetMetadata::new(decimal).ok_or(Error::::InvalidDecimal)?; + >::insert(asset_id, metadata); + Self::deposit_event(Event::::AssetMetadataSet(metadata)); + Ok(()) + } } impl Pallet { @@ -677,6 +692,11 @@ pub mod pallet { )); Ok(()) } + + pub fn generate_asset_id_for_parachain(asset: AssetId) -> u128 { + let asset_id = u128::from_be_bytes(sp_io::hashing::blake2_128(&asset.encode()[..])); + asset_id + } } impl TheaIncomingExecutor for Pallet { From d51eba53a9125d9c1e9e8c38fd1da0fb57996696 Mon Sep 17 00:00:00 2001 From: zktony Date: Mon, 29 Apr 2024 13:20:41 +0530 Subject: [PATCH 2/8] Added test cases --- pallets/thea-executor/src/lib.rs | 7 ++++--- pallets/thea-executor/src/tests.rs | 23 +++++++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/pallets/thea-executor/src/lib.rs b/pallets/thea-executor/src/lib.rs index 04d889fd7..c33c8a32e 100644 --- a/pallets/thea-executor/src/lib.rs +++ b/pallets/thea-executor/src/lib.rs @@ -26,6 +26,7 @@ extern crate core; use frame_support::pallet_prelude::Weight; use frame_support::traits::fungibles::Create; +use xcm::v3::AssetId as XcmAssetId; use sp_runtime::traits::One; pub use pallet::*; @@ -73,7 +74,7 @@ pub mod pallet { types::{AssetMetadata, Deposit}, Network, TheaBenchmarkHelper, TheaIncomingExecutor, TheaOutgoingExecutor, NATIVE_NETWORK, }; - use xcm::VersionedMultiLocation; + use xcm::{VersionedMultiLocation, VersionedMultiAsset}; #[pallet::pallet] #[pallet::without_storage_info] @@ -476,7 +477,7 @@ pub mod pallet { #[pallet::call_index(7)] #[pallet::weight(< T as Config >::TheaExecWeightInfo::claim_deposit(1))] #[transactional] - pub fn create_parachain_asset(origin: OriginFor, asset: AssetId, decimal: u8) -> DispatchResult { + pub fn create_parachain_asset(origin: OriginFor, asset: XcmAssetId, decimal: u8) -> DispatchResult { T::GovernanceOrigin::ensure_origin(origin)?; let asset_id = Self::generate_asset_id_for_parachain(asset); Self::resolve_create(asset_id.into(), Self::thea_account(), 1u128)?; @@ -693,7 +694,7 @@ pub mod pallet { Ok(()) } - pub fn generate_asset_id_for_parachain(asset: AssetId) -> u128 { + pub fn generate_asset_id_for_parachain(asset: XcmAssetId) -> u128 { let asset_id = u128::from_be_bytes(sp_io::hashing::blake2_128(&asset.encode()[..])); asset_id } diff --git a/pallets/thea-executor/src/tests.rs b/pallets/thea-executor/src/tests.rs index 2d0e26c7a..f51f87083 100644 --- a/pallets/thea-executor/src/tests.rs +++ b/pallets/thea-executor/src/tests.rs @@ -27,13 +27,13 @@ use frame_support::{ use frame_system::EventRecord; use parity_scale_codec::Encode; use sp_core::H160; -use sp_runtime::{ - traits::{AccountIdConversion, BadOrigin}, - SaturatedConversion, -}; +use sp_runtime::{traits::{AccountIdConversion, BadOrigin}, SaturatedConversion, TokenError}; use thea_primitives::types::NewWithdraw; use thea_primitives::types::{AssetMetadata, Deposit}; use xcm::{opaque::lts::Junctions, v3::MultiLocation, VersionedMultiLocation}; +use frame_support::traits::fungibles::Inspect; +use sp_runtime::legacy::byte_sized_error::DispatchError; +use xcm::v3::Junction; fn assert_last_event(generic_event: ::RuntimeEvent) { let events = frame_system::Pallet::::events(); @@ -517,6 +517,21 @@ fn test_claim_deposit_returns_asset_not_registered() { }) } +#[test] +fn test_create_parachain_asset() { + new_test_ext().execute_with(|| { + let multilocation = MultiLocation { parents: 1, interior: Junctions::X1(Junction::Parachain(100)) }; + let asset = xcm::v3::AssetId::Concrete(multilocation); + assert_ok!(TheaExecutor::create_parachain_asset(RuntimeOrigin::root(), asset, 10)); + let asset_id = TheaExecutor::generate_asset_id_for_parachain(asset); + assert!(Assets::asset_exists(asset_id)); + let expected_metadata = AssetMetadata::new(10); + let actual_metadata = >::get(asset_id); + assert_eq!(expected_metadata, actual_metadata); + assert!(TheaExecutor::create_parachain_asset(RuntimeOrigin::root(), asset, 10).is_err()); + }) +} + fn setup_pool() { let asset_id = 1u128; let admin = 1u64; From e9236fdc2c1a26ba6aa309cff28e6fdfb5063fd3 Mon Sep 17 00:00:00 2001 From: zktony Date: Mon, 29 Apr 2024 13:23:20 +0530 Subject: [PATCH 3/8] Formatted --- pallets/thea-executor/src/lib.rs | 14 +++++++++----- pallets/thea-executor/src/tests.rs | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/pallets/thea-executor/src/lib.rs b/pallets/thea-executor/src/lib.rs index c33c8a32e..bdd81ee20 100644 --- a/pallets/thea-executor/src/lib.rs +++ b/pallets/thea-executor/src/lib.rs @@ -26,9 +26,9 @@ extern crate core; use frame_support::pallet_prelude::Weight; use frame_support::traits::fungibles::Create; -use xcm::v3::AssetId as XcmAssetId; -use sp_runtime::traits::One; pub use pallet::*; +use sp_runtime::traits::One; +use xcm::v3::AssetId as XcmAssetId; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; @@ -74,7 +74,7 @@ pub mod pallet { types::{AssetMetadata, Deposit}, Network, TheaBenchmarkHelper, TheaIncomingExecutor, TheaOutgoingExecutor, NATIVE_NETWORK, }; - use xcm::{VersionedMultiLocation, VersionedMultiAsset}; + use xcm::{VersionedMultiAsset, VersionedMultiLocation}; #[pallet::pallet] #[pallet::without_storage_info] @@ -477,9 +477,13 @@ pub mod pallet { #[pallet::call_index(7)] #[pallet::weight(< T as Config >::TheaExecWeightInfo::claim_deposit(1))] #[transactional] - pub fn create_parachain_asset(origin: OriginFor, asset: XcmAssetId, decimal: u8) -> DispatchResult { + pub fn create_parachain_asset( + origin: OriginFor, + asset: XcmAssetId, + decimal: u8, + ) -> DispatchResult { T::GovernanceOrigin::ensure_origin(origin)?; - let asset_id = Self::generate_asset_id_for_parachain(asset); + let asset_id = Self::generate_asset_id_for_parachain(asset); Self::resolve_create(asset_id.into(), Self::thea_account(), 1u128)?; let metadata = AssetMetadata::new(decimal).ok_or(Error::::InvalidDecimal)?; >::insert(asset_id, metadata); diff --git a/pallets/thea-executor/src/tests.rs b/pallets/thea-executor/src/tests.rs index f51f87083..62691a442 100644 --- a/pallets/thea-executor/src/tests.rs +++ b/pallets/thea-executor/src/tests.rs @@ -20,6 +20,7 @@ use crate::{ mock::{new_test_ext, Assets, Test, *}, PendingWithdrawals, WithdrawalFees, *, }; +use frame_support::traits::fungibles::Inspect; use frame_support::{ assert_noop, assert_ok, traits::{fungible::Mutate as FungibleMutate, fungibles::Mutate as FungiblesMutate}, @@ -27,13 +28,15 @@ use frame_support::{ use frame_system::EventRecord; use parity_scale_codec::Encode; use sp_core::H160; -use sp_runtime::{traits::{AccountIdConversion, BadOrigin}, SaturatedConversion, TokenError}; +use sp_runtime::legacy::byte_sized_error::DispatchError; +use sp_runtime::{ + traits::{AccountIdConversion, BadOrigin}, + SaturatedConversion, TokenError, +}; use thea_primitives::types::NewWithdraw; use thea_primitives::types::{AssetMetadata, Deposit}; -use xcm::{opaque::lts::Junctions, v3::MultiLocation, VersionedMultiLocation}; -use frame_support::traits::fungibles::Inspect; -use sp_runtime::legacy::byte_sized_error::DispatchError; use xcm::v3::Junction; +use xcm::{opaque::lts::Junctions, v3::MultiLocation, VersionedMultiLocation}; fn assert_last_event(generic_event: ::RuntimeEvent) { let events = frame_system::Pallet::::events(); @@ -520,7 +523,8 @@ fn test_claim_deposit_returns_asset_not_registered() { #[test] fn test_create_parachain_asset() { new_test_ext().execute_with(|| { - let multilocation = MultiLocation { parents: 1, interior: Junctions::X1(Junction::Parachain(100)) }; + let multilocation = + MultiLocation { parents: 1, interior: Junctions::X1(Junction::Parachain(100)) }; let asset = xcm::v3::AssetId::Concrete(multilocation); assert_ok!(TheaExecutor::create_parachain_asset(RuntimeOrigin::root(), asset, 10)); let asset_id = TheaExecutor::generate_asset_id_for_parachain(asset); From ca06cfca1085dc384e7174a3fc9d4e3beb1580c2 Mon Sep 17 00:00:00 2001 From: zktony Date: Mon, 29 Apr 2024 13:57:18 +0530 Subject: [PATCH 4/8] Removed unused imports --- pallets/thea-executor/src/lib.rs | 4 +--- pallets/xcm-helper/src/benchmarking.rs | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pallets/thea-executor/src/lib.rs b/pallets/thea-executor/src/lib.rs index bdd81ee20..f79ab53b7 100644 --- a/pallets/thea-executor/src/lib.rs +++ b/pallets/thea-executor/src/lib.rs @@ -25,9 +25,7 @@ extern crate core; use frame_support::pallet_prelude::Weight; -use frame_support::traits::fungibles::Create; pub use pallet::*; -use sp_runtime::traits::One; use xcm::v3::AssetId as XcmAssetId; #[cfg(feature = "runtime-benchmarks")] @@ -74,7 +72,7 @@ pub mod pallet { types::{AssetMetadata, Deposit}, Network, TheaBenchmarkHelper, TheaIncomingExecutor, TheaOutgoingExecutor, NATIVE_NETWORK, }; - use xcm::{VersionedMultiAsset, VersionedMultiLocation}; + use xcm::VersionedMultiLocation; #[pallet::pallet] #[pallet::without_storage_info] diff --git a/pallets/xcm-helper/src/benchmarking.rs b/pallets/xcm-helper/src/benchmarking.rs index 7960aa457..376e8cea2 100644 --- a/pallets/xcm-helper/src/benchmarking.rs +++ b/pallets/xcm-helper/src/benchmarking.rs @@ -109,6 +109,9 @@ benchmarks! { // assert!(failed_withdrawals.is_empty()); // assert!(withdrawals.is_empty()) // } + + + } #[cfg(test)] From ae8e1aa838e0f9ecc7c3533943a7de9d679512e1 Mon Sep 17 00:00:00 2001 From: zktony Date: Mon, 29 Apr 2024 14:47:53 +0530 Subject: [PATCH 5/8] Fixed clippy warnings --- pallets/thea-executor/src/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pallets/thea-executor/src/lib.rs b/pallets/thea-executor/src/lib.rs index f79ab53b7..098b65441 100644 --- a/pallets/thea-executor/src/lib.rs +++ b/pallets/thea-executor/src/lib.rs @@ -477,7 +477,7 @@ pub mod pallet { #[transactional] pub fn create_parachain_asset( origin: OriginFor, - asset: XcmAssetId, + asset: Box, decimal: u8, ) -> DispatchResult { T::GovernanceOrigin::ensure_origin(origin)?; @@ -696,9 +696,8 @@ pub mod pallet { Ok(()) } - pub fn generate_asset_id_for_parachain(asset: XcmAssetId) -> u128 { - let asset_id = u128::from_be_bytes(sp_io::hashing::blake2_128(&asset.encode()[..])); - asset_id + pub fn generate_asset_id_for_parachain(asset: Box) -> u128 { + u128::from_be_bytes(sp_io::hashing::blake2_128(&asset.encode()[..])) } } From 39cc7f4f98176d0b181167696ce9c6ed6ff40fbb Mon Sep 17 00:00:00 2001 From: zktony Date: Mon, 29 Apr 2024 15:29:11 +0530 Subject: [PATCH 6/8] Resolved Gj comment --- Cargo.lock | 1 + pallets/thea-executor/src/lib.rs | 8 ++------ pallets/xcm-helper/src/lib.rs | 3 ++- primitives/polkadex/Cargo.toml | 2 ++ primitives/polkadex/src/assets.rs | 5 +++++ 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 743894dfa..cb3d02d24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7975,6 +7975,7 @@ dependencies = [ "sp-core", "sp-runtime", "sp-std", + "staging-xcm", ] [[package]] diff --git a/pallets/thea-executor/src/lib.rs b/pallets/thea-executor/src/lib.rs index 098b65441..b91932ab4 100644 --- a/pallets/thea-executor/src/lib.rs +++ b/pallets/thea-executor/src/lib.rs @@ -477,11 +477,11 @@ pub mod pallet { #[transactional] pub fn create_parachain_asset( origin: OriginFor, - asset: Box, + asset: sp_std::boxed::Box, decimal: u8, ) -> DispatchResult { T::GovernanceOrigin::ensure_origin(origin)?; - let asset_id = Self::generate_asset_id_for_parachain(asset); + let asset_id = polkadex_primitives::assets::generate_asset_id_for_parachain(asset); Self::resolve_create(asset_id.into(), Self::thea_account(), 1u128)?; let metadata = AssetMetadata::new(decimal).ok_or(Error::::InvalidDecimal)?; >::insert(asset_id, metadata); @@ -695,10 +695,6 @@ pub mod pallet { )); Ok(()) } - - pub fn generate_asset_id_for_parachain(asset: Box) -> u128 { - u128::from_be_bytes(sp_io::hashing::blake2_128(&asset.encode()[..])) - } } impl TheaIncomingExecutor for Pallet { diff --git a/pallets/xcm-helper/src/lib.rs b/pallets/xcm-helper/src/lib.rs index 75ac44201..1b0929b76 100644 --- a/pallets/xcm-helper/src/lib.rs +++ b/pallets/xcm-helper/src/lib.rs @@ -552,7 +552,8 @@ pub mod pallet { return T::NativeAssetId::get().into(); } // If it's not native, then hash and generate the asset id - let asset_id = u128::from_be_bytes(sp_io::hashing::blake2_128(&asset.encode()[..])); + let asset_id = + polkadex_primitives::assets::generate_asset_id_for_parachain(Box::new(asset)); if !>::contains_key(asset_id) { // Store the mapping >::insert(asset_id, asset); diff --git a/primitives/polkadex/Cargo.toml b/primitives/polkadex/Cargo.toml index 3877e18bb..11652d1f2 100644 --- a/primitives/polkadex/Cargo.toml +++ b/primitives/polkadex/Cargo.toml @@ -22,6 +22,7 @@ rust_decimal = { git = "https://github.com/Polkadex-Substrate/rust-decimal.git", "scale-codec", "serde", ], default-features = false } +xcm = { workspace = true, default-features = false } [dev-dependencies] pretty_assertions = "1.2.1" @@ -45,5 +46,6 @@ std = [ "sp-runtime/std", "rust_decimal/std", "rust_decimal/serde", + "xcm/std" ] full_crypto = ['sp-core/full_crypto'] diff --git a/primitives/polkadex/src/assets.rs b/primitives/polkadex/src/assets.rs index 1b83c23cc..e6197d189 100644 --- a/primitives/polkadex/src/assets.rs +++ b/primitives/polkadex/src/assets.rs @@ -20,6 +20,7 @@ use crate::Balance; #[cfg(not(feature = "std"))] use codec::alloc::string::ToString; use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::__private::sp_io; use frame_support::{ ensure, traits::{ @@ -275,6 +276,10 @@ impl<'de> Visitor<'de> for AssetId { } } +pub fn generate_asset_id_for_parachain(asset: sp_std::boxed::Box) -> u128 { + u128::from_be_bytes(sp_io::hashing::blake2_128(&asset.encode()[..])) +} + #[cfg(feature = "std")] impl TryFrom for AssetId { type Error = anyhow::Error; From 0a9437fc4641064f438cde04dc54d36a55fcd5f7 Mon Sep 17 00:00:00 2001 From: zktony Date: Mon, 29 Apr 2024 20:00:45 +0530 Subject: [PATCH 7/8] Fixed tests --- pallets/rewards/src/tests.rs | 6 ------ pallets/thea-executor/src/tests.rs | 15 ++++++++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/pallets/rewards/src/tests.rs b/pallets/rewards/src/tests.rs index d5bdd2f24..041835a94 100644 --- a/pallets/rewards/src/tests.rs +++ b/pallets/rewards/src/tests.rs @@ -937,11 +937,5 @@ pub fn claim_rewards_for_alice_at_multiple_intervals() { System::set_block_number( start_block.saturating_add(require_block_to_claim_50_percentage_of_rewards), ); - - // assert_ok!(Rewards::claim(RuntimeOrigin::signed(alice_account.clone()), reward_id)); - disabled since the whole amount is claimed now - assert_noop!( - Rewards::claim(RuntimeOrigin::signed(alice_account), reward_id), - Error::::AmountToLowToRedeem - ); }) } diff --git a/pallets/thea-executor/src/tests.rs b/pallets/thea-executor/src/tests.rs index 62691a442..71ec47daf 100644 --- a/pallets/thea-executor/src/tests.rs +++ b/pallets/thea-executor/src/tests.rs @@ -28,10 +28,9 @@ use frame_support::{ use frame_system::EventRecord; use parity_scale_codec::Encode; use sp_core::H160; -use sp_runtime::legacy::byte_sized_error::DispatchError; use sp_runtime::{ traits::{AccountIdConversion, BadOrigin}, - SaturatedConversion, TokenError, + SaturatedConversion, }; use thea_primitives::types::NewWithdraw; use thea_primitives::types::{AssetMetadata, Deposit}; @@ -526,13 +525,19 @@ fn test_create_parachain_asset() { let multilocation = MultiLocation { parents: 1, interior: Junctions::X1(Junction::Parachain(100)) }; let asset = xcm::v3::AssetId::Concrete(multilocation); - assert_ok!(TheaExecutor::create_parachain_asset(RuntimeOrigin::root(), asset, 10)); - let asset_id = TheaExecutor::generate_asset_id_for_parachain(asset); + assert_ok!(TheaExecutor::create_parachain_asset( + RuntimeOrigin::root(), + Box::new(asset), + 10 + )); + let asset_id = + polkadex_primitives::assets::generate_asset_id_for_parachain(Box::new(asset)); assert!(Assets::asset_exists(asset_id)); let expected_metadata = AssetMetadata::new(10); let actual_metadata = >::get(asset_id); assert_eq!(expected_metadata, actual_metadata); - assert!(TheaExecutor::create_parachain_asset(RuntimeOrigin::root(), asset, 10).is_err()); + assert!(TheaExecutor::create_parachain_asset(RuntimeOrigin::root(), Box::new(asset), 10) + .is_err()); }) } From 078856e6cd43e920e76c7f18844eac526f3aab8a Mon Sep 17 00:00:00 2001 From: zktony Date: Tue, 30 Apr 2024 12:51:05 +0530 Subject: [PATCH 8/8] Fixed Comment --- pallets/thea-executor/src/lib.rs | 10 ++++++++++ pallets/thea-executor/src/tests.rs | 13 +++++++++++-- pallets/xcm-helper/src/lib.rs | 3 ++- primitives/polkadex/src/assets.rs | 11 +++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/pallets/thea-executor/src/lib.rs b/pallets/thea-executor/src/lib.rs index b91932ab4..e1e879090 100644 --- a/pallets/thea-executor/src/lib.rs +++ b/pallets/thea-executor/src/lib.rs @@ -90,6 +90,7 @@ pub mod pallet { /// Assets Pallet type Assets: frame_support::traits::tokens::fungibles::Mutate + frame_support::traits::tokens::fungibles::Create + + frame_support::traits::tokens::fungibles::metadata::Mutate + frame_support::traits::tokens::fungibles::Inspect; /// Asset Id type AssetId: Member @@ -478,11 +479,20 @@ pub mod pallet { pub fn create_parachain_asset( origin: OriginFor, asset: sp_std::boxed::Box, + name: Vec, + symbol: Vec, decimal: u8, ) -> DispatchResult { T::GovernanceOrigin::ensure_origin(origin)?; let asset_id = polkadex_primitives::assets::generate_asset_id_for_parachain(asset); Self::resolve_create(asset_id.into(), Self::thea_account(), 1u128)?; + Self::set_token_metadata( + asset_id.into(), + &Self::thea_account(), + name, + symbol, + decimal, + )?; let metadata = AssetMetadata::new(decimal).ok_or(Error::::InvalidDecimal)?; >::insert(asset_id, metadata); Self::deposit_event(Event::::AssetMetadataSet(metadata)); diff --git a/pallets/thea-executor/src/tests.rs b/pallets/thea-executor/src/tests.rs index 71ec47daf..2cbde072e 100644 --- a/pallets/thea-executor/src/tests.rs +++ b/pallets/thea-executor/src/tests.rs @@ -525,9 +525,12 @@ fn test_create_parachain_asset() { let multilocation = MultiLocation { parents: 1, interior: Junctions::X1(Junction::Parachain(100)) }; let asset = xcm::v3::AssetId::Concrete(multilocation); + Balances::set_balance(&TheaExecutor::thea_account(), 1_000_000_000_000_000_000); assert_ok!(TheaExecutor::create_parachain_asset( RuntimeOrigin::root(), Box::new(asset), + Default::default(), + Default::default(), 10 )); let asset_id = @@ -536,8 +539,14 @@ fn test_create_parachain_asset() { let expected_metadata = AssetMetadata::new(10); let actual_metadata = >::get(asset_id); assert_eq!(expected_metadata, actual_metadata); - assert!(TheaExecutor::create_parachain_asset(RuntimeOrigin::root(), Box::new(asset), 10) - .is_err()); + assert!(TheaExecutor::create_parachain_asset( + RuntimeOrigin::root(), + Box::new(asset), + Default::default(), + Default::default(), + 10 + ) + .is_err()); }) } diff --git a/pallets/xcm-helper/src/lib.rs b/pallets/xcm-helper/src/lib.rs index 1b0929b76..cb6833941 100644 --- a/pallets/xcm-helper/src/lib.rs +++ b/pallets/xcm-helper/src/lib.rs @@ -184,7 +184,8 @@ pub mod pallet { /// Assets type Assets: frame_support::traits::tokens::fungibles::Mutate + frame_support::traits::tokens::fungibles::Create - + frame_support::traits::tokens::fungibles::Inspect; + + frame_support::traits::tokens::fungibles::Inspect + + frame_support::traits::tokens::fungibles::metadata::Mutate; /// Asset Id type AssetId: Member + Parameter diff --git a/primitives/polkadex/src/assets.rs b/primitives/polkadex/src/assets.rs index e6197d189..e51084e31 100644 --- a/primitives/polkadex/src/assets.rs +++ b/primitives/polkadex/src/assets.rs @@ -47,6 +47,7 @@ pub trait Resolver< + frame_support::traits::tokens::fungible::Inspect, Others: frame_support::traits::tokens::fungibles::Mutate + frame_support::traits::tokens::fungibles::Inspect + + frame_support::traits::tokens::fungibles::metadata::Mutate + frame_support::traits::tokens::fungibles::Create, AssetId: Into + sp_std::cmp::PartialEq + Copy, NativeAssetId: Get, @@ -150,6 +151,16 @@ pub trait Resolver< } Ok(()) } + + fn set_token_metadata( + asset: AssetId, + from: &AccountId, + name: sp_std::vec::Vec, + symbol: sp_std::vec::Vec, + decimal: u8, + ) -> Result<(), DispatchError> { + Others::set(asset.into(), from, name, symbol, decimal) + } } /// Enumerated asset on chain