Skip to content

Commit

Permalink
lp-forwarder: Pass the domain to
Browse files Browse the repository at this point in the history
  • Loading branch information
cdamian committed Aug 20, 2024
1 parent 173c44f commit fa6c253
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
6 changes: 5 additions & 1 deletion libs/traits/src/liquidity_pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ pub trait LpMessageForwarded: Sized {
fn unwrap_forwarded(self) -> Option<(Self::Domain, H160, Self)>;

/// Attempts to wrap into a forwarded message.
fn try_wrap_forward(forwarding_contract: H160, message: Self) -> Result<Self, DispatchError>;
fn try_wrap_forward(
domain: Self::Domain,
forwarding_contract: H160,
message: Self,
) -> Result<Self, DispatchError>;
}

pub trait RouterProvider<Domain>: Sized {
Expand Down
4 changes: 3 additions & 1 deletion pallets/liquidity-pools-forwarder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ pub mod pallet {
message: T::Message,
) -> DispatchResult {
let msg = RouterForwarding::<T>::get(&router_id)
.map(|info| T::Message::try_wrap_forward(info.contract, message.clone()))
.map(|info| {
T::Message::try_wrap_forward(Domain::Centrifuge, info.contract, message.clone())
})
.unwrap_or_else(|| {
ensure!(!message.is_forwarded(), Error::<T>::ForwardInfoNotFound);
Ok(message)
Expand Down
2 changes: 1 addition & 1 deletion pallets/liquidity-pools-forwarder/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl LpMessageForwarded for Message {
}
}

fn try_wrap_forward(_: H160, message: Self) -> Result<Self, DispatchError> {
fn try_wrap_forward(_: Self::Domain, _: H160, message: Self) -> Result<Self, DispatchError> {
match message {
Self::Forward => Err(ERROR_NESTING),
Self::NonForward => Ok(Self::Forward),
Expand Down
8 changes: 6 additions & 2 deletions pallets/liquidity-pools/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,13 @@ impl LpMessageForwarded for Message {
}
}

fn try_wrap_forward(forwarding_contract: H160, message: Self) -> Result<Self, DispatchError> {
fn try_wrap_forward(
source_domain: Self::Domain,
forwarding_contract: H160,
message: Self,
) -> Result<Self, DispatchError> {
Ok(Self::Forwarded {
source_domain: Domain::Centrifuge.into(),
source_domain: source_domain.into(),
forwarding_contract,
message: message.try_into().map_err(|_| {
DispatchError::Other(
Expand Down

0 comments on commit fa6c253

Please sign in to comment.