"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GrpcWebImpl = exports.PublicRPCServiceGetCurrentGuardianSetDesc = exports.PublicRPCServiceGetSignedVAADesc = exports.PublicRPCServiceGetLastHeartbeatsDesc = exports.PublicRPCServiceDesc = exports.PublicRPCServiceClientImpl = exports.GuardianSet = exports.GetCurrentGuardianSetResponse = exports.GetCurrentGuardianSetRequest = exports.GetLastHeartbeatsResponse_Entry = exports.GetLastHeartbeatsResponse = exports.GetLastHeartbeatsRequest = exports.GetSignedVAAResponse = exports.GetSignedVAARequest = exports.MessageID = exports.chainIDToJSON = exports.chainIDFromJSON = exports.ChainID = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const grpc_web_1 = require("@improbable-eng/grpc-web");
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const browser_headers_1 = require("browser-headers");
const gossip_1 = require("../../gossip/v1/gossip");
exports.protobufPackage = "publicrpc.v1";
var ChainID;
(function (ChainID) {
    ChainID[ChainID["CHAIN_ID_UNSPECIFIED"] = 0] = "CHAIN_ID_UNSPECIFIED";
    ChainID[ChainID["CHAIN_ID_SOLANA"] = 1] = "CHAIN_ID_SOLANA";
    ChainID[ChainID["CHAIN_ID_ETHEREUM"] = 2] = "CHAIN_ID_ETHEREUM";
    ChainID[ChainID["CHAIN_ID_TERRA"] = 3] = "CHAIN_ID_TERRA";
    ChainID[ChainID["CHAIN_ID_BSC"] = 4] = "CHAIN_ID_BSC";
    ChainID[ChainID["CHAIN_ID_POLYGON"] = 5] = "CHAIN_ID_POLYGON";
    ChainID[ChainID["CHAIN_ID_AVALANCHE"] = 6] = "CHAIN_ID_AVALANCHE";
    ChainID[ChainID["CHAIN_ID_OASIS"] = 7] = "CHAIN_ID_OASIS";
    ChainID[ChainID["CHAIN_ID_ALGORAND"] = 8] = "CHAIN_ID_ALGORAND";
    ChainID[ChainID["CHAIN_ID_AURORA"] = 9] = "CHAIN_ID_AURORA";
    ChainID[ChainID["CHAIN_ID_FANTOM"] = 10] = "CHAIN_ID_FANTOM";
    ChainID[ChainID["CHAIN_ID_KARURA"] = 11] = "CHAIN_ID_KARURA";
    ChainID[ChainID["CHAIN_ID_ACALA"] = 12] = "CHAIN_ID_ACALA";
    ChainID[ChainID["CHAIN_ID_KLAYTN"] = 13] = "CHAIN_ID_KLAYTN";
    ChainID[ChainID["CHAIN_ID_CELO"] = 14] = "CHAIN_ID_CELO";
    ChainID[ChainID["CHAIN_ID_NEAR"] = 15] = "CHAIN_ID_NEAR";
    ChainID[ChainID["CHAIN_ID_MOONBEAM"] = 16] = "CHAIN_ID_MOONBEAM";
    ChainID[ChainID["CHAIN_ID_NEON"] = 17] = "CHAIN_ID_NEON";
    ChainID[ChainID["CHAIN_ID_ALEPHIUM"] = 255] = "CHAIN_ID_ALEPHIUM";
    /**
     * CHAIN_ID_ETHEREUM_ROPSTEN - Special case - Eth has two testnets. CHAIN_ID_ETHEREUM is Goerli,
     * but we also want to connect to Ropsten, so we add a separate chain.
     */
    ChainID[ChainID["CHAIN_ID_ETHEREUM_ROPSTEN"] = 10001] = "CHAIN_ID_ETHEREUM_ROPSTEN";
    ChainID[ChainID["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(ChainID = exports.ChainID || (exports.ChainID = {}));
function chainIDFromJSON(object) {
    switch (object) {
        case 0:
        case "CHAIN_ID_UNSPECIFIED":
            return ChainID.CHAIN_ID_UNSPECIFIED;
        case 1:
        case "CHAIN_ID_SOLANA":
            return ChainID.CHAIN_ID_SOLANA;
        case 2:
        case "CHAIN_ID_ETHEREUM":
            return ChainID.CHAIN_ID_ETHEREUM;
        case 3:
        case "CHAIN_ID_TERRA":
            return ChainID.CHAIN_ID_TERRA;
        case 4:
        case "CHAIN_ID_BSC":
            return ChainID.CHAIN_ID_BSC;
        case 5:
        case "CHAIN_ID_POLYGON":
            return ChainID.CHAIN_ID_POLYGON;
        case 6:
        case "CHAIN_ID_AVALANCHE":
            return ChainID.CHAIN_ID_AVALANCHE;
        case 7:
        case "CHAIN_ID_OASIS":
            return ChainID.CHAIN_ID_OASIS;
        case 8:
        case "CHAIN_ID_ALGORAND":
            return ChainID.CHAIN_ID_ALGORAND;
        case 9:
        case "CHAIN_ID_AURORA":
            return ChainID.CHAIN_ID_AURORA;
        case 10:
        case "CHAIN_ID_FANTOM":
            return ChainID.CHAIN_ID_FANTOM;
        case 11:
        case "CHAIN_ID_KARURA":
            return ChainID.CHAIN_ID_KARURA;
        case 12:
        case "CHAIN_ID_ACALA":
            return ChainID.CHAIN_ID_ACALA;
        case 13:
        case "CHAIN_ID_KLAYTN":
            return ChainID.CHAIN_ID_KLAYTN;
        case 14:
        case "CHAIN_ID_CELO":
            return ChainID.CHAIN_ID_CELO;
        case 15:
        case "CHAIN_ID_NEAR":
            return ChainID.CHAIN_ID_NEAR;
        case 16:
        case "CHAIN_ID_MOONBEAM":
            return ChainID.CHAIN_ID_MOONBEAM;
        case 17:
        case "CHAIN_ID_NEON":
            return ChainID.CHAIN_ID_NEON;
        case 255:
        case "CHAIN_ID_ALEPHIUM":
            return ChainID.CHAIN_ID_ALEPHIUM;
        case 10001:
        case "CHAIN_ID_ETHEREUM_ROPSTEN":
            return ChainID.CHAIN_ID_ETHEREUM_ROPSTEN;
        case -1:
        case "UNRECOGNIZED":
        default:
            return ChainID.UNRECOGNIZED;
    }
}
exports.chainIDFromJSON = chainIDFromJSON;
function chainIDToJSON(object) {
    switch (object) {
        case ChainID.CHAIN_ID_UNSPECIFIED:
            return "CHAIN_ID_UNSPECIFIED";
        case ChainID.CHAIN_ID_SOLANA:
            return "CHAIN_ID_SOLANA";
        case ChainID.CHAIN_ID_ETHEREUM:
            return "CHAIN_ID_ETHEREUM";
        case ChainID.CHAIN_ID_TERRA:
            return "CHAIN_ID_TERRA";
        case ChainID.CHAIN_ID_BSC:
            return "CHAIN_ID_BSC";
        case ChainID.CHAIN_ID_POLYGON:
            return "CHAIN_ID_POLYGON";
        case ChainID.CHAIN_ID_AVALANCHE:
            return "CHAIN_ID_AVALANCHE";
        case ChainID.CHAIN_ID_OASIS:
            return "CHAIN_ID_OASIS";
        case ChainID.CHAIN_ID_ALGORAND:
            return "CHAIN_ID_ALGORAND";
        case ChainID.CHAIN_ID_AURORA:
            return "CHAIN_ID_AURORA";
        case ChainID.CHAIN_ID_FANTOM:
            return "CHAIN_ID_FANTOM";
        case ChainID.CHAIN_ID_KARURA:
            return "CHAIN_ID_KARURA";
        case ChainID.CHAIN_ID_ACALA:
            return "CHAIN_ID_ACALA";
        case ChainID.CHAIN_ID_KLAYTN:
            return "CHAIN_ID_KLAYTN";
        case ChainID.CHAIN_ID_CELO:
            return "CHAIN_ID_CELO";
        case ChainID.CHAIN_ID_NEAR:
            return "CHAIN_ID_NEAR";
        case ChainID.CHAIN_ID_MOONBEAM:
            return "CHAIN_ID_MOONBEAM";
        case ChainID.CHAIN_ID_NEON:
            return "CHAIN_ID_NEON";
        case ChainID.CHAIN_ID_ALEPHIUM:
            return "CHAIN_ID_ALEPHIUM";
        case ChainID.CHAIN_ID_ETHEREUM_ROPSTEN:
            return "CHAIN_ID_ETHEREUM_ROPSTEN";
        default:
            return "UNKNOWN";
    }
}
exports.chainIDToJSON = chainIDToJSON;
const baseMessageID = {
    emitterChain: 0,
    emitterAddress: "",
    targetChain: 0,
    sequence: "0",
};
exports.MessageID = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.emitterChain !== 0) {
            writer.uint32(8).int32(message.emitterChain);
        }
        if (message.emitterAddress !== "") {
            writer.uint32(18).string(message.emitterAddress);
        }
        if (message.targetChain !== 0) {
            writer.uint32(24).int32(message.targetChain);
        }
        if (message.sequence !== "0") {
            writer.uint32(32).uint64(message.sequence);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseMessageID);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.emitterChain = reader.int32();
                    break;
                case 2:
                    message.emitterAddress = reader.string();
                    break;
                case 3:
                    message.targetChain = reader.int32();
                    break;
                case 4:
                    message.sequence = longToString(reader.uint64());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseMessageID);
        if (object.emitterChain !== undefined && object.emitterChain !== null) {
            message.emitterChain = chainIDFromJSON(object.emitterChain);
        }
        else {
            message.emitterChain = 0;
        }
        if (object.emitterAddress !== undefined && object.emitterAddress !== null) {
            message.emitterAddress = String(object.emitterAddress);
        }
        else {
            message.emitterAddress = "";
        }
        if (object.targetChain !== undefined && object.targetChain !== null) {
            message.targetChain = chainIDFromJSON(object.targetChain);
        }
        else {
            message.targetChain = 0;
        }
        if (object.sequence !== undefined && object.sequence !== null) {
            message.sequence = String(object.sequence);
        }
        else {
            message.sequence = "0";
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.emitterChain !== undefined &&
            (obj.emitterChain = chainIDToJSON(message.emitterChain));
        message.emitterAddress !== undefined &&
            (obj.emitterAddress = message.emitterAddress);
        message.targetChain !== undefined &&
            (obj.targetChain = chainIDToJSON(message.targetChain));
        message.sequence !== undefined && (obj.sequence = message.sequence);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseMessageID);
        if (object.emitterChain !== undefined && object.emitterChain !== null) {
            message.emitterChain = object.emitterChain;
        }
        else {
            message.emitterChain = 0;
        }
        if (object.emitterAddress !== undefined && object.emitterAddress !== null) {
            message.emitterAddress = object.emitterAddress;
        }
        else {
            message.emitterAddress = "";
        }
        if (object.targetChain !== undefined && object.targetChain !== null) {
            message.targetChain = object.targetChain;
        }
        else {
            message.targetChain = 0;
        }
        if (object.sequence !== undefined && object.sequence !== null) {
            message.sequence = object.sequence;
        }
        else {
            message.sequence = "0";
        }
        return message;
    },
};
const baseGetSignedVAARequest = {};
exports.GetSignedVAARequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.messageId !== undefined) {
            exports.MessageID.encode(message.messageId, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGetSignedVAARequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.messageId = exports.MessageID.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetSignedVAARequest);
        if (object.messageId !== undefined && object.messageId !== null) {
            message.messageId = exports.MessageID.fromJSON(object.messageId);
        }
        else {
            message.messageId = undefined;
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.messageId !== undefined &&
            (obj.messageId = message.messageId
                ? exports.MessageID.toJSON(message.messageId)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseGetSignedVAARequest);
        if (object.messageId !== undefined && object.messageId !== null) {
            message.messageId = exports.MessageID.fromPartial(object.messageId);
        }
        else {
            message.messageId = undefined;
        }
        return message;
    },
};
const baseGetSignedVAAResponse = {};
exports.GetSignedVAAResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.vaaBytes.length !== 0) {
            writer.uint32(10).bytes(message.vaaBytes);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGetSignedVAAResponse);
        message.vaaBytes = new Uint8Array();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.vaaBytes = reader.bytes();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetSignedVAAResponse);
        message.vaaBytes = new Uint8Array();
        if (object.vaaBytes !== undefined && object.vaaBytes !== null) {
            message.vaaBytes = bytesFromBase64(object.vaaBytes);
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.vaaBytes !== undefined &&
            (obj.vaaBytes = base64FromBytes(message.vaaBytes !== undefined ? message.vaaBytes : new Uint8Array()));
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseGetSignedVAAResponse);
        if (object.vaaBytes !== undefined && object.vaaBytes !== null) {
            message.vaaBytes = object.vaaBytes;
        }
        else {
            message.vaaBytes = new Uint8Array();
        }
        return message;
    },
};
const baseGetLastHeartbeatsRequest = {};
exports.GetLastHeartbeatsRequest = {
    encode(_, writer = minimal_1.default.Writer.create()) {
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGetLastHeartbeatsRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(_) {
        const message = Object.assign({}, baseGetLastHeartbeatsRequest);
        return message;
    },
    toJSON(_) {
        const obj = {};
        return obj;
    },
    fromPartial(_) {
        const message = Object.assign({}, baseGetLastHeartbeatsRequest);
        return message;
    },
};
const baseGetLastHeartbeatsResponse = {};
exports.GetLastHeartbeatsResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.entries) {
            exports.GetLastHeartbeatsResponse_Entry.encode(v, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGetLastHeartbeatsResponse);
        message.entries = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.entries.push(exports.GetLastHeartbeatsResponse_Entry.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetLastHeartbeatsResponse);
        message.entries = [];
        if (object.entries !== undefined && object.entries !== null) {
            for (const e of object.entries) {
                message.entries.push(exports.GetLastHeartbeatsResponse_Entry.fromJSON(e));
            }
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.entries) {
            obj.entries = message.entries.map((e) => e ? exports.GetLastHeartbeatsResponse_Entry.toJSON(e) : undefined);
        }
        else {
            obj.entries = [];
        }
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseGetLastHeartbeatsResponse);
        message.entries = [];
        if (object.entries !== undefined && object.entries !== null) {
            for (const e of object.entries) {
                message.entries.push(exports.GetLastHeartbeatsResponse_Entry.fromPartial(e));
            }
        }
        return message;
    },
};
const baseGetLastHeartbeatsResponse_Entry = {
    verifiedGuardianAddr: "",
    p2pNodeAddr: "",
};
exports.GetLastHeartbeatsResponse_Entry = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.verifiedGuardianAddr !== "") {
            writer.uint32(10).string(message.verifiedGuardianAddr);
        }
        if (message.p2pNodeAddr !== "") {
            writer.uint32(18).string(message.p2pNodeAddr);
        }
        if (message.rawHeartbeat !== undefined) {
            gossip_1.Heartbeat.encode(message.rawHeartbeat, writer.uint32(26).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGetLastHeartbeatsResponse_Entry);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.verifiedGuardianAddr = reader.string();
                    break;
                case 2:
                    message.p2pNodeAddr = reader.string();
                    break;
                case 3:
                    message.rawHeartbeat = gossip_1.Heartbeat.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetLastHeartbeatsResponse_Entry);
        if (object.verifiedGuardianAddr !== undefined &&
            object.verifiedGuardianAddr !== null) {
            message.verifiedGuardianAddr = String(object.verifiedGuardianAddr);
        }
        else {
            message.verifiedGuardianAddr = "";
        }
        if (object.p2pNodeAddr !== undefined && object.p2pNodeAddr !== null) {
            message.p2pNodeAddr = String(object.p2pNodeAddr);
        }
        else {
            message.p2pNodeAddr = "";
        }
        if (object.rawHeartbeat !== undefined && object.rawHeartbeat !== null) {
            message.rawHeartbeat = gossip_1.Heartbeat.fromJSON(object.rawHeartbeat);
        }
        else {
            message.rawHeartbeat = undefined;
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.verifiedGuardianAddr !== undefined &&
            (obj.verifiedGuardianAddr = message.verifiedGuardianAddr);
        message.p2pNodeAddr !== undefined &&
            (obj.p2pNodeAddr = message.p2pNodeAddr);
        message.rawHeartbeat !== undefined &&
            (obj.rawHeartbeat = message.rawHeartbeat
                ? gossip_1.Heartbeat.toJSON(message.rawHeartbeat)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseGetLastHeartbeatsResponse_Entry);
        if (object.verifiedGuardianAddr !== undefined &&
            object.verifiedGuardianAddr !== null) {
            message.verifiedGuardianAddr = object.verifiedGuardianAddr;
        }
        else {
            message.verifiedGuardianAddr = "";
        }
        if (object.p2pNodeAddr !== undefined && object.p2pNodeAddr !== null) {
            message.p2pNodeAddr = object.p2pNodeAddr;
        }
        else {
            message.p2pNodeAddr = "";
        }
        if (object.rawHeartbeat !== undefined && object.rawHeartbeat !== null) {
            message.rawHeartbeat = gossip_1.Heartbeat.fromPartial(object.rawHeartbeat);
        }
        else {
            message.rawHeartbeat = undefined;
        }
        return message;
    },
};
const baseGetCurrentGuardianSetRequest = {};
exports.GetCurrentGuardianSetRequest = {
    encode(_, writer = minimal_1.default.Writer.create()) {
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGetCurrentGuardianSetRequest);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(_) {
        const message = Object.assign({}, baseGetCurrentGuardianSetRequest);
        return message;
    },
    toJSON(_) {
        const obj = {};
        return obj;
    },
    fromPartial(_) {
        const message = Object.assign({}, baseGetCurrentGuardianSetRequest);
        return message;
    },
};
const baseGetCurrentGuardianSetResponse = {};
exports.GetCurrentGuardianSetResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.guardianSet !== undefined) {
            exports.GuardianSet.encode(message.guardianSet, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGetCurrentGuardianSetResponse);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.guardianSet = exports.GuardianSet.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGetCurrentGuardianSetResponse);
        if (object.guardianSet !== undefined && object.guardianSet !== null) {
            message.guardianSet = exports.GuardianSet.fromJSON(object.guardianSet);
        }
        else {
            message.guardianSet = undefined;
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.guardianSet !== undefined &&
            (obj.guardianSet = message.guardianSet
                ? exports.GuardianSet.toJSON(message.guardianSet)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseGetCurrentGuardianSetResponse);
        if (object.guardianSet !== undefined && object.guardianSet !== null) {
            message.guardianSet = exports.GuardianSet.fromPartial(object.guardianSet);
        }
        else {
            message.guardianSet = undefined;
        }
        return message;
    },
};
const baseGuardianSet = { index: 0, addresses: "" };
exports.GuardianSet = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.index !== 0) {
            writer.uint32(8).uint32(message.index);
        }
        for (const v of message.addresses) {
            writer.uint32(18).string(v);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGuardianSet);
        message.addresses = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.index = reader.uint32();
                    break;
                case 2:
                    message.addresses.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGuardianSet);
        message.addresses = [];
        if (object.index !== undefined && object.index !== null) {
            message.index = Number(object.index);
        }
        else {
            message.index = 0;
        }
        if (object.addresses !== undefined && object.addresses !== null) {
            for (const e of object.addresses) {
                message.addresses.push(String(e));
            }
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.index !== undefined && (obj.index = message.index);
        if (message.addresses) {
            obj.addresses = message.addresses.map((e) => e);
        }
        else {
            obj.addresses = [];
        }
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseGuardianSet);
        message.addresses = [];
        if (object.index !== undefined && object.index !== null) {
            message.index = object.index;
        }
        else {
            message.index = 0;
        }
        if (object.addresses !== undefined && object.addresses !== null) {
            for (const e of object.addresses) {
                message.addresses.push(e);
            }
        }
        return message;
    },
};
class PublicRPCServiceClientImpl {
    constructor(rpc) {
        this.rpc = rpc;
        this.GetLastHeartbeats = this.GetLastHeartbeats.bind(this);
        this.GetSignedVAA = this.GetSignedVAA.bind(this);
        this.GetCurrentGuardianSet = this.GetCurrentGuardianSet.bind(this);
    }
    GetLastHeartbeats(request, metadata) {
        return this.rpc.unary(exports.PublicRPCServiceGetLastHeartbeatsDesc, exports.GetLastHeartbeatsRequest.fromPartial(request), metadata);
    }
    GetSignedVAA(request, metadata) {
        return this.rpc.unary(exports.PublicRPCServiceGetSignedVAADesc, exports.GetSignedVAARequest.fromPartial(request), metadata);
    }
    GetCurrentGuardianSet(request, metadata) {
        return this.rpc.unary(exports.PublicRPCServiceGetCurrentGuardianSetDesc, exports.GetCurrentGuardianSetRequest.fromPartial(request), metadata);
    }
}
exports.PublicRPCServiceClientImpl = PublicRPCServiceClientImpl;
exports.PublicRPCServiceDesc = {
    serviceName: "publicrpc.v1.PublicRPCService",
};
exports.PublicRPCServiceGetLastHeartbeatsDesc = {
    methodName: "GetLastHeartbeats",
    service: exports.PublicRPCServiceDesc,
    requestStream: false,
    responseStream: false,
    requestType: {
        serializeBinary() {
            return exports.GetLastHeartbeatsRequest.encode(this).finish();
        },
    },
    responseType: {
        deserializeBinary(data) {
            return Object.assign(Object.assign({}, exports.GetLastHeartbeatsResponse.decode(data)), { toObject() {
                    return this;
                } });
        },
    },
};
exports.PublicRPCServiceGetSignedVAADesc = {
    methodName: "GetSignedVAA",
    service: exports.PublicRPCServiceDesc,
    requestStream: false,
    responseStream: false,
    requestType: {
        serializeBinary() {
            return exports.GetSignedVAARequest.encode(this).finish();
        },
    },
    responseType: {
        deserializeBinary(data) {
            return Object.assign(Object.assign({}, exports.GetSignedVAAResponse.decode(data)), { toObject() {
                    return this;
                } });
        },
    },
};
exports.PublicRPCServiceGetCurrentGuardianSetDesc = {
    methodName: "GetCurrentGuardianSet",
    service: exports.PublicRPCServiceDesc,
    requestStream: false,
    responseStream: false,
    requestType: {
        serializeBinary() {
            return exports.GetCurrentGuardianSetRequest.encode(this).finish();
        },
    },
    responseType: {
        deserializeBinary(data) {
            return Object.assign(Object.assign({}, exports.GetCurrentGuardianSetResponse.decode(data)), { toObject() {
                    return this;
                } });
        },
    },
};
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 browser_headers_1.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_web_1.grpc.unary(methodDesc, {
                request,
                host: this.host,
                metadata: maybeCombinedMetadata,
                transport: this.options.transport,
                debug: this.options.debug,
                onEnd: function (response) {
                    if (response.status === grpc_web_1.grpc.Code.OK) {
                        resolve(response.message);
                    }
                    else {
                        const err = new Error(response.statusMessage);
                        err.code = response.status;
                        err.metadata = response.trailers;
                        reject(err);
                    }
                },
            });
        });
    }
}
exports.GrpcWebImpl = GrpcWebImpl;
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 (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
