Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
fixed some errors in foucoco runtime. Not yet finished.
  • Loading branch information
b-yap committed Jul 6, 2023
commit 38476cd92a25c94e61e804049ba957b29d20e091
6 changes: 3 additions & 3 deletions runtime/foucoco/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod weights;
pub mod xcm_config;
pub mod zenlink;
use crate::zenlink::*;
use xcm::v1::MultiLocation;
use xcm::v3::MultiLocation;
use zenlink_protocol::{AssetBalance, MultiAssetsHandler, PairInfo};

pub use parachain_staking::InflationInfo;
Expand Down Expand Up @@ -1471,7 +1471,7 @@ construct_runtime!(
ChildBounties: pallet_child_bounties::{Pallet, Call, Storage, Event<T>} = 21,

// Collator support. The order of these 4 are important and shall not change.
Authorship: pallet_authorship::{Pallet, Call, Storage} = 30,
Authorship: pallet_authorship::{Pallet, Storage} = 30,
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>} = 32,
Aura: pallet_aura::{Pallet, Storage, Config<T>} = 33,
AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config} = 34,
Expand Down Expand Up @@ -1724,7 +1724,7 @@ impl_runtime_apis! {
}
}

impl farming_rpc_runtime_api::FarmingRuntimeApi<Block, AccountId, PoolId, CurrencyId> for Runtime {
impl farming_rpc_runtime_api::FarmingRuntimeApi<Block, AccountId, PoolId> for Runtime {
fn get_farming_rewards(who: AccountId, pid: PoolId) -> Vec<(CurrencyId, Balance)> {
Farming::get_farming_rewards(&who, pid).unwrap_or(Vec::new())
}
Expand Down
50 changes: 36 additions & 14 deletions runtime/foucoco/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use sp_runtime::traits::Convert;
use xcm::latest::{prelude::*, Weight as XCMWeight};
use xcm_builder::{
AccountId32Aliases, AllowUnpaidExecutionFrom, ConvertedConcreteAssetId, EnsureXcmOrigin,
FixedWeightBounds, FungiblesAdapter, LocationInverter, ParentIsPreset, RelayChainAsNative,
FixedWeightBounds, FungiblesAdapter, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, UsingComponents,
};
Expand All @@ -29,10 +29,12 @@ use xcm_executor::{

parameter_types! {
pub const RelayLocation: MultiLocation = MultiLocation::parent();
pub const RelayNetwork: NetworkId = NetworkId::Any;
pub const RelayNetwork: NetworkId = NetworkId::Rococo;
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
pub UniversalLocation: InteriorMultiLocation =
X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into()));
}

/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
Expand Down Expand Up @@ -104,14 +106,17 @@ impl<ReserveProvider> FilterAssetLocation for MultiNativeAsset<ReserveProvider>
where
ReserveProvider: Reserve,
{
fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool {
if let Some(ref reserve) = ReserveProvider::reserve(asset) {
if reserve == origin {
return true
}
}
false
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
todo!()
}
// fn filter_asset_location(asset: &MultiAsset, origin: &MultiLocation) -> bool {
// if let Some(ref reserve) = ReserveProvider::reserve(asset) {
// if reserve == origin {
// return true
// }
// }
// false
// }
}

/// Means for transacting the fungibles assets of ths parachain.
Expand Down Expand Up @@ -241,16 +246,26 @@ impl xcm_executor::Config for XcmConfig {
type AssetTransactor = FungiblesTransactor;
type OriginConverter = XcmOriginToTransactDispatchOrigin;
type IsReserve = MultiNativeAsset<RelativeReserveProvider>;
type IsTeleporter = (); // Teleporting is disabled.
type LocationInverter = LocationInverter<Ancestry>;
type IsTeleporter = ();
type UniversalLocation = UniversalLocation;
// Teleporting is disabled.
type Barrier = Barrier;
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
type Trader =
UsingComponents<WeightToFee, RelayLocation, AccountId, Balances, ToAuthor<Runtime>>;
type ResponseHandler = PolkadotXcm;
type AssetTrap = PolkadotXcm;
type AssetLocker = ();
type AssetExchanger = ();
type AssetClaims = PolkadotXcm;
type SubscriptionService = PolkadotXcm;
type PalletInstancesInfo = ();
type MaxAssetsIntoHolding = ();
type FeeManager = ();
type MessageExporter = ();
type UniversalAliases = ();
type CallDispatcher = ();
type SafeCallFilter = ();
}

/// No local origins on this chain are allowed to dispatch XCM sends/executions.
Expand All @@ -260,13 +275,15 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
/// queues.
pub type XcmRouter = (
// Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm>,
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
// ..and XCMP to communicate with the sibling chains.
XcmpQueue,
);

impl pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type CurrencyMatcher = ();
type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmRouter = XcmRouter;
type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
Expand All @@ -277,13 +294,19 @@ impl pallet_xcm::Config for Runtime {
type XcmTeleportFilter = Nothing;
type XcmReserveTransferFilter = Everything;
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>;
type UniversalLocation = ();

type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;

const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
// ^ Override for AdvertisedXcmVersion default
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
type TrustedLockers = ();
type SovereignAccountOf = ();
type MaxLockers = ();
type WeightInfo = ();
type ReachableDest = ();
}

parameter_type_with_key! {
Expand All @@ -302,7 +325,6 @@ impl orml_xtokens::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
type BaseXcmWeight = BaseXcmWeight;
type LocationInverter = LocationInverter<Ancestry>;
type MaxAssetsForTransfer = MaxAssetsForTransfer;
type MinXcmFee = ParachainMinFee; //TODO to support hrmp transfer beetween parachain adjust this parameter
type MultiLocationsFilter = Everything;
Expand Down
2 changes: 1 addition & 1 deletion runtime/foucoco/src/zenlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use sp_runtime::{DispatchError, DispatchResult};
use sp_std::marker::PhantomData;

use zenlink_protocol::{
AssetId, AssetIdConverter, Config as ZenlinkConfig, LocalAssetHandler, PairLpGenerate,
AssetId, Config as ZenlinkConfig, LocalAssetHandler, PairLpGenerate,
ZenlinkMultiAssets, LOCAL, NATIVE,
};
pub type ZenlinkAssetId = zenlink_protocol::AssetId;
Expand Down