"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Contract = exports.GenesisState = void 0;
const binary_1 = require("../../../../binary");
const helpers_1 = require("../../../../helpers");
const registry_1 = require("../../../../registry");
function createBaseGenesisState() {
    return {
        contracts: []
    };
}
/**
 * GenesisState defines 08-wasm's keeper genesis state
 * @name GenesisState
 * @package ibc.lightclients.wasm.v1
 * @see proto type: ibc.lightclients.wasm.v1.GenesisState
 */
exports.GenesisState = {
    typeUrl: "/ibc.lightclients.wasm.v1.GenesisState",
    aminoType: "cosmos-sdk/GenesisState",
    is(o) {
        return o && (o.$typeUrl === exports.GenesisState.typeUrl || Array.isArray(o.contracts) && (!o.contracts.length || exports.Contract.is(o.contracts[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.GenesisState.typeUrl || Array.isArray(o.contracts) && (!o.contracts.length || exports.Contract.isAmino(o.contracts[0])));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        for (const v of message.contracts) {
            exports.Contract.encode(v, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGenesisState();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.contracts.push(exports.Contract.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseGenesisState();
        message.contracts = object.contracts?.map(e => exports.Contract.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseGenesisState();
        message.contracts = object.contracts?.map(e => exports.Contract.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.contracts) {
            obj.contracts = message.contracts.map(e => e ? exports.Contract.toAmino(e) : undefined);
        }
        else {
            obj.contracts = message.contracts;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.GenesisState.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/GenesisState",
            value: exports.GenesisState.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.GenesisState.decode(message.value);
    },
    toProto(message) {
        return exports.GenesisState.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.lightclients.wasm.v1.GenesisState",
            value: exports.GenesisState.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.GenesisState.typeUrl)) {
            return;
        }
        exports.Contract.registerTypeUrl();
    }
};
function createBaseContract() {
    return {
        codeBytes: new Uint8Array()
    };
}
/**
 * Contract stores contract code
 * @name Contract
 * @package ibc.lightclients.wasm.v1
 * @see proto type: ibc.lightclients.wasm.v1.Contract
 */
exports.Contract = {
    typeUrl: "/ibc.lightclients.wasm.v1.Contract",
    aminoType: "cosmos-sdk/Contract",
    is(o) {
        return o && (o.$typeUrl === exports.Contract.typeUrl || o.codeBytes instanceof Uint8Array || typeof o.codeBytes === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.Contract.typeUrl || o.code_bytes instanceof Uint8Array || typeof o.code_bytes === "string");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.codeBytes.length !== 0) {
            writer.uint32(10).bytes(message.codeBytes);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseContract();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.codeBytes = reader.bytes();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseContract();
        message.codeBytes = object.codeBytes ?? new Uint8Array();
        return message;
    },
    fromAmino(object) {
        const message = createBaseContract();
        if (object.code_bytes !== undefined && object.code_bytes !== null) {
            message.codeBytes = (0, helpers_1.bytesFromBase64)(object.code_bytes);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.code_bytes = message.codeBytes ? (0, helpers_1.base64FromBytes)(message.codeBytes) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.Contract.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/Contract",
            value: exports.Contract.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.Contract.decode(message.value);
    },
    toProto(message) {
        return exports.Contract.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.lightclients.wasm.v1.Contract",
            value: exports.Contract.encode(message).finish()
        };
    },
    registerTypeUrl() { }
};
