Skip to content

Commit

Permalink
view: thread ics20 withdrawals into planner
Browse files Browse the repository at this point in the history
Closes #3108

Also, this fixes a bug with handling IBC actions, where the relayed packets
were being inserted into the planner after it was already used to create the
plan.
  • Loading branch information
hdevalence authored and conorsch committed Oct 6, 2023
1 parent 6251b1e commit 36bd568
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions crates/view/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,24 @@ impl ViewProtocolService for ViewService {
planner.position_withdraw(position_id, reserves, trading_pair);
}

// Insert any ICS20 withdrawals.
for ics20_withdrawal in prq.ics20_withdrawals {
planner.ics20_withdrawal(
ics20_withdrawal
.try_into()
.map_err(|e| tonic::Status::invalid_argument(format!("{e:#}")))?,
);
}

// Finally, insert all the requested IBC actions.
for ibc_action in prq.ibc_actions {
planner.ibc_action(
ibc_action
.try_into()
.map_err(|e| tonic::Status::invalid_argument(format!("{e:#}")))?,
);
}

let fvk = self.storage.full_viewing_key().await.map_err(|e| {
tonic::Status::failed_precondition(format!("Error retrieving full viewing key: {e:#}"))
})?;
Expand All @@ -599,15 +617,6 @@ impl ViewProtocolService for ViewService {
.context("could not plan requested transaction")
.map_err(|e| tonic::Status::invalid_argument(format!("{e:#}")))?;

// Finally, insert all the requested IBC actions.
for ibc_action in prq.ibc_actions {
planner.ibc_action(
ibc_action
.try_into()
.map_err(|e| tonic::Status::invalid_argument(format!("{e:#}")))?,
);
}

Ok(tonic::Response::new(TransactionPlannerResponse {
plan: Some(plan.into()),
}))
Expand Down

0 comments on commit 36bd568

Please sign in to comment.