Skip to content

Commit a0223d0

Browse files
committed
Extract ibc packets info from rawLog for chains on cosmos-sdk < 0.50
1 parent 76c6bf8 commit a0223d0

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/secret_network_client.ts

+22-2
Original file line numberDiff line numberDiff line change
@@ -1481,16 +1481,36 @@ export class SecretNetworkClient {
14811481

14821482
// IBC ACKs:
14831483
if (txResp.code === TxResultCode.Success) {
1484-
const packetSequences =
1484+
let packetSequences =
14851485
arrayLog?.filter(
14861486
(x) => x.type === "send_packet" && x.key === "packet_sequence",
14871487
) || [];
14881488

1489-
const packetSrcChannels =
1489+
let packetSrcChannels =
14901490
arrayLog?.filter(
14911491
(x) => x.type === "send_packet" && x.key === "packet_src_channel",
14921492
) || [];
14931493

1494+
// if using secret.js we execute ibc request from another chain on cosmos-sdk < 0.50,
1495+
// try to extract ibc packets info from rawLog
1496+
if (packetSequences.length == 0 && packetSrcChannels.length == 0) {
1497+
try {
1498+
const jsonRawLog = JSON.parse(rawLog);
1499+
for (const l of jsonRawLog) {
1500+
for (const e of l.events) {
1501+
for (const a of e.attributes) {
1502+
if (`${e.type}.${a.key}` == "send_packet.packet_sequence") {
1503+
packetSequences.push(a);
1504+
}
1505+
if (`${e.type}.${a.key}` == "send_packet.packet_src_channel") {
1506+
packetSrcChannels.push(a);
1507+
}
1508+
}
1509+
}
1510+
}
1511+
} catch (e) {}
1512+
}
1513+
14941514
if (explicitIbcTxOptions.resolveResponses) {
14951515
for (let msgIndex = 0; msgIndex < packetSequences?.length; msgIndex++) {
14961516
// isDoneObject is used to cancel the second promise if the first one is resolved

0 commit comments

Comments
 (0)