-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into andy/acct_prefix
- Loading branch information
Showing
38 changed files
with
782 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
modules/src/application/ics20_fungible_token_transfer/context.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
use crate::ics04_channel::context::{ChannelKeeper, ChannelReader}; | ||
|
||
/// Captures all the dependencies which the ICS20 module requires to be able to dispatch and | ||
/// process IBC messages. | ||
pub trait Ics20Context: ChannelReader + ChannelKeeper + Clone {} |
23 changes: 21 additions & 2 deletions
23
modules/src/application/ics20_fungible_token_transfer/error.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//! ICS 20: IBC Transfer implementation | ||
pub mod context; | ||
pub mod error; | ||
pub mod msgs; | ||
pub mod relay_application_logic; |
5 changes: 3 additions & 2 deletions
5
modules/src/application/ics20_fungible_token_transfer/msgs/transfer.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
modules/src/application/ics20_fungible_token_transfer/relay_application_logic.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
//! This module implements the processing logic for ICS20 (token transfer) message. | ||
|
||
pub mod send_transfer; |
55 changes: 55 additions & 0 deletions
55
...es/src/application/ics20_fungible_token_transfer/relay_application_logic/send_transfer.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use crate::application::ics20_fungible_token_transfer::context::Ics20Context; | ||
use crate::application::ics20_fungible_token_transfer::error::{Error, Kind}; | ||
use crate::application::ics20_fungible_token_transfer::msgs::transfer::MsgTransfer; | ||
use crate::handler::HandlerOutput; | ||
use crate::ics04_channel::handler::send_packet::send_packet; | ||
use crate::ics04_channel::packet::Packet; | ||
use crate::ics04_channel::packet::PacketResult; | ||
|
||
pub(crate) fn send_transfer<Ctx>( | ||
ctx: &Ctx, | ||
msg: MsgTransfer, | ||
) -> Result<HandlerOutput<PacketResult>, Error> | ||
where | ||
Ctx: Ics20Context, | ||
{ | ||
let source_channel_end = ctx | ||
.channel_end(&(msg.source_port.clone(), msg.source_channel.clone())) | ||
.ok_or_else(|| { | ||
Kind::ChannelNotFound(msg.source_port.clone(), msg.source_channel.clone()) | ||
})?; | ||
|
||
let destination_port = source_channel_end.counterparty().port_id().clone(); | ||
let destination_channel = source_channel_end | ||
.counterparty() | ||
.channel_id() | ||
.ok_or_else(|| { | ||
Kind::DestinationChannelNotFound(msg.source_port.clone(), msg.source_channel.clone()) | ||
})?; | ||
|
||
// get the next sequence | ||
let sequence = ctx | ||
.get_next_sequence_send(&(msg.source_port.clone(), msg.source_channel.clone())) | ||
.ok_or_else(|| { | ||
Kind::SequenceSendNotFound(msg.source_port.clone(), msg.source_channel.clone()) | ||
})?; | ||
|
||
//TODO: Application LOGIC. | ||
|
||
let packet = Packet { | ||
sequence, | ||
source_port: msg.source_port, | ||
source_channel: msg.source_channel, | ||
destination_port, | ||
destination_channel: destination_channel.clone(), | ||
data: vec![], | ||
timeout_height: msg.timeout_height, | ||
timeout_timestamp: msg.timeout_timestamp, | ||
}; | ||
|
||
let handler_output = | ||
send_packet(ctx, packet).map_err(|e| Kind::HandlerRaisedError.context(e))?; | ||
|
||
//TODO: add event/atributes and writes to the store issued by the application logic for packet sending. | ||
Ok(handler_output) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.