Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit d0f7e3e

Browse files
failing on buy execution
1 parent 668da4c commit d0f7e3e

File tree

5 files changed

+60
-38
lines changed

5 files changed

+60
-38
lines changed

cumulus/parachains/integration-tests/emulated/networks/rococo-wococo-system/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,6 @@ decl_test_sender_receiver_accounts_parameter_types! {
9393
BridgeHubRococoPara { sender: ALICE, receiver: BOB },
9494
WococoRelay { sender: ALICE, receiver: BOB },
9595
AssetHubWococoPara { sender: ALICE, receiver: BOB },
96-
BridgeHubWococoPara { sender: ALICE, receiver: BOB }
96+
BridgeHubWococoPara { sender: ALICE, receiver: BOB },
97+
PenpalAPara { sender: ALICE, receiver: BOB }
9798
}

cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ pub use rococo_wococo_system_emulated_network::{
4343
bridge_hub_rococo_emulated_chain::{
4444
genesis::ED as BRIDGE_HUB_ROCOCO_ED, BridgeHubRococoParaPallet as BridgeHubRococoPallet,
4545
},
46+
penpal_emulated_chain::PenpalAParaPallet as PenpalAPallet,
4647
rococo_emulated_chain::{genesis::ED as ROCOCO_ED, RococoRelayPallet as RococoPallet},
4748
AssetHubRococoPara as AssetHubRococo, AssetHubRococoParaReceiver as AssetHubRococoReceiver,
4849
AssetHubRococoParaSender as AssetHubRococoSender, AssetHubWococoPara as AssetHubWococo,
4950
BridgeHubRococoPara as BridgeHubRococo, BridgeHubRococoParaReceiver as BridgeHubRococoReceiver,
5051
BridgeHubRococoParaSender as BridgeHubRococoSender, BridgeHubWococoPara as BridgeHubWococo,
51-
PenpalAPara as PenpalARococo, RococoRelay as Rococo, RococoRelayReceiver as RococoReceiver,
52-
RococoRelaySender as RococoSender,
52+
PenpalAPara as PenpalA, PenpalAParaSender as PenpalASender, PenpalAParaReceiver as PenpalAReceiver,
53+
RococoRelay as Rococo, RococoRelayReceiver as RococoReceiver, RococoRelaySender as RococoSender,
5354
};
5455

5556
pub const ASSET_ID: u32 = 1;

cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,14 @@ fn register_token() {
226226

227227
#[test]
228228
fn send_token_to_penpal() {
229-
BridgeHubRococo::fund_accounts(vec![(
230-
BridgeHubRococo::sovereign_account_id_of(MultiLocation {
229+
let asset_hub_sovereign = BridgeHubRococo::sovereign_account_id_of(
230+
MultiLocation {
231231
parents: 1,
232232
interior: X1(Parachain(ASSETHUB_PARA_ID)),
233-
}),
233+
}
234+
);
235+
BridgeHubRococo::fund_accounts(vec![(
236+
asset_hub_sovereign.clone(),
234237
INITIAL_FUND,
235238
)]);
236239

@@ -239,6 +242,30 @@ fn send_token_to_penpal() {
239242
(AssetHubRococoReceiver::get(), INITIAL_FUND),
240243
]);
241244

245+
PenpalA::fund_accounts(vec![
246+
(PenpalAReceiver::get(), INITIAL_FUND),
247+
(PenpalASender::get(), INITIAL_FUND),
248+
]);
249+
250+
let weth_asset_id: MultiLocation = (
251+
Parent,
252+
Parent,
253+
Ethereum { chain_id: 15 },
254+
AccountKey20 { network: None, key: WETH }
255+
).into();
256+
257+
// Create asset on penpal.
258+
PenpalA::execute_with(|| {
259+
assert_ok!(<PenpalA as PenpalAPallet>::ForeignAssets::create(
260+
<PenpalA as Chain>::RuntimeOrigin::signed(PenpalASender::get()),
261+
weth_asset_id,
262+
asset_hub_sovereign.into(),
263+
1000,
264+
));
265+
266+
//assert!(<PenpalA as PenpalAPallet>::Assets::asset_exists(weth_asset_id));
267+
});
268+
242269
let message_id_: H256 = [1; 32].into();
243270

244271
BridgeHubRococo::execute_with(|| {
@@ -255,7 +282,7 @@ fn send_token_to_penpal() {
255282
chain_id: CHAIN_ID,
256283
command: Command::SendToken {
257284
token: WETH.into(),
258-
destination: Destination::AccountId32 { id: AssetHubRococoReceiver::get().into() },
285+
destination: Destination::ForeignAccountId32 { para_id: 2000, id: AssetHubRococoReceiver::get().into() },
259286
amount: 1_000_000_000,
260287
},
261288
});
@@ -282,11 +309,11 @@ fn send_token_to_penpal() {
282309
);
283310
});
284311

285-
PenpalARococo::execute_with(|| {
286-
type RuntimeEvent = <PenpalARococo as Chain>::RuntimeEvent;
312+
PenpalA::execute_with(|| {
313+
type RuntimeEvent = <PenpalA as Chain>::RuntimeEvent;
287314

288315
assert_expected_events!(
289-
PenpalARococo,
316+
PenpalA,
290317
vec![
291318
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {},
292319
]

cumulus/parachains/runtimes/testing/penpal/src/lib.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
3232
mod weights;
3333
pub mod xcm_config;
3434

35-
use assets_common::{
36-
foreign_creators::ForeignCreators,
37-
matching::FromSiblingParachain,
38-
MultiLocationForAssetId,
39-
};
35+
use assets_common::MultiLocationForAssetId;
4036
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
4137
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
4238
use frame_support::{
@@ -75,7 +71,7 @@ use sp_std::prelude::*;
7571
#[cfg(feature = "std")]
7672
use sp_version::NativeVersion;
7773
use sp_version::RuntimeVersion;
78-
use xcm_config::{AssetsToBlockAuthor, ForeignCreatorsSovereignAccountOf, XcmOriginToTransactDispatchOrigin};
74+
use xcm_config::{AssetsToBlockAuthor, XcmOriginToTransactDispatchOrigin};
7975

8076
#[cfg(any(feature = "std", test))]
8177
pub use sp_runtime::BuildStorage;
@@ -473,9 +469,6 @@ parameter_types! {
473469
pub const ForeignAssetsMetadataDepositPerByte: Balance = MetadataDepositPerByte::get();
474470
}
475471

476-
/// We allow root to execute privileged asset operations.
477-
pub type AssetsForceOrigin = EnsureRoot<AccountId>;
478-
479472
/// Another pallet assets instance to store foreign assets from bridgehub.
480473
pub type ForeignAssetsInstance = pallet_assets::Instance2;
481474
impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
@@ -484,12 +477,8 @@ impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
484477
type AssetId = MultiLocationForAssetId;
485478
type AssetIdParameter = MultiLocationForAssetId;
486479
type Currency = Balances;
487-
type CreateOrigin = ForeignCreators<
488-
(FromSiblingParachain<parachain_info::Pallet<Runtime>>,),
489-
ForeignCreatorsSovereignAccountOf,
490-
AccountId,
491-
>;
492-
type ForceOrigin = AssetsForceOrigin;
480+
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
481+
type ForceOrigin = EnsureRoot<AccountId>;
493482
type AssetDeposit = ForeignAssetsAssetDeposit;
494483
type MetadataDepositBase = ForeignAssetsMetadataDepositBase;
495484
type MetadataDepositPerByte = ForeignAssetsMetadataDepositPerByte;

cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,22 @@ pub type Barrier = TrailingSetTopicAsId<
188188
pub type AccountIdOf<R> = <R as frame_system::Config>::AccountId;
189189

190190
/// Asset filter that allows all assets from a certain location matching asset id.
191-
pub struct AssetsFrom<T>(PhantomData<T>);
192-
impl<T: Get<MultiLocation>> ContainsPair<MultiAsset, MultiLocation> for AssetsFrom<T> {
191+
pub struct AssetPrefixFrom<Prefix, Origin>(PhantomData<(Prefix, Origin)>);
192+
impl<Prefix, Origin> ContainsPair<MultiAsset, MultiLocation> for AssetPrefixFrom<Prefix, Origin>
193+
where
194+
Prefix: Get<MultiLocation>,
195+
Origin: Get<MultiLocation>,
196+
{
193197
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
194-
let loc = T::get();
198+
let loc = Origin::get();
195199
&loc == origin &&
196200
matches!(asset, MultiAsset { id: AssetId::Concrete(asset_loc), fun: Fungible(_a) }
197-
if asset_loc.starts_with(&loc))
201+
if asset_loc.starts_with(&Prefix::get()))
198202
}
199203
}
200204

205+
type AssetsFrom<T> = AssetPrefixFrom<T, T>;
206+
201207
/// Asset filter that allows native/relay asset if coming from a certain location.
202208
pub struct NativeAssetFrom<T>(PhantomData<T>);
203209
impl<T: Get<MultiLocation>> ContainsPair<MultiAsset, MultiLocation> for NativeAssetFrom<T> {
@@ -245,10 +251,15 @@ parameter_types! {
245251
pub SystemAssetHubAssetsPalletLocation: MultiLocation =
246252
MultiLocation::new(1, X2(Parachain(1000), PalletInstance(50)));
247253
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
254+
pub EthereumLocation: MultiLocation = MultiLocation::new(2, X1(GlobalConsensus(Ethereum { chain_id: 15 })));
248255
}
249256

250-
pub type Reserves =
251-
(NativeAsset, AssetsFrom<SystemAssetHubLocation>, NativeAssetFrom<SystemAssetHubLocation>);
257+
pub type Reserves = (
258+
NativeAsset,
259+
AssetsFrom<SystemAssetHubLocation>,
260+
NativeAssetFrom<SystemAssetHubLocation>,
261+
AssetPrefixFrom<EthereumLocation, SystemAssetHubLocation>,
262+
);
252263

253264
pub struct XcmConfig;
254265
impl xcm_executor::Config for XcmConfig {
@@ -293,13 +304,6 @@ pub type XcmRouter = WithUniqueTopic<(
293304
XcmpQueue,
294305
)>;
295306

296-
// TODO(alistair): Only assethub should be able to create.
297-
pub type ForeignCreatorsSovereignAccountOf = (
298-
SiblingParachainConvertsVia<Sibling, AccountId>,
299-
AccountId32Aliases<RelayNetwork, AccountId>,
300-
ParentIsPreset<AccountId>,
301-
);
302-
303307
impl pallet_xcm::Config for Runtime {
304308
type RuntimeEvent = RuntimeEvent;
305309
type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;

0 commit comments

Comments
 (0)