Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Pull in latest Reserve Transfer code (paritytech#989)
Browse files Browse the repository at this point in the history
* pull in latest snowbridge

* better messages

* updated

* move trait for re-use

* update cumulus

* fix tests

* fix mocks and tests

* fix clippy error

* updated polkadot-sdk

* move AllowSiblingsOnly to core

* update polkadot-sdk

* update polkadot-sdk

* update polkadot-sdk
  • Loading branch information
alistair-singh authored Nov 3, 2023
1 parent 02e470c commit 59c657f
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 55 deletions.
107 changes: 70 additions & 37 deletions parachain/Cargo.lock

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

18 changes: 5 additions & 13 deletions parachain/pallets/control/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
use crate as snowbridge_control;
use frame_support::{
parameter_types,
traits::{tokens::fungible::Mutate, ConstU128, ConstU16, ConstU64, ConstU8, Contains},
traits::{tokens::fungible::Mutate, ConstU128, ConstU16, ConstU64, ConstU8},
weights::IdentityFee,
PalletId,
};
use sp_core::H256;
use xcm_executor::traits::ConvertLocation;

use snowbridge_core::{outbound::ConstantGasMeter, sibling_sovereign_account, AgentId, ParaId};
use snowbridge_core::{
outbound::ConstantGasMeter, sibling_sovereign_account, AgentId, AllowSiblingsOnly, ParaId,
};
use sp_runtime::{
traits::{AccountIdConversion, BlakeTwo256, IdentityLookup, Keccak256},
AccountId32, BuildStorage,
Expand Down Expand Up @@ -132,6 +134,7 @@ impl pallet_balances::Config for Test {
type FreezeIdentifier = ();
type MaxFreezes = ();
type RuntimeHoldReason = ();
type RuntimeFreezeReason = ();
type MaxHolds = ();
}

Expand Down Expand Up @@ -201,17 +204,6 @@ impl BenchmarkHelper<RuntimeOrigin> for () {
}
}

pub struct AllowSiblingsOnly;
impl Contains<MultiLocation> for AllowSiblingsOnly {
fn contains(location: &MultiLocation) -> bool {
if let MultiLocation { parents: 1, interior: X1(Parachain(_)) } = location {
true
} else {
false
}
}
}

impl crate::Config for Test {
type RuntimeEvent = RuntimeEvent;
type OwnParaId = OwnParaId;
Expand Down
1 change: 1 addition & 0 deletions parachain/pallets/inbound-queue/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl pallet_balances::Config for Test {
type FreezeIdentifier = ();
type MaxFreezes = ();
type RuntimeHoldReason = ();
type RuntimeFreezeReason = ();
type MaxHolds = ();
}

Expand Down
10 changes: 10 additions & 0 deletions parachain/primitives/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ pub use polkadot_parachain_primitives::primitives::{
Id as ParaId, IsSystem, Sibling as SiblingParaId,
};
pub use ringbuffer::{RingBufferMap, RingBufferMapImpl};

use frame_support::traits::Contains;
use sp_core::H256;
use sp_runtime::traits::AccountIdConversion;
use xcm::prelude::{Junction::Parachain, Junctions::X1, MultiLocation};

/// The ID of an agent contract
pub type AgentId = H256;
Expand All @@ -28,6 +31,13 @@ where
SiblingParaId::from(para_id).into_account_truncating()
}

pub struct AllowSiblingsOnly;
impl Contains<MultiLocation> for AllowSiblingsOnly {
fn contains(location: &MultiLocation) -> bool {
matches!(location, MultiLocation { parents: 1, interior: X1(Parachain(_)) })
}
}

pub const GWEI: u128 = 1_000_000_000;
pub const METH: u128 = 1_000_000_000_000_000;
pub const ETH: u128 = 1_000_000_000_000_000_000;
14 changes: 14 additions & 0 deletions parachain/primitives/core/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#[cfg(test)]
mod tests {
use frame_support::traits::Contains;
use snowbridge_core::AllowSiblingsOnly;
use xcm::prelude::{Junction::Parachain, Junctions::X1, MultiLocation};

#[test]
fn allow_siblings_predicate_only_allows_siblings() {
let sibling = MultiLocation::new(1, X1(Parachain(1000)));
let child = MultiLocation::new(0, X1(Parachain(1000)));
assert!(AllowSiblingsOnly::contains(&sibling), "Sibling returns true.");
assert!(!AllowSiblingsOnly::contains(&child), "Child returns false.");
}
}
2 changes: 1 addition & 1 deletion polkadot-sdk
Submodule polkadot-sdk updated 518 files
Loading

0 comments on commit 59c657f

Please sign in to comment.