Skip to content

Commit

Permalink
shielded-pool: add event creation functions for transfers
Browse files Browse the repository at this point in the history
Separate commit to make backporting easier.
  • Loading branch information
cronokirby committed Oct 1, 2024
1 parent 6001b86 commit d833dcf
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions crates/core/component/shielded-pool/src/event.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use penumbra_asset::Value;
use penumbra_keys::Address;
use penumbra_proto::core::component::shielded_pool::v1::{
EventInboundFungibleTokenTransfer, EventOutboundFungibleTokenRefund,
EventOutboundFungibleTokenTransfer, EventOutput, EventSpend,
event_outbound_fungible_token_refund::Reason, EventInboundFungibleTokenTransfer,
EventOutboundFungibleTokenRefund, EventOutboundFungibleTokenTransfer, EventOutput, EventSpend,
};
use penumbra_sct::Nullifier;

Expand Down Expand Up @@ -35,6 +35,30 @@ pub fn outbound_fungible_token_transfer(
}
}

#[derive(Clone, Copy, Debug)]
pub enum FungibleTokenRefundReason {
Timeout,
Error,
}

pub fn outbound_fungible_token_refund(
value: Value,
sender: Address,
receiver: String,
reason: FungibleTokenRefundReason,
) -> EventOutboundFungibleTokenRefund {
let reason = match reason {
FungibleTokenRefundReason::Timeout => Reason::Timeout,
FungibleTokenRefundReason::Error => Reason::Error,
};
EventOutboundFungibleTokenRefund {
value: Some(value.into()),
sender: Some(sender.into()),
receiver,
reason: reason as i32,
}
}

pub fn inbound_fungible_token_transfer(
value: Value,
sender: String,
Expand Down

0 comments on commit d833dcf

Please sign in to comment.