Use derive macro to generate XcmWeightInfo trait (#4618)

* Use derive macro to generate XcmWeightInfo trait

* Move the Weight type alias out of proc macro
This commit is contained in:
Keith Yeung
2021-12-28 22:38:11 -08:00
committed by GitHub
parent ebfe0b7168
commit cf509bdb51
6 changed files with 80 additions and 66 deletions
-62
View File
@@ -123,9 +123,6 @@ impl From<SendError> for Error {
pub type Result = result::Result<(), Error>;
/// Local weight type; execution time in picoseconds.
pub type Weight = u64;
/// Outcome of an XCM execution.
#[derive(Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)]
pub enum Outcome {
@@ -319,62 +316,3 @@ impl SendXcm for Tuple {
Err(SendError::CannotReachDestination(destination.into(), message))
}
}
/// The info needed to weight an XCM.
// TODO: Automate Generation
pub trait XcmWeightInfo<Call> {
fn withdraw_asset(assets: &MultiAssets) -> Weight;
fn reserve_asset_deposited(assets: &MultiAssets) -> Weight;
fn receive_teleported_asset(assets: &MultiAssets) -> Weight;
fn query_response(query_id: &u64, response: &Response, max_weight: &u64) -> Weight;
fn transfer_asset(assets: &MultiAssets, beneficiary: &MultiLocation) -> Weight;
fn transfer_reserve_asset(assets: &MultiAssets, dest: &MultiLocation, xcm: &Xcm<()>) -> Weight;
fn transact(
origin_type: &OriginKind,
require_weight_at_most: &u64,
call: &DoubleEncoded<Call>,
) -> Weight;
fn hrmp_new_channel_open_request(
sender: &u32,
max_message_size: &u32,
max_capacity: &u32,
) -> Weight;
fn hrmp_channel_accepted(recipient: &u32) -> Weight;
fn hrmp_channel_closing(initiator: &u32, sender: &u32, recipient: &u32) -> Weight;
fn clear_origin() -> Weight;
fn descend_origin(who: &InteriorMultiLocation) -> Weight;
fn report_error(query_id: &QueryId, dest: &MultiLocation, max_response_weight: &u64) -> Weight;
fn deposit_asset(
assets: &MultiAssetFilter,
max_assets: &u32,
beneficiary: &MultiLocation,
) -> Weight;
fn deposit_reserve_asset(
assets: &MultiAssetFilter,
max_assets: &u32,
dest: &MultiLocation,
xcm: &Xcm<()>,
) -> Weight;
fn exchange_asset(give: &MultiAssetFilter, receive: &MultiAssets) -> Weight;
fn initiate_reserve_withdraw(
assets: &MultiAssetFilter,
reserve: &MultiLocation,
xcm: &Xcm<()>,
) -> Weight;
fn initiate_teleport(assets: &MultiAssetFilter, dest: &MultiLocation, xcm: &Xcm<()>) -> Weight;
fn query_holding(
query_id: &u64,
dest: &MultiLocation,
assets: &MultiAssetFilter,
max_response_weight: &u64,
) -> Weight;
fn buy_execution(fees: &MultiAsset, weight_limit: &WeightLimit) -> Weight;
fn refund_surplus() -> Weight;
fn set_error_handler(xcm: &Xcm<Call>) -> Weight;
fn set_appendix(xcm: &Xcm<Call>) -> Weight;
fn clear_error() -> Weight;
fn claim_asset(assets: &MultiAssets, ticket: &MultiLocation) -> Weight;
fn trap(code: &u64) -> Weight;
fn subscribe_version(query_id: &QueryId, max_response_weight: &u64) -> Weight;
fn unsubscribe_version() -> Weight;
}