11//! IBC-related data types
22
3- use std:: collections:: { BTreeMap , BTreeSet } ;
43use std:: fmt:: Display ;
54use std:: str:: FromStr ;
65
76use borsh:: { BorshDeserialize , BorshSchema , BorshSerialize } ;
87use data_encoding:: { DecodePartial , HEXLOWER , HEXLOWER_PERMISSIVE } ;
98pub use ibc:: * ;
10- use masp_primitives:: transaction:: components:: ValueSum ;
11- use masp_primitives:: transaction:: TransparentAddress ;
129use namada_macros:: BorshDeserializer ;
1310#[ cfg( feature = "migrations" ) ]
1411use namada_migrations:: * ;
1512use serde:: { Deserialize , Serialize } ;
1613
1714use super :: address:: HASH_LEN ;
18- use crate :: address:: Address ;
1915use crate :: hash:: Hash ;
20- use crate :: masp:: TAddrData ;
21- use crate :: { storage, token} ;
22-
23- /// Abstract IBC storage read interface
24- pub trait Read < S > {
25- /// Storage error
26- type Err ;
27-
28- /// Extract MASP transaction from IBC envelope
29- fn try_extract_masp_tx_from_envelope (
30- tx_data : & [ u8 ] ,
31- ) -> Result < Option < masp_primitives:: transaction:: Transaction > , Self :: Err > ;
32-
33- /// Apply relevant IBC packets to the changed balances structure
34- fn apply_ibc_packet (
35- storage : & S ,
36- tx_data : & [ u8 ] ,
37- acc : ChangedBalances ,
38- keys_changed : & BTreeSet < storage:: Key > ,
39- ) -> Result < ChangedBalances , Self :: Err > ;
40- }
41-
42- /// Balances changed by a transaction
43- #[ derive( Default , Debug , Clone ) ]
44- pub struct ChangedBalances {
45- /// Map between MASP transparent address and namada types
46- pub decoder : BTreeMap < TransparentAddress , TAddrData > ,
47- /// Balances before the tx
48- pub pre : BTreeMap < TransparentAddress , ValueSum < Address , token:: Amount > > ,
49- /// Balances after the tx
50- pub post : BTreeMap < TransparentAddress , ValueSum < Address , token:: Amount > > ,
51- }
5216
5317/// IBC token hash derived from a denomination.
5418#[ derive(
@@ -69,7 +33,7 @@ pub struct ChangedBalances {
6933#[ repr( transparent) ]
7034pub struct IbcTokenHash ( pub [ u8 ; HASH_LEN ] ) ;
7135
72- impl std :: fmt :: Display for IbcTokenHash {
36+ impl Display for IbcTokenHash {
7337 #[ inline( always) ]
7438 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
7539 write ! ( f, "{}" , HEXLOWER . encode( & self . 0 ) )
0 commit comments