mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 15:11:02 +00:00
companion: for call usage https://github.com/paritytech/substrate/pull/9418 (#3522)
* add test for call size * fix box arg * fix xcm variant length + increase limit a bit * fix para sudo wrapper call length * reorganize * fmt * fix tests * update Substrate Co-authored-by: parity-processbot <>
This commit is contained in:
committed by
GitHub
parent
36b390ceea
commit
f78f803698
@@ -114,15 +114,19 @@ pub mod pallet {
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::weight(100_000_000)]
|
||||
pub fn send(origin: OriginFor<T>, dest: MultiLocation, message: Xcm<()>) -> DispatchResult {
|
||||
pub fn send(
|
||||
origin: OriginFor<T>,
|
||||
dest: Box<MultiLocation>,
|
||||
message: Box<Xcm<()>>,
|
||||
) -> DispatchResult {
|
||||
let origin_location = T::SendXcmOrigin::ensure_origin(origin)?;
|
||||
Self::send_xcm(origin_location.clone(), dest.clone(), message.clone()).map_err(
|
||||
Self::send_xcm(origin_location.clone(), *dest.clone(), *message.clone()).map_err(
|
||||
|e| match e {
|
||||
XcmError::CannotReachDestination(..) => Error::<T>::Unreachable,
|
||||
_ => Error::<T>::SendFailure,
|
||||
},
|
||||
)?;
|
||||
Self::deposit_event(Event::Sent(origin_location, dest, message));
|
||||
Self::deposit_event(Event::Sent(origin_location, *dest, *message));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -144,7 +148,7 @@ pub mod pallet {
|
||||
assets: assets.clone(),
|
||||
effects: sp_std::vec![ InitiateTeleport {
|
||||
assets: Wild(All),
|
||||
dest: dest.clone(),
|
||||
dest: *dest.clone(),
|
||||
effects: sp_std::vec![],
|
||||
} ]
|
||||
};
|
||||
@@ -152,8 +156,8 @@ pub mod pallet {
|
||||
})]
|
||||
pub fn teleport_assets(
|
||||
origin: OriginFor<T>,
|
||||
dest: MultiLocation,
|
||||
beneficiary: MultiLocation,
|
||||
dest: Box<MultiLocation>,
|
||||
beneficiary: Box<MultiLocation>,
|
||||
assets: MultiAssets,
|
||||
fee_asset_item: u32,
|
||||
dest_weight: Weight,
|
||||
@@ -176,7 +180,7 @@ pub mod pallet {
|
||||
assets,
|
||||
effects: vec![InitiateTeleport {
|
||||
assets: Wild(All),
|
||||
dest,
|
||||
dest: *dest,
|
||||
effects: vec![
|
||||
BuyExecution {
|
||||
fees,
|
||||
@@ -187,7 +191,7 @@ pub mod pallet {
|
||||
orders: vec![],
|
||||
instructions: vec![],
|
||||
},
|
||||
DepositAsset { assets: Wild(All), max_assets, beneficiary },
|
||||
DepositAsset { assets: Wild(All), max_assets, beneficiary: *beneficiary },
|
||||
],
|
||||
}],
|
||||
};
|
||||
@@ -216,15 +220,15 @@ pub mod pallet {
|
||||
#[pallet::weight({
|
||||
let mut message = Xcm::TransferReserveAsset {
|
||||
assets: assets.clone(),
|
||||
dest: dest.clone(),
|
||||
dest: *dest.clone(),
|
||||
effects: sp_std::vec![],
|
||||
};
|
||||
T::Weigher::weight(&mut message).map_or(Weight::max_value(), |w| 100_000_000 + w)
|
||||
})]
|
||||
pub fn reserve_transfer_assets(
|
||||
origin: OriginFor<T>,
|
||||
dest: MultiLocation,
|
||||
beneficiary: MultiLocation,
|
||||
dest: Box<MultiLocation>,
|
||||
beneficiary: Box<MultiLocation>,
|
||||
assets: MultiAssets,
|
||||
fee_asset_item: u32,
|
||||
dest_weight: Weight,
|
||||
@@ -245,7 +249,7 @@ pub mod pallet {
|
||||
let assets = assets.into();
|
||||
let mut message = Xcm::TransferReserveAsset {
|
||||
assets,
|
||||
dest,
|
||||
dest: *dest,
|
||||
effects: vec![
|
||||
BuyExecution {
|
||||
fees,
|
||||
@@ -256,7 +260,7 @@ pub mod pallet {
|
||||
orders: vec![],
|
||||
instructions: vec![],
|
||||
},
|
||||
DepositAsset { assets: Wild(All), max_assets, beneficiary },
|
||||
DepositAsset { assets: Wild(All), max_assets, beneficiary: *beneficiary },
|
||||
],
|
||||
};
|
||||
let weight =
|
||||
|
||||
@@ -46,7 +46,11 @@ fn send_works() {
|
||||
DepositAsset { assets: All.into(), max_assets: 1, beneficiary: sender.clone() },
|
||||
],
|
||||
};
|
||||
assert_ok!(XcmPallet::send(Origin::signed(ALICE), RelayLocation::get(), message.clone()));
|
||||
assert_ok!(XcmPallet::send(
|
||||
Origin::signed(ALICE),
|
||||
Box::new(RelayLocation::get()),
|
||||
Box::new(message.clone())
|
||||
));
|
||||
assert_eq!(
|
||||
sent_xcm(),
|
||||
vec![(
|
||||
@@ -83,7 +87,7 @@ fn send_fails_when_xcm_router_blocks() {
|
||||
assert_noop!(
|
||||
XcmPallet::send(
|
||||
Origin::signed(ALICE),
|
||||
X8(
|
||||
Box::new(X8(
|
||||
Junction::Parent,
|
||||
Junction::Parent,
|
||||
Junction::Parent,
|
||||
@@ -92,8 +96,8 @@ fn send_fails_when_xcm_router_blocks() {
|
||||
Junction::Parent,
|
||||
Junction::Parent,
|
||||
Junction::Parent
|
||||
),
|
||||
message.clone()
|
||||
)),
|
||||
Box::new(message.clone())
|
||||
),
|
||||
crate::Error::<Test>::SendFailure
|
||||
);
|
||||
@@ -113,8 +117,8 @@ fn teleport_assets_works() {
|
||||
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
|
||||
assert_ok!(XcmPallet::teleport_assets(
|
||||
Origin::signed(ALICE),
|
||||
RelayLocation::get(),
|
||||
X1(AccountId32 { network: Any, id: BOB.into() }),
|
||||
Box::new(RelayLocation::get()),
|
||||
Box::new(X1(AccountId32 { network: Any, id: BOB.into() })),
|
||||
(Here, SEND_AMOUNT).into(),
|
||||
0,
|
||||
weight,
|
||||
@@ -142,8 +146,8 @@ fn reserve_transfer_assets_works() {
|
||||
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
|
||||
assert_ok!(XcmPallet::reserve_transfer_assets(
|
||||
Origin::signed(ALICE),
|
||||
Parachain(PARA_ID).into(),
|
||||
dest.clone(),
|
||||
Box::new(Parachain(PARA_ID).into()),
|
||||
Box::new(dest.clone()),
|
||||
(Here, SEND_AMOUNT).into(),
|
||||
0,
|
||||
weight
|
||||
|
||||
@@ -190,8 +190,8 @@ mod tests {
|
||||
Relay::execute_with(|| {
|
||||
assert_ok!(RelayChainPalletXcm::reserve_transfer_assets(
|
||||
relay_chain::Origin::signed(ALICE),
|
||||
X1(Parachain(1)),
|
||||
X1(AccountId32 { network: Any, id: ALICE.into() }),
|
||||
Box::new(X1(Parachain(1))),
|
||||
Box::new(X1(AccountId32 { network: Any, id: ALICE.into() })),
|
||||
(Here, 123).into(),
|
||||
0,
|
||||
3,
|
||||
|
||||
Reference in New Issue
Block a user