diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d8bd3e1..37a6a466 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,9 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## Unreleased +### Features +* Add hash price support for nav values from on chain events [#543](https://github.com/provenance-io/explorer-service/pull/543) + ### Improvements * Add limit of 1 to missing block queries [#544](https://github.com/provenance-io/explorer-service/pull/544) diff --git a/service/src/main/java/io/provlabs/flow/api/NavEvent.java b/service/src/main/java/io/provlabs/flow/api/NavEvent.java new file mode 100644 index 00000000..ac1e0e09 --- /dev/null +++ b/service/src/main/java/io/provlabs/flow/api/NavEvent.java @@ -0,0 +1,1906 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: nav_event.proto + +package io.provlabs.flow.api; + +/** + *
+ * NavEvent represents a Net Asset Value (NAV) event within a block.
+ * 
+ * + * Protobuf type {@code nav.NavEvent} + */ +public final class NavEvent extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:nav.NavEvent) + NavEventOrBuilder { +private static final long serialVersionUID = 0L; + // Use NavEvent.newBuilder() to construct. + private NavEvent(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private NavEvent() { + txHash_ = ""; + eventType_ = ""; + scopeId_ = ""; + denom_ = ""; + priceDenom_ = ""; + source_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new NavEvent(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private NavEvent( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + blockHeight_ = input.readInt32(); + break; + } + case 16: { + + blockTime_ = input.readUInt64(); + break; + } + case 24: { + + chainId_ = input.readInt32(); + break; + } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); + + txHash_ = s; + break; + } + case 40: { + + eventOrder_ = input.readInt32(); + break; + } + case 50: { + java.lang.String s = input.readStringRequireUtf8(); + + eventType_ = s; + break; + } + case 58: { + java.lang.String s = input.readStringRequireUtf8(); + + scopeId_ = s; + break; + } + case 66: { + java.lang.String s = input.readStringRequireUtf8(); + + denom_ = s; + break; + } + case 72: { + + priceAmount_ = input.readInt64(); + break; + } + case 82: { + java.lang.String s = input.readStringRequireUtf8(); + + priceDenom_ = s; + break; + } + case 88: { + + volume_ = input.readInt64(); + break; + } + case 98: { + java.lang.String s = input.readStringRequireUtf8(); + + source_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_NavEvent_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_NavEvent_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.provlabs.flow.api.NavEvent.class, io.provlabs.flow.api.NavEvent.Builder.class); + } + + public static final int BLOCK_HEIGHT_FIELD_NUMBER = 1; + private int blockHeight_; + /** + *
+   * The block height where this Nav event occurred.
+   * 
+ * + * int32 block_height = 1; + * @return The blockHeight. + */ + @java.lang.Override + public int getBlockHeight() { + return blockHeight_; + } + + public static final int BLOCK_TIME_FIELD_NUMBER = 2; + private long blockTime_; + /** + *
+   * The block time in UNIX epoch format when the Nav event occurred.
+   * 
+ * + * uint64 block_time = 2; + * @return The blockTime. + */ + @java.lang.Override + public long getBlockTime() { + return blockTime_; + } + + public static final int CHAIN_ID_FIELD_NUMBER = 3; + private int chainId_; + /** + *
+   * The unique chain ID representing the blockchain where this NAV event occurred.
+   * 
+ * + * int32 chain_id = 3; + * @return The chainId. + */ + @java.lang.Override + public int getChainId() { + return chainId_; + } + + public static final int TX_HASH_FIELD_NUMBER = 4; + private volatile java.lang.Object txHash_; + /** + *
+   * The tx hash related to this NAV event.
+   * 
+ * + * string tx_hash = 4; + * @return The txHash. + */ + @java.lang.Override + public java.lang.String getTxHash() { + java.lang.Object ref = txHash_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + txHash_ = s; + return s; + } + } + /** + *
+   * The tx hash related to this NAV event.
+   * 
+ * + * string tx_hash = 4; + * @return The bytes for txHash. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getTxHashBytes() { + java.lang.Object ref = txHash_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + txHash_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int EVENT_ORDER_FIELD_NUMBER = 5; + private int eventOrder_; + /** + *
+   * The order in which this event was emitted within the block_height and tx_hash.
+   * 
+ * + * int32 event_order = 5; + * @return The eventOrder. + */ + @java.lang.Override + public int getEventOrder() { + return eventOrder_; + } + + public static final int EVENT_TYPE_FIELD_NUMBER = 6; + private volatile java.lang.Object eventType_; + /** + *
+   * The type of Nav event type.
+   * 
+ * + * string event_type = 6; + * @return The eventType. + */ + @java.lang.Override + public java.lang.String getEventType() { + java.lang.Object ref = eventType_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + eventType_ = s; + return s; + } + } + /** + *
+   * The type of Nav event type.
+   * 
+ * + * string event_type = 6; + * @return The bytes for eventType. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getEventTypeBytes() { + java.lang.Object ref = eventType_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + eventType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SCOPE_ID_FIELD_NUMBER = 7; + private volatile java.lang.Object scopeId_; + /** + *
+   * The scope ID associated with this Nav.
+   * 
+ * + * string scope_id = 7; + * @return The scopeId. + */ + @java.lang.Override + public java.lang.String getScopeId() { + java.lang.Object ref = scopeId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + scopeId_ = s; + return s; + } + } + /** + *
+   * The scope ID associated with this Nav.
+   * 
+ * + * string scope_id = 7; + * @return The bytes for scopeId. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getScopeIdBytes() { + java.lang.Object ref = scopeId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + scopeId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DENOM_FIELD_NUMBER = 8; + private volatile java.lang.Object denom_; + /** + *
+   * The token denomination for the Nav.
+   * 
+ * + * string denom = 8; + * @return The denom. + */ + @java.lang.Override + public java.lang.String getDenom() { + java.lang.Object ref = denom_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + denom_ = s; + return s; + } + } + /** + *
+   * The token denomination for the Nav.
+   * 
+ * + * string denom = 8; + * @return The bytes for denom. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getDenomBytes() { + java.lang.Object ref = denom_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + denom_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PRICE_AMOUNT_FIELD_NUMBER = 9; + private long priceAmount_; + /** + *
+   * The price amount for the NAV.
+   * 
+ * + * int64 price_amount = 9; + * @return The priceAmount. + */ + @java.lang.Override + public long getPriceAmount() { + return priceAmount_; + } + + public static final int PRICE_DENOM_FIELD_NUMBER = 10; + private volatile java.lang.Object priceDenom_; + /** + *
+   * The denomination of the price.
+   * 
+ * + * string price_denom = 10; + * @return The priceDenom. + */ + @java.lang.Override + public java.lang.String getPriceDenom() { + java.lang.Object ref = priceDenom_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + priceDenom_ = s; + return s; + } + } + /** + *
+   * The denomination of the price.
+   * 
+ * + * string price_denom = 10; + * @return The bytes for priceDenom. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getPriceDenomBytes() { + java.lang.Object ref = priceDenom_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + priceDenom_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int VOLUME_FIELD_NUMBER = 11; + private long volume_; + /** + *
+   * The volume of tokens involved in the Nav event.
+   * 
+ * + * int64 volume = 11; + * @return The volume. + */ + @java.lang.Override + public long getVolume() { + return volume_; + } + + public static final int SOURCE_FIELD_NUMBER = 12; + private volatile java.lang.Object source_; + /** + *
+   * The source of the NAV event.
+   * 
+ * + * string source = 12; + * @return The source. + */ + @java.lang.Override + public java.lang.String getSource() { + java.lang.Object ref = source_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + source_ = s; + return s; + } + } + /** + *
+   * The source of the NAV event.
+   * 
+ * + * string source = 12; + * @return The bytes for source. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getSourceBytes() { + java.lang.Object ref = source_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + source_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (blockHeight_ != 0) { + output.writeInt32(1, blockHeight_); + } + if (blockTime_ != 0L) { + output.writeUInt64(2, blockTime_); + } + if (chainId_ != 0) { + output.writeInt32(3, chainId_); + } + if (!getTxHashBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, txHash_); + } + if (eventOrder_ != 0) { + output.writeInt32(5, eventOrder_); + } + if (!getEventTypeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, eventType_); + } + if (!getScopeIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 7, scopeId_); + } + if (!getDenomBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, denom_); + } + if (priceAmount_ != 0L) { + output.writeInt64(9, priceAmount_); + } + if (!getPriceDenomBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 10, priceDenom_); + } + if (volume_ != 0L) { + output.writeInt64(11, volume_); + } + if (!getSourceBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 12, source_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (blockHeight_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, blockHeight_); + } + if (blockTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(2, blockTime_); + } + if (chainId_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, chainId_); + } + if (!getTxHashBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, txHash_); + } + if (eventOrder_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(5, eventOrder_); + } + if (!getEventTypeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, eventType_); + } + if (!getScopeIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, scopeId_); + } + if (!getDenomBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, denom_); + } + if (priceAmount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(9, priceAmount_); + } + if (!getPriceDenomBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(10, priceDenom_); + } + if (volume_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(11, volume_); + } + if (!getSourceBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(12, source_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof io.provlabs.flow.api.NavEvent)) { + return super.equals(obj); + } + io.provlabs.flow.api.NavEvent other = (io.provlabs.flow.api.NavEvent) obj; + + if (getBlockHeight() + != other.getBlockHeight()) return false; + if (getBlockTime() + != other.getBlockTime()) return false; + if (getChainId() + != other.getChainId()) return false; + if (!getTxHash() + .equals(other.getTxHash())) return false; + if (getEventOrder() + != other.getEventOrder()) return false; + if (!getEventType() + .equals(other.getEventType())) return false; + if (!getScopeId() + .equals(other.getScopeId())) return false; + if (!getDenom() + .equals(other.getDenom())) return false; + if (getPriceAmount() + != other.getPriceAmount()) return false; + if (!getPriceDenom() + .equals(other.getPriceDenom())) return false; + if (getVolume() + != other.getVolume()) return false; + if (!getSource() + .equals(other.getSource())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + BLOCK_HEIGHT_FIELD_NUMBER; + hash = (53 * hash) + getBlockHeight(); + hash = (37 * hash) + BLOCK_TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getBlockTime()); + hash = (37 * hash) + CHAIN_ID_FIELD_NUMBER; + hash = (53 * hash) + getChainId(); + hash = (37 * hash) + TX_HASH_FIELD_NUMBER; + hash = (53 * hash) + getTxHash().hashCode(); + hash = (37 * hash) + EVENT_ORDER_FIELD_NUMBER; + hash = (53 * hash) + getEventOrder(); + hash = (37 * hash) + EVENT_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getEventType().hashCode(); + hash = (37 * hash) + SCOPE_ID_FIELD_NUMBER; + hash = (53 * hash) + getScopeId().hashCode(); + hash = (37 * hash) + DENOM_FIELD_NUMBER; + hash = (53 * hash) + getDenom().hashCode(); + hash = (37 * hash) + PRICE_AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getPriceAmount()); + hash = (37 * hash) + PRICE_DENOM_FIELD_NUMBER; + hash = (53 * hash) + getPriceDenom().hashCode(); + hash = (37 * hash) + VOLUME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getVolume()); + hash = (37 * hash) + SOURCE_FIELD_NUMBER; + hash = (53 * hash) + getSource().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static io.provlabs.flow.api.NavEvent parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.provlabs.flow.api.NavEvent parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.provlabs.flow.api.NavEvent parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.provlabs.flow.api.NavEvent parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.provlabs.flow.api.NavEvent parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.provlabs.flow.api.NavEvent parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.provlabs.flow.api.NavEvent parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.provlabs.flow.api.NavEvent parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static io.provlabs.flow.api.NavEvent parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static io.provlabs.flow.api.NavEvent parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static io.provlabs.flow.api.NavEvent parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.provlabs.flow.api.NavEvent parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(io.provlabs.flow.api.NavEvent prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+   * NavEvent represents a Net Asset Value (NAV) event within a block.
+   * 
+ * + * Protobuf type {@code nav.NavEvent} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:nav.NavEvent) + io.provlabs.flow.api.NavEventOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_NavEvent_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_NavEvent_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.provlabs.flow.api.NavEvent.class, io.provlabs.flow.api.NavEvent.Builder.class); + } + + // Construct using io.provlabs.flow.api.NavEvent.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + blockHeight_ = 0; + + blockTime_ = 0L; + + chainId_ = 0; + + txHash_ = ""; + + eventOrder_ = 0; + + eventType_ = ""; + + scopeId_ = ""; + + denom_ = ""; + + priceAmount_ = 0L; + + priceDenom_ = ""; + + volume_ = 0L; + + source_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_NavEvent_descriptor; + } + + @java.lang.Override + public io.provlabs.flow.api.NavEvent getDefaultInstanceForType() { + return io.provlabs.flow.api.NavEvent.getDefaultInstance(); + } + + @java.lang.Override + public io.provlabs.flow.api.NavEvent build() { + io.provlabs.flow.api.NavEvent result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public io.provlabs.flow.api.NavEvent buildPartial() { + io.provlabs.flow.api.NavEvent result = new io.provlabs.flow.api.NavEvent(this); + result.blockHeight_ = blockHeight_; + result.blockTime_ = blockTime_; + result.chainId_ = chainId_; + result.txHash_ = txHash_; + result.eventOrder_ = eventOrder_; + result.eventType_ = eventType_; + result.scopeId_ = scopeId_; + result.denom_ = denom_; + result.priceAmount_ = priceAmount_; + result.priceDenom_ = priceDenom_; + result.volume_ = volume_; + result.source_ = source_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof io.provlabs.flow.api.NavEvent) { + return mergeFrom((io.provlabs.flow.api.NavEvent)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.provlabs.flow.api.NavEvent other) { + if (other == io.provlabs.flow.api.NavEvent.getDefaultInstance()) return this; + if (other.getBlockHeight() != 0) { + setBlockHeight(other.getBlockHeight()); + } + if (other.getBlockTime() != 0L) { + setBlockTime(other.getBlockTime()); + } + if (other.getChainId() != 0) { + setChainId(other.getChainId()); + } + if (!other.getTxHash().isEmpty()) { + txHash_ = other.txHash_; + onChanged(); + } + if (other.getEventOrder() != 0) { + setEventOrder(other.getEventOrder()); + } + if (!other.getEventType().isEmpty()) { + eventType_ = other.eventType_; + onChanged(); + } + if (!other.getScopeId().isEmpty()) { + scopeId_ = other.scopeId_; + onChanged(); + } + if (!other.getDenom().isEmpty()) { + denom_ = other.denom_; + onChanged(); + } + if (other.getPriceAmount() != 0L) { + setPriceAmount(other.getPriceAmount()); + } + if (!other.getPriceDenom().isEmpty()) { + priceDenom_ = other.priceDenom_; + onChanged(); + } + if (other.getVolume() != 0L) { + setVolume(other.getVolume()); + } + if (!other.getSource().isEmpty()) { + source_ = other.source_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + io.provlabs.flow.api.NavEvent parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.provlabs.flow.api.NavEvent) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int blockHeight_ ; + /** + *
+     * The block height where this Nav event occurred.
+     * 
+ * + * int32 block_height = 1; + * @return The blockHeight. + */ + @java.lang.Override + public int getBlockHeight() { + return blockHeight_; + } + /** + *
+     * The block height where this Nav event occurred.
+     * 
+ * + * int32 block_height = 1; + * @param value The blockHeight to set. + * @return This builder for chaining. + */ + public Builder setBlockHeight(int value) { + + blockHeight_ = value; + onChanged(); + return this; + } + /** + *
+     * The block height where this Nav event occurred.
+     * 
+ * + * int32 block_height = 1; + * @return This builder for chaining. + */ + public Builder clearBlockHeight() { + + blockHeight_ = 0; + onChanged(); + return this; + } + + private long blockTime_ ; + /** + *
+     * The block time in UNIX epoch format when the Nav event occurred.
+     * 
+ * + * uint64 block_time = 2; + * @return The blockTime. + */ + @java.lang.Override + public long getBlockTime() { + return blockTime_; + } + /** + *
+     * The block time in UNIX epoch format when the Nav event occurred.
+     * 
+ * + * uint64 block_time = 2; + * @param value The blockTime to set. + * @return This builder for chaining. + */ + public Builder setBlockTime(long value) { + + blockTime_ = value; + onChanged(); + return this; + } + /** + *
+     * The block time in UNIX epoch format when the Nav event occurred.
+     * 
+ * + * uint64 block_time = 2; + * @return This builder for chaining. + */ + public Builder clearBlockTime() { + + blockTime_ = 0L; + onChanged(); + return this; + } + + private int chainId_ ; + /** + *
+     * The unique chain ID representing the blockchain where this NAV event occurred.
+     * 
+ * + * int32 chain_id = 3; + * @return The chainId. + */ + @java.lang.Override + public int getChainId() { + return chainId_; + } + /** + *
+     * The unique chain ID representing the blockchain where this NAV event occurred.
+     * 
+ * + * int32 chain_id = 3; + * @param value The chainId to set. + * @return This builder for chaining. + */ + public Builder setChainId(int value) { + + chainId_ = value; + onChanged(); + return this; + } + /** + *
+     * The unique chain ID representing the blockchain where this NAV event occurred.
+     * 
+ * + * int32 chain_id = 3; + * @return This builder for chaining. + */ + public Builder clearChainId() { + + chainId_ = 0; + onChanged(); + return this; + } + + private java.lang.Object txHash_ = ""; + /** + *
+     * The tx hash related to this NAV event.
+     * 
+ * + * string tx_hash = 4; + * @return The txHash. + */ + public java.lang.String getTxHash() { + java.lang.Object ref = txHash_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + txHash_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+     * The tx hash related to this NAV event.
+     * 
+ * + * string tx_hash = 4; + * @return The bytes for txHash. + */ + public com.google.protobuf.ByteString + getTxHashBytes() { + java.lang.Object ref = txHash_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + txHash_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+     * The tx hash related to this NAV event.
+     * 
+ * + * string tx_hash = 4; + * @param value The txHash to set. + * @return This builder for chaining. + */ + public Builder setTxHash( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + txHash_ = value; + onChanged(); + return this; + } + /** + *
+     * The tx hash related to this NAV event.
+     * 
+ * + * string tx_hash = 4; + * @return This builder for chaining. + */ + public Builder clearTxHash() { + + txHash_ = getDefaultInstance().getTxHash(); + onChanged(); + return this; + } + /** + *
+     * The tx hash related to this NAV event.
+     * 
+ * + * string tx_hash = 4; + * @param value The bytes for txHash to set. + * @return This builder for chaining. + */ + public Builder setTxHashBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + txHash_ = value; + onChanged(); + return this; + } + + private int eventOrder_ ; + /** + *
+     * The order in which this event was emitted within the block_height and tx_hash.
+     * 
+ * + * int32 event_order = 5; + * @return The eventOrder. + */ + @java.lang.Override + public int getEventOrder() { + return eventOrder_; + } + /** + *
+     * The order in which this event was emitted within the block_height and tx_hash.
+     * 
+ * + * int32 event_order = 5; + * @param value The eventOrder to set. + * @return This builder for chaining. + */ + public Builder setEventOrder(int value) { + + eventOrder_ = value; + onChanged(); + return this; + } + /** + *
+     * The order in which this event was emitted within the block_height and tx_hash.
+     * 
+ * + * int32 event_order = 5; + * @return This builder for chaining. + */ + public Builder clearEventOrder() { + + eventOrder_ = 0; + onChanged(); + return this; + } + + private java.lang.Object eventType_ = ""; + /** + *
+     * The type of Nav event type.
+     * 
+ * + * string event_type = 6; + * @return The eventType. + */ + public java.lang.String getEventType() { + java.lang.Object ref = eventType_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + eventType_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+     * The type of Nav event type.
+     * 
+ * + * string event_type = 6; + * @return The bytes for eventType. + */ + public com.google.protobuf.ByteString + getEventTypeBytes() { + java.lang.Object ref = eventType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + eventType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+     * The type of Nav event type.
+     * 
+ * + * string event_type = 6; + * @param value The eventType to set. + * @return This builder for chaining. + */ + public Builder setEventType( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + eventType_ = value; + onChanged(); + return this; + } + /** + *
+     * The type of Nav event type.
+     * 
+ * + * string event_type = 6; + * @return This builder for chaining. + */ + public Builder clearEventType() { + + eventType_ = getDefaultInstance().getEventType(); + onChanged(); + return this; + } + /** + *
+     * The type of Nav event type.
+     * 
+ * + * string event_type = 6; + * @param value The bytes for eventType to set. + * @return This builder for chaining. + */ + public Builder setEventTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + eventType_ = value; + onChanged(); + return this; + } + + private java.lang.Object scopeId_ = ""; + /** + *
+     * The scope ID associated with this Nav.
+     * 
+ * + * string scope_id = 7; + * @return The scopeId. + */ + public java.lang.String getScopeId() { + java.lang.Object ref = scopeId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + scopeId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+     * The scope ID associated with this Nav.
+     * 
+ * + * string scope_id = 7; + * @return The bytes for scopeId. + */ + public com.google.protobuf.ByteString + getScopeIdBytes() { + java.lang.Object ref = scopeId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + scopeId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+     * The scope ID associated with this Nav.
+     * 
+ * + * string scope_id = 7; + * @param value The scopeId to set. + * @return This builder for chaining. + */ + public Builder setScopeId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + scopeId_ = value; + onChanged(); + return this; + } + /** + *
+     * The scope ID associated with this Nav.
+     * 
+ * + * string scope_id = 7; + * @return This builder for chaining. + */ + public Builder clearScopeId() { + + scopeId_ = getDefaultInstance().getScopeId(); + onChanged(); + return this; + } + /** + *
+     * The scope ID associated with this Nav.
+     * 
+ * + * string scope_id = 7; + * @param value The bytes for scopeId to set. + * @return This builder for chaining. + */ + public Builder setScopeIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + scopeId_ = value; + onChanged(); + return this; + } + + private java.lang.Object denom_ = ""; + /** + *
+     * The token denomination for the Nav.
+     * 
+ * + * string denom = 8; + * @return The denom. + */ + public java.lang.String getDenom() { + java.lang.Object ref = denom_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + denom_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+     * The token denomination for the Nav.
+     * 
+ * + * string denom = 8; + * @return The bytes for denom. + */ + public com.google.protobuf.ByteString + getDenomBytes() { + java.lang.Object ref = denom_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + denom_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+     * The token denomination for the Nav.
+     * 
+ * + * string denom = 8; + * @param value The denom to set. + * @return This builder for chaining. + */ + public Builder setDenom( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + denom_ = value; + onChanged(); + return this; + } + /** + *
+     * The token denomination for the Nav.
+     * 
+ * + * string denom = 8; + * @return This builder for chaining. + */ + public Builder clearDenom() { + + denom_ = getDefaultInstance().getDenom(); + onChanged(); + return this; + } + /** + *
+     * The token denomination for the Nav.
+     * 
+ * + * string denom = 8; + * @param value The bytes for denom to set. + * @return This builder for chaining. + */ + public Builder setDenomBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + denom_ = value; + onChanged(); + return this; + } + + private long priceAmount_ ; + /** + *
+     * The price amount for the NAV.
+     * 
+ * + * int64 price_amount = 9; + * @return The priceAmount. + */ + @java.lang.Override + public long getPriceAmount() { + return priceAmount_; + } + /** + *
+     * The price amount for the NAV.
+     * 
+ * + * int64 price_amount = 9; + * @param value The priceAmount to set. + * @return This builder for chaining. + */ + public Builder setPriceAmount(long value) { + + priceAmount_ = value; + onChanged(); + return this; + } + /** + *
+     * The price amount for the NAV.
+     * 
+ * + * int64 price_amount = 9; + * @return This builder for chaining. + */ + public Builder clearPriceAmount() { + + priceAmount_ = 0L; + onChanged(); + return this; + } + + private java.lang.Object priceDenom_ = ""; + /** + *
+     * The denomination of the price.
+     * 
+ * + * string price_denom = 10; + * @return The priceDenom. + */ + public java.lang.String getPriceDenom() { + java.lang.Object ref = priceDenom_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + priceDenom_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+     * The denomination of the price.
+     * 
+ * + * string price_denom = 10; + * @return The bytes for priceDenom. + */ + public com.google.protobuf.ByteString + getPriceDenomBytes() { + java.lang.Object ref = priceDenom_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + priceDenom_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+     * The denomination of the price.
+     * 
+ * + * string price_denom = 10; + * @param value The priceDenom to set. + * @return This builder for chaining. + */ + public Builder setPriceDenom( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + priceDenom_ = value; + onChanged(); + return this; + } + /** + *
+     * The denomination of the price.
+     * 
+ * + * string price_denom = 10; + * @return This builder for chaining. + */ + public Builder clearPriceDenom() { + + priceDenom_ = getDefaultInstance().getPriceDenom(); + onChanged(); + return this; + } + /** + *
+     * The denomination of the price.
+     * 
+ * + * string price_denom = 10; + * @param value The bytes for priceDenom to set. + * @return This builder for chaining. + */ + public Builder setPriceDenomBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + priceDenom_ = value; + onChanged(); + return this; + } + + private long volume_ ; + /** + *
+     * The volume of tokens involved in the Nav event.
+     * 
+ * + * int64 volume = 11; + * @return The volume. + */ + @java.lang.Override + public long getVolume() { + return volume_; + } + /** + *
+     * The volume of tokens involved in the Nav event.
+     * 
+ * + * int64 volume = 11; + * @param value The volume to set. + * @return This builder for chaining. + */ + public Builder setVolume(long value) { + + volume_ = value; + onChanged(); + return this; + } + /** + *
+     * The volume of tokens involved in the Nav event.
+     * 
+ * + * int64 volume = 11; + * @return This builder for chaining. + */ + public Builder clearVolume() { + + volume_ = 0L; + onChanged(); + return this; + } + + private java.lang.Object source_ = ""; + /** + *
+     * The source of the NAV event.
+     * 
+ * + * string source = 12; + * @return The source. + */ + public java.lang.String getSource() { + java.lang.Object ref = source_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + source_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+     * The source of the NAV event.
+     * 
+ * + * string source = 12; + * @return The bytes for source. + */ + public com.google.protobuf.ByteString + getSourceBytes() { + java.lang.Object ref = source_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + source_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+     * The source of the NAV event.
+     * 
+ * + * string source = 12; + * @param value The source to set. + * @return This builder for chaining. + */ + public Builder setSource( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + source_ = value; + onChanged(); + return this; + } + /** + *
+     * The source of the NAV event.
+     * 
+ * + * string source = 12; + * @return This builder for chaining. + */ + public Builder clearSource() { + + source_ = getDefaultInstance().getSource(); + onChanged(); + return this; + } + /** + *
+     * The source of the NAV event.
+     * 
+ * + * string source = 12; + * @param value The bytes for source to set. + * @return This builder for chaining. + */ + public Builder setSourceBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + source_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:nav.NavEvent) + } + + // @@protoc_insertion_point(class_scope:nav.NavEvent) + private static final io.provlabs.flow.api.NavEvent DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new io.provlabs.flow.api.NavEvent(); + } + + public static io.provlabs.flow.api.NavEvent getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public NavEvent parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new NavEvent(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public io.provlabs.flow.api.NavEvent getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/service/src/main/java/io/provlabs/flow/api/NavEventOrBuilder.java b/service/src/main/java/io/provlabs/flow/api/NavEventOrBuilder.java new file mode 100644 index 00000000..634778c0 --- /dev/null +++ b/service/src/main/java/io/provlabs/flow/api/NavEventOrBuilder.java @@ -0,0 +1,189 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: nav_event.proto + +package io.provlabs.flow.api; + +public interface NavEventOrBuilder extends + // @@protoc_insertion_point(interface_extends:nav.NavEvent) + com.google.protobuf.MessageOrBuilder { + + /** + *
+   * The block height where this Nav event occurred.
+   * 
+ * + * int32 block_height = 1; + * @return The blockHeight. + */ + int getBlockHeight(); + + /** + *
+   * The block time in UNIX epoch format when the Nav event occurred.
+   * 
+ * + * uint64 block_time = 2; + * @return The blockTime. + */ + long getBlockTime(); + + /** + *
+   * The unique chain ID representing the blockchain where this NAV event occurred.
+   * 
+ * + * int32 chain_id = 3; + * @return The chainId. + */ + int getChainId(); + + /** + *
+   * The tx hash related to this NAV event.
+   * 
+ * + * string tx_hash = 4; + * @return The txHash. + */ + java.lang.String getTxHash(); + /** + *
+   * The tx hash related to this NAV event.
+   * 
+ * + * string tx_hash = 4; + * @return The bytes for txHash. + */ + com.google.protobuf.ByteString + getTxHashBytes(); + + /** + *
+   * The order in which this event was emitted within the block_height and tx_hash.
+   * 
+ * + * int32 event_order = 5; + * @return The eventOrder. + */ + int getEventOrder(); + + /** + *
+   * The type of Nav event type.
+   * 
+ * + * string event_type = 6; + * @return The eventType. + */ + java.lang.String getEventType(); + /** + *
+   * The type of Nav event type.
+   * 
+ * + * string event_type = 6; + * @return The bytes for eventType. + */ + com.google.protobuf.ByteString + getEventTypeBytes(); + + /** + *
+   * The scope ID associated with this Nav.
+   * 
+ * + * string scope_id = 7; + * @return The scopeId. + */ + java.lang.String getScopeId(); + /** + *
+   * The scope ID associated with this Nav.
+   * 
+ * + * string scope_id = 7; + * @return The bytes for scopeId. + */ + com.google.protobuf.ByteString + getScopeIdBytes(); + + /** + *
+   * The token denomination for the Nav.
+   * 
+ * + * string denom = 8; + * @return The denom. + */ + java.lang.String getDenom(); + /** + *
+   * The token denomination for the Nav.
+   * 
+ * + * string denom = 8; + * @return The bytes for denom. + */ + com.google.protobuf.ByteString + getDenomBytes(); + + /** + *
+   * The price amount for the NAV.
+   * 
+ * + * int64 price_amount = 9; + * @return The priceAmount. + */ + long getPriceAmount(); + + /** + *
+   * The denomination of the price.
+   * 
+ * + * string price_denom = 10; + * @return The priceDenom. + */ + java.lang.String getPriceDenom(); + /** + *
+   * The denomination of the price.
+   * 
+ * + * string price_denom = 10; + * @return The bytes for priceDenom. + */ + com.google.protobuf.ByteString + getPriceDenomBytes(); + + /** + *
+   * The volume of tokens involved in the Nav event.
+   * 
+ * + * int64 volume = 11; + * @return The volume. + */ + long getVolume(); + + /** + *
+   * The source of the NAV event.
+   * 
+ * + * string source = 12; + * @return The source. + */ + java.lang.String getSource(); + /** + *
+   * The source of the NAV event.
+   * 
+ * + * string source = 12; + * @return The bytes for source. + */ + com.google.protobuf.ByteString + getSourceBytes(); +} diff --git a/service/src/main/java/io/provlabs/flow/api/NavEventOuterClass.java b/service/src/main/java/io/provlabs/flow/api/NavEventOuterClass.java new file mode 100644 index 00000000..7dafd981 --- /dev/null +++ b/service/src/main/java/io/provlabs/flow/api/NavEventOuterClass.java @@ -0,0 +1,81 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: nav_event.proto + +package io.provlabs.flow.api; + +public final class NavEventOuterClass { + private NavEventOuterClass() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + static final com.google.protobuf.Descriptors.Descriptor + internal_static_nav_NavEvent_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_nav_NavEvent_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_nav_NavEventRequest_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_nav_NavEventRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_nav_NavEventResponse_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_nav_NavEventResponse_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\017nav_event.proto\022\003nav\"\354\001\n\010NavEvent\022\024\n\014b" + + "lock_height\030\001 \001(\005\022\022\n\nblock_time\030\002 \001(\004\022\020\n" + + "\010chain_id\030\003 \001(\005\022\017\n\007tx_hash\030\004 \001(\t\022\023\n\013even" + + "t_order\030\005 \001(\005\022\022\n\nevent_type\030\006 \001(\t\022\020\n\010sco" + + "pe_id\030\007 \001(\t\022\r\n\005denom\030\010 \001(\t\022\024\n\014price_amou" + + "nt\030\t \001(\003\022\023\n\013price_denom\030\n \001(\t\022\016\n\006volume\030" + + "\013 \001(\003\022\016\n\006source\030\014 \001(\t\"{\n\017NavEventRequest" + + "\022\r\n\005denom\030\001 \001(\t\022\020\n\010scope_id\030\002 \001(\t\022\024\n\014pri" + + "ce_denoms\030\003 \003(\t\022\021\n\tfrom_date\030\004 \001(\t\022\017\n\007to" + + "_date\030\005 \001(\t\022\r\n\005limit\030\006 \001(\005\"5\n\020NavEventRe" + + "sponse\022!\n\nnav_events\030\001 \003(\0132\r.nav.NavEven" + + "t2I\n\nNavService\022;\n\014GetNavEvents\022\024.nav.Na" + + "vEventRequest\032\025.nav.NavEventResponseB \n\024" + + "io.provlabs.flow.apiP\001Z\006/typesb\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }); + internal_static_nav_NavEvent_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_nav_NavEvent_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_nav_NavEvent_descriptor, + new java.lang.String[] { "BlockHeight", "BlockTime", "ChainId", "TxHash", "EventOrder", "EventType", "ScopeId", "Denom", "PriceAmount", "PriceDenom", "Volume", "Source", }); + internal_static_nav_NavEventRequest_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_nav_NavEventRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_nav_NavEventRequest_descriptor, + new java.lang.String[] { "Denom", "ScopeId", "PriceDenoms", "FromDate", "ToDate", "Limit", }); + internal_static_nav_NavEventResponse_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_nav_NavEventResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_nav_NavEventResponse_descriptor, + new java.lang.String[] { "NavEvents", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/service/src/main/java/io/provlabs/flow/api/NavEventRequest.java b/service/src/main/java/io/provlabs/flow/api/NavEventRequest.java new file mode 100644 index 00000000..aefc6493 --- /dev/null +++ b/service/src/main/java/io/provlabs/flow/api/NavEventRequest.java @@ -0,0 +1,1420 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: nav_event.proto + +package io.provlabs.flow.api; + +/** + *
+ * NavEventRequest represents a request for NavEvents by either `denom` or `scope_id`.
+ * One of `denom` or `scope_id` must be provided; the other fields are optional.
+ * 
+ * + * Protobuf type {@code nav.NavEventRequest} + */ +public final class NavEventRequest extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:nav.NavEventRequest) + NavEventRequestOrBuilder { +private static final long serialVersionUID = 0L; + // Use NavEventRequest.newBuilder() to construct. + private NavEventRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private NavEventRequest() { + denom_ = ""; + scopeId_ = ""; + priceDenoms_ = com.google.protobuf.LazyStringArrayList.EMPTY; + fromDate_ = ""; + toDate_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new NavEventRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private NavEventRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + denom_ = s; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + scopeId_ = s; + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + priceDenoms_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + priceDenoms_.add(s); + break; + } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); + + fromDate_ = s; + break; + } + case 42: { + java.lang.String s = input.readStringRequireUtf8(); + + toDate_ = s; + break; + } + case 48: { + + limit_ = input.readInt32(); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + priceDenoms_ = priceDenoms_.getUnmodifiableView(); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_NavEventRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_NavEventRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.provlabs.flow.api.NavEventRequest.class, io.provlabs.flow.api.NavEventRequest.Builder.class); + } + + public static final int DENOM_FIELD_NUMBER = 1; + private volatile java.lang.Object denom_; + /** + *
+   * The token denomination to filter events by. Either `denom` or `scope_id` is required.
+   * 
+ * + * string denom = 1; + * @return The denom. + */ + @java.lang.Override + public java.lang.String getDenom() { + java.lang.Object ref = denom_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + denom_ = s; + return s; + } + } + /** + *
+   * The token denomination to filter events by. Either `denom` or `scope_id` is required.
+   * 
+ * + * string denom = 1; + * @return The bytes for denom. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getDenomBytes() { + java.lang.Object ref = denom_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + denom_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SCOPE_ID_FIELD_NUMBER = 2; + private volatile java.lang.Object scopeId_; + /** + *
+   * The scope ID to filter events by. Either `denom` or `scope_id` is required.
+   * 
+ * + * string scope_id = 2; + * @return The scopeId. + */ + @java.lang.Override + public java.lang.String getScopeId() { + java.lang.Object ref = scopeId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + scopeId_ = s; + return s; + } + } + /** + *
+   * The scope ID to filter events by. Either `denom` or `scope_id` is required.
+   * 
+ * + * string scope_id = 2; + * @return The bytes for scopeId. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getScopeIdBytes() { + java.lang.Object ref = scopeId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + scopeId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PRICE_DENOMS_FIELD_NUMBER = 3; + private com.google.protobuf.LazyStringList priceDenoms_; + /** + *
+   * Optional. A list of price denominations to filter by.
+   * 
+ * + * repeated string price_denoms = 3; + * @return A list containing the priceDenoms. + */ + public com.google.protobuf.ProtocolStringList + getPriceDenomsList() { + return priceDenoms_; + } + /** + *
+   * Optional. A list of price denominations to filter by.
+   * 
+ * + * repeated string price_denoms = 3; + * @return The count of priceDenoms. + */ + public int getPriceDenomsCount() { + return priceDenoms_.size(); + } + /** + *
+   * Optional. A list of price denominations to filter by.
+   * 
+ * + * repeated string price_denoms = 3; + * @param index The index of the element to return. + * @return The priceDenoms at the given index. + */ + public java.lang.String getPriceDenoms(int index) { + return priceDenoms_.get(index); + } + /** + *
+   * Optional. A list of price denominations to filter by.
+   * 
+ * + * repeated string price_denoms = 3; + * @param index The index of the value to return. + * @return The bytes of the priceDenoms at the given index. + */ + public com.google.protobuf.ByteString + getPriceDenomsBytes(int index) { + return priceDenoms_.getByteString(index); + } + + public static final int FROM_DATE_FIELD_NUMBER = 4; + private volatile java.lang.Object fromDate_; + /** + *
+   * Optional. The start date (in string format) to filter events.
+   * 
+ * + * string from_date = 4; + * @return The fromDate. + */ + @java.lang.Override + public java.lang.String getFromDate() { + java.lang.Object ref = fromDate_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + fromDate_ = s; + return s; + } + } + /** + *
+   * Optional. The start date (in string format) to filter events.
+   * 
+ * + * string from_date = 4; + * @return The bytes for fromDate. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getFromDateBytes() { + java.lang.Object ref = fromDate_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + fromDate_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TO_DATE_FIELD_NUMBER = 5; + private volatile java.lang.Object toDate_; + /** + *
+   * Optional. The end date (in string format) to filter events.
+   * 
+ * + * string to_date = 5; + * @return The toDate. + */ + @java.lang.Override + public java.lang.String getToDate() { + java.lang.Object ref = toDate_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + toDate_ = s; + return s; + } + } + /** + *
+   * Optional. The end date (in string format) to filter events.
+   * 
+ * + * string to_date = 5; + * @return The bytes for toDate. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getToDateBytes() { + java.lang.Object ref = toDate_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + toDate_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int LIMIT_FIELD_NUMBER = 6; + private int limit_; + /** + *
+   * Optional. The maximum number of results to return. If not provided, defaults to 100.
+   * 
+ * + * int32 limit = 6; + * @return The limit. + */ + @java.lang.Override + public int getLimit() { + return limit_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getDenomBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, denom_); + } + if (!getScopeIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, scopeId_); + } + for (int i = 0; i < priceDenoms_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, priceDenoms_.getRaw(i)); + } + if (!getFromDateBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, fromDate_); + } + if (!getToDateBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, toDate_); + } + if (limit_ != 0) { + output.writeInt32(6, limit_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getDenomBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, denom_); + } + if (!getScopeIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, scopeId_); + } + { + int dataSize = 0; + for (int i = 0; i < priceDenoms_.size(); i++) { + dataSize += computeStringSizeNoTag(priceDenoms_.getRaw(i)); + } + size += dataSize; + size += 1 * getPriceDenomsList().size(); + } + if (!getFromDateBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, fromDate_); + } + if (!getToDateBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, toDate_); + } + if (limit_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(6, limit_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof io.provlabs.flow.api.NavEventRequest)) { + return super.equals(obj); + } + io.provlabs.flow.api.NavEventRequest other = (io.provlabs.flow.api.NavEventRequest) obj; + + if (!getDenom() + .equals(other.getDenom())) return false; + if (!getScopeId() + .equals(other.getScopeId())) return false; + if (!getPriceDenomsList() + .equals(other.getPriceDenomsList())) return false; + if (!getFromDate() + .equals(other.getFromDate())) return false; + if (!getToDate() + .equals(other.getToDate())) return false; + if (getLimit() + != other.getLimit()) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DENOM_FIELD_NUMBER; + hash = (53 * hash) + getDenom().hashCode(); + hash = (37 * hash) + SCOPE_ID_FIELD_NUMBER; + hash = (53 * hash) + getScopeId().hashCode(); + if (getPriceDenomsCount() > 0) { + hash = (37 * hash) + PRICE_DENOMS_FIELD_NUMBER; + hash = (53 * hash) + getPriceDenomsList().hashCode(); + } + hash = (37 * hash) + FROM_DATE_FIELD_NUMBER; + hash = (53 * hash) + getFromDate().hashCode(); + hash = (37 * hash) + TO_DATE_FIELD_NUMBER; + hash = (53 * hash) + getToDate().hashCode(); + hash = (37 * hash) + LIMIT_FIELD_NUMBER; + hash = (53 * hash) + getLimit(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static io.provlabs.flow.api.NavEventRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.provlabs.flow.api.NavEventRequest parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.provlabs.flow.api.NavEventRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.provlabs.flow.api.NavEventRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.provlabs.flow.api.NavEventRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.provlabs.flow.api.NavEventRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.provlabs.flow.api.NavEventRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.provlabs.flow.api.NavEventRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static io.provlabs.flow.api.NavEventRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static io.provlabs.flow.api.NavEventRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static io.provlabs.flow.api.NavEventRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.provlabs.flow.api.NavEventRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(io.provlabs.flow.api.NavEventRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+   * NavEventRequest represents a request for NavEvents by either `denom` or `scope_id`.
+   * One of `denom` or `scope_id` must be provided; the other fields are optional.
+   * 
+ * + * Protobuf type {@code nav.NavEventRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:nav.NavEventRequest) + io.provlabs.flow.api.NavEventRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_NavEventRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_NavEventRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.provlabs.flow.api.NavEventRequest.class, io.provlabs.flow.api.NavEventRequest.Builder.class); + } + + // Construct using io.provlabs.flow.api.NavEventRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + denom_ = ""; + + scopeId_ = ""; + + priceDenoms_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + fromDate_ = ""; + + toDate_ = ""; + + limit_ = 0; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_NavEventRequest_descriptor; + } + + @java.lang.Override + public io.provlabs.flow.api.NavEventRequest getDefaultInstanceForType() { + return io.provlabs.flow.api.NavEventRequest.getDefaultInstance(); + } + + @java.lang.Override + public io.provlabs.flow.api.NavEventRequest build() { + io.provlabs.flow.api.NavEventRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public io.provlabs.flow.api.NavEventRequest buildPartial() { + io.provlabs.flow.api.NavEventRequest result = new io.provlabs.flow.api.NavEventRequest(this); + int from_bitField0_ = bitField0_; + result.denom_ = denom_; + result.scopeId_ = scopeId_; + if (((bitField0_ & 0x00000001) != 0)) { + priceDenoms_ = priceDenoms_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.priceDenoms_ = priceDenoms_; + result.fromDate_ = fromDate_; + result.toDate_ = toDate_; + result.limit_ = limit_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof io.provlabs.flow.api.NavEventRequest) { + return mergeFrom((io.provlabs.flow.api.NavEventRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.provlabs.flow.api.NavEventRequest other) { + if (other == io.provlabs.flow.api.NavEventRequest.getDefaultInstance()) return this; + if (!other.getDenom().isEmpty()) { + denom_ = other.denom_; + onChanged(); + } + if (!other.getScopeId().isEmpty()) { + scopeId_ = other.scopeId_; + onChanged(); + } + if (!other.priceDenoms_.isEmpty()) { + if (priceDenoms_.isEmpty()) { + priceDenoms_ = other.priceDenoms_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensurePriceDenomsIsMutable(); + priceDenoms_.addAll(other.priceDenoms_); + } + onChanged(); + } + if (!other.getFromDate().isEmpty()) { + fromDate_ = other.fromDate_; + onChanged(); + } + if (!other.getToDate().isEmpty()) { + toDate_ = other.toDate_; + onChanged(); + } + if (other.getLimit() != 0) { + setLimit(other.getLimit()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + io.provlabs.flow.api.NavEventRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.provlabs.flow.api.NavEventRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.lang.Object denom_ = ""; + /** + *
+     * The token denomination to filter events by. Either `denom` or `scope_id` is required.
+     * 
+ * + * string denom = 1; + * @return The denom. + */ + public java.lang.String getDenom() { + java.lang.Object ref = denom_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + denom_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+     * The token denomination to filter events by. Either `denom` or `scope_id` is required.
+     * 
+ * + * string denom = 1; + * @return The bytes for denom. + */ + public com.google.protobuf.ByteString + getDenomBytes() { + java.lang.Object ref = denom_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + denom_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+     * The token denomination to filter events by. Either `denom` or `scope_id` is required.
+     * 
+ * + * string denom = 1; + * @param value The denom to set. + * @return This builder for chaining. + */ + public Builder setDenom( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + denom_ = value; + onChanged(); + return this; + } + /** + *
+     * The token denomination to filter events by. Either `denom` or `scope_id` is required.
+     * 
+ * + * string denom = 1; + * @return This builder for chaining. + */ + public Builder clearDenom() { + + denom_ = getDefaultInstance().getDenom(); + onChanged(); + return this; + } + /** + *
+     * The token denomination to filter events by. Either `denom` or `scope_id` is required.
+     * 
+ * + * string denom = 1; + * @param value The bytes for denom to set. + * @return This builder for chaining. + */ + public Builder setDenomBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + denom_ = value; + onChanged(); + return this; + } + + private java.lang.Object scopeId_ = ""; + /** + *
+     * The scope ID to filter events by. Either `denom` or `scope_id` is required.
+     * 
+ * + * string scope_id = 2; + * @return The scopeId. + */ + public java.lang.String getScopeId() { + java.lang.Object ref = scopeId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + scopeId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+     * The scope ID to filter events by. Either `denom` or `scope_id` is required.
+     * 
+ * + * string scope_id = 2; + * @return The bytes for scopeId. + */ + public com.google.protobuf.ByteString + getScopeIdBytes() { + java.lang.Object ref = scopeId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + scopeId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+     * The scope ID to filter events by. Either `denom` or `scope_id` is required.
+     * 
+ * + * string scope_id = 2; + * @param value The scopeId to set. + * @return This builder for chaining. + */ + public Builder setScopeId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + scopeId_ = value; + onChanged(); + return this; + } + /** + *
+     * The scope ID to filter events by. Either `denom` or `scope_id` is required.
+     * 
+ * + * string scope_id = 2; + * @return This builder for chaining. + */ + public Builder clearScopeId() { + + scopeId_ = getDefaultInstance().getScopeId(); + onChanged(); + return this; + } + /** + *
+     * The scope ID to filter events by. Either `denom` or `scope_id` is required.
+     * 
+ * + * string scope_id = 2; + * @param value The bytes for scopeId to set. + * @return This builder for chaining. + */ + public Builder setScopeIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + scopeId_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringList priceDenoms_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensurePriceDenomsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + priceDenoms_ = new com.google.protobuf.LazyStringArrayList(priceDenoms_); + bitField0_ |= 0x00000001; + } + } + /** + *
+     * Optional. A list of price denominations to filter by.
+     * 
+ * + * repeated string price_denoms = 3; + * @return A list containing the priceDenoms. + */ + public com.google.protobuf.ProtocolStringList + getPriceDenomsList() { + return priceDenoms_.getUnmodifiableView(); + } + /** + *
+     * Optional. A list of price denominations to filter by.
+     * 
+ * + * repeated string price_denoms = 3; + * @return The count of priceDenoms. + */ + public int getPriceDenomsCount() { + return priceDenoms_.size(); + } + /** + *
+     * Optional. A list of price denominations to filter by.
+     * 
+ * + * repeated string price_denoms = 3; + * @param index The index of the element to return. + * @return The priceDenoms at the given index. + */ + public java.lang.String getPriceDenoms(int index) { + return priceDenoms_.get(index); + } + /** + *
+     * Optional. A list of price denominations to filter by.
+     * 
+ * + * repeated string price_denoms = 3; + * @param index The index of the value to return. + * @return The bytes of the priceDenoms at the given index. + */ + public com.google.protobuf.ByteString + getPriceDenomsBytes(int index) { + return priceDenoms_.getByteString(index); + } + /** + *
+     * Optional. A list of price denominations to filter by.
+     * 
+ * + * repeated string price_denoms = 3; + * @param index The index to set the value at. + * @param value The priceDenoms to set. + * @return This builder for chaining. + */ + public Builder setPriceDenoms( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensurePriceDenomsIsMutable(); + priceDenoms_.set(index, value); + onChanged(); + return this; + } + /** + *
+     * Optional. A list of price denominations to filter by.
+     * 
+ * + * repeated string price_denoms = 3; + * @param value The priceDenoms to add. + * @return This builder for chaining. + */ + public Builder addPriceDenoms( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensurePriceDenomsIsMutable(); + priceDenoms_.add(value); + onChanged(); + return this; + } + /** + *
+     * Optional. A list of price denominations to filter by.
+     * 
+ * + * repeated string price_denoms = 3; + * @param values The priceDenoms to add. + * @return This builder for chaining. + */ + public Builder addAllPriceDenoms( + java.lang.Iterable values) { + ensurePriceDenomsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, priceDenoms_); + onChanged(); + return this; + } + /** + *
+     * Optional. A list of price denominations to filter by.
+     * 
+ * + * repeated string price_denoms = 3; + * @return This builder for chaining. + */ + public Builder clearPriceDenoms() { + priceDenoms_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + *
+     * Optional. A list of price denominations to filter by.
+     * 
+ * + * repeated string price_denoms = 3; + * @param value The bytes of the priceDenoms to add. + * @return This builder for chaining. + */ + public Builder addPriceDenomsBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensurePriceDenomsIsMutable(); + priceDenoms_.add(value); + onChanged(); + return this; + } + + private java.lang.Object fromDate_ = ""; + /** + *
+     * Optional. The start date (in string format) to filter events.
+     * 
+ * + * string from_date = 4; + * @return The fromDate. + */ + public java.lang.String getFromDate() { + java.lang.Object ref = fromDate_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + fromDate_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+     * Optional. The start date (in string format) to filter events.
+     * 
+ * + * string from_date = 4; + * @return The bytes for fromDate. + */ + public com.google.protobuf.ByteString + getFromDateBytes() { + java.lang.Object ref = fromDate_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + fromDate_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+     * Optional. The start date (in string format) to filter events.
+     * 
+ * + * string from_date = 4; + * @param value The fromDate to set. + * @return This builder for chaining. + */ + public Builder setFromDate( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + fromDate_ = value; + onChanged(); + return this; + } + /** + *
+     * Optional. The start date (in string format) to filter events.
+     * 
+ * + * string from_date = 4; + * @return This builder for chaining. + */ + public Builder clearFromDate() { + + fromDate_ = getDefaultInstance().getFromDate(); + onChanged(); + return this; + } + /** + *
+     * Optional. The start date (in string format) to filter events.
+     * 
+ * + * string from_date = 4; + * @param value The bytes for fromDate to set. + * @return This builder for chaining. + */ + public Builder setFromDateBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + fromDate_ = value; + onChanged(); + return this; + } + + private java.lang.Object toDate_ = ""; + /** + *
+     * Optional. The end date (in string format) to filter events.
+     * 
+ * + * string to_date = 5; + * @return The toDate. + */ + public java.lang.String getToDate() { + java.lang.Object ref = toDate_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + toDate_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+     * Optional. The end date (in string format) to filter events.
+     * 
+ * + * string to_date = 5; + * @return The bytes for toDate. + */ + public com.google.protobuf.ByteString + getToDateBytes() { + java.lang.Object ref = toDate_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + toDate_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+     * Optional. The end date (in string format) to filter events.
+     * 
+ * + * string to_date = 5; + * @param value The toDate to set. + * @return This builder for chaining. + */ + public Builder setToDate( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + toDate_ = value; + onChanged(); + return this; + } + /** + *
+     * Optional. The end date (in string format) to filter events.
+     * 
+ * + * string to_date = 5; + * @return This builder for chaining. + */ + public Builder clearToDate() { + + toDate_ = getDefaultInstance().getToDate(); + onChanged(); + return this; + } + /** + *
+     * Optional. The end date (in string format) to filter events.
+     * 
+ * + * string to_date = 5; + * @param value The bytes for toDate to set. + * @return This builder for chaining. + */ + public Builder setToDateBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + toDate_ = value; + onChanged(); + return this; + } + + private int limit_ ; + /** + *
+     * Optional. The maximum number of results to return. If not provided, defaults to 100.
+     * 
+ * + * int32 limit = 6; + * @return The limit. + */ + @java.lang.Override + public int getLimit() { + return limit_; + } + /** + *
+     * Optional. The maximum number of results to return. If not provided, defaults to 100.
+     * 
+ * + * int32 limit = 6; + * @param value The limit to set. + * @return This builder for chaining. + */ + public Builder setLimit(int value) { + + limit_ = value; + onChanged(); + return this; + } + /** + *
+     * Optional. The maximum number of results to return. If not provided, defaults to 100.
+     * 
+ * + * int32 limit = 6; + * @return This builder for chaining. + */ + public Builder clearLimit() { + + limit_ = 0; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:nav.NavEventRequest) + } + + // @@protoc_insertion_point(class_scope:nav.NavEventRequest) + private static final io.provlabs.flow.api.NavEventRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new io.provlabs.flow.api.NavEventRequest(); + } + + public static io.provlabs.flow.api.NavEventRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public NavEventRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new NavEventRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public io.provlabs.flow.api.NavEventRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/service/src/main/java/io/provlabs/flow/api/NavEventRequestOrBuilder.java b/service/src/main/java/io/provlabs/flow/api/NavEventRequestOrBuilder.java new file mode 100644 index 00000000..2d720aae --- /dev/null +++ b/service/src/main/java/io/provlabs/flow/api/NavEventRequestOrBuilder.java @@ -0,0 +1,140 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: nav_event.proto + +package io.provlabs.flow.api; + +public interface NavEventRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:nav.NavEventRequest) + com.google.protobuf.MessageOrBuilder { + + /** + *
+   * The token denomination to filter events by. Either `denom` or `scope_id` is required.
+   * 
+ * + * string denom = 1; + * @return The denom. + */ + java.lang.String getDenom(); + /** + *
+   * The token denomination to filter events by. Either `denom` or `scope_id` is required.
+   * 
+ * + * string denom = 1; + * @return The bytes for denom. + */ + com.google.protobuf.ByteString + getDenomBytes(); + + /** + *
+   * The scope ID to filter events by. Either `denom` or `scope_id` is required.
+   * 
+ * + * string scope_id = 2; + * @return The scopeId. + */ + java.lang.String getScopeId(); + /** + *
+   * The scope ID to filter events by. Either `denom` or `scope_id` is required.
+   * 
+ * + * string scope_id = 2; + * @return The bytes for scopeId. + */ + com.google.protobuf.ByteString + getScopeIdBytes(); + + /** + *
+   * Optional. A list of price denominations to filter by.
+   * 
+ * + * repeated string price_denoms = 3; + * @return A list containing the priceDenoms. + */ + java.util.List + getPriceDenomsList(); + /** + *
+   * Optional. A list of price denominations to filter by.
+   * 
+ * + * repeated string price_denoms = 3; + * @return The count of priceDenoms. + */ + int getPriceDenomsCount(); + /** + *
+   * Optional. A list of price denominations to filter by.
+   * 
+ * + * repeated string price_denoms = 3; + * @param index The index of the element to return. + * @return The priceDenoms at the given index. + */ + java.lang.String getPriceDenoms(int index); + /** + *
+   * Optional. A list of price denominations to filter by.
+   * 
+ * + * repeated string price_denoms = 3; + * @param index The index of the value to return. + * @return The bytes of the priceDenoms at the given index. + */ + com.google.protobuf.ByteString + getPriceDenomsBytes(int index); + + /** + *
+   * Optional. The start date (in string format) to filter events.
+   * 
+ * + * string from_date = 4; + * @return The fromDate. + */ + java.lang.String getFromDate(); + /** + *
+   * Optional. The start date (in string format) to filter events.
+   * 
+ * + * string from_date = 4; + * @return The bytes for fromDate. + */ + com.google.protobuf.ByteString + getFromDateBytes(); + + /** + *
+   * Optional. The end date (in string format) to filter events.
+   * 
+ * + * string to_date = 5; + * @return The toDate. + */ + java.lang.String getToDate(); + /** + *
+   * Optional. The end date (in string format) to filter events.
+   * 
+ * + * string to_date = 5; + * @return The bytes for toDate. + */ + com.google.protobuf.ByteString + getToDateBytes(); + + /** + *
+   * Optional. The maximum number of results to return. If not provided, defaults to 100.
+   * 
+ * + * int32 limit = 6; + * @return The limit. + */ + int getLimit(); +} diff --git a/service/src/main/java/io/provlabs/flow/api/NavEventResponse.java b/service/src/main/java/io/provlabs/flow/api/NavEventResponse.java new file mode 100644 index 00000000..4fbfc9c9 --- /dev/null +++ b/service/src/main/java/io/provlabs/flow/api/NavEventResponse.java @@ -0,0 +1,778 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: nav_event.proto + +package io.provlabs.flow.api; + +/** + *
+ * NavEventResponse represents the response containing a list of NavEvents.
+ * 
+ * + * Protobuf type {@code nav.NavEventResponse} + */ +public final class NavEventResponse extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:nav.NavEventResponse) + NavEventResponseOrBuilder { +private static final long serialVersionUID = 0L; + // Use NavEventResponse.newBuilder() to construct. + private NavEventResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private NavEventResponse() { + navEvents_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new NavEventResponse(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private NavEventResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + navEvents_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + navEvents_.add( + input.readMessage(io.provlabs.flow.api.NavEvent.parser(), extensionRegistry)); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + navEvents_ = java.util.Collections.unmodifiableList(navEvents_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_NavEventResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_NavEventResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.provlabs.flow.api.NavEventResponse.class, io.provlabs.flow.api.NavEventResponse.Builder.class); + } + + public static final int NAV_EVENTS_FIELD_NUMBER = 1; + private java.util.List navEvents_; + /** + * repeated .nav.NavEvent nav_events = 1; + */ + @java.lang.Override + public java.util.List getNavEventsList() { + return navEvents_; + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + @java.lang.Override + public java.util.List + getNavEventsOrBuilderList() { + return navEvents_; + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + @java.lang.Override + public int getNavEventsCount() { + return navEvents_.size(); + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + @java.lang.Override + public io.provlabs.flow.api.NavEvent getNavEvents(int index) { + return navEvents_.get(index); + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + @java.lang.Override + public io.provlabs.flow.api.NavEventOrBuilder getNavEventsOrBuilder( + int index) { + return navEvents_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < navEvents_.size(); i++) { + output.writeMessage(1, navEvents_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < navEvents_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, navEvents_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof io.provlabs.flow.api.NavEventResponse)) { + return super.equals(obj); + } + io.provlabs.flow.api.NavEventResponse other = (io.provlabs.flow.api.NavEventResponse) obj; + + if (!getNavEventsList() + .equals(other.getNavEventsList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getNavEventsCount() > 0) { + hash = (37 * hash) + NAV_EVENTS_FIELD_NUMBER; + hash = (53 * hash) + getNavEventsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static io.provlabs.flow.api.NavEventResponse parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.provlabs.flow.api.NavEventResponse parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.provlabs.flow.api.NavEventResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.provlabs.flow.api.NavEventResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.provlabs.flow.api.NavEventResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.provlabs.flow.api.NavEventResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.provlabs.flow.api.NavEventResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.provlabs.flow.api.NavEventResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static io.provlabs.flow.api.NavEventResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static io.provlabs.flow.api.NavEventResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static io.provlabs.flow.api.NavEventResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.provlabs.flow.api.NavEventResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(io.provlabs.flow.api.NavEventResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+   * NavEventResponse represents the response containing a list of NavEvents.
+   * 
+ * + * Protobuf type {@code nav.NavEventResponse} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:nav.NavEventResponse) + io.provlabs.flow.api.NavEventResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_NavEventResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_NavEventResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.provlabs.flow.api.NavEventResponse.class, io.provlabs.flow.api.NavEventResponse.Builder.class); + } + + // Construct using io.provlabs.flow.api.NavEventResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getNavEventsFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (navEventsBuilder_ == null) { + navEvents_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + navEventsBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_NavEventResponse_descriptor; + } + + @java.lang.Override + public io.provlabs.flow.api.NavEventResponse getDefaultInstanceForType() { + return io.provlabs.flow.api.NavEventResponse.getDefaultInstance(); + } + + @java.lang.Override + public io.provlabs.flow.api.NavEventResponse build() { + io.provlabs.flow.api.NavEventResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public io.provlabs.flow.api.NavEventResponse buildPartial() { + io.provlabs.flow.api.NavEventResponse result = new io.provlabs.flow.api.NavEventResponse(this); + int from_bitField0_ = bitField0_; + if (navEventsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + navEvents_ = java.util.Collections.unmodifiableList(navEvents_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.navEvents_ = navEvents_; + } else { + result.navEvents_ = navEventsBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof io.provlabs.flow.api.NavEventResponse) { + return mergeFrom((io.provlabs.flow.api.NavEventResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.provlabs.flow.api.NavEventResponse other) { + if (other == io.provlabs.flow.api.NavEventResponse.getDefaultInstance()) return this; + if (navEventsBuilder_ == null) { + if (!other.navEvents_.isEmpty()) { + if (navEvents_.isEmpty()) { + navEvents_ = other.navEvents_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureNavEventsIsMutable(); + navEvents_.addAll(other.navEvents_); + } + onChanged(); + } + } else { + if (!other.navEvents_.isEmpty()) { + if (navEventsBuilder_.isEmpty()) { + navEventsBuilder_.dispose(); + navEventsBuilder_ = null; + navEvents_ = other.navEvents_; + bitField0_ = (bitField0_ & ~0x00000001); + navEventsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getNavEventsFieldBuilder() : null; + } else { + navEventsBuilder_.addAllMessages(other.navEvents_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + io.provlabs.flow.api.NavEventResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.provlabs.flow.api.NavEventResponse) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List navEvents_ = + java.util.Collections.emptyList(); + private void ensureNavEventsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + navEvents_ = new java.util.ArrayList(navEvents_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + io.provlabs.flow.api.NavEvent, io.provlabs.flow.api.NavEvent.Builder, io.provlabs.flow.api.NavEventOrBuilder> navEventsBuilder_; + + /** + * repeated .nav.NavEvent nav_events = 1; + */ + public java.util.List getNavEventsList() { + if (navEventsBuilder_ == null) { + return java.util.Collections.unmodifiableList(navEvents_); + } else { + return navEventsBuilder_.getMessageList(); + } + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + public int getNavEventsCount() { + if (navEventsBuilder_ == null) { + return navEvents_.size(); + } else { + return navEventsBuilder_.getCount(); + } + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + public io.provlabs.flow.api.NavEvent getNavEvents(int index) { + if (navEventsBuilder_ == null) { + return navEvents_.get(index); + } else { + return navEventsBuilder_.getMessage(index); + } + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + public Builder setNavEvents( + int index, io.provlabs.flow.api.NavEvent value) { + if (navEventsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNavEventsIsMutable(); + navEvents_.set(index, value); + onChanged(); + } else { + navEventsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + public Builder setNavEvents( + int index, io.provlabs.flow.api.NavEvent.Builder builderForValue) { + if (navEventsBuilder_ == null) { + ensureNavEventsIsMutable(); + navEvents_.set(index, builderForValue.build()); + onChanged(); + } else { + navEventsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + public Builder addNavEvents(io.provlabs.flow.api.NavEvent value) { + if (navEventsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNavEventsIsMutable(); + navEvents_.add(value); + onChanged(); + } else { + navEventsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + public Builder addNavEvents( + int index, io.provlabs.flow.api.NavEvent value) { + if (navEventsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNavEventsIsMutable(); + navEvents_.add(index, value); + onChanged(); + } else { + navEventsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + public Builder addNavEvents( + io.provlabs.flow.api.NavEvent.Builder builderForValue) { + if (navEventsBuilder_ == null) { + ensureNavEventsIsMutable(); + navEvents_.add(builderForValue.build()); + onChanged(); + } else { + navEventsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + public Builder addNavEvents( + int index, io.provlabs.flow.api.NavEvent.Builder builderForValue) { + if (navEventsBuilder_ == null) { + ensureNavEventsIsMutable(); + navEvents_.add(index, builderForValue.build()); + onChanged(); + } else { + navEventsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + public Builder addAllNavEvents( + java.lang.Iterable values) { + if (navEventsBuilder_ == null) { + ensureNavEventsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, navEvents_); + onChanged(); + } else { + navEventsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + public Builder clearNavEvents() { + if (navEventsBuilder_ == null) { + navEvents_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + navEventsBuilder_.clear(); + } + return this; + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + public Builder removeNavEvents(int index) { + if (navEventsBuilder_ == null) { + ensureNavEventsIsMutable(); + navEvents_.remove(index); + onChanged(); + } else { + navEventsBuilder_.remove(index); + } + return this; + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + public io.provlabs.flow.api.NavEvent.Builder getNavEventsBuilder( + int index) { + return getNavEventsFieldBuilder().getBuilder(index); + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + public io.provlabs.flow.api.NavEventOrBuilder getNavEventsOrBuilder( + int index) { + if (navEventsBuilder_ == null) { + return navEvents_.get(index); } else { + return navEventsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + public java.util.List + getNavEventsOrBuilderList() { + if (navEventsBuilder_ != null) { + return navEventsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(navEvents_); + } + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + public io.provlabs.flow.api.NavEvent.Builder addNavEventsBuilder() { + return getNavEventsFieldBuilder().addBuilder( + io.provlabs.flow.api.NavEvent.getDefaultInstance()); + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + public io.provlabs.flow.api.NavEvent.Builder addNavEventsBuilder( + int index) { + return getNavEventsFieldBuilder().addBuilder( + index, io.provlabs.flow.api.NavEvent.getDefaultInstance()); + } + /** + * repeated .nav.NavEvent nav_events = 1; + */ + public java.util.List + getNavEventsBuilderList() { + return getNavEventsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + io.provlabs.flow.api.NavEvent, io.provlabs.flow.api.NavEvent.Builder, io.provlabs.flow.api.NavEventOrBuilder> + getNavEventsFieldBuilder() { + if (navEventsBuilder_ == null) { + navEventsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + io.provlabs.flow.api.NavEvent, io.provlabs.flow.api.NavEvent.Builder, io.provlabs.flow.api.NavEventOrBuilder>( + navEvents_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + navEvents_ = null; + } + return navEventsBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:nav.NavEventResponse) + } + + // @@protoc_insertion_point(class_scope:nav.NavEventResponse) + private static final io.provlabs.flow.api.NavEventResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new io.provlabs.flow.api.NavEventResponse(); + } + + public static io.provlabs.flow.api.NavEventResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public NavEventResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new NavEventResponse(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public io.provlabs.flow.api.NavEventResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/service/src/main/java/io/provlabs/flow/api/NavEventResponseOrBuilder.java b/service/src/main/java/io/provlabs/flow/api/NavEventResponseOrBuilder.java new file mode 100644 index 00000000..c73a9163 --- /dev/null +++ b/service/src/main/java/io/provlabs/flow/api/NavEventResponseOrBuilder.java @@ -0,0 +1,33 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: nav_event.proto + +package io.provlabs.flow.api; + +public interface NavEventResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:nav.NavEventResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .nav.NavEvent nav_events = 1; + */ + java.util.List + getNavEventsList(); + /** + * repeated .nav.NavEvent nav_events = 1; + */ + io.provlabs.flow.api.NavEvent getNavEvents(int index); + /** + * repeated .nav.NavEvent nav_events = 1; + */ + int getNavEventsCount(); + /** + * repeated .nav.NavEvent nav_events = 1; + */ + java.util.List + getNavEventsOrBuilderList(); + /** + * repeated .nav.NavEvent nav_events = 1; + */ + io.provlabs.flow.api.NavEventOrBuilder getNavEventsOrBuilder( + int index); +} diff --git a/service/src/main/java/io/provlabs/flow/api/NavServiceGrpc.java b/service/src/main/java/io/provlabs/flow/api/NavServiceGrpc.java new file mode 100644 index 00000000..d47c18ec --- /dev/null +++ b/service/src/main/java/io/provlabs/flow/api/NavServiceGrpc.java @@ -0,0 +1,303 @@ +package io.provlabs.flow.api; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + *
+ * NavService is the gRPC service for retrieving NavEvents.
+ * 
+ */ +@javax.annotation.Generated( + value = "by gRPC proto compiler", + comments = "Source: nav_event.proto") +public final class NavServiceGrpc { + + private NavServiceGrpc() {} + + public static final String SERVICE_NAME = "nav.NavService"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor getGetNavEventsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetNavEvents", + requestType = io.provlabs.flow.api.NavEventRequest.class, + responseType = io.provlabs.flow.api.NavEventResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getGetNavEventsMethod() { + io.grpc.MethodDescriptor getGetNavEventsMethod; + if ((getGetNavEventsMethod = NavServiceGrpc.getGetNavEventsMethod) == null) { + synchronized (NavServiceGrpc.class) { + if ((getGetNavEventsMethod = NavServiceGrpc.getGetNavEventsMethod) == null) { + NavServiceGrpc.getGetNavEventsMethod = getGetNavEventsMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetNavEvents")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + io.provlabs.flow.api.NavEventRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + io.provlabs.flow.api.NavEventResponse.getDefaultInstance())) + .setSchemaDescriptor(new NavServiceMethodDescriptorSupplier("GetNavEvents")) + .build(); + } + } + } + return getGetNavEventsMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static NavServiceStub newStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public NavServiceStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new NavServiceStub(channel, callOptions); + } + }; + return NavServiceStub.newStub(factory, channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static NavServiceBlockingStub newBlockingStub( + io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public NavServiceBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new NavServiceBlockingStub(channel, callOptions); + } + }; + return NavServiceBlockingStub.newStub(factory, channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static NavServiceFutureStub newFutureStub( + io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public NavServiceFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new NavServiceFutureStub(channel, callOptions); + } + }; + return NavServiceFutureStub.newStub(factory, channel); + } + + /** + *
+   * NavService is the gRPC service for retrieving NavEvents.
+   * 
+ */ + public static abstract class NavServiceImplBase implements io.grpc.BindableService { + + /** + */ + public void getNavEvents(io.provlabs.flow.api.NavEventRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetNavEventsMethod(), responseObserver); + } + + @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getGetNavEventsMethod(), + asyncUnaryCall( + new MethodHandlers< + io.provlabs.flow.api.NavEventRequest, + io.provlabs.flow.api.NavEventResponse>( + this, METHODID_GET_NAV_EVENTS))) + .build(); + } + } + + /** + *
+   * NavService is the gRPC service for retrieving NavEvents.
+   * 
+ */ + public static final class NavServiceStub extends io.grpc.stub.AbstractAsyncStub { + private NavServiceStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected NavServiceStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new NavServiceStub(channel, callOptions); + } + + /** + */ + public void getNavEvents(io.provlabs.flow.api.NavEventRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetNavEventsMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + *
+   * NavService is the gRPC service for retrieving NavEvents.
+   * 
+ */ + public static final class NavServiceBlockingStub extends io.grpc.stub.AbstractBlockingStub { + private NavServiceBlockingStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected NavServiceBlockingStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new NavServiceBlockingStub(channel, callOptions); + } + + /** + */ + public io.provlabs.flow.api.NavEventResponse getNavEvents(io.provlabs.flow.api.NavEventRequest request) { + return blockingUnaryCall( + getChannel(), getGetNavEventsMethod(), getCallOptions(), request); + } + } + + /** + *
+   * NavService is the gRPC service for retrieving NavEvents.
+   * 
+ */ + public static final class NavServiceFutureStub extends io.grpc.stub.AbstractFutureStub { + private NavServiceFutureStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected NavServiceFutureStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new NavServiceFutureStub(channel, callOptions); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture getNavEvents( + io.provlabs.flow.api.NavEventRequest request) { + return futureUnaryCall( + getChannel().newCall(getGetNavEventsMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_GET_NAV_EVENTS = 0; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final NavServiceImplBase serviceImpl; + private final int methodId; + + MethodHandlers(NavServiceImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_GET_NAV_EVENTS: + serviceImpl.getNavEvents((io.provlabs.flow.api.NavEventRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private static abstract class NavServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + NavServiceBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return io.provlabs.flow.api.NavEventOuterClass.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("NavService"); + } + } + + private static final class NavServiceFileDescriptorSupplier + extends NavServiceBaseDescriptorSupplier { + NavServiceFileDescriptorSupplier() {} + } + + private static final class NavServiceMethodDescriptorSupplier + extends NavServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + NavServiceMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (NavServiceGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new NavServiceFileDescriptorSupplier()) + .addMethod(getGetNavEventsMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/service/src/main/kotlin/io/provenance/explorer/config/ExplorerProperties.kt b/service/src/main/kotlin/io/provenance/explorer/config/ExplorerProperties.kt index 27eff1aa..dd4af046 100644 --- a/service/src/main/kotlin/io/provenance/explorer/config/ExplorerProperties.kt +++ b/service/src/main/kotlin/io/provenance/explorer/config/ExplorerProperties.kt @@ -13,6 +13,7 @@ import java.math.BigDecimal class ExplorerProperties( val mainnet: String, val pbUrl: String, + val flowApiUrl: String, val initialHistoricalDayCount: String, val spotlightTtlMs: String, val genesisVersionUrl: String, diff --git a/service/src/main/kotlin/io/provenance/explorer/config/FlowApiGrpcClientConfig.kt b/service/src/main/kotlin/io/provenance/explorer/config/FlowApiGrpcClientConfig.kt new file mode 100644 index 00000000..9242903f --- /dev/null +++ b/service/src/main/kotlin/io/provenance/explorer/config/FlowApiGrpcClientConfig.kt @@ -0,0 +1,16 @@ +package io.provenance.explorer.config + +import org.springframework.boot.context.properties.EnableConfigurationProperties +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import java.net.URI + +@EnableConfigurationProperties( + value = [ExplorerProperties::class] +) +@Configuration +class FlowApiGrpcClientConfig(val props: ExplorerProperties) { + + @Bean + fun flowApiChannelUri() = URI(props.flowApiUrl) +} diff --git a/service/src/main/kotlin/io/provenance/explorer/domain/models/explorer/OsmosisModels.kt b/service/src/main/kotlin/io/provenance/explorer/domain/models/explorer/HistoricalPriceModels.kt similarity index 58% rename from service/src/main/kotlin/io/provenance/explorer/domain/models/explorer/OsmosisModels.kt rename to service/src/main/kotlin/io/provenance/explorer/domain/models/explorer/HistoricalPriceModels.kt index 55313a97..37d58b43 100644 --- a/service/src/main/kotlin/io/provenance/explorer/domain/models/explorer/OsmosisModels.kt +++ b/service/src/main/kotlin/io/provenance/explorer/domain/models/explorer/HistoricalPriceModels.kt @@ -2,6 +2,24 @@ package io.provenance.explorer.domain.models import java.math.BigDecimal +data class HistoricalPrice( + val time: Long, + val high: BigDecimal, + val low: BigDecimal, + val close: BigDecimal, + val open: BigDecimal, + val volume: BigDecimal +) + +fun HistoricalPrice.toCsv(): List = listOf( + "$time", + "$open", + "$high", + "$low", + "$close", + "$volume" +) + data class OsmosisHistoricalPrice( val time: Long, val high: BigDecimal, diff --git a/service/src/main/kotlin/io/provenance/explorer/grpc/flow/FlowApiGrpcClient.kt b/service/src/main/kotlin/io/provenance/explorer/grpc/flow/FlowApiGrpcClient.kt new file mode 100644 index 00000000..1e83a69d --- /dev/null +++ b/service/src/main/kotlin/io/provenance/explorer/grpc/flow/FlowApiGrpcClient.kt @@ -0,0 +1,59 @@ +package io.provenance.explorer.grpc.flow + +import io.grpc.ManagedChannelBuilder +import io.provenance.explorer.config.interceptor.GrpcLoggingInterceptor +import io.provenance.explorer.domain.core.logger +import io.provlabs.flow.api.NavEvent +import io.provlabs.flow.api.NavEventRequest +import io.provlabs.flow.api.NavEventResponse +import io.provlabs.flow.api.NavServiceGrpc +import kotlinx.coroutines.runBlocking +import org.joda.time.DateTime +import org.joda.time.format.DateTimeFormat +import org.springframework.stereotype.Component +import java.net.URI +import java.util.concurrent.TimeUnit + +@Component +class FlowApiGrpcClient(flowApiChannelUri: URI) { + + private val navService: NavServiceGrpc.NavServiceBlockingStub + + init { + val channel = + ManagedChannelBuilder.forAddress(flowApiChannelUri.host, flowApiChannelUri.port) + .also { + if (flowApiChannelUri.scheme == "grpcs") { + it.useTransportSecurity() + } else { + it.usePlaintext() + } + } + .idleTimeout(60, TimeUnit.SECONDS) + .keepAliveTime(10, TimeUnit.SECONDS) + .keepAliveTimeout(10, TimeUnit.SECONDS) + .intercept(GrpcLoggingInterceptor()) + .build() + + navService = NavServiceGrpc.newBlockingStub(channel) + } + + fun getMarkerNavByPriceDenoms(denom: String, priceDenoms: List, fromDate: DateTime?, limit: Int = 100): List = runBlocking { + val fromDateString = fromDate?.toString(DateTimeFormat.forPattern("yyyy-MM-dd")) ?: "" + val requestBuilder = NavEventRequest.newBuilder() + .setDenom(denom) + .setFromDate(fromDateString) + .setLimit(limit) + + priceDenoms.forEach { requestBuilder.addPriceDenoms(it) } + val request = requestBuilder.build() + try { + logger().info("getMarkerNavByPriceDenoms $request") + val response: NavEventResponse = navService.getNavEvents(request) + return@runBlocking response.navEventsList + } catch (e: Exception) { + logger().error("Error fetching Nav Events: ${e.message}", e) + emptyList() + } + } +} diff --git a/service/src/main/kotlin/io/provenance/explorer/service/TokenService.kt b/service/src/main/kotlin/io/provenance/explorer/service/TokenService.kt index 0dabd3cb..c6f68491 100644 --- a/service/src/main/kotlin/io/provenance/explorer/service/TokenService.kt +++ b/service/src/main/kotlin/io/provenance/explorer/service/TokenService.kt @@ -2,17 +2,10 @@ package io.provenance.explorer.service import com.fasterxml.jackson.module.kotlin.readValue import cosmos.auth.v1beta1.Auth -import io.ktor.client.call.body -import io.ktor.client.plugins.ResponseException -import io.ktor.client.request.accept -import io.ktor.client.request.get -import io.ktor.client.statement.HttpResponse -import io.ktor.client.statement.bodyAsText -import io.ktor.http.ContentType -import io.provenance.explorer.KTOR_CLIENT_JAVA import io.provenance.explorer.VANILLA_MAPPER import io.provenance.explorer.config.ExplorerProperties.Companion.PROV_ACC_PREFIX import io.provenance.explorer.config.ExplorerProperties.Companion.UTILITY_TOKEN +import io.provenance.explorer.config.ExplorerProperties.Companion.UTILITY_TOKEN_BASE_MULTIPLIER import io.provenance.explorer.domain.core.logger import io.provenance.explorer.domain.entities.AccountRecord import io.provenance.explorer.domain.entities.CacheKeys @@ -27,17 +20,20 @@ import io.provenance.explorer.domain.entities.vestingAccountTypes import io.provenance.explorer.domain.exceptions.validate import io.provenance.explorer.domain.extensions.CsvData import io.provenance.explorer.domain.extensions.pageCountOfResults +import io.provenance.explorer.domain.extensions.percentChange import io.provenance.explorer.domain.extensions.roundWhole import io.provenance.explorer.domain.extensions.startOfDay import io.provenance.explorer.domain.extensions.toCoinStr import io.provenance.explorer.domain.extensions.toOffset import io.provenance.explorer.domain.extensions.toPercentage -import io.provenance.explorer.domain.models.OsmosisApiResponse -import io.provenance.explorer.domain.models.OsmosisHistoricalPrice +import io.provenance.explorer.domain.extensions.toThirdDecimal +import io.provenance.explorer.domain.models.HistoricalPrice import io.provenance.explorer.domain.models.explorer.TokenHistoricalDataRequest +import io.provenance.explorer.domain.models.toCsv import io.provenance.explorer.grpc.v1.AccountGrpcClient import io.provenance.explorer.model.AssetHolder import io.provenance.explorer.model.CmcLatestDataAbbrev +import io.provenance.explorer.model.CmcLatestQuoteAbbrev import io.provenance.explorer.model.RichAccount import io.provenance.explorer.model.TokenDistribution import io.provenance.explorer.model.TokenDistributionAmount @@ -45,6 +41,9 @@ import io.provenance.explorer.model.TokenSupply import io.provenance.explorer.model.base.CoinStr import io.provenance.explorer.model.base.CountStrTotal import io.provenance.explorer.model.base.PagedResults +import io.provenance.explorer.model.base.USD_UPPER +import io.provenance.explorer.service.pricing.fetchers.HistoricalPriceFetcher +import io.provenance.explorer.service.pricing.fetchers.HistoricalPriceFetcherFactory import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.map @@ -52,21 +51,28 @@ import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.jetbrains.exposed.sql.transactions.transaction import org.joda.time.DateTime -import org.joda.time.DateTimeZone -import org.joda.time.Duration import org.springframework.stereotype.Service import java.math.BigDecimal import java.math.RoundingMode -import java.net.URLEncoder import java.util.zip.ZipEntry import java.util.zip.ZipOutputStream import javax.servlet.ServletOutputStream @Service -class TokenService(private val accountClient: AccountGrpcClient) { - +class TokenService( + private val accountClient: AccountGrpcClient, + private val historicalPriceFetcherFactory: HistoricalPriceFetcherFactory +) { protected val logger = logger(TokenService::class) + private val historicalPriceFetchers: List by lazy { + historicalPriceFetcherFactory.createNhashFetchers() + } + + private val deprecatedHistoricalPricingFetchers: List by lazy { + historicalPriceFetcherFactory.createOsmosisPriceFetcher() + } + fun getTokenDistributionStats() = transaction { TokenDistributionAmountsRecord.getStats() } fun saveResults(records: List) = runBlocking { @@ -232,77 +238,37 @@ class TokenService(private val accountClient: AccountGrpcClient) { VANILLA_MAPPER.readValue(it) } - fun fetchOsmosisData(fromDate: DateTime?): List = runBlocking { - val input = buildInputQuery(fromDate, determineTimeFrame(fromDate)) - try { - val url = """https://app.osmosis.zone/api/edge-trpc-assets/assets.getAssetHistoricalPrice?input=$input""" - logger.info("Calling $url with fromDate $fromDate") - val response: HttpResponse = KTOR_CLIENT_JAVA.get(url) { - accept(ContentType.Application.Json) - } - - val rawResponse: String = response.bodyAsText() - logger.debug("Osmosis GET: $url Raw Response: $rawResponse") - - val osmosisApiResponse: OsmosisApiResponse = response.body() - osmosisApiResponse.result.data.json - } catch (e: ResponseException) { - logger.error("Error fetching from Osmosis API: ${e.response}", e) - emptyList() - } catch (e: Exception) { - logger.error("Error fetching from Osmosis API: ${e.message}", e) - emptyList() + fun fetchHistoricalPriceData(fromDate: DateTime?): List = runBlocking { + val allPrices = historicalPriceFetchers.flatMap { fetcher -> + fetcher.fetchHistoricalPrice(fromDate) } + return@runBlocking allPrices } - enum class TimeFrame(val minutes: Int) { - FIVE_MINUTES(5), - TWO_HOURS(120), - ONE_DAY(1440) + fun fetchLegacyHistoricalPriceData(fromDate: DateTime?): List = runBlocking { + val allPrices = deprecatedHistoricalPricingFetchers.flatMap { fetcher -> + fetcher.fetchHistoricalPrice(fromDate) + } + return@runBlocking allPrices } - /** - * Determines the appropriate TimeFrame based on the fromDate. - * - * @param fromDate The starting date to determine the time frame. - * @return The appropriate TimeFrame enum value. - */ - fun determineTimeFrame(fromDate: DateTime?): TimeFrame { - val now = DateTime.now(DateTimeZone.UTC) - val duration = Duration(fromDate, now) - return when { - duration.standardDays <= 14 -> TimeFrame.FIVE_MINUTES - duration.standardDays <= 60 -> TimeFrame.TWO_HOURS - else -> TimeFrame.ONE_DAY - } + fun processLatestTokenData(list: List, today: DateTime): CmcLatestDataAbbrev? { + val prevRecord = list.firstOrNull() ?: return null + val price = list.last().close.toThirdDecimal() + val percentChg = price.percentChange(prevRecord.close.toThirdDecimal()) + val vol24Hr = list.sumOf { it.volume.toThirdDecimal() }.stripTrailingZeros() + val marketCap = price.multiply(totalSupply().divide(UTILITY_TOKEN_BASE_MULTIPLIER)).toThirdDecimal() + + return CmcLatestDataAbbrev( + today, + mapOf(USD_UPPER to CmcLatestQuoteAbbrev(price, percentChg, vol24Hr, marketCap, today)) + ) } - /** - * Builds the input query parameter for fetching historical data. - * - * This function constructs a URL-encoded JSON query parameter for fetching historical data based on the given - * `fromDate` and `timeFrame`. The `timeFrame` represents the number of minutes between updates. The allowed values - * for `timeFrame` are defined in the `TimeFrame` enum: - * - FIVE_MINUTES: data goes back 2 weeks. - * - TWO_HOURS: data goes back 2 months. - * - ONE_DAY: data goes back to the beginning of time. - * - * The function calculates the total number of frames (`numRecentFrames`) from the `fromDate` to the current time, - * based on the specified `timeFrame`. - * - * @param fromDate The starting date from which to calculate the number of frames. - * @param timeFrame The time interval between updates, specified as a `TimeFrame` enum value. - * @return A URL-encoded JSON string to be used as a query parameter for fetching historical data. - */ - fun buildInputQuery(fromDate: DateTime?, timeFrame: TimeFrame): String { - val coinDenom = "ibc/CE5BFF1D9BADA03BB5CCA5F56939392A761B53A10FBD03B37506669C3218D3B2" - val coinMinimalDenom = "ibc/CE5BFF1D9BADA03BB5CCA5F56939392A761B53A10FBD03B37506669C3218D3B2" - val now = DateTime.now(DateTimeZone.UTC) - val duration = Duration(fromDate, now) - val numRecentFrames = (duration.standardMinutes / timeFrame.minutes).toInt() - return URLEncoder.encode( - """{"json":{"coinDenom":"$coinDenom","coinMinimalDenom":"$coinMinimalDenom","timeFrame":{"custom":{"timeFrame":${timeFrame.minutes},"numRecentFrames":$numRecentFrames}}}}""", - "UTF-8" + fun cacheLatestTokenData(data: CmcLatestDataAbbrev) { + CacheUpdateRecord.updateCacheByKey( + CacheKeys.UTILITY_TOKEN_LATEST.key, + VANILLA_MAPPER.writeValueAsString(data) ) } @@ -311,7 +277,7 @@ class TokenService(private val accountClient: AccountGrpcClient) { val baseFileName = filters.getFileNameBase() val fileList = runBlocking { - val data = fetchOsmosisData(filters.fromDate) + val data = fetchLegacyHistoricalPriceData(filters.fromDate) listOf( CsvData( "TokenHistoricalData", @@ -333,17 +299,6 @@ class TokenService(private val accountClient: AccountGrpcClient) { zos.close() return zos } - - private fun OsmosisHistoricalPrice.toCsv(): List { - return listOf( - time.toString(), - open.toString(), - high.toString(), - low.toString(), - close.toString(), - volume.toString() - ) - } } fun BigDecimal.asPercentOf(divisor: BigDecimal): BigDecimal = this.divide(divisor, 20, RoundingMode.CEILING) diff --git a/service/src/main/kotlin/io/provenance/explorer/service/async/ScheduledTaskService.kt b/service/src/main/kotlin/io/provenance/explorer/service/async/ScheduledTaskService.kt index f84f1a36..25f46998 100644 --- a/service/src/main/kotlin/io/provenance/explorer/service/async/ScheduledTaskService.kt +++ b/service/src/main/kotlin/io/provenance/explorer/service/async/ScheduledTaskService.kt @@ -3,7 +3,6 @@ package io.provenance.explorer.service.async import cosmos.authz.v1beta1.msgExec import cosmos.authz.v1beta1.msgGrant import cosmos.authz.v1beta1.msgRevoke -import io.provenance.explorer.VANILLA_MAPPER import io.provenance.explorer.config.ExplorerProperties import io.provenance.explorer.config.ExplorerProperties.Companion.UTILITY_TOKEN import io.provenance.explorer.config.ExplorerProperties.Companion.UTILITY_TOKEN_BASE_DECIMAL_PLACES @@ -13,7 +12,6 @@ import io.provenance.explorer.domain.entities.BlockCacheRecord import io.provenance.explorer.domain.entities.BlockTxCountsCacheRecord import io.provenance.explorer.domain.entities.BlockTxRetryRecord import io.provenance.explorer.domain.entities.CacheKeys -import io.provenance.explorer.domain.entities.CacheUpdateRecord import io.provenance.explorer.domain.entities.ChainMarketRateStatsRecord import io.provenance.explorer.domain.entities.GovProposalRecord import io.provenance.explorer.domain.entities.ProcessQueueRecord @@ -36,16 +34,13 @@ import io.provenance.explorer.domain.entities.ValidatorStateRecord import io.provenance.explorer.domain.extensions.getType import io.provenance.explorer.domain.extensions.height import io.provenance.explorer.domain.extensions.monthToQuarter -import io.provenance.explorer.domain.extensions.percentChange import io.provenance.explorer.domain.extensions.startOfDay import io.provenance.explorer.domain.extensions.toDateTime import io.provenance.explorer.domain.extensions.toThirdDecimal -import io.provenance.explorer.domain.models.OsmosisHistoricalPrice +import io.provenance.explorer.domain.models.HistoricalPrice import io.provenance.explorer.grpc.extensions.getMsgSubTypes import io.provenance.explorer.grpc.extensions.getMsgType import io.provenance.explorer.model.CmcHistoricalQuote -import io.provenance.explorer.model.CmcLatestDataAbbrev -import io.provenance.explorer.model.CmcLatestQuoteAbbrev import io.provenance.explorer.model.CmcQuote import io.provenance.explorer.model.base.USD_UPPER import io.provenance.explorer.service.AccountService @@ -312,12 +307,12 @@ class ScheduledTaskService( if (latest != null) { startDate = latest.timestamp.minusDays(1).startOfDay() } - val dlobRes = tokenService.fetchOsmosisData(startDate) ?: return + val dlobRes = tokenService.fetchLegacyHistoricalPriceData(startDate) ?: return logger.info("Updating token historical data starting from $startDate with ${dlobRes.size} buy records for roll-up.") val baseMap = Interval(startDate, today) .let { int -> generateSequence(int.start) { dt -> dt.plusDays(1) }.takeWhile { dt -> dt < int.end } } - .map { it to emptyList() }.toMap().toMutableMap() + .map { it to emptyList() }.toMap().toMutableMap() var prevPrice = TokenHistoricalDailyRecord.lastKnownPriceForDate(startDate) baseMap.putAll( @@ -359,33 +354,15 @@ class ScheduledTaskService( @Scheduled(cron = "0 0/5 * * * ?") // Every 5 minutes fun updateTokenLatest() { val today = DateTime.now().withZone(DateTimeZone.UTC) - val startDate = today.minusDays(7) - tokenService.fetchOsmosisData(startDate) - ?.sortedBy { it.time } - ?.let { list -> - val prevRecIdx = list.indexOfLast { DateTime(it.time * 1000).isBefore(today.minusDays(1)) } - val prevRecord = list[prevRecIdx] - val price = list.last().close.toThirdDecimal() - val percentChg = if (prevRecIdx == list.lastIndex) { - BigDecimal.ZERO - } else { - price.percentChange(prevRecord.close.toThirdDecimal()) - } - val vol24Hr = if (prevRecIdx == list.lastIndex) { - BigDecimal.ZERO - } else { - list.subList(prevRecIdx + 1, list.lastIndex + 1).sumOf { it.volume.toThirdDecimal() }.stripTrailingZeros() - } - val marketCap = price.multiply(tokenService.totalSupply().divide(UTILITY_TOKEN_BASE_MULTIPLIER)).toThirdDecimal() - val rec = CmcLatestDataAbbrev( - today, - mapOf(USD_UPPER to CmcLatestQuoteAbbrev(price, percentChg, vol24Hr, marketCap, today)) - ) - CacheUpdateRecord.updateCacheByKey( - CacheKeys.UTILITY_TOKEN_LATEST.key, - VANILLA_MAPPER.writeValueAsString(rec) - ) + val startDate = today.minusDays(1) + val list = tokenService.fetchHistoricalPriceData(startDate)?.sortedBy { it.time } + + list?.let { + val latestData = tokenService.processLatestTokenData(it, today) + latestData?.let { data -> + tokenService.cacheLatestTokenData(data) } + } } // Remove once the ranges have been updated diff --git a/service/src/main/kotlin/io/provenance/explorer/service/pricing/fetchers/FetcherConfiguration.kt b/service/src/main/kotlin/io/provenance/explorer/service/pricing/fetchers/FetcherConfiguration.kt new file mode 100644 index 00000000..9f7d47c4 --- /dev/null +++ b/service/src/main/kotlin/io/provenance/explorer/service/pricing/fetchers/FetcherConfiguration.kt @@ -0,0 +1,14 @@ +package io.provenance.explorer.service.pricing.fetchers + +import io.provenance.explorer.grpc.flow.FlowApiGrpcClient +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class FetcherConfiguration { + + @Bean + fun historicalPriceFetcherFactory(flowApiGrpcClient: FlowApiGrpcClient): HistoricalPriceFetcherFactory { + return HistoricalPriceFetcherFactory(flowApiGrpcClient) + } +} diff --git a/service/src/main/kotlin/io/provenance/explorer/service/pricing/fetchers/FlowApiPriceFetcher.kt b/service/src/main/kotlin/io/provenance/explorer/service/pricing/fetchers/FlowApiPriceFetcher.kt new file mode 100644 index 00000000..c437bd77 --- /dev/null +++ b/service/src/main/kotlin/io/provenance/explorer/service/pricing/fetchers/FlowApiPriceFetcher.kt @@ -0,0 +1,62 @@ +package io.provenance.explorer.service.pricing.fetchers + +import io.provenance.explorer.config.ExplorerProperties +import io.provenance.explorer.domain.models.HistoricalPrice +import io.provenance.explorer.grpc.flow.FlowApiGrpcClient +import io.provlabs.flow.api.NavEvent +import org.joda.time.DateTime +import java.math.BigDecimal +import java.math.RoundingMode + +class FlowApiPriceFetcher( + val denom: String, + val pricingDenoms: List, + private val flowApiGrpcClient: FlowApiGrpcClient +) : HistoricalPriceFetcher { + + override fun fetchHistoricalPrice(fromDate: DateTime?): List { + val onChainNavEvents = getMarkerNavByPriceDenoms(fromDate, 17800) + return onChainNavEvents.map { navEvent -> + val volumeHash = calculateVolumeHash(navEvent.volume) + val pricePerHash = getPricePerHashFromMicroUsd(navEvent.priceAmount, navEvent.volume) + HistoricalPrice( + time = navEvent.blockTime, + high = pricePerHash, + low = pricePerHash, + close = pricePerHash, + open = pricePerHash, + volume = pricePerHash.multiply(volumeHash) + ) + } + } + + fun getMarkerNavByPriceDenoms(fromDate: DateTime?, limit: Int): List { + return flowApiGrpcClient.getMarkerNavByPriceDenoms(denom, pricingDenoms, fromDate, limit) + } + + fun calculateVolumeHash(volumeNhash: Long): BigDecimal { + if (volumeNhash == 0L) { + return BigDecimal.ZERO + } + return BigDecimal(volumeNhash).divide(ExplorerProperties.UTILITY_TOKEN_BASE_MULTIPLIER, 10, RoundingMode.HALF_UP) + } + + /** + * Calculates the price per hash unit based on the total price in micro-USD and the volume in nHash. + * + * @param priceAmountMicros The total price in micro-USD (e.g., 123456789 equals $123.456789 USD). + * @param volumeNhash The volume of the transaction in nHash (nano Hash). + * 1 Hash = 1,000,000,000 nHash. + * @return The price per hash unit in USD, rounded down to 3 decimal places. + * Returns 0.0 if the volumeNhash is 0 to avoid division by zero. + */ + fun getPricePerHashFromMicroUsd(priceAmountMicros: Long, volumeNhash: Long): BigDecimal { + if (volumeNhash == 0L) { + return BigDecimal.ZERO + } + val volumeHash = calculateVolumeHash(volumeNhash) + val priceInUsd = BigDecimal(priceAmountMicros).divide(BigDecimal(1_000_000), 10, RoundingMode.HALF_UP) + val pricePerHash = priceInUsd.divide(volumeHash, 10, RoundingMode.HALF_UP) + return pricePerHash.setScale(3, RoundingMode.FLOOR) + } +} diff --git a/service/src/main/kotlin/io/provenance/explorer/service/pricing/fetchers/HistoricalPriceFetcher.kt b/service/src/main/kotlin/io/provenance/explorer/service/pricing/fetchers/HistoricalPriceFetcher.kt new file mode 100644 index 00000000..76ef7f47 --- /dev/null +++ b/service/src/main/kotlin/io/provenance/explorer/service/pricing/fetchers/HistoricalPriceFetcher.kt @@ -0,0 +1,8 @@ +package io.provenance.explorer.service.pricing.fetchers + +import io.provenance.explorer.domain.models.HistoricalPrice +import org.joda.time.DateTime + +interface HistoricalPriceFetcher { + fun fetchHistoricalPrice(fromDate: DateTime?): List +} diff --git a/service/src/main/kotlin/io/provenance/explorer/service/pricing/fetchers/HistoricalPriceFetcherFactory.kt b/service/src/main/kotlin/io/provenance/explorer/service/pricing/fetchers/HistoricalPriceFetcherFactory.kt new file mode 100644 index 00000000..8fd4302e --- /dev/null +++ b/service/src/main/kotlin/io/provenance/explorer/service/pricing/fetchers/HistoricalPriceFetcherFactory.kt @@ -0,0 +1,21 @@ +package io.provenance.explorer.service.pricing.fetchers + +import io.provenance.explorer.config.ExplorerProperties.Companion.UTILITY_TOKEN +import io.provenance.explorer.grpc.flow.FlowApiGrpcClient + +class HistoricalPriceFetcherFactory( + private val flowApiGrpcClient: FlowApiGrpcClient +) { + fun createNhashFetchers(): List { + return listOf( + OsmosisPriceFetcher(), + FlowApiPriceFetcher(UTILITY_TOKEN, listOf("uusd.trading", "uusdc.figure.se", "uusdt.figure.se"), flowApiGrpcClient) + ) + } + + fun createOsmosisPriceFetcher(): List { + return listOf( + OsmosisPriceFetcher() + ) + } +} diff --git a/service/src/main/kotlin/io/provenance/explorer/service/pricing/fetchers/OsmosisPriceFetcher.kt b/service/src/main/kotlin/io/provenance/explorer/service/pricing/fetchers/OsmosisPriceFetcher.kt new file mode 100644 index 00000000..52d40faf --- /dev/null +++ b/service/src/main/kotlin/io/provenance/explorer/service/pricing/fetchers/OsmosisPriceFetcher.kt @@ -0,0 +1,111 @@ +package io.provenance.explorer.service.pricing.fetchers + +import io.ktor.client.call.body +import io.ktor.client.plugins.ResponseException +import io.ktor.client.request.accept +import io.ktor.client.request.get +import io.ktor.client.statement.HttpResponse +import io.ktor.client.statement.bodyAsText +import io.ktor.http.ContentType +import io.provenance.explorer.KTOR_CLIENT_JAVA +import io.provenance.explorer.domain.core.logger +import io.provenance.explorer.domain.models.HistoricalPrice +import io.provenance.explorer.domain.models.OsmosisApiResponse +import io.provenance.explorer.domain.models.OsmosisHistoricalPrice +import kotlinx.coroutines.runBlocking +import org.joda.time.DateTime +import org.joda.time.DateTimeZone +import org.joda.time.Duration +import java.net.URLEncoder + +class OsmosisPriceFetcher : HistoricalPriceFetcher { + + val logger = logger(OsmosisPriceFetcher::class) + override fun fetchHistoricalPrice(fromDate: DateTime?): List { + val osmosisHistoricalPrices = fetchOsmosisData(fromDate) + return osmosisHistoricalPrices.map { osmosisPrice -> + HistoricalPrice( + time = osmosisPrice.time, + high = osmosisPrice.high, + low = osmosisPrice.low, + close = osmosisPrice.close, + open = osmosisPrice.open, + volume = osmosisPrice.volume + ) + } + } + + fun fetchOsmosisData(fromDate: DateTime?): List = runBlocking { + val input = buildInputQuery(fromDate, determineTimeFrame(fromDate)) + try { + val url = """https://app.osmosis.zone/api/edge-trpc-assets/assets.getAssetHistoricalPrice?input=$input""" + logger.debug("Calling $url with fromDate $fromDate") + val response: HttpResponse = KTOR_CLIENT_JAVA.get(url) { + accept(ContentType.Application.Json) + } + + val rawResponse: String = response.bodyAsText() + logger.debug("Osmosis GET: $url Raw Response: $rawResponse") + + val osmosisApiResponse: OsmosisApiResponse = response.body() + osmosisApiResponse.result.data.json + } catch (e: ResponseException) { + logger.error("Error fetching from Osmosis API: ${e.response}", e) + emptyList() + } catch (e: Exception) { + logger.error("Error fetching from Osmosis API: ${e.message}", e) + emptyList() + } + } + + enum class TimeFrame(val minutes: Int) { + FIVE_MINUTES(5), + TWO_HOURS(120), + ONE_DAY(1440) + } + + /** + * Determines the appropriate TimeFrame based on the fromDate. + * + * @param fromDate The starting date to determine the time frame. + * @return The appropriate TimeFrame enum value. + */ + fun determineTimeFrame(fromDate: DateTime?): TimeFrame { + val now = DateTime.now(DateTimeZone.UTC) + val duration = Duration(fromDate, now) + return when { + duration.standardDays <= 14 -> TimeFrame.FIVE_MINUTES + duration.standardDays <= 60 -> TimeFrame.TWO_HOURS + else -> TimeFrame.ONE_DAY + } + } + + /** + * Builds the input query parameter for fetching historical data. + * + * This function constructs a URL-encoded JSON query parameter for fetching historical data based on the given + * `fromDate` and `timeFrame`. The `timeFrame` represents the number of minutes between updates. The allowed values + * for `timeFrame` are defined in the `TimeFrame` enum: + * - FIVE_MINUTES: data goes back 2 weeks. + * - TWO_HOURS: data goes back 2 months. + * - ONE_DAY: data goes back to the beginning of time. + * + * The function calculates the total number of frames (`numRecentFrames`) from the `fromDate` to the current time, + * based on the specified `timeFrame`. + * + * @param fromDate The starting date from which to calculate the number of frames. + * @param timeFrame The time interval between updates, specified as a `TimeFrame` enum value. + * @return A URL-encoded JSON string to be used as a query parameter for fetching historical data. + */ + fun buildInputQuery(fromDate: DateTime?, timeFrame: TimeFrame): String { + val coinDenom = "ibc/CE5BFF1D9BADA03BB5CCA5F56939392A761B53A10FBD03B37506669C3218D3B2" + val coinMinimalDenom = "ibc/CE5BFF1D9BADA03BB5CCA5F56939392A761B53A10FBD03B37506669C3218D3B2" + val now = DateTime.now(DateTimeZone.UTC) + val duration = Duration(fromDate, now) + val numRecentFrames = (duration.standardMinutes / timeFrame.minutes).toInt() + return URLEncoder.encode( + """{"json":{"coinDenom":"$coinDenom","coinMinimalDenom":"$coinMinimalDenom","timeFrame":{"custom":{"timeFrame":${timeFrame.minutes},"numRecentFrames":$numRecentFrames}}}}""", + "UTF-8" + ) + } +} diff --git a/service/src/main/resources/application-container.properties b/service/src/main/resources/application-container.properties index fa6c85e7..83d77da5 100644 --- a/service/src/main/resources/application-container.properties +++ b/service/src/main/resources/application-container.properties @@ -10,6 +10,7 @@ explorer.spotlight-ttl-ms=${SPOTLIGHT_TTL_MS} explorer.initial-historical-day-count=${INITIAL_HIST_DAY_COUNT} explorer.mainnet=${EXPLORER_MAINNET} explorer.pb-url=${EXPLORER_PB_URL} +explorer.flow-api-url=${EXPLORER_FLOW_API_URL} explorer.genesis-version-url=${EXPLORER_GENESIS_VERSION_URL} explorer.upgrade-version-regex=${EXPLORER_UPGRADE_VERSION_REGEX} explorer.upgrade-github-repo=${EXPLORER_UPGRADE_GITHUB_REPO} diff --git a/service/src/main/resources/application-development.properties b/service/src/main/resources/application-development.properties index 53ce166b..993079bd 100644 --- a/service/src/main/resources/application-development.properties +++ b/service/src/main/resources/application-development.properties @@ -7,6 +7,7 @@ spring.datasource.hikari.schema=explorer spring.datasource.hikari.maximum-pool-size=40 #explorer.pb-url=http://localhost:9090 +explorer.flow-api-url=http://localhost:50051 explorer.initial-historical-day-count=14 explorer.spotlight-ttl-ms=5000 explorer.upgrade-version-regex=(v[0-9]+.[0-9]+.[0-9]+[-\\w\\d]*) diff --git a/service/src/test/kotlin/io/provenance/explorer/service/TokenServiceTest.kt b/service/src/test/kotlin/io/provenance/explorer/service/TokenServiceTest.kt index 524c2b9e..277ce959 100644 --- a/service/src/test/kotlin/io/provenance/explorer/service/TokenServiceTest.kt +++ b/service/src/test/kotlin/io/provenance/explorer/service/TokenServiceTest.kt @@ -1,11 +1,11 @@ package io.provenance.explorer.service -import io.provenance.explorer.domain.models.OsmosisHistoricalPrice +import io.provenance.explorer.domain.models.HistoricalPrice +import io.provenance.explorer.grpc.flow.FlowApiGrpcClient import io.provenance.explorer.grpc.v1.AccountGrpcClient +import io.provenance.explorer.service.pricing.fetchers.HistoricalPriceFetcherFactory import kotlinx.coroutines.runBlocking import org.joda.time.DateTime -import org.joda.time.DateTimeZone -import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -14,51 +14,77 @@ import java.net.URI class TokenServiceTest { private lateinit var accountClient: AccountGrpcClient + private lateinit var flowApiGrpcClient: FlowApiGrpcClient + private lateinit var historicalPriceFetcherFactory: HistoricalPriceFetcherFactory private lateinit var tokenService: TokenService @BeforeEach fun setUp() { - accountClient = AccountGrpcClient(URI("https://www.google.com")) - tokenService = TokenService(accountClient) + accountClient = AccountGrpcClient(URI("http://localhost:26657")) + flowApiGrpcClient = FlowApiGrpcClient(URI("http://localhost:50051")) + historicalPriceFetcherFactory = HistoricalPriceFetcherFactory(flowApiGrpcClient) // Set the factory as needed + tokenService = TokenService(accountClient, historicalPriceFetcherFactory) } @Test @Disabled("Test was used to manually call the endpoint") - fun `test fetchOsmosisData and print results`() = runBlocking { - val fromDate = DateTime.parse("2024-05-08") + fun `test fetchHistoricalPriceData`() = runBlocking { + val fromDate = DateTime.now().minusDays(7) - val result: List = tokenService.fetchOsmosisData(fromDate) + val result: List = tokenService.fetchHistoricalPriceData(fromDate) result.forEach { - println("Time: ${DateTime(it.time * 1000)}, Open: ${it.open}, High: ${it.high}, Low: ${it.low}, Close: ${it.close}, Volume: ${it.volume}") + println("Time: ${DateTime(it.time)}, Open: ${it.open}, High: ${it.high}, Low: ${it.low}, Close: ${it.close}, Volume: ${it.volume}") } + + assert(result.isNotEmpty()) { "Expected non-empty list of HistoricalPrice" } } @Test - fun `test determineTimeFrame`() { - val now = DateTime.now(DateTimeZone.UTC) + @Disabled("Test was used to manually call the endpoint") + fun `test fetchHistoricalPriceData and process `() = runBlocking { + val fromDate = DateTime.now().minusDays(1) + + val result: List = tokenService.fetchHistoricalPriceData(fromDate) - val fromDate1 = now.minusDays(10) - val timeFrame1 = tokenService.determineTimeFrame(fromDate1) - assertEquals(TokenService.TimeFrame.FIVE_MINUTES, timeFrame1) + tokenService.processLatestTokenData(result, fromDate) - val fromDate2 = now.minusDays(30) - val timeFrame2 = tokenService.determineTimeFrame(fromDate2) - assertEquals(TokenService.TimeFrame.TWO_HOURS, timeFrame2) + result.forEach { + println("Time: ${DateTime(it.time)}, Open: ${it.open}, High: ${it.high}, Low: ${it.low}, Close: ${it.close}, Volume: ${it.volume}") + } - val fromDate3 = now.minusDays(90) - val timeFrame3 = tokenService.determineTimeFrame(fromDate3) - assertEquals(TokenService.TimeFrame.ONE_DAY, timeFrame3) + assert(result.isNotEmpty()) { "Expected non-empty list of HistoricalPrice" } } @Test - fun `test buildInputQuery`() { - val now = DateTime.now(DateTimeZone.UTC) - - val fromDate1 = now.minusDays(10) - val timeFrame1 = TokenService.TimeFrame.FIVE_MINUTES - val inputQuery1 = tokenService.buildInputQuery(fromDate1, timeFrame1) - val expectedQuery1 = """%7B%22json%22%3A%7B%22coinDenom%22%3A%22ibc%2FCE5BFF1D9BADA03BB5CCA5F56939392A761B53A10FBD03B37506669C3218D3B2%22%2C%22coinMinimalDenom%22%3A%22ibc%2FCE5BFF1D9BADA03BB5CCA5F56939392A761B53A10FBD03B37506669C3218D3B2%22%2C%22timeFrame%22%3A%7B%22custom%22%3A%7B%22timeFrame%22%3A5%2C%22numRecentFrames%22%3A2880%7D%7D%7D%7D""" - assertEquals(expectedQuery1, inputQuery1) + @Disabled("Test was used to manually call the endpoint") + fun `test fetchLegacyHistoricalPriceData`() = runBlocking { + val fromDate = DateTime.now().minusDays(7) + + val result: List = tokenService.fetchLegacyHistoricalPriceData(fromDate) + + result.forEach { + println("Time: ${DateTime(it.time)}, Open: ${it.open}, High: ${it.high}, Low: ${it.low}, Close: ${it.close}, Volume: ${it.volume}") + } + + assert(result.isNotEmpty()) { "Expected non-empty list of HistoricalPrice" } + } + + @Test + @Disabled("Test was used to manually call the endpoint") + fun `test getTokenDistributionStats`() { + val result = tokenService.getTokenDistributionStats() + println(result) + assert(result.isNotEmpty()) { "Expected non-empty token distribution stats" } + } + + @Test + @Disabled("Test was used to manually call the endpoint") + fun `test getTokenBreakdown`() = runBlocking { + val result = tokenService.getTokenBreakdown() + println("Max supply: ${result.maxSupply}") + println("Community pool supply: ${result.communityPool}") + println("Bonded supply: ${result.bonded}") + println("Burned supply: ${result.burned}") } } diff --git a/service/src/test/kotlin/io/provenance/explorer/service/pricing/fetchers/FlowApiPriceFetcherTest.kt b/service/src/test/kotlin/io/provenance/explorer/service/pricing/fetchers/FlowApiPriceFetcherTest.kt new file mode 100644 index 00000000..f1669505 --- /dev/null +++ b/service/src/test/kotlin/io/provenance/explorer/service/pricing/fetchers/FlowApiPriceFetcherTest.kt @@ -0,0 +1,83 @@ +package io.provenance.explorer.service.pricing.fetchers + +import io.provenance.explorer.config.ExplorerProperties +import io.provenance.explorer.domain.models.HistoricalPrice +import io.provenance.explorer.grpc.flow.FlowApiGrpcClient +import io.provlabs.flow.api.NavEvent +import org.joda.time.DateTime +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import java.math.BigDecimal +import java.net.URI + +class FlowApiPriceFetcherTest { + + private lateinit var flowApiPriceFetcher: FlowApiPriceFetcher + + @BeforeEach + fun setUp() { + flowApiPriceFetcher = FlowApiPriceFetcher( + ExplorerProperties.UTILITY_TOKEN, + listOf("uusd.trading", "uusdc.figure.se"), + FlowApiGrpcClient(URI("http://localhost:50051")) + ) + } + + @Test + @Disabled("Test was used to manually call the endpoint") + fun `test fetchHistoricalPrice and print results`() { + val fromDate = DateTime.now().minusDays(1) + + val result: List = flowApiPriceFetcher.fetchHistoricalPrice(fromDate) + result.forEach { + println("Time: ${DateTime(it.time * 1000)}, Open: ${it.open}, High: ${it.high}, Low: ${it.low}, Close: ${it.close}, Volume: ${it.volume}") + } + + val totalVolume = result.sumOf { it.volume } + println("Total Volume: $totalVolume") + } + + @Test + @Disabled("Test was used to manually call the endpoint") + fun `test getMarkerNavByPriceDenoms and print results`() { + val fromDate = DateTime.now().minusDays(1) + val limit = 100 + + val result: List = flowApiPriceFetcher.getMarkerNavByPriceDenoms(fromDate, limit) + + val groupedByPriceDenom = result.groupBy { it.priceDenom } + + groupedByPriceDenom.forEach { (priceDenom, events) -> + println("PriceDenom: $priceDenom, Count: ${events.size}") + } + + result.forEach { navEvent -> + val pricePerHash = flowApiPriceFetcher.getPricePerHashFromMicroUsd(navEvent.priceAmount, navEvent.volume) + println("NavEvent: Time=${DateTime(navEvent.blockTime * 1000)}, PriceDenom=${navEvent.priceDenom}, Hash Price: $pricePerHash") + } + + assert(result.isNotEmpty()) { "Expected non-empty NavEvent list" } + } + + @Test + fun `test calculatePricePerHashFromMicroUsd`() { + var result = flowApiPriceFetcher.getPricePerHashFromMicroUsd( + 4800000000L, + 300000000000000 + ) + assertEquals(BigDecimal("0.016"), result, "Price per hash calculation is incorrect") + + result = flowApiPriceFetcher.getPricePerHashFromMicroUsd(12345L, 0L) + assertEquals(BigDecimal.ZERO, result, "Should return 0.0 when volume is 0") + } + + @Test + fun `test calculateVolumeHash`() { + val volumeNhash = 1000000000000L + val result = flowApiPriceFetcher.calculateVolumeHash(volumeNhash) + val expected = 1000.0.toBigDecimal().setScale(10) + assertEquals(expected, result, "Volume hash calculation is incorrect") + } +} diff --git a/service/src/test/kotlin/io/provenance/explorer/service/pricing/fetchers/HistoricalPriceFetcherFactoryTest.kt b/service/src/test/kotlin/io/provenance/explorer/service/pricing/fetchers/HistoricalPriceFetcherFactoryTest.kt new file mode 100644 index 00000000..de0ea8b5 --- /dev/null +++ b/service/src/test/kotlin/io/provenance/explorer/service/pricing/fetchers/HistoricalPriceFetcherFactoryTest.kt @@ -0,0 +1,40 @@ +package io.provenance.explorer.service.pricing.fetchers + +import io.provenance.explorer.config.ExplorerProperties.Companion.UTILITY_TOKEN +import io.provenance.explorer.grpc.flow.FlowApiGrpcClient +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import java.net.URI + +class HistoricalPriceFetcherFactoryTest { + + private lateinit var flowApiGrpcClient: FlowApiGrpcClient + private lateinit var factory: HistoricalPriceFetcherFactory + + @BeforeEach + fun setUp() { + flowApiGrpcClient = FlowApiGrpcClient(URI("http://localhost:50051")) + factory = HistoricalPriceFetcherFactory(flowApiGrpcClient) + } + + @Test + fun `test createNhashFetchers`() { + val fetchers = factory.createNhashFetchers() + assertEquals(2, fetchers.size) + assertTrue(fetchers[0] is OsmosisPriceFetcher) + assertTrue(fetchers[1] is FlowApiPriceFetcher) + + val flowApiPriceFetcher = fetchers[1] as FlowApiPriceFetcher + assertEquals(UTILITY_TOKEN, flowApiPriceFetcher.denom) + assertEquals(listOf("uusd.trading", "uusdc.figure.se", "uusdt.figure.se"), flowApiPriceFetcher.pricingDenoms) + } + + @Test + fun `test createOsmosisPriceFetcher`() { + val fetchers = factory.createOsmosisPriceFetcher() + assertEquals(1, fetchers.size) + assertTrue(fetchers[0] is OsmosisPriceFetcher) + } +} diff --git a/service/src/test/kotlin/io/provenance/explorer/service/pricing/fetchers/OsmosisPriceFetcherTest.kt b/service/src/test/kotlin/io/provenance/explorer/service/pricing/fetchers/OsmosisPriceFetcherTest.kt new file mode 100644 index 00000000..7cb0bec0 --- /dev/null +++ b/service/src/test/kotlin/io/provenance/explorer/service/pricing/fetchers/OsmosisPriceFetcherTest.kt @@ -0,0 +1,61 @@ +package io.provenance.explorer.service.pricing.fetchers + +import io.provenance.explorer.domain.models.OsmosisHistoricalPrice +import kotlinx.coroutines.runBlocking +import org.joda.time.DateTime +import org.joda.time.DateTimeZone +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +class OsmosisPriceFetcherTest { + + private lateinit var osmosisPriceFetcher: OsmosisPriceFetcher + + @BeforeEach + fun setUp() { + osmosisPriceFetcher = OsmosisPriceFetcher() + } + + @Test + @Disabled("Test was used to manually call the endpoint") + fun `test fetchOsmosisData and print results`() = runBlocking { + val fromDate = DateTime.parse("2024-10-01") + + val result: List = osmosisPriceFetcher.fetchOsmosisData(fromDate) + result.forEach { + println("Time: ${DateTime(it.time * 1000)}, Open: ${it.open}, High: ${it.high}, Low: ${it.low}, Close: ${it.close}, Volume: ${it.volume}") + } + val totalVolume = result.sumOf { it.volume } + println("Total Volume: $totalVolume") + } + + @Test + fun `test determineTimeFrame`() { + val now = DateTime.now(DateTimeZone.UTC) + + val fromDate1 = now.minusDays(10) + val timeFrame1 = osmosisPriceFetcher.determineTimeFrame(fromDate1) + assertEquals(OsmosisPriceFetcher.TimeFrame.FIVE_MINUTES, timeFrame1) + + val fromDate2 = now.minusDays(30) + val timeFrame2 = osmosisPriceFetcher.determineTimeFrame(fromDate2) + assertEquals(OsmosisPriceFetcher.TimeFrame.TWO_HOURS, timeFrame2) + + val fromDate3 = now.minusDays(90) + val timeFrame3 = osmosisPriceFetcher.determineTimeFrame(fromDate3) + assertEquals(OsmosisPriceFetcher.TimeFrame.ONE_DAY, timeFrame3) + } + + @Test + fun `test buildInputQuery`() { + val now = DateTime.now(DateTimeZone.UTC) + + val fromDate1 = now.minusDays(10) + val timeFrame1 = OsmosisPriceFetcher.TimeFrame.FIVE_MINUTES + val inputQuery1 = osmosisPriceFetcher.buildInputQuery(fromDate1, timeFrame1) + val expectedQuery1 = """%7B%22json%22%3A%7B%22coinDenom%22%3A%22ibc%2FCE5BFF1D9BADA03BB5CCA5F56939392A761B53A10FBD03B37506669C3218D3B2%22%2C%22coinMinimalDenom%22%3A%22ibc%2FCE5BFF1D9BADA03BB5CCA5F56939392A761B53A10FBD03B37506669C3218D3B2%22%2C%22timeFrame%22%3A%7B%22custom%22%3A%7B%22timeFrame%22%3A5%2C%22numRecentFrames%22%3A2880%7D%7D%7D%7D""" + assertEquals(expectedQuery1, inputQuery1) + } +}