/* eslint-disable */
import Long from "long";
import { grpc } from "@improbable-eng/grpc-web";
import _m0 from "protobufjs/minimal";
import { BrowserHeaders } from "browser-headers";
import { ObservationRequest } from "../../gossip/v1/gossip";
export const protobufPackage = "node.v1";
const baseInjectGovernanceVAARequest = {
    currentSetIndex: 0,
    timestamp: 0,
};
export const InjectGovernanceVAARequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.currentSetIndex !== 0) {
            writer.uint32(8).uint32(message.currentSetIndex);
        }
        for (const v of message.messages) {
            GovernanceMessage.encode(v, writer.uint32(18).fork()).ldelim();
        }
        if (message.timestamp !== 0) {
            writer.uint32(24).uint32(message.timestamp);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseInjectGovernanceVAARequest);
        message.messages = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.currentSetIndex = reader.uint32();
                    break;
                case 2:
                    message.messages.push(GovernanceMessage.decode(reader, reader.uint32()));
                    break;
                case 3:
                    message.timestamp = reader.uint32();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseInjectGovernanceVAARequest);
        message.messages = [];
        if (object.currentSetIndex !== undefined &&
            object.currentSetIndex !== null) {
            message.currentSetIndex = Number(object.currentSetIndex);
        }
        else {
            message.currentSetIndex = 0;
        }
        if (object.messages !== undefined && object.messages !== null) {
            for (const e of object.messages) {
                message.messages.push(GovernanceMessage.fromJSON(e));
            }
        }
        if (object.timestamp !== undefined && object.timestamp !== null) {
            message.timestamp = Number(object.timestamp);
        }
        else {
            message.timestamp = 0;
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.currentSetIndex !== undefined &&
            (obj.currentSetIndex = message.currentSetIndex);
        if (message.messages) {
            obj.messages = message.messages.map((e) => e ? GovernanceMessage.toJSON(e) : undefined);
        }
        else {
            obj.messages = [];
        }
        message.timestamp !== undefined && (obj.timestamp = message.timestamp);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseInjectGovernanceVAARequest);
        message.messages = [];
        if (object.currentSetIndex !== undefined &&
            object.currentSetIndex !== null) {
            message.currentSetIndex = object.currentSetIndex;
        }
        else {
            message.currentSetIndex = 0;
        }
        if (object.messages !== undefined && object.messages !== null) {
            for (const e of object.messages) {
                message.messages.push(GovernanceMessage.fromPartial(e));
            }
        }
        if (object.timestamp !== undefined && object.timestamp !== null) {
            message.timestamp = object.timestamp;
        }
        else {
            message.timestamp = 0;
        }
        return message;
    },
};
const baseGovernanceMessage = {
    sequence: "0",
    nonce: 0,
    targetChainId: 0,
};
export const GovernanceMessage = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.sequence !== "0") {
            writer.uint32(16).uint64(message.sequence);
        }
        if (message.nonce !== 0) {
            writer.uint32(24).uint32(message.nonce);
        }
        if (message.targetChainId !== 0) {
            writer.uint32(32).uint32(message.targetChainId);
        }
        if (message.updateMessageFee !== undefined) {
            UpdateMessageFee.encode(message.updateMessageFee, writer.uint32(66).fork()).ldelim();
        }
        if (message.transferFee !== undefined) {
            TransferFee.encode(message.transferFee, writer.uint32(74).fork()).ldelim();
        }
        if (message.guardianSet !== undefined) {
            GuardianSetUpgrade.encode(message.guardianSet, writer.uint32(82).fork()).ldelim();
        }
        if (message.contractUpgrade !== undefined) {
            ContractUpgrade.encode(message.contractUpgrade, writer.uint32(90).fork()).ldelim();
        }
        if (message.bridgeRegisterChain !== undefined) {
            BridgeRegisterChain.encode(message.bridgeRegisterChain, writer.uint32(98).fork()).ldelim();
        }
        if (message.bridgeContractUpgrade !== undefined) {
            BridgeUpgradeContract.encode(message.bridgeContractUpgrade, writer.uint32(106).fork()).ldelim();
        }
        if (message.destroyUnexecutedSequenceContracts !== undefined) {
            TokenBridgeDestroyUnexecutedSequenceContracts.encode(message.destroyUnexecutedSequenceContracts, writer.uint32(162).fork()).ldelim();
        }
        if (message.updateMinimalConsistencyLevel !== undefined) {
            TokenBridgeUpdateMinimalConsistencyLevel.encode(message.updateMinimalConsistencyLevel, writer.uint32(170).fork()).ldelim();
        }
        if (message.updateRefundAddress !== undefined) {
            TokenBridgeUpdateRefundAddress.encode(message.updateRefundAddress, writer.uint32(178).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGovernanceMessage);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 2:
                    message.sequence = longToString(reader.uint64());
                    break;
                case 3:
                    message.nonce = reader.uint32();
                    break;
                case 4:
                    message.targetChainId = reader.uint32();
                    break;
                case 8:
                    message.updateMessageFee = UpdateMessageFee.decode(reader, reader.uint32());
                    break;
                case 9:
                    message.transferFee = TransferFee.decode(reader, reader.uint32());
                    break;
                case 10:
                    message.guardianSet = GuardianSetUpgrade.decode(reader, reader.uint32());
                    break;
                case 11:
                    message.contractUpgrade = ContractUpgrade.decode(reader, reader.uint32());
                    break;
                case 12:
                    message.bridgeRegisterChain = BridgeRegisterChain.decode(reader, reader.uint32());
                    break;
                case 13:
                    message.bridgeContractUpgrade = BridgeUpgradeContract.decode(reader, reader.uint32());
                    break;
                case 20:
                    message.destroyUnexecutedSequenceContracts =
                        TokenBridgeDestroyUnexecutedSequenceContracts.decode(reader, reader.uint32());
                    break;
                case 21:
                    message.updateMinimalConsistencyLevel =
                        TokenBridgeUpdateMinimalConsistencyLevel.decode(reader, reader.uint32());
                    break;
                case 22:
                    message.updateRefundAddress = TokenBridgeUpdateRefundAddress.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGovernanceMessage);
        if (object.sequence !== undefined && object.sequence !== null) {
            message.sequence = String(object.sequence);
        }
        else {
            message.sequence = "0";
        }
        if (object.nonce !== undefined && object.nonce !== null) {
            message.nonce = Number(object.nonce);
        }
        else {
            message.nonce = 0;
        }
        if (object.targetChainId !== undefined && object.targetChainId !== null) {
            message.targetChainId = Number(object.targetChainId);
        }
        else {
            message.targetChainId = 0;
        }
        if (object.updateMessageFee !== undefined &&
            object.updateMessageFee !== null) {
            message.updateMessageFee = UpdateMessageFee.fromJSON(object.updateMessageFee);
        }
        else {
            message.updateMessageFee = undefined;
        }
        if (object.transferFee !== undefined && object.transferFee !== null) {
            message.transferFee = TransferFee.fromJSON(object.transferFee);
        }
        else {
            message.transferFee = undefined;
        }
        if (object.guardianSet !== undefined && object.guardianSet !== null) {
            message.guardianSet = GuardianSetUpgrade.fromJSON(object.guardianSet);
        }
        else {
            message.guardianSet = undefined;
        }
        if (object.contractUpgrade !== undefined &&
            object.contractUpgrade !== null) {
            message.contractUpgrade = ContractUpgrade.fromJSON(object.contractUpgrade);
        }
        else {
            message.contractUpgrade = undefined;
        }
        if (object.bridgeRegisterChain !== undefined &&
            object.bridgeRegisterChain !== null) {
            message.bridgeRegisterChain = BridgeRegisterChain.fromJSON(object.bridgeRegisterChain);
        }
        else {
            message.bridgeRegisterChain = undefined;
        }
        if (object.bridgeContractUpgrade !== undefined &&
            object.bridgeContractUpgrade !== null) {
            message.bridgeContractUpgrade = BridgeUpgradeContract.fromJSON(object.bridgeContractUpgrade);
        }
        else {
            message.bridgeContractUpgrade = undefined;
        }
        if (object.destroyUnexecutedSequenceContracts !== undefined &&
            object.destroyUnexecutedSequenceContracts !== null) {
            message.destroyUnexecutedSequenceContracts =
                TokenBridgeDestroyUnexecutedSequenceContracts.fromJSON(object.destroyUnexecutedSequenceContracts);
        }
        else {
            message.destroyUnexecutedSequenceContracts = undefined;
        }
        if (object.updateMinimalConsistencyLevel !== undefined &&
            object.updateMinimalConsistencyLevel !== null) {
            message.updateMinimalConsistencyLevel =
                TokenBridgeUpdateMinimalConsistencyLevel.fromJSON(object.updateMinimalConsistencyLevel);
        }
        else {
            message.updateMinimalConsistencyLevel = undefined;
        }
        if (object.updateRefundAddress !== undefined &&
            object.updateRefundAddress !== null) {
            message.updateRefundAddress = TokenBridgeUpdateRefundAddress.fromJSON(object.updateRefundAddress);
        }
        else {
            message.updateRefundAddress = undefined;
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.sequence !== undefined && (obj.sequence = message.sequence);
        message.nonce !== undefined && (obj.nonce = message.nonce);
        message.targetChainId !== undefined &&
            (obj.targetChainId = message.targetChainId);
        message.updateMessageFee !== undefined &&
            (obj.updateMessageFee = message.updateMessageFee
                ? UpdateMessageFee.toJSON(message.updateMessageFee)
                : undefined);
        message.transferFee !== undefined &&
            (obj.transferFee = message.transferFee
                ? TransferFee.toJSON(message.transferFee)
                : undefined);
        message.guardianSet !== undefined &&
            (obj.guardianSet = message.guardianSet
                ? GuardianSetUpgrade.toJSON(message.guardianSet)
                : undefined);
        message.contractUpgrade !== undefined &&
            (obj.contractUpgrade = message.contractUpgrade
                ? ContractUpgrade.toJSON(message.contractUpgrade)
                : undefined);
        message.bridgeRegisterChain !== undefined &&
            (obj.bridgeRegisterChain = message.bridgeRegisterChain
                ? BridgeRegisterChain.toJSON(message.bridgeRegisterChain)
                : undefined);
        message.bridgeContractUpgrade !== undefined &&
            (obj.bridgeContractUpgrade = message.bridgeContractUpgrade
                ? BridgeUpgradeContract.toJSON(message.bridgeContractUpgrade)
                : undefined);
        message.destroyUnexecutedSequenceContracts !== undefined &&
            (obj.destroyUnexecutedSequenceContracts =
                message.destroyUnexecutedSequenceContracts
                    ? TokenBridgeDestroyUnexecutedSequenceContracts.toJSON(message.destroyUnexecutedSequenceContracts)
                    : undefined);
        message.updateMinimalConsistencyLevel !== undefined &&
            (obj.updateMinimalConsistencyLevel = message.updateMinimalConsistencyLevel
                ? TokenBridgeUpdateMinimalConsistencyLevel.toJSON(message.updateMinimalConsistencyLevel)
                : undefined);
        message.updateRefundAddress !== undefined &&
            (obj.updateRefundAddress = message.updateRefundAddress
                ? TokenBridgeUpdateRefundAddress.toJSON(message.updateRefundAddress)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseGovernanceMessage);
        if (object.sequence !== undefined && object.sequence !== null) {
            message.sequence = object.sequence;
        }
        else {
            message.sequence = "0";
        }
        if (object.nonce !== undefined && object.nonce !== null) {
            message.nonce = object.nonce;
        }
        else {
            message.nonce = 0;
        }
        if (object.targetChainId !== undefined && object.targetChainId !== null) {
            message.targetChainId = object.targetChainId;
        }
        else {
            message.targetChainId = 0;
        }
        if (object.updateMessageFee !== undefined &&
            object.updateMessageFee !== null) {
            message.updateMessageFee = UpdateMessageFee.fromPartial(object.updateMessageFee);
        }
        else {
            message.updateMessageFee = undefined;
        }
        if (object.transferFee !== undefined && object.transferFee !== null) {
            message.transferFee = TransferFee.fromPartial(object.transferFee);
        }
        else {
            message.transferFee = undefined;
        }
        if (object.guardianSet !== undefined && object.guardianSet !== null) {
            message.guardianSet = GuardianSetUpgrade.fromPartial(object.guardianSet);
        }
        else {
            message.guardianSet = undefined;
        }
        if (object.contractUpgrade !== undefined &&
            object.contractUpgrade !== null) {
            message.contractUpgrade = ContractUpgrade.fromPartial(object.contractUpgrade);
        }
        else {
            message.contractUpgrade = undefined;
        }
        if (object.bridgeRegisterChain !== undefined &&
            object.bridgeRegisterChain !== null) {
            message.bridgeRegisterChain = BridgeRegisterChain.fromPartial(object.bridgeRegisterChain);
        }
        else {
            message.bridgeRegisterChain = undefined;
        }
        if (object.bridgeContractUpgrade !== undefined &&
            object.bridgeContractUpgrade !== null) {
            message.bridgeContractUpgrade = BridgeUpgradeContract.fromPartial(object.bridgeContractUpgrade);
        }
        else {
            message.bridgeContractUpgrade = undefined;
        }
        if (object.destroyUnexecutedSequenceContracts !== undefined &&
            object.destroyUnexecutedSequenceContracts !== null) {
            message.destroyUnexecutedSequenceContracts =
                TokenBridgeDestroyUnexecutedSequenceContracts.fromPartial(object.destroyUnexecutedSequenceContracts);
        }
        else {
            message.destroyUnexecutedSequenceContracts = undefined;
        }
        if (object.updateMinimalConsistencyLevel !== undefined &&
            object.updateMinimalConsistencyLevel !== null) {
            message.updateMinimalConsistencyLevel =
                TokenBridgeUpdateMinimalConsistencyLevel.fromPartial(object.updateMinimalConsistencyLevel);
        }
        else {
            message.updateMinimalConsistencyLevel = undefined;
        }
        if (object.updateRefundAddress !== undefined &&
            object.updateRefundAddress !== null) {
            message.updateRefundAddress = TokenBridgeUpdateRefundAddress.fromPartial(object.updateRefundAddress);
        }
        else {
            message.updateRefundAddress = undefined;
        }
        return message;
    },
};
const baseInjectGovernanceVAAResponse = {};
export const InjectGovernanceVAAResponse = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.digests) {
            writer.uint32(10).bytes(v);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseInjectGovernanceVAAResponse);
        message.digests = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.digests.push(reader.bytes());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseInjectGovernanceVAAResponse);
        message.digests = [];
        if (object.digests !== undefined && object.digests !== null) {
            for (const e of object.digests) {
                message.digests.push(bytesFromBase64(e));
            }
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.digests) {
            obj.digests = message.digests.map((e) => base64FromBytes(e !== undefined ? e : new Uint8Array()));
        }
        else {
            obj.digests = [];
        }
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseInjectGovernanceVAAResponse);
        message.digests = [];
        if (object.digests !== undefined && object.digests !== null) {
            for (const e of object.digests) {
                message.digests.push(e);
            }
        }
        return message;
    },
};
const baseUpdateMessageFee = { newMessageFee: "" };
export const UpdateMessageFee = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.newMessageFee !== "") {
            writer.uint32(10).string(message.newMessageFee);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseUpdateMessageFee);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.newMessageFee = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseUpdateMessageFee);
        if (object.newMessageFee !== undefined && object.newMessageFee !== null) {
            message.newMessageFee = String(object.newMessageFee);
        }
        else {
            message.newMessageFee = "";
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.newMessageFee !== undefined &&
            (obj.newMessageFee = message.newMessageFee);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseUpdateMessageFee);
        if (object.newMessageFee !== undefined && object.newMessageFee !== null) {
            message.newMessageFee = object.newMessageFee;
        }
        else {
            message.newMessageFee = "";
        }
        return message;
    },
};
const baseTransferFee = { amount: "", recipient: "" };
export const TransferFee = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.amount !== "") {
            writer.uint32(10).string(message.amount);
        }
        if (message.recipient !== "") {
            writer.uint32(18).string(message.recipient);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseTransferFee);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.amount = reader.string();
                    break;
                case 2:
                    message.recipient = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTransferFee);
        if (object.amount !== undefined && object.amount !== null) {
            message.amount = String(object.amount);
        }
        else {
            message.amount = "";
        }
        if (object.recipient !== undefined && object.recipient !== null) {
            message.recipient = String(object.recipient);
        }
        else {
            message.recipient = "";
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.amount !== undefined && (obj.amount = message.amount);
        message.recipient !== undefined && (obj.recipient = message.recipient);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseTransferFee);
        if (object.amount !== undefined && object.amount !== null) {
            message.amount = object.amount;
        }
        else {
            message.amount = "";
        }
        if (object.recipient !== undefined && object.recipient !== null) {
            message.recipient = object.recipient;
        }
        else {
            message.recipient = "";
        }
        return message;
    },
};
const baseGuardianSetUpgrade = {};
export const GuardianSetUpgrade = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.guardians) {
            GuardianSetUpgrade_Guardian.encode(v, writer.uint32(26).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGuardianSetUpgrade);
        message.guardians = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 3:
                    message.guardians.push(GuardianSetUpgrade_Guardian.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGuardianSetUpgrade);
        message.guardians = [];
        if (object.guardians !== undefined && object.guardians !== null) {
            for (const e of object.guardians) {
                message.guardians.push(GuardianSetUpgrade_Guardian.fromJSON(e));
            }
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.guardians) {
            obj.guardians = message.guardians.map((e) => e ? GuardianSetUpgrade_Guardian.toJSON(e) : undefined);
        }
        else {
            obj.guardians = [];
        }
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseGuardianSetUpgrade);
        message.guardians = [];
        if (object.guardians !== undefined && object.guardians !== null) {
            for (const e of object.guardians) {
                message.guardians.push(GuardianSetUpgrade_Guardian.fromPartial(e));
            }
        }
        return message;
    },
};
const baseGuardianSetUpgrade_Guardian = { pubkey: "", name: "" };
export const GuardianSetUpgrade_Guardian = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.pubkey !== "") {
            writer.uint32(10).string(message.pubkey);
        }
        if (message.name !== "") {
            writer.uint32(18).string(message.name);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGuardianSetUpgrade_Guardian);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.pubkey = reader.string();
                    break;
                case 2:
                    message.name = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGuardianSetUpgrade_Guardian);
        if (object.pubkey !== undefined && object.pubkey !== null) {
            message.pubkey = String(object.pubkey);
        }
        else {
            message.pubkey = "";
        }
        if (object.name !== undefined && object.name !== null) {
            message.name = String(object.name);
        }
        else {
            message.name = "";
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.pubkey !== undefined && (obj.pubkey = message.pubkey);
        message.name !== undefined && (obj.name = message.name);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseGuardianSetUpgrade_Guardian);
        if (object.pubkey !== undefined && object.pubkey !== null) {
            message.pubkey = object.pubkey;
        }
        else {
            message.pubkey = "";
        }
        if (object.name !== undefined && object.name !== null) {
            message.name = object.name;
        }
        else {
            message.name = "";
        }
        return message;
    },
};
const baseGuardianKey = { unsafeDeterministicKey: false };
export const GuardianKey = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.data.length !== 0) {
            writer.uint32(10).bytes(message.data);
        }
        if (message.unsafeDeterministicKey === true) {
            writer.uint32(16).bool(message.unsafeDeterministicKey);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGuardianKey);
        message.data = new Uint8Array();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.data = reader.bytes();
                    break;
                case 2:
                    message.unsafeDeterministicKey = reader.bool();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGuardianKey);
        message.data = new Uint8Array();
        if (object.data !== undefined && object.data !== null) {
            message.data = bytesFromBase64(object.data);
        }
        if (object.unsafeDeterministicKey !== undefined &&
            object.unsafeDeterministicKey !== null) {
            message.unsafeDeterministicKey = Boolean(object.unsafeDeterministicKey);
        }
        else {
            message.unsafeDeterministicKey = false;
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.data !== undefined &&
            (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array()));
        message.unsafeDeterministicKey !== undefined &&
            (obj.unsafeDeterministicKey = message.unsafeDeterministicKey);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseGuardianKey);
        if (object.data !== undefined && object.data !== null) {
            message.data = object.data;
        }
        else {
            message.data = new Uint8Array();
        }
        if (object.unsafeDeterministicKey !== undefined &&
            object.unsafeDeterministicKey !== null) {
            message.unsafeDeterministicKey = object.unsafeDeterministicKey;
        }
        else {
            message.unsafeDeterministicKey = false;
        }
        return message;
    },
};
const baseBridgeRegisterChain = {
    module: "",
    chainId: 0,
    emitterAddress: "",
};
export const BridgeRegisterChain = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.module !== "") {
            writer.uint32(10).string(message.module);
        }
        if (message.chainId !== 0) {
            writer.uint32(16).uint32(message.chainId);
        }
        if (message.emitterAddress !== "") {
            writer.uint32(26).string(message.emitterAddress);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseBridgeRegisterChain);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.module = reader.string();
                    break;
                case 2:
                    message.chainId = reader.uint32();
                    break;
                case 3:
                    message.emitterAddress = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseBridgeRegisterChain);
        if (object.module !== undefined && object.module !== null) {
            message.module = String(object.module);
        }
        else {
            message.module = "";
        }
        if (object.chainId !== undefined && object.chainId !== null) {
            message.chainId = Number(object.chainId);
        }
        else {
            message.chainId = 0;
        }
        if (object.emitterAddress !== undefined && object.emitterAddress !== null) {
            message.emitterAddress = String(object.emitterAddress);
        }
        else {
            message.emitterAddress = "";
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.module !== undefined && (obj.module = message.module);
        message.chainId !== undefined && (obj.chainId = message.chainId);
        message.emitterAddress !== undefined &&
            (obj.emitterAddress = message.emitterAddress);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseBridgeRegisterChain);
        if (object.module !== undefined && object.module !== null) {
            message.module = object.module;
        }
        else {
            message.module = "";
        }
        if (object.chainId !== undefined && object.chainId !== null) {
            message.chainId = object.chainId;
        }
        else {
            message.chainId = 0;
        }
        if (object.emitterAddress !== undefined && object.emitterAddress !== null) {
            message.emitterAddress = object.emitterAddress;
        }
        else {
            message.emitterAddress = "";
        }
        return message;
    },
};
const baseContractUpgrade = { payload: "" };
export const ContractUpgrade = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.payload !== "") {
            writer.uint32(10).string(message.payload);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseContractUpgrade);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.payload = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseContractUpgrade);
        if (object.payload !== undefined && object.payload !== null) {
            message.payload = String(object.payload);
        }
        else {
            message.payload = "";
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.payload !== undefined && (obj.payload = message.payload);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseContractUpgrade);
        if (object.payload !== undefined && object.payload !== null) {
            message.payload = object.payload;
        }
        else {
            message.payload = "";
        }
        return message;
    },
};
const baseBridgeUpgradeContract = { module: "", payload: "" };
export const BridgeUpgradeContract = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.module !== "") {
            writer.uint32(10).string(message.module);
        }
        if (message.payload !== "") {
            writer.uint32(18).string(message.payload);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseBridgeUpgradeContract);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.module = reader.string();
                    break;
                case 2:
                    message.payload = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseBridgeUpgradeContract);
        if (object.module !== undefined && object.module !== null) {
            message.module = String(object.module);
        }
        else {
            message.module = "";
        }
        if (object.payload !== undefined && object.payload !== null) {
            message.payload = String(object.payload);
        }
        else {
            message.payload = "";
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.module !== undefined && (obj.module = message.module);
        message.payload !== undefined && (obj.payload = message.payload);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseBridgeUpgradeContract);
        if (object.module !== undefined && object.module !== null) {
            message.module = object.module;
        }
        else {
            message.module = "";
        }
        if (object.payload !== undefined && object.payload !== null) {
            message.payload = object.payload;
        }
        else {
            message.payload = "";
        }
        return message;
    },
};
const baseTokenBridgeDestroyUnexecutedSequenceContracts = {
    emitterChain: 0,
    sequences: "0",
};
export const TokenBridgeDestroyUnexecutedSequenceContracts = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.emitterChain !== 0) {
            writer.uint32(8).uint32(message.emitterChain);
        }
        writer.uint32(18).fork();
        for (const v of message.sequences) {
            writer.uint64(v);
        }
        writer.ldelim();
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseTokenBridgeDestroyUnexecutedSequenceContracts);
        message.sequences = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.emitterChain = reader.uint32();
                    break;
                case 2:
                    if ((tag & 7) === 2) {
                        const end2 = reader.uint32() + reader.pos;
                        while (reader.pos < end2) {
                            message.sequences.push(longToString(reader.uint64()));
                        }
                    }
                    else {
                        message.sequences.push(longToString(reader.uint64()));
                    }
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTokenBridgeDestroyUnexecutedSequenceContracts);
        message.sequences = [];
        if (object.emitterChain !== undefined && object.emitterChain !== null) {
            message.emitterChain = Number(object.emitterChain);
        }
        else {
            message.emitterChain = 0;
        }
        if (object.sequences !== undefined && object.sequences !== null) {
            for (const e of object.sequences) {
                message.sequences.push(String(e));
            }
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.emitterChain !== undefined &&
            (obj.emitterChain = message.emitterChain);
        if (message.sequences) {
            obj.sequences = message.sequences.map((e) => e);
        }
        else {
            obj.sequences = [];
        }
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseTokenBridgeDestroyUnexecutedSequenceContracts);
        message.sequences = [];
        if (object.emitterChain !== undefined && object.emitterChain !== null) {
            message.emitterChain = object.emitterChain;
        }
        else {
            message.emitterChain = 0;
        }
        if (object.sequences !== undefined && object.sequences !== null) {
            for (const e of object.sequences) {
                message.sequences.push(e);
            }
        }
        return message;
    },
};
const baseTokenBridgeUpdateMinimalConsistencyLevel = {
    newConsistencyLevel: 0,
};
export const TokenBridgeUpdateMinimalConsistencyLevel = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.newConsistencyLevel !== 0) {
            writer.uint32(8).uint32(message.newConsistencyLevel);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseTokenBridgeUpdateMinimalConsistencyLevel);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.newConsistencyLevel = reader.uint32();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTokenBridgeUpdateMinimalConsistencyLevel);
        if (object.newConsistencyLevel !== undefined &&
            object.newConsistencyLevel !== null) {
            message.newConsistencyLevel = Number(object.newConsistencyLevel);
        }
        else {
            message.newConsistencyLevel = 0;
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.newConsistencyLevel !== undefined &&
            (obj.newConsistencyLevel = message.newConsistencyLevel);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseTokenBridgeUpdateMinimalConsistencyLevel);
        if (object.newConsistencyLevel !== undefined &&
            object.newConsistencyLevel !== null) {
            message.newConsistencyLevel = object.newConsistencyLevel;
        }
        else {
            message.newConsistencyLevel = 0;
        }
        return message;
    },
};
const baseTokenBridgeUpdateRefundAddress = { newRefundAddress: "" };
export const TokenBridgeUpdateRefundAddress = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.newRefundAddress !== "") {
            writer.uint32(10).string(message.newRefundAddress);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseTokenBridgeUpdateRefundAddress);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.newRefundAddress = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTokenBridgeUpdateRefundAddress);
        if (object.newRefundAddress !== undefined &&
            object.newRefundAddress !== null) {
            message.newRefundAddress = String(object.newRefundAddress);
        }
        else {
            message.newRefundAddress = "";
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.newRefundAddress !== undefined &&
            (obj.newRefundAddress = message.newRefundAddress);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseTokenBridgeUpdateRefundAddress);
        if (object.newRefundAddress !== undefined &&
            object.newRefundAddress !== null) {
            message.newRefundAddress = object.newRefundAddress;
        }
        else {
            message.newRefundAddress = "";
        }
        return message;
    },
};
const baseFindMissingMessagesRequest = {
    emitterChain: 0,
    targetChain: 0,
    emitterAddress: "",
    rpcBackfill: false,
    backfillNodes: "",
};
export const FindMissingMessagesRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.emitterChain !== 0) {
            writer.uint32(8).uint32(message.emitterChain);
        }
        if (message.targetChain !== 0) {
            writer.uint32(16).uint32(message.targetChain);
        }
        if (message.emitterAddress !== "") {
            writer.uint32(26).string(message.emitterAddress);
        }
        if (message.rpcBackfill === true) {
            writer.uint32(32).bool(message.rpcBackfill);
        }
        for (const v of message.backfillNodes) {
            writer.uint32(42).string(v);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseFindMissingMessagesRequest);
        message.backfillNodes = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.emitterChain = reader.uint32();
                    break;
                case 2:
                    message.targetChain = reader.uint32();
                    break;
                case 3:
                    message.emitterAddress = reader.string();
                    break;
                case 4:
                    message.rpcBackfill = reader.bool();
                    break;
                case 5:
                    message.backfillNodes.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseFindMissingMessagesRequest);
        message.backfillNodes = [];
        if (object.emitterChain !== undefined && object.emitterChain !== null) {
            message.emitterChain = Number(object.emitterChain);
        }
        else {
            message.emitterChain = 0;
        }
        if (object.targetChain !== undefined && object.targetChain !== null) {
            message.targetChain = Number(object.targetChain);
        }
        else {
            message.targetChain = 0;
        }
        if (object.emitterAddress !== undefined && object.emitterAddress !== null) {
            message.emitterAddress = String(object.emitterAddress);
        }
        else {
            message.emitterAddress = "";
        }
        if (object.rpcBackfill !== undefined && object.rpcBackfill !== null) {
            message.rpcBackfill = Boolean(object.rpcBackfill);
        }
        else {
            message.rpcBackfill = false;
        }
        if (object.backfillNodes !== undefined && object.backfillNodes !== null) {
            for (const e of object.backfillNodes) {
                message.backfillNodes.push(String(e));
            }
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.emitterChain !== undefined &&
            (obj.emitterChain = message.emitterChain);
        message.targetChain !== undefined &&
            (obj.targetChain = message.targetChain);
        message.emitterAddress !== undefined &&
            (obj.emitterAddress = message.emitterAddress);
        message.rpcBackfill !== undefined &&
            (obj.rpcBackfill = message.rpcBackfill);
        if (message.backfillNodes) {
            obj.backfillNodes = message.backfillNodes.map((e) => e);
        }
        else {
            obj.backfillNodes = [];
        }
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseFindMissingMessagesRequest);
        message.backfillNodes = [];
        if (object.emitterChain !== undefined && object.emitterChain !== null) {
            message.emitterChain = object.emitterChain;
        }
        else {
            message.emitterChain = 0;
        }
        if (object.targetChain !== undefined && object.targetChain !== null) {
            message.targetChain = object.targetChain;
        }
        else {
            message.targetChain = 0;
        }
        if (object.emitterAddress !== undefined && object.emitterAddress !== null) {
            message.emitterAddress = object.emitterAddress;
        }
        else {
            message.emitterAddress = "";
        }
        if (object.rpcBackfill !== undefined && object.rpcBackfill !== null) {
            message.rpcBackfill = object.rpcBackfill;
        }
        else {
            message.rpcBackfill = false;
        }
        if (object.backfillNodes !== undefined && object.backfillNodes !== null) {
            for (const e of object.backfillNodes) {
                message.backfillNodes.push(e);
            }
        }
        return message;
    },
};
const baseFindMissingMessagesResponse = {
    missingMessages: "",
    firstSequence: "0",
    lastSequence: "0",
};
export const FindMissingMessagesResponse = {
    encode(message, writer = _m0.Writer.create()) {
        for (const v of message.missingMessages) {
            writer.uint32(10).string(v);
        }
        if (message.firstSequence !== "0") {
            writer.uint32(16).uint64(message.firstSequence);
        }
        if (message.lastSequence !== "0") {
            writer.uint32(24).uint64(message.lastSequence);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseFindMissingMessagesResponse);
        message.missingMessages = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.missingMessages.push(reader.string());
                    break;
                case 2:
                    message.firstSequence = longToString(reader.uint64());
                    break;
                case 3:
                    message.lastSequence = longToString(reader.uint64());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseFindMissingMessagesResponse);
        message.missingMessages = [];
        if (object.missingMessages !== undefined &&
            object.missingMessages !== null) {
            for (const e of object.missingMessages) {
                message.missingMessages.push(String(e));
            }
        }
        if (object.firstSequence !== undefined && object.firstSequence !== null) {
            message.firstSequence = String(object.firstSequence);
        }
        else {
            message.firstSequence = "0";
        }
        if (object.lastSequence !== undefined && object.lastSequence !== null) {
            message.lastSequence = String(object.lastSequence);
        }
        else {
            message.lastSequence = "0";
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.missingMessages) {
            obj.missingMessages = message.missingMessages.map((e) => e);
        }
        else {
            obj.missingMessages = [];
        }
        message.firstSequence !== undefined &&
            (obj.firstSequence = message.firstSequence);
        message.lastSequence !== undefined &&
            (obj.lastSequence = message.lastSequence);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseFindMissingMessagesResponse);
        message.missingMessages = [];
        if (object.missingMessages !== undefined &&
            object.missingMessages !== null) {
            for (const e of object.missingMessages) {
                message.missingMessages.push(e);
            }
        }
        if (object.firstSequence !== undefined && object.firstSequence !== null) {
            message.firstSequence = object.firstSequence;
        }
        else {
            message.firstSequence = "0";
        }
        if (object.lastSequence !== undefined && object.lastSequence !== null) {
            message.lastSequence = object.lastSequence;
        }
        else {
            message.lastSequence = "0";
        }
        return message;
    },
};
const baseSendObservationRequestRequest = {};
export const SendObservationRequestRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.observationRequest !== undefined) {
            ObservationRequest.encode(message.observationRequest, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseSendObservationRequestRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.observationRequest = ObservationRequest.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseSendObservationRequestRequest);
        if (object.observationRequest !== undefined &&
            object.observationRequest !== null) {
            message.observationRequest = ObservationRequest.fromJSON(object.observationRequest);
        }
        else {
            message.observationRequest = undefined;
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.observationRequest !== undefined &&
            (obj.observationRequest = message.observationRequest
                ? ObservationRequest.toJSON(message.observationRequest)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseSendObservationRequestRequest);
        if (object.observationRequest !== undefined &&
            object.observationRequest !== null) {
            message.observationRequest = ObservationRequest.fromPartial(object.observationRequest);
        }
        else {
            message.observationRequest = undefined;
        }
        return message;
    },
};
const baseSendObservationRequestResponse = {};
export const SendObservationRequestResponse = {
    encode(_, writer = _m0.Writer.create()) {
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseSendObservationRequestResponse);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(_) {
        const message = Object.assign({}, baseSendObservationRequestResponse);
        return message;
    },
    toJSON(_) {
        const obj = {};
        return obj;
    },
    fromPartial(_) {
        const message = Object.assign({}, baseSendObservationRequestResponse);
        return message;
    },
};
const baseGetNextGovernanceVAASequenceRequest = {};
export const GetNextGovernanceVAASequenceRequest = {
    encode(_, writer = _m0.Writer.create()) {
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGetNextGovernanceVAASequenceRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(_) {
        const message = Object.assign({}, baseGetNextGovernanceVAASequenceRequest);
        return message;
    },
    toJSON(_) {
        const obj = {};
        return obj;
    },
    fromPartial(_) {
        const message = Object.assign({}, baseGetNextGovernanceVAASequenceRequest);
        return message;
    },
};
const baseGetNextGovernanceVAASequenceResponse = { sequence: "0" };
export const GetNextGovernanceVAASequenceResponse = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.sequence !== "0") {
            writer.uint32(8).uint64(message.sequence);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGetNextGovernanceVAASequenceResponse);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.sequence = longToString(reader.uint64());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetNextGovernanceVAASequenceResponse);
        if (object.sequence !== undefined && object.sequence !== null) {
            message.sequence = String(object.sequence);
        }
        else {
            message.sequence = "0";
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.sequence !== undefined && (obj.sequence = message.sequence);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseGetNextGovernanceVAASequenceResponse);
        if (object.sequence !== undefined && object.sequence !== null) {
            message.sequence = object.sequence;
        }
        else {
            message.sequence = "0";
        }
        return message;
    },
};
export class NodePrivilegedServiceClientImpl {
    constructor(rpc) {
        this.rpc = rpc;
        this.InjectGovernanceVAA = this.InjectGovernanceVAA.bind(this);
        this.FindMissingMessages = this.FindMissingMessages.bind(this);
        this.SendObservationRequest = this.SendObservationRequest.bind(this);
        this.GetNextGovernanceVAASequence =
            this.GetNextGovernanceVAASequence.bind(this);
    }
    InjectGovernanceVAA(request, metadata) {
        return this.rpc.unary(NodePrivilegedServiceInjectGovernanceVAADesc, InjectGovernanceVAARequest.fromPartial(request), metadata);
    }
    FindMissingMessages(request, metadata) {
        return this.rpc.unary(NodePrivilegedServiceFindMissingMessagesDesc, FindMissingMessagesRequest.fromPartial(request), metadata);
    }
    SendObservationRequest(request, metadata) {
        return this.rpc.unary(NodePrivilegedServiceSendObservationRequestDesc, SendObservationRequestRequest.fromPartial(request), metadata);
    }
    GetNextGovernanceVAASequence(request, metadata) {
        return this.rpc.unary(NodePrivilegedServiceGetNextGovernanceVAASequenceDesc, GetNextGovernanceVAASequenceRequest.fromPartial(request), metadata);
    }
}
export const NodePrivilegedServiceDesc = {
    serviceName: "node.v1.NodePrivilegedService",
};
export const NodePrivilegedServiceInjectGovernanceVAADesc = {
    methodName: "InjectGovernanceVAA",
    service: NodePrivilegedServiceDesc,
    requestStream: false,
    responseStream: false,
    requestType: {
        serializeBinary() {
            return InjectGovernanceVAARequest.encode(this).finish();
        },
    },
    responseType: {
        deserializeBinary(data) {
            return Object.assign(Object.assign({}, InjectGovernanceVAAResponse.decode(data)), { toObject() {
                    return this;
                } });
        },
    },
};
export const NodePrivilegedServiceFindMissingMessagesDesc = {
    methodName: "FindMissingMessages",
    service: NodePrivilegedServiceDesc,
    requestStream: false,
    responseStream: false,
    requestType: {
        serializeBinary() {
            return FindMissingMessagesRequest.encode(this).finish();
        },
    },
    responseType: {
        deserializeBinary(data) {
            return Object.assign(Object.assign({}, FindMissingMessagesResponse.decode(data)), { toObject() {
                    return this;
                } });
        },
    },
};
export const NodePrivilegedServiceSendObservationRequestDesc = {
    methodName: "SendObservationRequest",
    service: NodePrivilegedServiceDesc,
    requestStream: false,
    responseStream: false,
    requestType: {
        serializeBinary() {
            return SendObservationRequestRequest.encode(this).finish();
        },
    },
    responseType: {
        deserializeBinary(data) {
            return Object.assign(Object.assign({}, SendObservationRequestResponse.decode(data)), { toObject() {
                    return this;
                } });
        },
    },
};
export const NodePrivilegedServiceGetNextGovernanceVAASequenceDesc = {
    methodName: "GetNextGovernanceVAASequence",
    service: NodePrivilegedServiceDesc,
    requestStream: false,
    responseStream: false,
    requestType: {
        serializeBinary() {
            return GetNextGovernanceVAASequenceRequest.encode(this).finish();
        },
    },
    responseType: {
        deserializeBinary(data) {
            return Object.assign(Object.assign({}, GetNextGovernanceVAASequenceResponse.decode(data)), { toObject() {
                    return this;
                } });
        },
    },
};
export class GrpcWebImpl {
    constructor(host, options) {
        this.host = host;
        this.options = options;
    }
    unary(methodDesc, _request, metadata) {
        var _a;
        const request = Object.assign(Object.assign({}, _request), methodDesc.requestType);
        const maybeCombinedMetadata = metadata && this.options.metadata
            ? new BrowserHeaders(Object.assign(Object.assign({}, (_a = this.options) === null || _a === void 0 ? void 0 : _a.metadata.headersMap), metadata === null || metadata === void 0 ? void 0 : metadata.headersMap))
            : metadata || this.options.metadata;
        return new Promise((resolve, reject) => {
            grpc.unary(methodDesc, {
                request,
                host: this.host,
                metadata: maybeCombinedMetadata,
                transport: this.options.transport,
                debug: this.options.debug,
                onEnd: function (response) {
                    if (response.status === grpc.Code.OK) {
                        resolve(response.message);
                    }
                    else {
                        const err = new Error(response.statusMessage);
                        err.code = response.status;
                        err.metadata = response.trailers;
                        reject(err);
                    }
                },
            });
        });
    }
}
var globalThis = (() => {
    if (typeof globalThis !== "undefined")
        return globalThis;
    if (typeof self !== "undefined")
        return self;
    if (typeof window !== "undefined")
        return window;
    if (typeof global !== "undefined")
        return global;
    throw "Unable to locate global object";
})();
const atob = globalThis.atob ||
    ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
function bytesFromBase64(b64) {
    const bin = atob(b64);
    const arr = new Uint8Array(bin.length);
    for (let i = 0; i < bin.length; ++i) {
        arr[i] = bin.charCodeAt(i);
    }
    return arr;
}
const btoa = globalThis.btoa ||
    ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
function base64FromBytes(arr) {
    const bin = [];
    for (const byte of arr) {
        bin.push(String.fromCharCode(byte));
    }
    return btoa(bin.join(""));
}
function longToString(long) {
    return long.toString();
}
if (_m0.util.Long !== Long) {
    _m0.util.Long = Long;
    _m0.configure();
}
