/* eslint-disable */ import * as _m0 from "protobufjs/minimal"; import { Timestamp } from "../../../google/protobuf/timestamp"; export const protobufPackage = "decimal.fee.v1"; /** CoinPrice defines the coin price. */ export interface CoinPrice { /** denom defines the base currency (coin) denomination which is priced. */ denom: string; /** quote defines the quote currency denomination in the pair (USD as the first example). */ quote: string; /** price defines the coin price in quote currency. */ price: string; /** updated_at defines the moment of the previous coin price update. */ updatedAt: Date | undefined; } function createBaseCoinPrice(): CoinPrice { return { denom: "", quote: "", price: "", updatedAt: undefined }; } export const CoinPrice = { encode(message: CoinPrice, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.denom !== "") { writer.uint32(10).string(message.denom); } if (message.quote !== "") { writer.uint32(18).string(message.quote); } if (message.price !== "") { writer.uint32(26).string(message.price); } if (message.updatedAt !== undefined) { Timestamp.encode(toTimestamp(message.updatedAt), writer.uint32(34).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): CoinPrice { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseCoinPrice(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.denom = reader.string(); break; case 2: message.quote = reader.string(); break; case 3: message.price = reader.string(); break; case 4: message.updatedAt = fromTimestamp(Timestamp.decode(reader, reader.uint32())); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): CoinPrice { return { denom: isSet(object.denom) ? String(object.denom) : "", quote: isSet(object.quote) ? String(object.quote) : "", price: isSet(object.price) ? String(object.price) : "", updatedAt: isSet(object.updatedAt) ? fromJsonTimestamp(object.updatedAt) : undefined, }; }, toJSON(message: CoinPrice): unknown { const obj: any = {}; message.denom !== undefined && (obj.denom = message.denom); message.quote !== undefined && (obj.quote = message.quote); message.price !== undefined && (obj.price = message.price); message.updatedAt !== undefined && (obj.updatedAt = message.updatedAt.toISOString()); return obj; }, fromPartial, I>>(object: I): CoinPrice { const message = createBaseCoinPrice(); message.denom = object.denom ?? ""; message.quote = object.quote ?? ""; message.price = object.price ?? ""; message.updatedAt = object.updatedAt ?? undefined; return message; }, }; type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { const seconds = date.getTime() / 1_000; const nanos = (date.getTime() % 1_000) * 1_000_000; return { seconds, nanos }; } function fromTimestamp(t: Timestamp): Date { let millis = t.seconds * 1_000; millis += t.nanos / 1_000_000; return new Date(millis); } function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); } } function isSet(value: any): boolean { return value !== null && value !== undefined; }