Skip to content

Commit

Permalink
ShieldingTransfer for IBC messages
Browse files Browse the repository at this point in the history
  • Loading branch information
yito88 committed May 30, 2024
1 parent d9c3766 commit a0e2e6c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions crates/ibc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub use msg::*;
use namada_core::address::{self, Address, MASP};
use namada_core::masp::PaymentAddress;
use namada_events::extend::{ReadFromEventAttributes, Success as SuccessAttr};
use namada_token::UnshieldingTransfer;
use namada_token::ShieldingTransfer;
pub use nft::*;
use prost::Message;
use thiserror::Error;
Expand Down Expand Up @@ -154,7 +154,7 @@ where
pub fn execute(
&mut self,
tx_data: &[u8],
) -> Result<Option<UnshieldingTransfer>, Error> {
) -> Result<Option<ShieldingTransfer>, Error> {
let message = decode_message(tx_data)?;
match &message {
IbcMessage::Transfer(msg) => {
Expand Down
22 changes: 11 additions & 11 deletions crates/ibc/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ibc::core::channel::types::msgs::{
};
use ibc::core::handler::types::msgs::MsgEnvelope;
use ibc::primitives::proto::Protobuf;
use namada_token::UnshieldingTransfer;
use namada_token::ShieldingTransfer;

/// The different variants of an Ibc message
pub enum IbcMessage {
Expand All @@ -31,7 +31,7 @@ pub struct MsgTransfer {
/// IBC transfer message
pub message: IbcMsgTransfer,
/// Shieleded transfer for MASP transaction
pub transfer: Option<UnshieldingTransfer>,
pub transfer: Option<ShieldingTransfer>,
}

impl BorshSerialize for MsgTransfer {
Expand All @@ -50,7 +50,7 @@ impl BorshDeserialize for MsgTransfer {
reader: &mut R,
) -> std::io::Result<Self> {
use std::io::{Error, ErrorKind};
let (msg, transfer): (Vec<u8>, Option<UnshieldingTransfer>) =
let (msg, transfer): (Vec<u8>, Option<ShieldingTransfer>) =
BorshDeserialize::deserialize_reader(reader)?;
let message = IbcMsgTransfer::decode_vec(&msg)
.map_err(|err| Error::new(ErrorKind::InvalidData, err))?;
Expand All @@ -64,7 +64,7 @@ pub struct MsgNftTransfer {
/// IBC NFT transfer message
pub message: IbcMsgNftTransfer,
/// Shieleded transfer for MASP transaction
pub transfer: Option<UnshieldingTransfer>,
pub transfer: Option<ShieldingTransfer>,
}

impl BorshSerialize for MsgNftTransfer {
Expand All @@ -83,7 +83,7 @@ impl BorshDeserialize for MsgNftTransfer {
reader: &mut R,
) -> std::io::Result<Self> {
use std::io::{Error, ErrorKind};
let (msg, transfer): (Vec<u8>, Option<UnshieldingTransfer>) =
let (msg, transfer): (Vec<u8>, Option<ShieldingTransfer>) =
BorshDeserialize::deserialize_reader(reader)?;
let message = IbcMsgNftTransfer::decode_vec(&msg)
.map_err(|err| Error::new(ErrorKind::InvalidData, err))?;
Expand All @@ -97,7 +97,7 @@ pub struct MsgRecvPacket {
/// IBC receiving packet message
pub message: IbcMsgRecvPacket,
/// Shieleded transfer for MASP transaction
pub transfer: Option<UnshieldingTransfer>,
pub transfer: Option<ShieldingTransfer>,
}

impl BorshSerialize for MsgRecvPacket {
Expand All @@ -116,7 +116,7 @@ impl BorshDeserialize for MsgRecvPacket {
reader: &mut R,
) -> std::io::Result<Self> {
use std::io::{Error, ErrorKind};
let (msg, transfer): (Vec<u8>, Option<UnshieldingTransfer>) =
let (msg, transfer): (Vec<u8>, Option<ShieldingTransfer>) =
BorshDeserialize::deserialize_reader(reader)?;
let message = IbcMsgRecvPacket::decode_vec(&msg)
.map_err(|err| Error::new(ErrorKind::InvalidData, err))?;
Expand All @@ -131,7 +131,7 @@ pub struct MsgAcknowledgement {
/// IBC acknowledgement message
pub message: IbcMsgAcknowledgement,
/// Shieleded transfer for MASP transaction
pub transfer: Option<UnshieldingTransfer>,
pub transfer: Option<ShieldingTransfer>,
}

impl BorshSerialize for MsgAcknowledgement {
Expand All @@ -150,7 +150,7 @@ impl BorshDeserialize for MsgAcknowledgement {
reader: &mut R,
) -> std::io::Result<Self> {
use std::io::{Error, ErrorKind};
let (msg, transfer): (Vec<u8>, Option<UnshieldingTransfer>) =
let (msg, transfer): (Vec<u8>, Option<ShieldingTransfer>) =
BorshDeserialize::deserialize_reader(reader)?;
let message = IbcMsgAcknowledgement::decode_vec(&msg)
.map_err(|err| Error::new(ErrorKind::InvalidData, err))?;
Expand All @@ -165,7 +165,7 @@ pub struct MsgTimeout {
/// IBC timeout message
pub message: IbcMsgTimeout,
/// Shieleded transfer for MASP transaction
pub transfer: Option<UnshieldingTransfer>,
pub transfer: Option<ShieldingTransfer>,
}

impl BorshSerialize for MsgTimeout {
Expand All @@ -184,7 +184,7 @@ impl BorshDeserialize for MsgTimeout {
reader: &mut R,
) -> std::io::Result<Self> {
use std::io::{Error, ErrorKind};
let (msg, transfer): (Vec<u8>, Option<UnshieldingTransfer>) =
let (msg, transfer): (Vec<u8>, Option<ShieldingTransfer>) =
BorshDeserialize::deserialize_reader(reader)?;
let message = IbcMsgTimeout::decode_vec(&msg)
.map_err(|err| Error::new(ErrorKind::InvalidData, err))?;
Expand Down
2 changes: 1 addition & 1 deletion crates/node/src/bench_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ impl BenchShieldedCtx {
timeout_timestamp_on_b: timeout_timestamp,
};

let transfer = UnshieldingTransfer::deserialize(
let transfer = ShieldingTransfer::deserialize(
&mut tx.tx.data(&tx.cmt).unwrap().as_slice(),
)
.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions crates/sdk/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2567,9 +2567,9 @@ pub async fn build_ibc_transfer(
let transfer = shielded_parts.map(|(shielded_transfer, asset_types)| {
let masp_tx_hash =
tx.add_masp_tx_section(shielded_transfer.masp_tx.clone()).1;
let transfer = token::UnshieldingTransfer {
let transfer = token::ShieldingTransfer {
// The token will be escrowed to IBC address
target: Address::Internal(InternalAddress::Ibc),
source: source.clone(),
token: args.token.clone(),
amount: validated_amount,
// Link the Transfer to the MASP Transaction by hash code
Expand Down

0 comments on commit a0e2e6c

Please sign in to comment.