@@ -13,29 +13,46 @@ export const ibcSendFtDecoder: MessageDecoder = {
1313 const parsed = zMsgIbcTransfer . safeParse ( message ) ;
1414 return parsed . success && parsed . data . source_port === "transfer" ;
1515 } ,
16- decode : async ( message : Message , log : Log , _apiClient : ApiClient ) => {
16+ decode : async ( message : Message , log : Log , apiClient : ApiClient ) => {
1717 const parsed = zMsgIbcTransfer . parse ( message ) ;
1818 const { receiver, sender, source_channel, source_port, token } = parsed ;
1919
2020 const event = log . events . find ( ( event ) => event . type === "send_packet" ) ;
2121
2222 if ( ! event ) throw new Error ( "IBC Transfer send packet event not found" ) ;
2323
24+ const dstChannel = event . attributes . find (
25+ ( attr ) => attr . key === "packet_dst_channel"
26+ ) ?. value ;
27+ if ( ! dstChannel ) throw new Error ( `IBC Transfer dst channel not found` ) ;
28+
29+ const dstPort = event . attributes . find (
30+ ( attr ) => attr . key === "packet_dst_port"
31+ ) ?. value ;
32+ if ( ! dstPort ) throw new Error ( `IBC Transfer dst port not found` ) ;
33+
34+ const srcChainId = await apiClient . getChainId ( ) ;
35+
36+ const dstChainId = await apiClient . findIbcCounterPartyChainId (
37+ srcChainId ,
38+ source_port ,
39+ source_channel
40+ ) ;
41+ if ( ! dstChainId ) throw new Error ( `IBC Transfer dst chain id not found` ) ;
42+
2443 return {
2544 action : "ibc_ft_send" ,
2645 data : {
2746 amount : token . amount ,
2847 denom : token . denom ,
29- destinationChannel :
30- event . attributes . find ( ( attr ) => attr . key === "packet_dst_channel" )
31- ?. value ?? "" ,
32- destinationPort :
33- event . attributes . find ( ( attr ) => attr . key === "packet_dst_port" )
34- ?. value ?? "" ,
48+ dstChainId,
49+ dstChannel,
50+ dstPort,
3551 receiver,
3652 sender,
37- sourceChannel : source_channel ,
38- sourcePort : source_port ,
53+ srcChainId,
54+ srcChannel : source_channel ,
55+ srcPort : source_port ,
3956 } ,
4057 isIbc : true ,
4158 isOp : false ,
@@ -48,7 +65,7 @@ export const ibcReceiveFtDecoder: MessageDecoder = {
4865 const parsed = zMsgIbcRecvPacket . safeParse ( message ) ;
4966 return parsed . success && parsed . data . packet . source_port === "transfer" ;
5067 } ,
51- decode : async ( message : Message , _log : Log , _apiClient : ApiClient ) => {
68+ decode : async ( message : Message , _log : Log , apiClient : ApiClient ) => {
5269 const parsed = zMsgIbcRecvPacket . parse ( message ) ;
5370 const {
5471 packet : {
@@ -64,17 +81,28 @@ export const ibcReceiveFtDecoder: MessageDecoder = {
6481 Buffer . from ( data , "base64" ) . toString ( )
6582 ) ;
6683
84+ const dstChainId = await apiClient . getChainId ( ) ;
85+
86+ const srcChainId = await apiClient . findIbcCounterPartyChainId (
87+ dstChainId ,
88+ destination_port ,
89+ destination_channel
90+ ) ;
91+ if ( ! srcChainId ) throw new Error ( `IBC Transfer src chain id not found` ) ;
92+
6793 return {
6894 action : "ibc_ft_receive" ,
6995 data : {
7096 amount : parsedPacket . amount ,
7197 denom : parsedPacket . denom ,
72- destinationChannel : destination_channel ,
73- destinationPort : destination_port ,
98+ dstChainId,
99+ dstChannel : destination_channel ,
100+ dstPort : destination_port ,
74101 receiver : parsedPacket . receiver ,
75102 sender : parsedPacket . sender ,
76- sourceChannel : source_channel ,
77- sourcePort : source_port ,
103+ srcChainId,
104+ srcChannel : source_channel ,
105+ srcPort : source_port ,
78106 } ,
79107 isIbc : true ,
80108 isOp : false ,
0 commit comments