Skip to content

Commit

Permalink
ExecuteInstruction
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc committed Jan 15, 2025
1 parent 226ed93 commit c3a575d
Show file tree
Hide file tree
Showing 14 changed files with 2,230 additions and 873 deletions.
34 changes: 34 additions & 0 deletions polkadot/xcm/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,40 @@ impl Reanchorable for Location {
}
}

impl Reanchorable for Asset {
type Error = ();

/// Mutate the location of the asset identifier if concrete, giving it the same location
/// relative to a `target` context. The local context is provided as `context`.
fn reanchor(&mut self, target: &Location, context: &InteriorLocation) -> result::Result<(), ()> {
self.id.reanchor(target, context)
}

/// Mutate the location of the asset identifier if concrete, giving it the same location
/// relative to a `target` context. The local context is provided as `context`.
fn reanchored(mut self, target: &Location, context: &InteriorLocation) -> result::Result<Self, ()> {
self.id.reanchor(target, context)?;
Ok(self)
}
}

impl Reanchorable for Assets {
type Error = ();

fn reanchor(&mut self, target: &Location, context: &InteriorLocation) -> result::Result<(), ()> {
self.0.iter_mut().try_for_each(|i| i.reanchor(target, context))?;
self.0.sort();
Ok(())
}

fn reanchored(mut self, target: &Location, context: &InteriorLocation) -> result::Result<Self, ()> {
match self.reanchor(target, context) {
Ok(()) => Ok(self),
Err(()) => Err(()),
}
}
}

/// Result value when attempting to send an XCM message.
pub type SendResult<T> = result::Result<(T, Assets), SendError>;

Expand Down
2 changes: 1 addition & 1 deletion polkadot/xcm/src/v5/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ impl TryFrom<OldAsset> for Asset {
serde::Serialize,
serde::Deserialize,
)]
pub struct Assets(Vec<Asset>);
pub struct Assets(pub(crate) Vec<Asset>);

/// Maximum number of items we expect in a single `Assets` value. Note this is not (yet)
/// enforced, and just serves to provide a sensible `max_encoded_len` for `Assets`.
Expand Down
Loading

0 comments on commit c3a575d

Please sign in to comment.