ibc_app_transfer/
context.rs1use ibc_app_transfer_types::{Memo, PrefixedCoin, PrefixedDenom};
4use ibc_core::host::types::error::HostError;
5use ibc_core::host::types::identifiers::{ChannelId, PortId};
6use ibc_core::primitives::prelude::*;
7use ibc_core::primitives::Signer;
8
9pub trait TokenTransferValidationContext {
11 type AccountId;
13
14 fn sender_account(&self, sender: &Signer) -> Result<Self::AccountId, HostError>;
16
17 fn receiver_account(&self, receiver: &Signer) -> Result<Self::AccountId, HostError>;
19
20 fn get_port(&self) -> Result<PortId, HostError>;
22
23 fn can_send_coins(&self) -> Result<(), HostError>;
25
26 fn can_receive_coins(&self) -> Result<(), HostError>;
28
29 fn escrow_coins_validate(
34 &self,
35 from_account: &Self::AccountId,
36 port_id: &PortId,
37 channel_id: &ChannelId,
38 coin: &PrefixedCoin,
39 memo: &Memo,
40 ) -> Result<(), HostError>;
41
42 fn unescrow_coins_validate(
44 &self,
45 to_account: &Self::AccountId,
46 port_id: &PortId,
47 channel_id: &ChannelId,
48 coin: &PrefixedCoin,
49 ) -> Result<(), HostError>;
50
51 fn mint_coins_validate(
53 &self,
54 account: &Self::AccountId,
55 coin: &PrefixedCoin,
56 ) -> Result<(), HostError>;
57
58 fn burn_coins_validate(
63 &self,
64 account: &Self::AccountId,
65 coin: &PrefixedCoin,
66 memo: &Memo,
67 ) -> Result<(), HostError>;
68
69 fn denom_hash_string(&self, _denom: &PrefixedDenom) -> Option<String> {
72 None
73 }
74}
75
76pub trait TokenTransferExecutionContext: TokenTransferValidationContext {
78 fn escrow_coins_execute(
83 &mut self,
84 from_account: &Self::AccountId,
85 port_id: &PortId,
86 channel_id: &ChannelId,
87 coin: &PrefixedCoin,
88 memo: &Memo,
89 ) -> Result<(), HostError>;
90
91 fn unescrow_coins_execute(
93 &mut self,
94 to_account: &Self::AccountId,
95 port_id: &PortId,
96 channel_id: &ChannelId,
97 coin: &PrefixedCoin,
98 ) -> Result<(), HostError>;
99
100 fn mint_coins_execute(
102 &mut self,
103 account: &Self::AccountId,
104 coin: &PrefixedCoin,
105 ) -> Result<(), HostError>;
106
107 fn burn_coins_execute(
112 &mut self,
113 account: &Self::AccountId,
114 coin: &PrefixedCoin,
115 memo: &Memo,
116 ) -> Result<(), HostError>;
117}