"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InterchainAccount = void 0;
const auth_1 = require("../../../../cosmos/auth/v1beta1/auth");
const binary_1 = require("../../../../binary");
function createBaseInterchainAccount() {
    return {
        $typeUrl: "/ibc.applications.interchain_accounts.v1.InterchainAccount",
        baseAccount: auth_1.BaseAccount.fromPartial({}),
        accountOwner: ""
    };
}
exports.InterchainAccount = {
    typeUrl: "/ibc.applications.interchain_accounts.v1.InterchainAccount",
    aminoType: "cosmos-sdk/InterchainAccount",
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.baseAccount !== undefined) {
            auth_1.BaseAccount.encode(message.baseAccount, writer.uint32(10).fork()).ldelim();
        }
        if (message.accountOwner !== "") {
            writer.uint32(18).string(message.accountOwner);
        }
        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 = createBaseInterchainAccount();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.baseAccount = auth_1.BaseAccount.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.accountOwner = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseInterchainAccount();
        message.baseAccount = object.baseAccount !== undefined && object.baseAccount !== null ? auth_1.BaseAccount.fromPartial(object.baseAccount) : undefined;
        message.accountOwner = object.accountOwner ?? "";
        return message;
    },
    fromAmino(object) {
        return {
            baseAccount: object?.base_account ? auth_1.BaseAccount.fromAmino(object.base_account) : undefined,
            accountOwner: object.account_owner
        };
    },
    toAmino(message) {
        const obj = {};
        obj.base_account = message.baseAccount ? auth_1.BaseAccount.toAmino(message.baseAccount) : undefined;
        obj.account_owner = message.accountOwner;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.InterchainAccount.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/InterchainAccount",
            value: exports.InterchainAccount.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.InterchainAccount.decode(message.value);
    },
    toProto(message) {
        return exports.InterchainAccount.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.interchain_accounts.v1.InterchainAccount",
            value: exports.InterchainAccount.encode(message).finish()
        };
    }
};
//# sourceMappingURL=account.js.map