//@ts-nocheck
import { BinaryReader, BinaryWriter } from '../../../../binary.js';
import {} from '../../../../json-safe.js';
import { isSet } from '../../../../helpers.js';
import { decodeBase64 as bytesFromBase64 } from '@endo/base64';
import { encodeBase64 as base64FromBytes } from '@endo/base64';
function createBaseGenesisState() {
    return {
        contracts: [],
    };
}
export const GenesisState = {
    typeUrl: '/ibc.lightclients.wasm.v1.GenesisState',
    encode(message, writer = BinaryWriter.create()) {
        for (const v of message.contracts) {
            Contract.encode(v, writer.uint32(10).fork()).ldelim();
        }
        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 = createBaseGenesisState();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.contracts.push(Contract.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        return {
            contracts: Array.isArray(object?.contracts)
                ? object.contracts.map((e) => Contract.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.contracts) {
            obj.contracts = message.contracts.map(e => e ? Contract.toJSON(e) : undefined);
        }
        else {
            obj.contracts = [];
        }
        return obj;
    },
    fromPartial(object) {
        const message = createBaseGenesisState();
        message.contracts =
            object.contracts?.map(e => Contract.fromPartial(e)) || [];
        return message;
    },
    fromProtoMsg(message) {
        return GenesisState.decode(message.value);
    },
    toProto(message) {
        return GenesisState.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/ibc.lightclients.wasm.v1.GenesisState',
            value: GenesisState.encode(message).finish(),
        };
    },
};
function createBaseContract() {
    return {
        codeBytes: new Uint8Array(),
    };
}
export const Contract = {
    typeUrl: '/ibc.lightclients.wasm.v1.Contract',
    encode(message, writer = BinaryWriter.create()) {
        if (message.codeBytes.length !== 0) {
            writer.uint32(10).bytes(message.codeBytes);
        }
        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 = 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;
    },
    fromJSON(object) {
        return {
            codeBytes: isSet(object.codeBytes)
                ? bytesFromBase64(object.codeBytes)
                : new Uint8Array(),
        };
    },
    toJSON(message) {
        const obj = {};
        message.codeBytes !== undefined &&
            (obj.codeBytes = base64FromBytes(message.codeBytes !== undefined ? message.codeBytes : new Uint8Array()));
        return obj;
    },
    fromPartial(object) {
        const message = createBaseContract();
        message.codeBytes = object.codeBytes ?? new Uint8Array();
        return message;
    },
    fromProtoMsg(message) {
        return Contract.decode(message.value);
    },
    toProto(message) {
        return Contract.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/ibc.lightclients.wasm.v1.Contract',
            value: Contract.encode(message).finish(),
        };
    },
};
//# sourceMappingURL=genesis.js.map