const parseEvents = (rawLog: readonly Log[]) => {
  try {
    if (rawLog && Object.keys(rawLog).length > 0) {
      const { events } = rawLog[0];
      if (events) {
        // eslint-disable-next-line no-restricted-syntax
        for (const event of events) {
          if (event.type === 'send_packet') {
            const { attributes } = event;
            const sourceChannelAttr = attributes.find((attr) => attr.key === 'packet_src_channel');
            const sourceChannelValue = sourceChannelAttr ? sourceChannelAttr.value : undefined;
            const destChannelAttr = attributes.find((attr) => attr.key === 'packet_dst_channel');
            const destChannelValue = destChannelAttr ? destChannelAttr.value : undefined;
            const sequenceAttr = attributes.find((attr) => attr.key === 'packet_sequence');
            const sequence = sequenceAttr ? sequenceAttr.value : undefined;
            const timeoutHeightAttr = attributes.find(
              (attr) => attr.key === 'packet_timeout_height'
            );
            const timeoutHeight = timeoutHeightAttr ? timeoutHeightAttr.value : undefined;
            const timeoutTimestampAttr = attributes.find(
              (attr) => attr.key === 'packet_timeout_timestamp'
            );
            const timeoutTimestamp = timeoutTimestampAttr ? timeoutTimestampAttr.value : undefined;
            if (sequence && destChannelValue && sourceChannelValue) {
              return {
                destChannelId: destChannelValue,
                sourceChannelId: sourceChannelValue,
                sequence,
                timeoutHeight,
                timeoutTimestamp,
              };
            }
          }
        }
      }
    }
    return null;
  } catch (e) {
    console.debug('error parseLog', e);
    return null;
  }
};

export default parseEvents;

Synonyms

soft3.js/examples/utils.ts
cyb/src/utils/utils.ts
pussy-ts/src/utils/utils.ts
bostrom.network/src/lib/utils.ts
pussy-ts/src/services/ibc-history/utils.ts
cyb/src/services/CozoDb/utils.ts
cyb/src/containers/mint/utils.ts
cyb/src/containers/portal/utils.ts
pussy-ts/src/containers/portal/utils.ts
cyb/src/utils/search/utils.ts
pussy-ts/src/services/CozoDb/utils.ts
pussy-ts/src/utils/search/utils.ts
cyb/src/containers/warp/utils.ts
cyb/src/components/time/utils.ts
pussy-ts/src/containers/warp/utils.ts
cyb/src/pages/teleport/swap/utils.ts
pussy-ts/src/pages/teleport/swap/utils.ts
cyb/src/features/studio/utils/utils.ts
cyb/src/containers/sigma/hooks/utils.ts
cyb/src/pages/robot/Brain/utils.ts
cyb/src/services/backend/services/sync/utils.ts
pussy-ts/src/services/backend/services/sync/utils.ts
cyb/src/pages/teleport/components/Inputs/utils.ts
pussy-ts/src/services/backend/services/indexer/utils.ts
pussy-ts/src/services/backend/services/lcd/utils.ts
pussy-ts/src/pages/teleport/components/Inputs/utils.ts
cyb/src/features/studio/components/Editor/utils/utils.ts
cyb/src/pages/robot/_refactor/account/tabs/feeds/utils.ts

Neighbours