Skip to content

Commit

Permalink
Fixed typing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
crnbarr93 committed Mar 19, 2024
1 parent 3de2c6f commit 516fb1a
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions packages/std/src/ado_contract/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,27 +165,24 @@ impl<'a> ADOContract<'a> {
/// Handles receiving and verifies an AMPPkt from the Kernel before executing the appropriate messages.
///
/// Calls the provided handler with the AMP packet attached within the context.
pub fn execute_amp_receive<M: DeserializeOwned, E: Into<ContractError>>(
pub fn execute_amp_receive<M: DeserializeOwned>(
&self,
ctx: ExecuteContext,
mut packet: AMPPkt,
handler: ExecuteContextFunction<M, E>,
handler: ExecuteContextFunction<M>,
) -> Result<Response, ContractError> {
packet.verify_origin(&ctx.info, &ctx.deps.as_ref())?;
let ctx = ctx.with_ctx(packet.clone());
let msg_opt = packet.messages.pop();
if let Some(msg_opt) = msg_opt {
let msg: M = from_binary(&msg_opt.message)?;
let response = handler(ctx, msg);
match response {
Err(e) => Err(e.into()),
Ok(response) => Ok(response),
ensure!(
packet.messages.len() == 1,
ContractError::InvalidPacket {
error: Some("Invalid packet length".to_string())
}
} else {
Err(ContractError::InvalidPacket {
error: Some("AMP Packet received with no messages".to_string()),
})
}
);
let msg = packet.messages.pop().unwrap();
let msg: M = from_binary(&msg.message)?;
let response = handler(ctx, msg)?;
Ok(response)
}

/// Generates a message to pay a fee for a given action by the given payee
Expand Down

0 comments on commit 516fb1a

Please sign in to comment.