Skip to content

Commit 042a440

Browse files
authored
fix: transferring TIA was displaying 0 on notifications and summary (#2048)
1 parent 856fb6e commit 042a440

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

apps/namadillo/src/lib/transactions.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,31 @@ export const createIbcTransferMessage = (
104104
};
105105
};
106106

107+
const getIbcTransferAttributes = (
108+
tx: DeliverTxResponse
109+
): Record<string, string> => {
110+
const transferAttributes = getEventAttribute(tx, "ibc_transfer");
111+
if ("amount" in transferAttributes) {
112+
return transferAttributes;
113+
}
114+
115+
// Fallback to send_packet event if ibc_transfer doesn't contain amount
116+
const sendPackageAttributes = getEventAttribute(tx, "send_packet");
117+
if ("packet_data" in sendPackageAttributes) {
118+
const packetData = JSON.parse(sendPackageAttributes.packet_data);
119+
return {
120+
...transferAttributes,
121+
amount: packetData.amount || "",
122+
receiver: packetData.receiver || "",
123+
sender: packetData.sender || "",
124+
};
125+
}
126+
127+
throw new Error(
128+
"Unable to find the correct amount value in the IBC transaction"
129+
);
130+
};
131+
107132
export const createTransferDataFromIbc = (
108133
tx: DeliverTxResponse,
109134
rpc: string,
@@ -113,7 +138,7 @@ export const createTransferDataFromIbc = (
113138
details: IbcTransferStage,
114139
isShieldedTx: boolean
115140
): TransferTransactionData => {
116-
const transferAttributes = getEventAttribute(tx, "ibc_transfer");
141+
const transferAttributes = getIbcTransferAttributes(tx);
117142
const packetAttributes = getEventAttribute(tx, "send_packet");
118143
const feeAttributes = getEventAttribute(tx, "fee_pay");
119144
const tipAttributes = getEventAttribute(tx, "tip_pay");

0 commit comments

Comments
 (0)