import { stateFromJSON, orderFromJSON } from "./channel";
import { omitDefault, Long } from "../../../../helpers";
export const AminoConverter = {
  "/ibc.core.channel.v1.MsgChannelOpenInit": {
    aminoType: "cosmos-sdk/MsgChannelOpenInit",
    toAmino: ({
      portId,
      channel,
      signer
    }) => {
      return {
        port_id: portId,
        channel: {
          state: channel.state,
          ordering: channel.ordering,
          counterparty: {
            port_id: channel.counterparty.portId,
            channel_id: channel.counterparty.channelId
          },
          connection_hops: channel.connectionHops,
          version: channel.version
        },
        signer
      };
    },
    fromAmino: ({
      port_id,
      channel,
      signer
    }) => {
      return {
        portId: port_id,
        channel: {
          state: stateFromJSON(channel.state),
          ordering: orderFromJSON(channel.ordering),
          counterparty: {
            portId: channel.counterparty.port_id,
            channelId: channel.counterparty.channel_id
          },
          connectionHops: channel.connection_hops,
          version: channel.version
        },
        signer
      };
    }
  },
  "/ibc.core.channel.v1.MsgChannelOpenTry": {
    aminoType: "cosmos-sdk/MsgChannelOpenTry",
    toAmino: ({
      portId,
      previousChannelId,
      channel,
      counterpartyVersion,
      proofInit,
      proofHeight,
      signer
    }) => {
      var _omitDefault, _omitDefault2;
      return {
        port_id: portId,
        previous_channel_id: previousChannelId,
        channel: {
          state: channel.state,
          ordering: channel.ordering,
          counterparty: {
            port_id: channel.counterparty.portId,
            channel_id: channel.counterparty.channelId
          },
          connection_hops: channel.connectionHops,
          version: channel.version
        },
        counterparty_version: counterpartyVersion,
        proof_init: proofInit,
        proof_height: proofHeight ? {
          revision_height: (_omitDefault = omitDefault(proofHeight.revisionHeight)) === null || _omitDefault === void 0 ? void 0 : _omitDefault.toString(),
          revision_number: (_omitDefault2 = omitDefault(proofHeight.revisionNumber)) === null || _omitDefault2 === void 0 ? void 0 : _omitDefault2.toString()
        } : {},
        signer
      };
    },
    fromAmino: ({
      port_id,
      previous_channel_id,
      channel,
      counterparty_version,
      proof_init,
      proof_height,
      signer
    }) => {
      return {
        portId: port_id,
        previousChannelId: previous_channel_id,
        channel: {
          state: stateFromJSON(channel.state),
          ordering: orderFromJSON(channel.ordering),
          counterparty: {
            portId: channel.counterparty.port_id,
            channelId: channel.counterparty.channel_id
          },
          connectionHops: channel.connection_hops,
          version: channel.version
        },
        counterpartyVersion: counterparty_version,
        proofInit: proof_init,
        proofHeight: proof_height ? {
          revisionHeight: Long.fromString(proof_height.revision_height || "0", true),
          revisionNumber: Long.fromString(proof_height.revision_number || "0", true)
        } : undefined,
        signer
      };
    }
  },
  "/ibc.core.channel.v1.MsgChannelOpenAck": {
    aminoType: "cosmos-sdk/MsgChannelOpenAck",
    toAmino: ({
      portId,
      channelId,
      counterpartyChannelId,
      counterpartyVersion,
      proofTry,
      proofHeight,
      signer
    }) => {
      var _omitDefault3, _omitDefault4;
      return {
        port_id: portId,
        channel_id: channelId,
        counterparty_channel_id: counterpartyChannelId,
        counterparty_version: counterpartyVersion,
        proof_try: proofTry,
        proof_height: proofHeight ? {
          revision_height: (_omitDefault3 = omitDefault(proofHeight.revisionHeight)) === null || _omitDefault3 === void 0 ? void 0 : _omitDefault3.toString(),
          revision_number: (_omitDefault4 = omitDefault(proofHeight.revisionNumber)) === null || _omitDefault4 === void 0 ? void 0 : _omitDefault4.toString()
        } : {},
        signer
      };
    },
    fromAmino: ({
      port_id,
      channel_id,
      counterparty_channel_id,
      counterparty_version,
      proof_try,
      proof_height,
      signer
    }) => {
      return {
        portId: port_id,
        channelId: channel_id,
        counterpartyChannelId: counterparty_channel_id,
        counterpartyVersion: counterparty_version,
        proofTry: proof_try,
        proofHeight: proof_height ? {
          revisionHeight: Long.fromString(proof_height.revision_height || "0", true),
          revisionNumber: Long.fromString(proof_height.revision_number || "0", true)
        } : undefined,
        signer
      };
    }
  },
  "/ibc.core.channel.v1.MsgChannelOpenConfirm": {
    aminoType: "cosmos-sdk/MsgChannelOpenConfirm",
    toAmino: ({
      portId,
      channelId,
      proofAck,
      proofHeight,
      signer
    }) => {
      var _omitDefault5, _omitDefault6;
      return {
        port_id: portId,
        channel_id: channelId,
        proof_ack: proofAck,
        proof_height: proofHeight ? {
          revision_height: (_omitDefault5 = omitDefault(proofHeight.revisionHeight)) === null || _omitDefault5 === void 0 ? void 0 : _omitDefault5.toString(),
          revision_number: (_omitDefault6 = omitDefault(proofHeight.revisionNumber)) === null || _omitDefault6 === void 0 ? void 0 : _omitDefault6.toString()
        } : {},
        signer
      };
    },
    fromAmino: ({
      port_id,
      channel_id,
      proof_ack,
      proof_height,
      signer
    }) => {
      return {
        portId: port_id,
        channelId: channel_id,
        proofAck: proof_ack,
        proofHeight: proof_height ? {
          revisionHeight: Long.fromString(proof_height.revision_height || "0", true),
          revisionNumber: Long.fromString(proof_height.revision_number || "0", true)
        } : undefined,
        signer
      };
    }
  },
  "/ibc.core.channel.v1.MsgChannelCloseInit": {
    aminoType: "cosmos-sdk/MsgChannelCloseInit",
    toAmino: ({
      portId,
      channelId,
      signer
    }) => {
      return {
        port_id: portId,
        channel_id: channelId,
        signer
      };
    },
    fromAmino: ({
      port_id,
      channel_id,
      signer
    }) => {
      return {
        portId: port_id,
        channelId: channel_id,
        signer
      };
    }
  },
  "/ibc.core.channel.v1.MsgChannelCloseConfirm": {
    aminoType: "cosmos-sdk/MsgChannelCloseConfirm",
    toAmino: ({
      portId,
      channelId,
      proofInit,
      proofHeight,
      signer
    }) => {
      var _omitDefault7, _omitDefault8;
      return {
        port_id: portId,
        channel_id: channelId,
        proof_init: proofInit,
        proof_height: proofHeight ? {
          revision_height: (_omitDefault7 = omitDefault(proofHeight.revisionHeight)) === null || _omitDefault7 === void 0 ? void 0 : _omitDefault7.toString(),
          revision_number: (_omitDefault8 = omitDefault(proofHeight.revisionNumber)) === null || _omitDefault8 === void 0 ? void 0 : _omitDefault8.toString()
        } : {},
        signer
      };
    },
    fromAmino: ({
      port_id,
      channel_id,
      proof_init,
      proof_height,
      signer
    }) => {
      return {
        portId: port_id,
        channelId: channel_id,
        proofInit: proof_init,
        proofHeight: proof_height ? {
          revisionHeight: Long.fromString(proof_height.revision_height || "0", true),
          revisionNumber: Long.fromString(proof_height.revision_number || "0", true)
        } : undefined,
        signer
      };
    }
  },
  "/ibc.core.channel.v1.MsgRecvPacket": {
    aminoType: "cosmos-sdk/MsgRecvPacket",
    toAmino: ({
      packet,
      proofCommitment,
      proofHeight,
      signer
    }) => {
      var _omitDefault9, _omitDefault10, _omitDefault11, _omitDefault12;
      return {
        packet: {
          sequence: packet.sequence.toString(),
          source_port: packet.sourcePort,
          source_channel: packet.sourceChannel,
          destination_port: packet.destinationPort,
          destination_channel: packet.destinationChannel,
          data: packet.data,
          timeout_height: packet.timeoutHeight ? {
            revision_height: (_omitDefault9 = omitDefault(packet.timeoutHeight.revisionHeight)) === null || _omitDefault9 === void 0 ? void 0 : _omitDefault9.toString(),
            revision_number: (_omitDefault10 = omitDefault(packet.timeoutHeight.revisionNumber)) === null || _omitDefault10 === void 0 ? void 0 : _omitDefault10.toString()
          } : {},
          timeout_timestamp: packet.timeoutTimestamp.toString()
        },
        proof_commitment: proofCommitment,
        proof_height: proofHeight ? {
          revision_height: (_omitDefault11 = omitDefault(proofHeight.revisionHeight)) === null || _omitDefault11 === void 0 ? void 0 : _omitDefault11.toString(),
          revision_number: (_omitDefault12 = omitDefault(proofHeight.revisionNumber)) === null || _omitDefault12 === void 0 ? void 0 : _omitDefault12.toString()
        } : {},
        signer
      };
    },
    fromAmino: ({
      packet,
      proof_commitment,
      proof_height,
      signer
    }) => {
      return {
        packet: {
          sequence: Long.fromString(packet.sequence),
          sourcePort: packet.source_port,
          sourceChannel: packet.source_channel,
          destinationPort: packet.destination_port,
          destinationChannel: packet.destination_channel,
          data: packet.data,
          timeoutHeight: packet.timeout_height ? {
            revisionHeight: Long.fromString(packet.timeout_height.revision_height || "0", true),
            revisionNumber: Long.fromString(packet.timeout_height.revision_number || "0", true)
          } : undefined,
          timeoutTimestamp: Long.fromString(packet.timeout_timestamp)
        },
        proofCommitment: proof_commitment,
        proofHeight: proof_height ? {
          revisionHeight: Long.fromString(proof_height.revision_height || "0", true),
          revisionNumber: Long.fromString(proof_height.revision_number || "0", true)
        } : undefined,
        signer
      };
    }
  },
  "/ibc.core.channel.v1.MsgTimeout": {
    aminoType: "cosmos-sdk/MsgTimeout",
    toAmino: ({
      packet,
      proofUnreceived,
      proofHeight,
      nextSequenceRecv,
      signer
    }) => {
      var _omitDefault13, _omitDefault14, _omitDefault15, _omitDefault16;
      return {
        packet: {
          sequence: packet.sequence.toString(),
          source_port: packet.sourcePort,
          source_channel: packet.sourceChannel,
          destination_port: packet.destinationPort,
          destination_channel: packet.destinationChannel,
          data: packet.data,
          timeout_height: packet.timeoutHeight ? {
            revision_height: (_omitDefault13 = omitDefault(packet.timeoutHeight.revisionHeight)) === null || _omitDefault13 === void 0 ? void 0 : _omitDefault13.toString(),
            revision_number: (_omitDefault14 = omitDefault(packet.timeoutHeight.revisionNumber)) === null || _omitDefault14 === void 0 ? void 0 : _omitDefault14.toString()
          } : {},
          timeout_timestamp: packet.timeoutTimestamp.toString()
        },
        proof_unreceived: proofUnreceived,
        proof_height: proofHeight ? {
          revision_height: (_omitDefault15 = omitDefault(proofHeight.revisionHeight)) === null || _omitDefault15 === void 0 ? void 0 : _omitDefault15.toString(),
          revision_number: (_omitDefault16 = omitDefault(proofHeight.revisionNumber)) === null || _omitDefault16 === void 0 ? void 0 : _omitDefault16.toString()
        } : {},
        next_sequence_recv: nextSequenceRecv.toString(),
        signer
      };
    },
    fromAmino: ({
      packet,
      proof_unreceived,
      proof_height,
      next_sequence_recv,
      signer
    }) => {
      return {
        packet: {
          sequence: Long.fromString(packet.sequence),
          sourcePort: packet.source_port,
          sourceChannel: packet.source_channel,
          destinationPort: packet.destination_port,
          destinationChannel: packet.destination_channel,
          data: packet.data,
          timeoutHeight: packet.timeout_height ? {
            revisionHeight: Long.fromString(packet.timeout_height.revision_height || "0", true),
            revisionNumber: Long.fromString(packet.timeout_height.revision_number || "0", true)
          } : undefined,
          timeoutTimestamp: Long.fromString(packet.timeout_timestamp)
        },
        proofUnreceived: proof_unreceived,
        proofHeight: proof_height ? {
          revisionHeight: Long.fromString(proof_height.revision_height || "0", true),
          revisionNumber: Long.fromString(proof_height.revision_number || "0", true)
        } : undefined,
        nextSequenceRecv: Long.fromString(next_sequence_recv),
        signer
      };
    }
  },
  "/ibc.core.channel.v1.MsgTimeoutOnClose": {
    aminoType: "cosmos-sdk/MsgTimeoutOnClose",
    toAmino: ({
      packet,
      proofUnreceived,
      proofClose,
      proofHeight,
      nextSequenceRecv,
      signer
    }) => {
      var _omitDefault17, _omitDefault18, _omitDefault19, _omitDefault20;
      return {
        packet: {
          sequence: packet.sequence.toString(),
          source_port: packet.sourcePort,
          source_channel: packet.sourceChannel,
          destination_port: packet.destinationPort,
          destination_channel: packet.destinationChannel,
          data: packet.data,
          timeout_height: packet.timeoutHeight ? {
            revision_height: (_omitDefault17 = omitDefault(packet.timeoutHeight.revisionHeight)) === null || _omitDefault17 === void 0 ? void 0 : _omitDefault17.toString(),
            revision_number: (_omitDefault18 = omitDefault(packet.timeoutHeight.revisionNumber)) === null || _omitDefault18 === void 0 ? void 0 : _omitDefault18.toString()
          } : {},
          timeout_timestamp: packet.timeoutTimestamp.toString()
        },
        proof_unreceived: proofUnreceived,
        proof_close: proofClose,
        proof_height: proofHeight ? {
          revision_height: (_omitDefault19 = omitDefault(proofHeight.revisionHeight)) === null || _omitDefault19 === void 0 ? void 0 : _omitDefault19.toString(),
          revision_number: (_omitDefault20 = omitDefault(proofHeight.revisionNumber)) === null || _omitDefault20 === void 0 ? void 0 : _omitDefault20.toString()
        } : {},
        next_sequence_recv: nextSequenceRecv.toString(),
        signer
      };
    },
    fromAmino: ({
      packet,
      proof_unreceived,
      proof_close,
      proof_height,
      next_sequence_recv,
      signer
    }) => {
      return {
        packet: {
          sequence: Long.fromString(packet.sequence),
          sourcePort: packet.source_port,
          sourceChannel: packet.source_channel,
          destinationPort: packet.destination_port,
          destinationChannel: packet.destination_channel,
          data: packet.data,
          timeoutHeight: packet.timeout_height ? {
            revisionHeight: Long.fromString(packet.timeout_height.revision_height || "0", true),
            revisionNumber: Long.fromString(packet.timeout_height.revision_number || "0", true)
          } : undefined,
          timeoutTimestamp: Long.fromString(packet.timeout_timestamp)
        },
        proofUnreceived: proof_unreceived,
        proofClose: proof_close,
        proofHeight: proof_height ? {
          revisionHeight: Long.fromString(proof_height.revision_height || "0", true),
          revisionNumber: Long.fromString(proof_height.revision_number || "0", true)
        } : undefined,
        nextSequenceRecv: Long.fromString(next_sequence_recv),
        signer
      };
    }
  },
  "/ibc.core.channel.v1.MsgAcknowledgement": {
    aminoType: "cosmos-sdk/MsgAcknowledgement",
    toAmino: ({
      packet,
      acknowledgement,
      proofAcked,
      proofHeight,
      signer
    }) => {
      var _omitDefault21, _omitDefault22, _omitDefault23, _omitDefault24;
      return {
        packet: {
          sequence: packet.sequence.toString(),
          source_port: packet.sourcePort,
          source_channel: packet.sourceChannel,
          destination_port: packet.destinationPort,
          destination_channel: packet.destinationChannel,
          data: packet.data,
          timeout_height: packet.timeoutHeight ? {
            revision_height: (_omitDefault21 = omitDefault(packet.timeoutHeight.revisionHeight)) === null || _omitDefault21 === void 0 ? void 0 : _omitDefault21.toString(),
            revision_number: (_omitDefault22 = omitDefault(packet.timeoutHeight.revisionNumber)) === null || _omitDefault22 === void 0 ? void 0 : _omitDefault22.toString()
          } : {},
          timeout_timestamp: packet.timeoutTimestamp.toString()
        },
        acknowledgement,
        proof_acked: proofAcked,
        proof_height: proofHeight ? {
          revision_height: (_omitDefault23 = omitDefault(proofHeight.revisionHeight)) === null || _omitDefault23 === void 0 ? void 0 : _omitDefault23.toString(),
          revision_number: (_omitDefault24 = omitDefault(proofHeight.revisionNumber)) === null || _omitDefault24 === void 0 ? void 0 : _omitDefault24.toString()
        } : {},
        signer
      };
    },
    fromAmino: ({
      packet,
      acknowledgement,
      proof_acked,
      proof_height,
      signer
    }) => {
      return {
        packet: {
          sequence: Long.fromString(packet.sequence),
          sourcePort: packet.source_port,
          sourceChannel: packet.source_channel,
          destinationPort: packet.destination_port,
          destinationChannel: packet.destination_channel,
          data: packet.data,
          timeoutHeight: packet.timeout_height ? {
            revisionHeight: Long.fromString(packet.timeout_height.revision_height || "0", true),
            revisionNumber: Long.fromString(packet.timeout_height.revision_number || "0", true)
          } : undefined,
          timeoutTimestamp: Long.fromString(packet.timeout_timestamp)
        },
        acknowledgement,
        proofAcked: proof_acked,
        proofHeight: proof_height ? {
          revisionHeight: Long.fromString(proof_height.revision_height || "0", true),
          revisionNumber: Long.fromString(proof_height.revision_number || "0", true)
        } : undefined,
        signer
      };
    }
  }
};