import { BinaryReader, BinaryWriter } from "../../../../binary";
import { bytesFromBase64, base64FromBytes } from "../../../../helpers";
import { GlobalDecoderRegistry } from "../../../../registry";
function createBaseIncentivizedAcknowledgement() {
    return {
        appAcknowledgement: new Uint8Array(),
        forwardRelayerAddress: "",
        underlyingAppSuccess: false
    };
}
export const IncentivizedAcknowledgement = {
    typeUrl: "/ibc.applications.fee.v1.IncentivizedAcknowledgement",
    aminoType: "cosmos-sdk/IncentivizedAcknowledgement",
    is(o) {
        return o && (o.$typeUrl === IncentivizedAcknowledgement.typeUrl || (o.appAcknowledgement instanceof Uint8Array || typeof o.appAcknowledgement === "string") && typeof o.forwardRelayerAddress === "string" && typeof o.underlyingAppSuccess === "boolean");
    },
    isAmino(o) {
        return o && (o.$typeUrl === IncentivizedAcknowledgement.typeUrl || (o.app_acknowledgement instanceof Uint8Array || typeof o.app_acknowledgement === "string") && typeof o.forward_relayer_address === "string" && typeof o.underlying_app_success === "boolean");
    },
    encode(message, writer = BinaryWriter.create()) {
        if (message.appAcknowledgement.length !== 0) {
            writer.uint32(10).bytes(message.appAcknowledgement);
        }
        if (message.forwardRelayerAddress !== "") {
            writer.uint32(18).string(message.forwardRelayerAddress);
        }
        if (message.underlyingAppSuccess === true) {
            writer.uint32(24).bool(message.underlyingAppSuccess);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseIncentivizedAcknowledgement();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.appAcknowledgement = reader.bytes();
                    break;
                case 2:
                    message.forwardRelayerAddress = reader.string();
                    break;
                case 3:
                    message.underlyingAppSuccess = reader.bool();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseIncentivizedAcknowledgement();
        message.appAcknowledgement = object.appAcknowledgement ?? new Uint8Array();
        message.forwardRelayerAddress = object.forwardRelayerAddress ?? "";
        message.underlyingAppSuccess = object.underlyingAppSuccess ?? false;
        return message;
    },
    fromAmino(object) {
        const message = createBaseIncentivizedAcknowledgement();
        if (object.app_acknowledgement !== undefined && object.app_acknowledgement !== null) {
            message.appAcknowledgement = bytesFromBase64(object.app_acknowledgement);
        }
        if (object.forward_relayer_address !== undefined && object.forward_relayer_address !== null) {
            message.forwardRelayerAddress = object.forward_relayer_address;
        }
        if (object.underlying_app_success !== undefined && object.underlying_app_success !== null) {
            message.underlyingAppSuccess = object.underlying_app_success;
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.app_acknowledgement = message.appAcknowledgement ? base64FromBytes(message.appAcknowledgement) : undefined;
        obj.forward_relayer_address = message.forwardRelayerAddress === "" ? undefined : message.forwardRelayerAddress;
        obj.underlying_app_success = message.underlyingAppSuccess === false ? undefined : message.underlyingAppSuccess;
        return obj;
    },
    fromAminoMsg(object) {
        return IncentivizedAcknowledgement.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/IncentivizedAcknowledgement",
            value: IncentivizedAcknowledgement.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return IncentivizedAcknowledgement.decode(message.value);
    },
    toProto(message) {
        return IncentivizedAcknowledgement.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.fee.v1.IncentivizedAcknowledgement",
            value: IncentivizedAcknowledgement.encode(message).finish()
        };
    }
};
GlobalDecoderRegistry.register(IncentivizedAcknowledgement.typeUrl, IncentivizedAcknowledgement);
GlobalDecoderRegistry.registerAminoProtoMapping(IncentivizedAcknowledgement.aminoType, IncentivizedAcknowledgement.typeUrl);
