Skip to content

Commit

Permalink
fix transactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo committed Dec 30, 2023
1 parent ed7bcac commit 96d191f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
4 changes: 2 additions & 2 deletions runtime/shibuya/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use frame_support::{
parameter_types,
traits::{
AsEnsureOriginWithArg, ConstU32, Contains, Currency, EitherOfDiverse, EqualPrivilegeOnly,
FindAuthor, Get, Imbalance, InstanceFilter, Nothing, OnFinalize, OnUnbalanced,
Everything, FindAuthor, Get, Imbalance, InstanceFilter, OnFinalize, OnUnbalanced,
WithdrawReasons,
},
weights::{
Expand Down Expand Up @@ -708,7 +708,7 @@ impl pallet_contracts::Config for Runtime {
/// and make sure they are stable. Dispatchables exposed to contracts are not allowed to
/// change because that would break already deployed contracts. The `Call` structure itself
/// is not allowed to change the indices of existing pallets, too.
type CallFilter = Nothing;
type CallFilter = Everything;
type DepositPerItem = DepositPerItem;
type DepositPerByte = DepositPerByte;
type DefaultDepositLimit = DefaultDepositLimit;
Expand Down
31 changes: 19 additions & 12 deletions runtime/shibuya/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
// along with Astar. If not, see <http://www.gnu.org/licenses/>.

use super::{
AccountId, AllPalletsWithSystem, AssetId, Assets, Balance, Balances, DealWithFees,
ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
ShibuyaAssetLocationIdConverter, TreasuryAccountId, XcAssetConfig, XcmWeightToFee, XcmpQueue,
CollectionId, ItemId, Uniques,
AccountId, AllPalletsWithSystem, AssetId, Assets, Balance, Balances, CollectionId,
DealWithFees, ItemId, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall,
RuntimeEvent, RuntimeOrigin, ShibuyaAssetLocationIdConverter, TreasuryAccountId, Uniques,
XcAssetConfig, XcmWeightToFee, XcmpQueue,
};
use crate::weights;
use frame_support::{
Expand All @@ -32,17 +32,17 @@ use frame_system::EnsureRoot;
use sp_runtime::traits::Convert;

// Polkadot imports
use pallet_xc_asset_config::XcAssetLocation;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, ConvertedConcreteId, CurrencyAdapter,
EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, IsConcrete, NoChecking,
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WithComputedOrigin,
NonFungiblesAdapter,
NonFungiblesAdapter, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
WithComputedOrigin,
};
use pallet_xc_asset_config::XcAssetLocation;
use xcm_executor::{
traits::{Convert as XcmConvert, Error as MatchError, JustTry, MatchesNonFungibles},
XcmExecutor,
Expand Down Expand Up @@ -119,7 +119,10 @@ impl MatchesNonFungibles<CollectionId, ItemId> for MultiAssetToUniquesConverter
(NonFungible(ref instance), Concrete(ref class)) => (instance, class),
_ => return Err(MatchError::AssetNotHandled),
};
let collection_id = XcAssetConfig::get_asset_id(*class).unwrap();
let collection_id: CollectionId = XcAssetConfig::get_asset_id(*class)
.ok_or(MatchError::AssetNotHandled)?
.try_into()
.map_err(|_| MatchError::AssetIdConversionFailed)?;

let item_id = match instance {
Index(indx) => *indx,
Expand All @@ -133,7 +136,7 @@ impl MatchesNonFungibles<CollectionId, ItemId> for MultiAssetToUniquesConverter
pub type NonFungiblesTransactor = NonFungiblesAdapter<
// Use the uniques pallet:
Uniques,
// This will handle any non-fungible asset which is registered in xc-assets pallet.
// This will handle any non-fungible asset which is registered in xc-assets pallet.
MultiAssetToUniquesConverter,
// Convert an XCM MultiLocation into a local account id:
LocationToAccountId,
Expand All @@ -146,7 +149,11 @@ pub type NonFungiblesTransactor = NonFungiblesAdapter<
>;

/// Means for transacting assets on this chain.
pub type AssetTransactors = (CurrencyTransactor, FungiblesTransactor, NonFungiblesTransactor);
pub type AssetTransactors = (
CurrencyTransactor,
FungiblesTransactor,
NonFungiblesTransactor,
);

/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can
Expand Down

0 comments on commit 96d191f

Please sign in to comment.