//@ts-nocheck
import { BinaryReader, BinaryWriter } from '../../../binary.js';
import { isSet } from '../../../helpers.js';
import { decodeBase64 as bytesFromBase64 } from '@endo/base64';
import { encodeBase64 as base64FromBytes } from '@endo/base64';
import {} from '../../../json-safe.js';
function createBaseRemoteTokenMessenger() {
    return {
        domainId: 0,
        address: new Uint8Array(),
    };
}
export const RemoteTokenMessenger = {
    typeUrl: '/circle.cctp.v1.RemoteTokenMessenger',
    encode(message, writer = BinaryWriter.create()) {
        if (message.domainId !== 0) {
            writer.uint32(8).uint32(message.domainId);
        }
        if (message.address.length !== 0) {
            writer.uint32(18).bytes(message.address);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseRemoteTokenMessenger();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.domainId = reader.uint32();
                    break;
                case 2:
                    message.address = reader.bytes();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        return {
            domainId: isSet(object.domainId) ? Number(object.domainId) : 0,
            address: isSet(object.address)
                ? bytesFromBase64(object.address)
                : new Uint8Array(),
        };
    },
    toJSON(message) {
        const obj = {};
        message.domainId !== undefined &&
            (obj.domainId = Math.round(message.domainId));
        message.address !== undefined &&
            (obj.address = base64FromBytes(message.address !== undefined ? message.address : new Uint8Array()));
        return obj;
    },
    fromPartial(object) {
        const message = createBaseRemoteTokenMessenger();
        message.domainId = object.domainId ?? 0;
        message.address = object.address ?? new Uint8Array();
        return message;
    },
    fromProtoMsg(message) {
        return RemoteTokenMessenger.decode(message.value);
    },
    toProto(message) {
        return RemoteTokenMessenger.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/circle.cctp.v1.RemoteTokenMessenger',
            value: RemoteTokenMessenger.encode(message).finish(),
        };
    },
};
//# sourceMappingURL=remote_token_messenger.js.map