diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fff9a0b..17794114 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features * Add hash price support for nav values from on chain events [#543](https://github.com/provenance-io/explorer-service/pull/543) * Integrate on-chain NAV data into historical hash price calculations [#555](https://github.com/provenance-io/explorer-service/pull/555) +* Use on-chain NAV data for latest asset pricing on markers [#556](https://github.com/provenance-io/explorer-service/pull/556) ### Improvements diff --git a/docker/docker-compose-db.yml b/docker/docker-compose-db.yml index 9daf381c..8b9b512a 100644 --- a/docker/docker-compose-db.yml +++ b/docker/docker-compose-db.yml @@ -1,4 +1,3 @@ -version: '3.5' services: explorer-postgres: image: postgres:13.2 @@ -15,19 +14,3 @@ services: volumes: pg-local-testnet: -# -#services: -# explorer-postgres: -# image: postgres:13.2 -# container_name: postgres-local-mainnet -# environment: -# - POSTGRES_USER=postgres -# - POSTGRES_PASSWORD=password1 -# ports: -# - 5432:5432 -# volumes: -# - ./db-init:/docker-entrypoint-initdb.d/ # inits the db with username/password -# - pg-local-mainnet:/var/lib/postgresql/data -# -#volumes: -# pg-local-mainnet: diff --git a/service/src/main/java/io/provlabs/flow/api/LatestNavEventRequest.java b/service/src/main/java/io/provlabs/flow/api/LatestNavEventRequest.java new file mode 100644 index 00000000..37bc8cc6 --- /dev/null +++ b/service/src/main/java/io/provlabs/flow/api/LatestNavEventRequest.java @@ -0,0 +1,1159 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: nav_event.proto + +package io.provlabs.flow.api; + +/** + *
+ * LatestNavEventRequest represents a request for the latest NAV events by price denom.
+ * It requires a price denomination and at least one of `include_markers` or `include_scope` to be true.
+ * 
+ * + * Protobuf type {@code nav.LatestNavEventRequest} + */ +public final class LatestNavEventRequest extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:nav.LatestNavEventRequest) + LatestNavEventRequestOrBuilder { +private static final long serialVersionUID = 0L; + // Use LatestNavEventRequest.newBuilder() to construct. + private LatestNavEventRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private LatestNavEventRequest() { + priceDenom_ = ""; + fromDate_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new LatestNavEventRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private LatestNavEventRequest( + 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 10: { + java.lang.String s = input.readStringRequireUtf8(); + + priceDenom_ = s; + break; + } + case 16: { + + includeMarkers_ = input.readBool(); + break; + } + case 24: { + + includeScope_ = input.readBool(); + break; + } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); + + fromDate_ = s; + break; + } + case 42: { + io.provlabs.flow.api.PaginationRequest.Builder subBuilder = null; + if (pagination_ != null) { + subBuilder = pagination_.toBuilder(); + } + pagination_ = input.readMessage(io.provlabs.flow.api.PaginationRequest.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(pagination_); + pagination_ = subBuilder.buildPartial(); + } + + 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_LatestNavEventRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_LatestNavEventRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.provlabs.flow.api.LatestNavEventRequest.class, io.provlabs.flow.api.LatestNavEventRequest.Builder.class); + } + + public static final int PRICE_DENOM_FIELD_NUMBER = 1; + private volatile java.lang.Object priceDenom_; + /** + *
+   * The denomination of the price to filter by.
+   * 
+ * + * string price_denom = 1; + * @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 to filter by.
+   * 
+ * + * string price_denom = 1; + * @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 INCLUDE_MARKERS_FIELD_NUMBER = 2; + private boolean includeMarkers_; + /** + *
+   * Boolean to include markers in the result.
+   * 
+ * + * bool include_markers = 2; + * @return The includeMarkers. + */ + @java.lang.Override + public boolean getIncludeMarkers() { + return includeMarkers_; + } + + public static final int INCLUDE_SCOPE_FIELD_NUMBER = 3; + private boolean includeScope_; + /** + *
+   * Boolean to include scope in the result.
+   * 
+ * + * bool include_scope = 3; + * @return The includeScope. + */ + @java.lang.Override + public boolean getIncludeScope() { + return includeScope_; + } + + 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 from.
+   * 
+ * + * 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 from.
+   * 
+ * + * 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 PAGINATION_FIELD_NUMBER = 5; + private io.provlabs.flow.api.PaginationRequest pagination_; + /** + *
+   * Pagination details for the request
+   * 
+ * + * .nav.PaginationRequest pagination = 5; + * @return Whether the pagination field is set. + */ + @java.lang.Override + public boolean hasPagination() { + return pagination_ != null; + } + /** + *
+   * Pagination details for the request
+   * 
+ * + * .nav.PaginationRequest pagination = 5; + * @return The pagination. + */ + @java.lang.Override + public io.provlabs.flow.api.PaginationRequest getPagination() { + return pagination_ == null ? io.provlabs.flow.api.PaginationRequest.getDefaultInstance() : pagination_; + } + /** + *
+   * Pagination details for the request
+   * 
+ * + * .nav.PaginationRequest pagination = 5; + */ + @java.lang.Override + public io.provlabs.flow.api.PaginationRequestOrBuilder getPaginationOrBuilder() { + return getPagination(); + } + + 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 (!getPriceDenomBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, priceDenom_); + } + if (includeMarkers_ != false) { + output.writeBool(2, includeMarkers_); + } + if (includeScope_ != false) { + output.writeBool(3, includeScope_); + } + if (!getFromDateBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, fromDate_); + } + if (pagination_ != null) { + output.writeMessage(5, getPagination()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getPriceDenomBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, priceDenom_); + } + if (includeMarkers_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(2, includeMarkers_); + } + if (includeScope_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(3, includeScope_); + } + if (!getFromDateBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, fromDate_); + } + if (pagination_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, getPagination()); + } + 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.LatestNavEventRequest)) { + return super.equals(obj); + } + io.provlabs.flow.api.LatestNavEventRequest other = (io.provlabs.flow.api.LatestNavEventRequest) obj; + + if (!getPriceDenom() + .equals(other.getPriceDenom())) return false; + if (getIncludeMarkers() + != other.getIncludeMarkers()) return false; + if (getIncludeScope() + != other.getIncludeScope()) return false; + if (!getFromDate() + .equals(other.getFromDate())) return false; + if (hasPagination() != other.hasPagination()) return false; + if (hasPagination()) { + if (!getPagination() + .equals(other.getPagination())) 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) + PRICE_DENOM_FIELD_NUMBER; + hash = (53 * hash) + getPriceDenom().hashCode(); + hash = (37 * hash) + INCLUDE_MARKERS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getIncludeMarkers()); + hash = (37 * hash) + INCLUDE_SCOPE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getIncludeScope()); + hash = (37 * hash) + FROM_DATE_FIELD_NUMBER; + hash = (53 * hash) + getFromDate().hashCode(); + if (hasPagination()) { + hash = (37 * hash) + PAGINATION_FIELD_NUMBER; + hash = (53 * hash) + getPagination().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static io.provlabs.flow.api.LatestNavEventRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.provlabs.flow.api.LatestNavEventRequest 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.LatestNavEventRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.provlabs.flow.api.LatestNavEventRequest 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.LatestNavEventRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.provlabs.flow.api.LatestNavEventRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.provlabs.flow.api.LatestNavEventRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.provlabs.flow.api.LatestNavEventRequest 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.LatestNavEventRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static io.provlabs.flow.api.LatestNavEventRequest 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.LatestNavEventRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.provlabs.flow.api.LatestNavEventRequest 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.LatestNavEventRequest 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; + } + /** + *
+   * LatestNavEventRequest represents a request for the latest NAV events by price denom.
+   * It requires a price denomination and at least one of `include_markers` or `include_scope` to be true.
+   * 
+ * + * Protobuf type {@code nav.LatestNavEventRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:nav.LatestNavEventRequest) + io.provlabs.flow.api.LatestNavEventRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_LatestNavEventRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_LatestNavEventRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.provlabs.flow.api.LatestNavEventRequest.class, io.provlabs.flow.api.LatestNavEventRequest.Builder.class); + } + + // Construct using io.provlabs.flow.api.LatestNavEventRequest.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(); + priceDenom_ = ""; + + includeMarkers_ = false; + + includeScope_ = false; + + fromDate_ = ""; + + if (paginationBuilder_ == null) { + pagination_ = null; + } else { + pagination_ = null; + paginationBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_LatestNavEventRequest_descriptor; + } + + @java.lang.Override + public io.provlabs.flow.api.LatestNavEventRequest getDefaultInstanceForType() { + return io.provlabs.flow.api.LatestNavEventRequest.getDefaultInstance(); + } + + @java.lang.Override + public io.provlabs.flow.api.LatestNavEventRequest build() { + io.provlabs.flow.api.LatestNavEventRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public io.provlabs.flow.api.LatestNavEventRequest buildPartial() { + io.provlabs.flow.api.LatestNavEventRequest result = new io.provlabs.flow.api.LatestNavEventRequest(this); + result.priceDenom_ = priceDenom_; + result.includeMarkers_ = includeMarkers_; + result.includeScope_ = includeScope_; + result.fromDate_ = fromDate_; + if (paginationBuilder_ == null) { + result.pagination_ = pagination_; + } else { + result.pagination_ = paginationBuilder_.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.LatestNavEventRequest) { + return mergeFrom((io.provlabs.flow.api.LatestNavEventRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.provlabs.flow.api.LatestNavEventRequest other) { + if (other == io.provlabs.flow.api.LatestNavEventRequest.getDefaultInstance()) return this; + if (!other.getPriceDenom().isEmpty()) { + priceDenom_ = other.priceDenom_; + onChanged(); + } + if (other.getIncludeMarkers() != false) { + setIncludeMarkers(other.getIncludeMarkers()); + } + if (other.getIncludeScope() != false) { + setIncludeScope(other.getIncludeScope()); + } + if (!other.getFromDate().isEmpty()) { + fromDate_ = other.fromDate_; + onChanged(); + } + if (other.hasPagination()) { + mergePagination(other.getPagination()); + } + 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.LatestNavEventRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.provlabs.flow.api.LatestNavEventRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object priceDenom_ = ""; + /** + *
+     * The denomination of the price to filter by.
+     * 
+ * + * string price_denom = 1; + * @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 to filter by.
+     * 
+ * + * string price_denom = 1; + * @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 to filter by.
+     * 
+ * + * string price_denom = 1; + * @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 to filter by.
+     * 
+ * + * string price_denom = 1; + * @return This builder for chaining. + */ + public Builder clearPriceDenom() { + + priceDenom_ = getDefaultInstance().getPriceDenom(); + onChanged(); + return this; + } + /** + *
+     * The denomination of the price to filter by.
+     * 
+ * + * string price_denom = 1; + * @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 boolean includeMarkers_ ; + /** + *
+     * Boolean to include markers in the result.
+     * 
+ * + * bool include_markers = 2; + * @return The includeMarkers. + */ + @java.lang.Override + public boolean getIncludeMarkers() { + return includeMarkers_; + } + /** + *
+     * Boolean to include markers in the result.
+     * 
+ * + * bool include_markers = 2; + * @param value The includeMarkers to set. + * @return This builder for chaining. + */ + public Builder setIncludeMarkers(boolean value) { + + includeMarkers_ = value; + onChanged(); + return this; + } + /** + *
+     * Boolean to include markers in the result.
+     * 
+ * + * bool include_markers = 2; + * @return This builder for chaining. + */ + public Builder clearIncludeMarkers() { + + includeMarkers_ = false; + onChanged(); + return this; + } + + private boolean includeScope_ ; + /** + *
+     * Boolean to include scope in the result.
+     * 
+ * + * bool include_scope = 3; + * @return The includeScope. + */ + @java.lang.Override + public boolean getIncludeScope() { + return includeScope_; + } + /** + *
+     * Boolean to include scope in the result.
+     * 
+ * + * bool include_scope = 3; + * @param value The includeScope to set. + * @return This builder for chaining. + */ + public Builder setIncludeScope(boolean value) { + + includeScope_ = value; + onChanged(); + return this; + } + /** + *
+     * Boolean to include scope in the result.
+     * 
+ * + * bool include_scope = 3; + * @return This builder for chaining. + */ + public Builder clearIncludeScope() { + + includeScope_ = false; + onChanged(); + return this; + } + + private java.lang.Object fromDate_ = ""; + /** + *
+     * Optional. The start date (in string format) to filter events from.
+     * 
+ * + * 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 from.
+     * 
+ * + * 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 from.
+     * 
+ * + * 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 from.
+     * 
+ * + * 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 from.
+     * 
+ * + * 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 io.provlabs.flow.api.PaginationRequest pagination_; + private com.google.protobuf.SingleFieldBuilderV3< + io.provlabs.flow.api.PaginationRequest, io.provlabs.flow.api.PaginationRequest.Builder, io.provlabs.flow.api.PaginationRequestOrBuilder> paginationBuilder_; + /** + *
+     * Pagination details for the request
+     * 
+ * + * .nav.PaginationRequest pagination = 5; + * @return Whether the pagination field is set. + */ + public boolean hasPagination() { + return paginationBuilder_ != null || pagination_ != null; + } + /** + *
+     * Pagination details for the request
+     * 
+ * + * .nav.PaginationRequest pagination = 5; + * @return The pagination. + */ + public io.provlabs.flow.api.PaginationRequest getPagination() { + if (paginationBuilder_ == null) { + return pagination_ == null ? io.provlabs.flow.api.PaginationRequest.getDefaultInstance() : pagination_; + } else { + return paginationBuilder_.getMessage(); + } + } + /** + *
+     * Pagination details for the request
+     * 
+ * + * .nav.PaginationRequest pagination = 5; + */ + public Builder setPagination(io.provlabs.flow.api.PaginationRequest value) { + if (paginationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + pagination_ = value; + onChanged(); + } else { + paginationBuilder_.setMessage(value); + } + + return this; + } + /** + *
+     * Pagination details for the request
+     * 
+ * + * .nav.PaginationRequest pagination = 5; + */ + public Builder setPagination( + io.provlabs.flow.api.PaginationRequest.Builder builderForValue) { + if (paginationBuilder_ == null) { + pagination_ = builderForValue.build(); + onChanged(); + } else { + paginationBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+     * Pagination details for the request
+     * 
+ * + * .nav.PaginationRequest pagination = 5; + */ + public Builder mergePagination(io.provlabs.flow.api.PaginationRequest value) { + if (paginationBuilder_ == null) { + if (pagination_ != null) { + pagination_ = + io.provlabs.flow.api.PaginationRequest.newBuilder(pagination_).mergeFrom(value).buildPartial(); + } else { + pagination_ = value; + } + onChanged(); + } else { + paginationBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+     * Pagination details for the request
+     * 
+ * + * .nav.PaginationRequest pagination = 5; + */ + public Builder clearPagination() { + if (paginationBuilder_ == null) { + pagination_ = null; + onChanged(); + } else { + pagination_ = null; + paginationBuilder_ = null; + } + + return this; + } + /** + *
+     * Pagination details for the request
+     * 
+ * + * .nav.PaginationRequest pagination = 5; + */ + public io.provlabs.flow.api.PaginationRequest.Builder getPaginationBuilder() { + + onChanged(); + return getPaginationFieldBuilder().getBuilder(); + } + /** + *
+     * Pagination details for the request
+     * 
+ * + * .nav.PaginationRequest pagination = 5; + */ + public io.provlabs.flow.api.PaginationRequestOrBuilder getPaginationOrBuilder() { + if (paginationBuilder_ != null) { + return paginationBuilder_.getMessageOrBuilder(); + } else { + return pagination_ == null ? + io.provlabs.flow.api.PaginationRequest.getDefaultInstance() : pagination_; + } + } + /** + *
+     * Pagination details for the request
+     * 
+ * + * .nav.PaginationRequest pagination = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + io.provlabs.flow.api.PaginationRequest, io.provlabs.flow.api.PaginationRequest.Builder, io.provlabs.flow.api.PaginationRequestOrBuilder> + getPaginationFieldBuilder() { + if (paginationBuilder_ == null) { + paginationBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + io.provlabs.flow.api.PaginationRequest, io.provlabs.flow.api.PaginationRequest.Builder, io.provlabs.flow.api.PaginationRequestOrBuilder>( + getPagination(), + getParentForChildren(), + isClean()); + pagination_ = null; + } + return paginationBuilder_; + } + @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.LatestNavEventRequest) + } + + // @@protoc_insertion_point(class_scope:nav.LatestNavEventRequest) + private static final io.provlabs.flow.api.LatestNavEventRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new io.provlabs.flow.api.LatestNavEventRequest(); + } + + public static io.provlabs.flow.api.LatestNavEventRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public LatestNavEventRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new LatestNavEventRequest(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.LatestNavEventRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/service/src/main/java/io/provlabs/flow/api/LatestNavEventRequestOrBuilder.java b/service/src/main/java/io/provlabs/flow/api/LatestNavEventRequestOrBuilder.java new file mode 100644 index 00000000..6829016c --- /dev/null +++ b/service/src/main/java/io/provlabs/flow/api/LatestNavEventRequestOrBuilder.java @@ -0,0 +1,96 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: nav_event.proto + +package io.provlabs.flow.api; + +public interface LatestNavEventRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:nav.LatestNavEventRequest) + com.google.protobuf.MessageOrBuilder { + + /** + *
+   * The denomination of the price to filter by.
+   * 
+ * + * string price_denom = 1; + * @return The priceDenom. + */ + java.lang.String getPriceDenom(); + /** + *
+   * The denomination of the price to filter by.
+   * 
+ * + * string price_denom = 1; + * @return The bytes for priceDenom. + */ + com.google.protobuf.ByteString + getPriceDenomBytes(); + + /** + *
+   * Boolean to include markers in the result.
+   * 
+ * + * bool include_markers = 2; + * @return The includeMarkers. + */ + boolean getIncludeMarkers(); + + /** + *
+   * Boolean to include scope in the result.
+   * 
+ * + * bool include_scope = 3; + * @return The includeScope. + */ + boolean getIncludeScope(); + + /** + *
+   * Optional. The start date (in string format) to filter events from.
+   * 
+ * + * string from_date = 4; + * @return The fromDate. + */ + java.lang.String getFromDate(); + /** + *
+   * Optional. The start date (in string format) to filter events from.
+   * 
+ * + * string from_date = 4; + * @return The bytes for fromDate. + */ + com.google.protobuf.ByteString + getFromDateBytes(); + + /** + *
+   * Pagination details for the request
+   * 
+ * + * .nav.PaginationRequest pagination = 5; + * @return Whether the pagination field is set. + */ + boolean hasPagination(); + /** + *
+   * Pagination details for the request
+   * 
+ * + * .nav.PaginationRequest pagination = 5; + * @return The pagination. + */ + io.provlabs.flow.api.PaginationRequest getPagination(); + /** + *
+   * Pagination details for the request
+   * 
+ * + * .nav.PaginationRequest pagination = 5; + */ + io.provlabs.flow.api.PaginationRequestOrBuilder getPaginationOrBuilder(); +} diff --git a/service/src/main/java/io/provlabs/flow/api/NavEventOuterClass.java b/service/src/main/java/io/provlabs/flow/api/NavEventOuterClass.java index 7dafd981..89d35946 100644 --- a/service/src/main/java/io/provlabs/flow/api/NavEventOuterClass.java +++ b/service/src/main/java/io/provlabs/flow/api/NavEventOuterClass.java @@ -14,6 +14,16 @@ public static void registerAllExtensions( registerAllExtensions( (com.google.protobuf.ExtensionRegistryLite) registry); } + static final com.google.protobuf.Descriptors.Descriptor + internal_static_nav_PaginationRequest_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_nav_PaginationRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_nav_PaginationResponse_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_nav_PaginationResponse_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor internal_static_nav_NavEvent_descriptor; static final @@ -24,6 +34,11 @@ public static void registerAllExtensions( static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_nav_NavEventRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_nav_LatestNavEventRequest_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_nav_LatestNavEventRequest_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor internal_static_nav_NavEventResponse_descriptor; static final @@ -38,43 +53,73 @@ public static void registerAllExtensions( 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" + "\n\017nav_event.proto\022\003nav\"4\n\021PaginationRequ" + + "est\022\014\n\004page\030\001 \001(\005\022\021\n\tpage_size\030\002 \001(\005\"T\n\022" + + "PaginationResponse\022\024\n\014current_page\030\001 \001(\005" + + "\022\023\n\013total_pages\030\002 \001(\005\022\023\n\013total_items\030\003 \001" + + "(\005\"\354\001\n\010NavEvent\022\024\n\014block_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\007t" + + "x_hash\030\004 \001(\t\022\023\n\013event_order\030\005 \001(\005\022\022\n\neve" + + "nt_type\030\006 \001(\t\022\020\n\010scope_id\030\007 \001(\t\022\r\n\005denom" + + "\030\010 \001(\t\022\024\n\014price_amount\030\t \001(\003\022\023\n\013price_de" + + "nom\030\n \001(\t\022\016\n\006volume\030\013 \001(\003\022\016\n\006source\030\014 \001(" + + "\t\"\230\001\n\017NavEventRequest\022\r\n\005denom\030\001 \001(\t\022\020\n\010" + + "scope_id\030\002 \001(\t\022\024\n\014price_denoms\030\003 \003(\t\022\021\n\t" + + "from_date\030\004 \001(\t\022\017\n\007to_date\030\005 \001(\t\022*\n\npagi" + + "nation\030\006 \001(\0132\026.nav.PaginationRequest\"\233\001\n" + + "\025LatestNavEventRequest\022\023\n\013price_denom\030\001 " + + "\001(\t\022\027\n\017include_markers\030\002 \001(\010\022\025\n\rinclude_" + + "scope\030\003 \001(\010\022\021\n\tfrom_date\030\004 \001(\t\022*\n\npagina" + + "tion\030\005 \001(\0132\026.nav.PaginationRequest\"b\n\020Na" + + "vEventResponse\022!\n\nnav_events\030\001 \003(\0132\r.nav" + + ".NavEvent\022+\n\npagination\030\002 \001(\0132\027.nav.Pagi" + + "nationResponse2\222\001\n\nNavService\022;\n\014GetNavE" + + "vents\022\024.nav.NavEventRequest\032\025.nav.NavEve" + + "ntResponse\022G\n\022GetLatestNavEvents\022\032.nav.L" + + "atestNavEventRequest\032\025.nav.NavEventRespo" + + "nseB \n\024io.provlabs.flow.apiP\001Z\006/typesb\006p" + + "roto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { }); - internal_static_nav_NavEvent_descriptor = + internal_static_nav_PaginationRequest_descriptor = getDescriptor().getMessageTypes().get(0); + internal_static_nav_PaginationRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_nav_PaginationRequest_descriptor, + new java.lang.String[] { "Page", "PageSize", }); + internal_static_nav_PaginationResponse_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_nav_PaginationResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_nav_PaginationResponse_descriptor, + new java.lang.String[] { "CurrentPage", "TotalPages", "TotalItems", }); + internal_static_nav_NavEvent_descriptor = + getDescriptor().getMessageTypes().get(2); 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); + getDescriptor().getMessageTypes().get(3); 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", }); + new java.lang.String[] { "Denom", "ScopeId", "PriceDenoms", "FromDate", "ToDate", "Pagination", }); + internal_static_nav_LatestNavEventRequest_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_nav_LatestNavEventRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_nav_LatestNavEventRequest_descriptor, + new java.lang.String[] { "PriceDenom", "IncludeMarkers", "IncludeScope", "FromDate", "Pagination", }); internal_static_nav_NavEventResponse_descriptor = - getDescriptor().getMessageTypes().get(2); + getDescriptor().getMessageTypes().get(5); internal_static_nav_NavEventResponse_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_nav_NavEventResponse_descriptor, - new java.lang.String[] { "NavEvents", }); + new java.lang.String[] { "NavEvents", "Pagination", }); } // @@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 index aefc6493..956f9cdf 100644 --- a/service/src/main/java/io/provlabs/flow/api/NavEventRequest.java +++ b/service/src/main/java/io/provlabs/flow/api/NavEventRequest.java @@ -92,9 +92,17 @@ private NavEventRequest( toDate_ = s; break; } - case 48: { + case 50: { + io.provlabs.flow.api.PaginationRequest.Builder subBuilder = null; + if (pagination_ != null) { + subBuilder = pagination_.toBuilder(); + } + pagination_ = input.readMessage(io.provlabs.flow.api.PaginationRequest.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(pagination_); + pagination_ = subBuilder.buildPartial(); + } - limit_ = input.readInt32(); break; } default: { @@ -367,19 +375,42 @@ public java.lang.String getToDate() { } } - public static final int LIMIT_FIELD_NUMBER = 6; - private int limit_; + public static final int PAGINATION_FIELD_NUMBER = 6; + private io.provlabs.flow.api.PaginationRequest pagination_; + /** + *
+   * Pagination details for the request
+   * 
+ * + * .nav.PaginationRequest pagination = 6; + * @return Whether the pagination field is set. + */ + @java.lang.Override + public boolean hasPagination() { + return pagination_ != null; + } /** *
-   * Optional. The maximum number of results to return. If not provided, defaults to 100.
+   * Pagination details for the request
    * 
* - * int32 limit = 6; - * @return The limit. + * .nav.PaginationRequest pagination = 6; + * @return The pagination. */ @java.lang.Override - public int getLimit() { - return limit_; + public io.provlabs.flow.api.PaginationRequest getPagination() { + return pagination_ == null ? io.provlabs.flow.api.PaginationRequest.getDefaultInstance() : pagination_; + } + /** + *
+   * Pagination details for the request
+   * 
+ * + * .nav.PaginationRequest pagination = 6; + */ + @java.lang.Override + public io.provlabs.flow.api.PaginationRequestOrBuilder getPaginationOrBuilder() { + return getPagination(); } private byte memoizedIsInitialized = -1; @@ -411,8 +442,8 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (!getToDateBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 5, toDate_); } - if (limit_ != 0) { - output.writeInt32(6, limit_); + if (pagination_ != null) { + output.writeMessage(6, getPagination()); } unknownFields.writeTo(output); } @@ -443,9 +474,9 @@ public int getSerializedSize() { if (!getToDateBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, toDate_); } - if (limit_ != 0) { + if (pagination_ != null) { size += com.google.protobuf.CodedOutputStream - .computeInt32Size(6, limit_); + .computeMessageSize(6, getPagination()); } size += unknownFields.getSerializedSize(); memoizedSize = size; @@ -472,8 +503,11 @@ public boolean equals(final java.lang.Object obj) { .equals(other.getFromDate())) return false; if (!getToDate() .equals(other.getToDate())) return false; - if (getLimit() - != other.getLimit()) return false; + if (hasPagination() != other.hasPagination()) return false; + if (hasPagination()) { + if (!getPagination() + .equals(other.getPagination())) return false; + } if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -497,8 +531,10 @@ public int hashCode() { 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(); + if (hasPagination()) { + hash = (37 * hash) + PAGINATION_FIELD_NUMBER; + hash = (53 * hash) + getPagination().hashCode(); + } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -647,8 +683,12 @@ public Builder clear() { toDate_ = ""; - limit_ = 0; - + if (paginationBuilder_ == null) { + pagination_ = null; + } else { + pagination_ = null; + paginationBuilder_ = null; + } return this; } @@ -685,7 +725,11 @@ public io.provlabs.flow.api.NavEventRequest buildPartial() { result.priceDenoms_ = priceDenoms_; result.fromDate_ = fromDate_; result.toDate_ = toDate_; - result.limit_ = limit_; + if (paginationBuilder_ == null) { + result.pagination_ = pagination_; + } else { + result.pagination_ = paginationBuilder_.build(); + } onBuilt(); return result; } @@ -760,8 +804,8 @@ public Builder mergeFrom(io.provlabs.flow.api.NavEventRequest other) { toDate_ = other.toDate_; onChanged(); } - if (other.getLimit() != 0) { - setLimit(other.getLimit()); + if (other.hasPagination()) { + mergePagination(other.getPagination()); } this.mergeUnknownFields(other.unknownFields); onChanged(); @@ -1323,47 +1367,159 @@ public Builder setToDateBytes( return this; } - private int limit_ ; + private io.provlabs.flow.api.PaginationRequest pagination_; + private com.google.protobuf.SingleFieldBuilderV3< + io.provlabs.flow.api.PaginationRequest, io.provlabs.flow.api.PaginationRequest.Builder, io.provlabs.flow.api.PaginationRequestOrBuilder> paginationBuilder_; /** *
-     * Optional. The maximum number of results to return. If not provided, defaults to 100.
+     * Pagination details for the request
      * 
* - * int32 limit = 6; - * @return The limit. + * .nav.PaginationRequest pagination = 6; + * @return Whether the pagination field is set. */ - @java.lang.Override - public int getLimit() { - return limit_; + public boolean hasPagination() { + return paginationBuilder_ != null || pagination_ != null; } /** *
-     * Optional. The maximum number of results to return. If not provided, defaults to 100.
+     * Pagination details for the request
      * 
* - * int32 limit = 6; - * @param value The limit to set. - * @return This builder for chaining. + * .nav.PaginationRequest pagination = 6; + * @return The pagination. */ - public Builder setLimit(int value) { - - limit_ = value; - onChanged(); + public io.provlabs.flow.api.PaginationRequest getPagination() { + if (paginationBuilder_ == null) { + return pagination_ == null ? io.provlabs.flow.api.PaginationRequest.getDefaultInstance() : pagination_; + } else { + return paginationBuilder_.getMessage(); + } + } + /** + *
+     * Pagination details for the request
+     * 
+ * + * .nav.PaginationRequest pagination = 6; + */ + public Builder setPagination(io.provlabs.flow.api.PaginationRequest value) { + if (paginationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + pagination_ = value; + onChanged(); + } else { + paginationBuilder_.setMessage(value); + } + return this; } /** *
-     * Optional. The maximum number of results to return. If not provided, defaults to 100.
+     * Pagination details for the request
      * 
* - * int32 limit = 6; - * @return This builder for chaining. + * .nav.PaginationRequest pagination = 6; + */ + public Builder setPagination( + io.provlabs.flow.api.PaginationRequest.Builder builderForValue) { + if (paginationBuilder_ == null) { + pagination_ = builderForValue.build(); + onChanged(); + } else { + paginationBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+     * Pagination details for the request
+     * 
+ * + * .nav.PaginationRequest pagination = 6; + */ + public Builder mergePagination(io.provlabs.flow.api.PaginationRequest value) { + if (paginationBuilder_ == null) { + if (pagination_ != null) { + pagination_ = + io.provlabs.flow.api.PaginationRequest.newBuilder(pagination_).mergeFrom(value).buildPartial(); + } else { + pagination_ = value; + } + onChanged(); + } else { + paginationBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+     * Pagination details for the request
+     * 
+ * + * .nav.PaginationRequest pagination = 6; + */ + public Builder clearPagination() { + if (paginationBuilder_ == null) { + pagination_ = null; + onChanged(); + } else { + pagination_ = null; + paginationBuilder_ = null; + } + + return this; + } + /** + *
+     * Pagination details for the request
+     * 
+ * + * .nav.PaginationRequest pagination = 6; */ - public Builder clearLimit() { + public io.provlabs.flow.api.PaginationRequest.Builder getPaginationBuilder() { - limit_ = 0; onChanged(); - return this; + return getPaginationFieldBuilder().getBuilder(); + } + /** + *
+     * Pagination details for the request
+     * 
+ * + * .nav.PaginationRequest pagination = 6; + */ + public io.provlabs.flow.api.PaginationRequestOrBuilder getPaginationOrBuilder() { + if (paginationBuilder_ != null) { + return paginationBuilder_.getMessageOrBuilder(); + } else { + return pagination_ == null ? + io.provlabs.flow.api.PaginationRequest.getDefaultInstance() : pagination_; + } + } + /** + *
+     * Pagination details for the request
+     * 
+ * + * .nav.PaginationRequest pagination = 6; + */ + private com.google.protobuf.SingleFieldBuilderV3< + io.provlabs.flow.api.PaginationRequest, io.provlabs.flow.api.PaginationRequest.Builder, io.provlabs.flow.api.PaginationRequestOrBuilder> + getPaginationFieldBuilder() { + if (paginationBuilder_ == null) { + paginationBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + io.provlabs.flow.api.PaginationRequest, io.provlabs.flow.api.PaginationRequest.Builder, io.provlabs.flow.api.PaginationRequestOrBuilder>( + getPagination(), + getParentForChildren(), + isClean()); + pagination_ = null; + } + return paginationBuilder_; } @java.lang.Override public final Builder setUnknownFields( diff --git a/service/src/main/java/io/provlabs/flow/api/NavEventRequestOrBuilder.java b/service/src/main/java/io/provlabs/flow/api/NavEventRequestOrBuilder.java index 2d720aae..62276bd1 100644 --- a/service/src/main/java/io/provlabs/flow/api/NavEventRequestOrBuilder.java +++ b/service/src/main/java/io/provlabs/flow/api/NavEventRequestOrBuilder.java @@ -130,11 +130,28 @@ public interface NavEventRequestOrBuilder extends /** *
-   * Optional. The maximum number of results to return. If not provided, defaults to 100.
+   * Pagination details for the request
    * 
* - * int32 limit = 6; - * @return The limit. + * .nav.PaginationRequest pagination = 6; + * @return Whether the pagination field is set. */ - int getLimit(); + boolean hasPagination(); + /** + *
+   * Pagination details for the request
+   * 
+ * + * .nav.PaginationRequest pagination = 6; + * @return The pagination. + */ + io.provlabs.flow.api.PaginationRequest getPagination(); + /** + *
+   * Pagination details for the request
+   * 
+ * + * .nav.PaginationRequest pagination = 6; + */ + io.provlabs.flow.api.PaginationRequestOrBuilder getPaginationOrBuilder(); } diff --git a/service/src/main/java/io/provlabs/flow/api/NavEventResponse.java b/service/src/main/java/io/provlabs/flow/api/NavEventResponse.java index 4fbfc9c9..dcf907d3 100644 --- a/service/src/main/java/io/provlabs/flow/api/NavEventResponse.java +++ b/service/src/main/java/io/provlabs/flow/api/NavEventResponse.java @@ -63,6 +63,19 @@ private NavEventResponse( input.readMessage(io.provlabs.flow.api.NavEvent.parser(), extensionRegistry)); break; } + case 18: { + io.provlabs.flow.api.PaginationResponse.Builder subBuilder = null; + if (pagination_ != null) { + subBuilder = pagination_.toBuilder(); + } + pagination_ = input.readMessage(io.provlabs.flow.api.PaginationResponse.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(pagination_); + pagination_ = subBuilder.buildPartial(); + } + + break; + } default: { if (!parseUnknownField( input, unknownFields, extensionRegistry, tag)) { @@ -101,6 +114,10 @@ private NavEventResponse( public static final int NAV_EVENTS_FIELD_NUMBER = 1; private java.util.List navEvents_; /** + *
+   * The list of NavEvents
+   * 
+ * * repeated .nav.NavEvent nav_events = 1; */ @java.lang.Override @@ -108,6 +125,10 @@ public java.util.List getNavEventsList() { return navEvents_; } /** + *
+   * The list of NavEvents
+   * 
+ * * repeated .nav.NavEvent nav_events = 1; */ @java.lang.Override @@ -116,6 +137,10 @@ public java.util.List getNavEventsList() { return navEvents_; } /** + *
+   * The list of NavEvents
+   * 
+ * * repeated .nav.NavEvent nav_events = 1; */ @java.lang.Override @@ -123,6 +148,10 @@ public int getNavEventsCount() { return navEvents_.size(); } /** + *
+   * The list of NavEvents
+   * 
+ * * repeated .nav.NavEvent nav_events = 1; */ @java.lang.Override @@ -130,6 +159,10 @@ public io.provlabs.flow.api.NavEvent getNavEvents(int index) { return navEvents_.get(index); } /** + *
+   * The list of NavEvents
+   * 
+ * * repeated .nav.NavEvent nav_events = 1; */ @java.lang.Override @@ -138,6 +171,44 @@ public io.provlabs.flow.api.NavEventOrBuilder getNavEventsOrBuilder( return navEvents_.get(index); } + public static final int PAGINATION_FIELD_NUMBER = 2; + private io.provlabs.flow.api.PaginationResponse pagination_; + /** + *
+   * Pagination details for the response
+   * 
+ * + * .nav.PaginationResponse pagination = 2; + * @return Whether the pagination field is set. + */ + @java.lang.Override + public boolean hasPagination() { + return pagination_ != null; + } + /** + *
+   * Pagination details for the response
+   * 
+ * + * .nav.PaginationResponse pagination = 2; + * @return The pagination. + */ + @java.lang.Override + public io.provlabs.flow.api.PaginationResponse getPagination() { + return pagination_ == null ? io.provlabs.flow.api.PaginationResponse.getDefaultInstance() : pagination_; + } + /** + *
+   * Pagination details for the response
+   * 
+ * + * .nav.PaginationResponse pagination = 2; + */ + @java.lang.Override + public io.provlabs.flow.api.PaginationResponseOrBuilder getPaginationOrBuilder() { + return getPagination(); + } + private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { @@ -155,6 +226,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < navEvents_.size(); i++) { output.writeMessage(1, navEvents_.get(i)); } + if (pagination_ != null) { + output.writeMessage(2, getPagination()); + } unknownFields.writeTo(output); } @@ -168,6 +242,10 @@ public int getSerializedSize() { size += com.google.protobuf.CodedOutputStream .computeMessageSize(1, navEvents_.get(i)); } + if (pagination_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getPagination()); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -185,6 +263,11 @@ public boolean equals(final java.lang.Object obj) { if (!getNavEventsList() .equals(other.getNavEventsList())) return false; + if (hasPagination() != other.hasPagination()) return false; + if (hasPagination()) { + if (!getPagination() + .equals(other.getPagination())) return false; + } if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -200,6 +283,10 @@ public int hashCode() { hash = (37 * hash) + NAV_EVENTS_FIELD_NUMBER; hash = (53 * hash) + getNavEventsList().hashCode(); } + if (hasPagination()) { + hash = (37 * hash) + PAGINATION_FIELD_NUMBER; + hash = (53 * hash) + getPagination().hashCode(); + } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -344,6 +431,12 @@ public Builder clear() { } else { navEventsBuilder_.clear(); } + if (paginationBuilder_ == null) { + pagination_ = null; + } else { + pagination_ = null; + paginationBuilder_ = null; + } return this; } @@ -380,6 +473,11 @@ public io.provlabs.flow.api.NavEventResponse buildPartial() { } else { result.navEvents_ = navEventsBuilder_.build(); } + if (paginationBuilder_ == null) { + result.pagination_ = pagination_; + } else { + result.pagination_ = paginationBuilder_.build(); + } onBuilt(); return result; } @@ -454,6 +552,9 @@ public Builder mergeFrom(io.provlabs.flow.api.NavEventResponse other) { } } } + if (other.hasPagination()) { + mergePagination(other.getPagination()); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -497,6 +598,10 @@ private void ensureNavEventsIsMutable() { io.provlabs.flow.api.NavEvent, io.provlabs.flow.api.NavEvent.Builder, io.provlabs.flow.api.NavEventOrBuilder> navEventsBuilder_; /** + *
+     * The list of NavEvents
+     * 
+ * * repeated .nav.NavEvent nav_events = 1; */ public java.util.List getNavEventsList() { @@ -507,6 +612,10 @@ public java.util.List getNavEventsList() { } } /** + *
+     * The list of NavEvents
+     * 
+ * * repeated .nav.NavEvent nav_events = 1; */ public int getNavEventsCount() { @@ -517,6 +626,10 @@ public int getNavEventsCount() { } } /** + *
+     * The list of NavEvents
+     * 
+ * * repeated .nav.NavEvent nav_events = 1; */ public io.provlabs.flow.api.NavEvent getNavEvents(int index) { @@ -527,6 +640,10 @@ public io.provlabs.flow.api.NavEvent getNavEvents(int index) { } } /** + *
+     * The list of NavEvents
+     * 
+ * * repeated .nav.NavEvent nav_events = 1; */ public Builder setNavEvents( @@ -544,6 +661,10 @@ public Builder setNavEvents( return this; } /** + *
+     * The list of NavEvents
+     * 
+ * * repeated .nav.NavEvent nav_events = 1; */ public Builder setNavEvents( @@ -558,6 +679,10 @@ public Builder setNavEvents( return this; } /** + *
+     * The list of NavEvents
+     * 
+ * * repeated .nav.NavEvent nav_events = 1; */ public Builder addNavEvents(io.provlabs.flow.api.NavEvent value) { @@ -574,6 +699,10 @@ public Builder addNavEvents(io.provlabs.flow.api.NavEvent value) { return this; } /** + *
+     * The list of NavEvents
+     * 
+ * * repeated .nav.NavEvent nav_events = 1; */ public Builder addNavEvents( @@ -591,6 +720,10 @@ public Builder addNavEvents( return this; } /** + *
+     * The list of NavEvents
+     * 
+ * * repeated .nav.NavEvent nav_events = 1; */ public Builder addNavEvents( @@ -605,6 +738,10 @@ public Builder addNavEvents( return this; } /** + *
+     * The list of NavEvents
+     * 
+ * * repeated .nav.NavEvent nav_events = 1; */ public Builder addNavEvents( @@ -619,6 +756,10 @@ public Builder addNavEvents( return this; } /** + *
+     * The list of NavEvents
+     * 
+ * * repeated .nav.NavEvent nav_events = 1; */ public Builder addAllNavEvents( @@ -634,6 +775,10 @@ public Builder addAllNavEvents( return this; } /** + *
+     * The list of NavEvents
+     * 
+ * * repeated .nav.NavEvent nav_events = 1; */ public Builder clearNavEvents() { @@ -647,6 +792,10 @@ public Builder clearNavEvents() { return this; } /** + *
+     * The list of NavEvents
+     * 
+ * * repeated .nav.NavEvent nav_events = 1; */ public Builder removeNavEvents(int index) { @@ -660,6 +809,10 @@ public Builder removeNavEvents(int index) { return this; } /** + *
+     * The list of NavEvents
+     * 
+ * * repeated .nav.NavEvent nav_events = 1; */ public io.provlabs.flow.api.NavEvent.Builder getNavEventsBuilder( @@ -667,6 +820,10 @@ public io.provlabs.flow.api.NavEvent.Builder getNavEventsBuilder( return getNavEventsFieldBuilder().getBuilder(index); } /** + *
+     * The list of NavEvents
+     * 
+ * * repeated .nav.NavEvent nav_events = 1; */ public io.provlabs.flow.api.NavEventOrBuilder getNavEventsOrBuilder( @@ -677,6 +834,10 @@ public io.provlabs.flow.api.NavEventOrBuilder getNavEventsOrBuilder( } } /** + *
+     * The list of NavEvents
+     * 
+ * * repeated .nav.NavEvent nav_events = 1; */ public java.util.List @@ -688,6 +849,10 @@ public io.provlabs.flow.api.NavEventOrBuilder getNavEventsOrBuilder( } } /** + *
+     * The list of NavEvents
+     * 
+ * * repeated .nav.NavEvent nav_events = 1; */ public io.provlabs.flow.api.NavEvent.Builder addNavEventsBuilder() { @@ -695,6 +860,10 @@ public io.provlabs.flow.api.NavEvent.Builder addNavEventsBuilder() { io.provlabs.flow.api.NavEvent.getDefaultInstance()); } /** + *
+     * The list of NavEvents
+     * 
+ * * repeated .nav.NavEvent nav_events = 1; */ public io.provlabs.flow.api.NavEvent.Builder addNavEventsBuilder( @@ -703,6 +872,10 @@ public io.provlabs.flow.api.NavEvent.Builder addNavEventsBuilder( index, io.provlabs.flow.api.NavEvent.getDefaultInstance()); } /** + *
+     * The list of NavEvents
+     * 
+ * * repeated .nav.NavEvent nav_events = 1; */ public java.util.List @@ -723,6 +896,161 @@ public io.provlabs.flow.api.NavEvent.Builder addNavEventsBuilder( } return navEventsBuilder_; } + + private io.provlabs.flow.api.PaginationResponse pagination_; + private com.google.protobuf.SingleFieldBuilderV3< + io.provlabs.flow.api.PaginationResponse, io.provlabs.flow.api.PaginationResponse.Builder, io.provlabs.flow.api.PaginationResponseOrBuilder> paginationBuilder_; + /** + *
+     * Pagination details for the response
+     * 
+ * + * .nav.PaginationResponse pagination = 2; + * @return Whether the pagination field is set. + */ + public boolean hasPagination() { + return paginationBuilder_ != null || pagination_ != null; + } + /** + *
+     * Pagination details for the response
+     * 
+ * + * .nav.PaginationResponse pagination = 2; + * @return The pagination. + */ + public io.provlabs.flow.api.PaginationResponse getPagination() { + if (paginationBuilder_ == null) { + return pagination_ == null ? io.provlabs.flow.api.PaginationResponse.getDefaultInstance() : pagination_; + } else { + return paginationBuilder_.getMessage(); + } + } + /** + *
+     * Pagination details for the response
+     * 
+ * + * .nav.PaginationResponse pagination = 2; + */ + public Builder setPagination(io.provlabs.flow.api.PaginationResponse value) { + if (paginationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + pagination_ = value; + onChanged(); + } else { + paginationBuilder_.setMessage(value); + } + + return this; + } + /** + *
+     * Pagination details for the response
+     * 
+ * + * .nav.PaginationResponse pagination = 2; + */ + public Builder setPagination( + io.provlabs.flow.api.PaginationResponse.Builder builderForValue) { + if (paginationBuilder_ == null) { + pagination_ = builderForValue.build(); + onChanged(); + } else { + paginationBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+     * Pagination details for the response
+     * 
+ * + * .nav.PaginationResponse pagination = 2; + */ + public Builder mergePagination(io.provlabs.flow.api.PaginationResponse value) { + if (paginationBuilder_ == null) { + if (pagination_ != null) { + pagination_ = + io.provlabs.flow.api.PaginationResponse.newBuilder(pagination_).mergeFrom(value).buildPartial(); + } else { + pagination_ = value; + } + onChanged(); + } else { + paginationBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+     * Pagination details for the response
+     * 
+ * + * .nav.PaginationResponse pagination = 2; + */ + public Builder clearPagination() { + if (paginationBuilder_ == null) { + pagination_ = null; + onChanged(); + } else { + pagination_ = null; + paginationBuilder_ = null; + } + + return this; + } + /** + *
+     * Pagination details for the response
+     * 
+ * + * .nav.PaginationResponse pagination = 2; + */ + public io.provlabs.flow.api.PaginationResponse.Builder getPaginationBuilder() { + + onChanged(); + return getPaginationFieldBuilder().getBuilder(); + } + /** + *
+     * Pagination details for the response
+     * 
+ * + * .nav.PaginationResponse pagination = 2; + */ + public io.provlabs.flow.api.PaginationResponseOrBuilder getPaginationOrBuilder() { + if (paginationBuilder_ != null) { + return paginationBuilder_.getMessageOrBuilder(); + } else { + return pagination_ == null ? + io.provlabs.flow.api.PaginationResponse.getDefaultInstance() : pagination_; + } + } + /** + *
+     * Pagination details for the response
+     * 
+ * + * .nav.PaginationResponse pagination = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + io.provlabs.flow.api.PaginationResponse, io.provlabs.flow.api.PaginationResponse.Builder, io.provlabs.flow.api.PaginationResponseOrBuilder> + getPaginationFieldBuilder() { + if (paginationBuilder_ == null) { + paginationBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + io.provlabs.flow.api.PaginationResponse, io.provlabs.flow.api.PaginationResponse.Builder, io.provlabs.flow.api.PaginationResponseOrBuilder>( + getPagination(), + getParentForChildren(), + isClean()); + pagination_ = null; + } + return paginationBuilder_; + } @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { diff --git a/service/src/main/java/io/provlabs/flow/api/NavEventResponseOrBuilder.java b/service/src/main/java/io/provlabs/flow/api/NavEventResponseOrBuilder.java index c73a9163..a38d05e8 100644 --- a/service/src/main/java/io/provlabs/flow/api/NavEventResponseOrBuilder.java +++ b/service/src/main/java/io/provlabs/flow/api/NavEventResponseOrBuilder.java @@ -8,26 +8,73 @@ public interface NavEventResponseOrBuilder extends com.google.protobuf.MessageOrBuilder { /** + *
+   * The list of NavEvents
+   * 
+ * * repeated .nav.NavEvent nav_events = 1; */ java.util.List getNavEventsList(); /** + *
+   * The list of NavEvents
+   * 
+ * * repeated .nav.NavEvent nav_events = 1; */ io.provlabs.flow.api.NavEvent getNavEvents(int index); /** + *
+   * The list of NavEvents
+   * 
+ * * repeated .nav.NavEvent nav_events = 1; */ int getNavEventsCount(); /** + *
+   * The list of NavEvents
+   * 
+ * * repeated .nav.NavEvent nav_events = 1; */ java.util.List getNavEventsOrBuilderList(); /** + *
+   * The list of NavEvents
+   * 
+ * * repeated .nav.NavEvent nav_events = 1; */ io.provlabs.flow.api.NavEventOrBuilder getNavEventsOrBuilder( int index); + + /** + *
+   * Pagination details for the response
+   * 
+ * + * .nav.PaginationResponse pagination = 2; + * @return Whether the pagination field is set. + */ + boolean hasPagination(); + /** + *
+   * Pagination details for the response
+   * 
+ * + * .nav.PaginationResponse pagination = 2; + * @return The pagination. + */ + io.provlabs.flow.api.PaginationResponse getPagination(); + /** + *
+   * Pagination details for the response
+   * 
+ * + * .nav.PaginationResponse pagination = 2; + */ + io.provlabs.flow.api.PaginationResponseOrBuilder getPaginationOrBuilder(); } diff --git a/service/src/main/java/io/provlabs/flow/api/NavServiceGrpc.java b/service/src/main/java/io/provlabs/flow/api/NavServiceGrpc.java index d47c18ec..84440f4a 100644 --- a/service/src/main/java/io/provlabs/flow/api/NavServiceGrpc.java +++ b/service/src/main/java/io/provlabs/flow/api/NavServiceGrpc.java @@ -61,6 +61,37 @@ io.provlabs.flow.api.NavEventResponse> getGetNavEventsMethod() { return getGetNavEventsMethod; } + private static volatile io.grpc.MethodDescriptor getGetLatestNavEventsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetLatestNavEvents", + requestType = io.provlabs.flow.api.LatestNavEventRequest.class, + responseType = io.provlabs.flow.api.NavEventResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getGetLatestNavEventsMethod() { + io.grpc.MethodDescriptor getGetLatestNavEventsMethod; + if ((getGetLatestNavEventsMethod = NavServiceGrpc.getGetLatestNavEventsMethod) == null) { + synchronized (NavServiceGrpc.class) { + if ((getGetLatestNavEventsMethod = NavServiceGrpc.getGetLatestNavEventsMethod) == null) { + NavServiceGrpc.getGetLatestNavEventsMethod = getGetLatestNavEventsMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetLatestNavEvents")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + io.provlabs.flow.api.LatestNavEventRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + io.provlabs.flow.api.NavEventResponse.getDefaultInstance())) + .setSchemaDescriptor(new NavServiceMethodDescriptorSupplier("GetLatestNavEvents")) + .build(); + } + } + } + return getGetLatestNavEventsMethod; + } + /** * Creates a new async stub that supports all call types for the service */ @@ -113,12 +144,25 @@ public NavServiceFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions public static abstract class NavServiceImplBase implements io.grpc.BindableService { /** + *
+     * Retrieves NavEvents based on denom, scope, and optional filters.
+     * 
*/ public void getNavEvents(io.provlabs.flow.api.NavEventRequest request, io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getGetNavEventsMethod(), responseObserver); } + /** + *
+     * Retrieves the latest NavEvents based on price denomination and marker/scope inclusion.
+     * 
+ */ + public void getLatestNavEvents(io.provlabs.flow.api.LatestNavEventRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetLatestNavEventsMethod(), responseObserver); + } + @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) .addMethod( @@ -128,6 +172,13 @@ public void getNavEvents(io.provlabs.flow.api.NavEventRequest request, io.provlabs.flow.api.NavEventRequest, io.provlabs.flow.api.NavEventResponse>( this, METHODID_GET_NAV_EVENTS))) + .addMethod( + getGetLatestNavEventsMethod(), + asyncUnaryCall( + new MethodHandlers< + io.provlabs.flow.api.LatestNavEventRequest, + io.provlabs.flow.api.NavEventResponse>( + this, METHODID_GET_LATEST_NAV_EVENTS))) .build(); } } @@ -150,12 +201,26 @@ protected NavServiceStub build( } /** + *
+     * Retrieves NavEvents based on denom, scope, and optional filters.
+     * 
*/ public void getNavEvents(io.provlabs.flow.api.NavEventRequest request, io.grpc.stub.StreamObserver responseObserver) { asyncUnaryCall( getChannel().newCall(getGetNavEventsMethod(), getCallOptions()), request, responseObserver); } + + /** + *
+     * Retrieves the latest NavEvents based on price denomination and marker/scope inclusion.
+     * 
+ */ + public void getLatestNavEvents(io.provlabs.flow.api.LatestNavEventRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetLatestNavEventsMethod(), getCallOptions()), request, responseObserver); + } } /** @@ -176,11 +241,24 @@ protected NavServiceBlockingStub build( } /** + *
+     * Retrieves NavEvents based on denom, scope, and optional filters.
+     * 
*/ public io.provlabs.flow.api.NavEventResponse getNavEvents(io.provlabs.flow.api.NavEventRequest request) { return blockingUnaryCall( getChannel(), getGetNavEventsMethod(), getCallOptions(), request); } + + /** + *
+     * Retrieves the latest NavEvents based on price denomination and marker/scope inclusion.
+     * 
+ */ + public io.provlabs.flow.api.NavEventResponse getLatestNavEvents(io.provlabs.flow.api.LatestNavEventRequest request) { + return blockingUnaryCall( + getChannel(), getGetLatestNavEventsMethod(), getCallOptions(), request); + } } /** @@ -201,15 +279,30 @@ protected NavServiceFutureStub build( } /** + *
+     * Retrieves NavEvents based on denom, scope, and optional filters.
+     * 
*/ public com.google.common.util.concurrent.ListenableFuture getNavEvents( io.provlabs.flow.api.NavEventRequest request) { return futureUnaryCall( getChannel().newCall(getGetNavEventsMethod(), getCallOptions()), request); } + + /** + *
+     * Retrieves the latest NavEvents based on price denomination and marker/scope inclusion.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getLatestNavEvents( + io.provlabs.flow.api.LatestNavEventRequest request) { + return futureUnaryCall( + getChannel().newCall(getGetLatestNavEventsMethod(), getCallOptions()), request); + } } private static final int METHODID_GET_NAV_EVENTS = 0; + private static final int METHODID_GET_LATEST_NAV_EVENTS = 1; private static final class MethodHandlers implements io.grpc.stub.ServerCalls.UnaryMethod, @@ -232,6 +325,10 @@ public void invoke(Req request, io.grpc.stub.StreamObserver responseObserv serviceImpl.getNavEvents((io.provlabs.flow.api.NavEventRequest) request, (io.grpc.stub.StreamObserver) responseObserver); break; + case METHODID_GET_LATEST_NAV_EVENTS: + serviceImpl.getLatestNavEvents((io.provlabs.flow.api.LatestNavEventRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; default: throw new AssertionError(); } @@ -294,6 +391,7 @@ public static io.grpc.ServiceDescriptor getServiceDescriptor() { serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) .setSchemaDescriptor(new NavServiceFileDescriptorSupplier()) .addMethod(getGetNavEventsMethod()) + .addMethod(getGetLatestNavEventsMethod()) .build(); } } diff --git a/service/src/main/java/io/provlabs/flow/api/PaginationRequest.java b/service/src/main/java/io/provlabs/flow/api/PaginationRequest.java new file mode 100644 index 00000000..cc2dd33a --- /dev/null +++ b/service/src/main/java/io/provlabs/flow/api/PaginationRequest.java @@ -0,0 +1,587 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: nav_event.proto + +package io.provlabs.flow.api; + +/** + *
+ * Pagination request to handle pagination in requests
+ * 
+ * + * Protobuf type {@code nav.PaginationRequest} + */ +public final class PaginationRequest extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:nav.PaginationRequest) + PaginationRequestOrBuilder { +private static final long serialVersionUID = 0L; + // Use PaginationRequest.newBuilder() to construct. + private PaginationRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private PaginationRequest() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new PaginationRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private PaginationRequest( + 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: { + + page_ = input.readInt32(); + break; + } + case 16: { + + pageSize_ = 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 { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_PaginationRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_PaginationRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.provlabs.flow.api.PaginationRequest.class, io.provlabs.flow.api.PaginationRequest.Builder.class); + } + + public static final int PAGE_FIELD_NUMBER = 1; + private int page_; + /** + *
+   * The page number
+   * 
+ * + * int32 page = 1; + * @return The page. + */ + @java.lang.Override + public int getPage() { + return page_; + } + + public static final int PAGE_SIZE_FIELD_NUMBER = 2; + private int pageSize_; + /** + *
+   * The size of each page
+   * 
+ * + * int32 page_size = 2; + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + + 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 (page_ != 0) { + output.writeInt32(1, page_); + } + if (pageSize_ != 0) { + output.writeInt32(2, pageSize_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (page_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, page_); + } + if (pageSize_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, pageSize_); + } + 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.PaginationRequest)) { + return super.equals(obj); + } + io.provlabs.flow.api.PaginationRequest other = (io.provlabs.flow.api.PaginationRequest) obj; + + if (getPage() + != other.getPage()) return false; + if (getPageSize() + != other.getPageSize()) 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) + PAGE_FIELD_NUMBER; + hash = (53 * hash) + getPage(); + hash = (37 * hash) + PAGE_SIZE_FIELD_NUMBER; + hash = (53 * hash) + getPageSize(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static io.provlabs.flow.api.PaginationRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.provlabs.flow.api.PaginationRequest 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.PaginationRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.provlabs.flow.api.PaginationRequest 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.PaginationRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.provlabs.flow.api.PaginationRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.provlabs.flow.api.PaginationRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.provlabs.flow.api.PaginationRequest 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.PaginationRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static io.provlabs.flow.api.PaginationRequest 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.PaginationRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.provlabs.flow.api.PaginationRequest 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.PaginationRequest 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; + } + /** + *
+   * Pagination request to handle pagination in requests
+   * 
+ * + * Protobuf type {@code nav.PaginationRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:nav.PaginationRequest) + io.provlabs.flow.api.PaginationRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_PaginationRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_PaginationRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.provlabs.flow.api.PaginationRequest.class, io.provlabs.flow.api.PaginationRequest.Builder.class); + } + + // Construct using io.provlabs.flow.api.PaginationRequest.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(); + page_ = 0; + + pageSize_ = 0; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_PaginationRequest_descriptor; + } + + @java.lang.Override + public io.provlabs.flow.api.PaginationRequest getDefaultInstanceForType() { + return io.provlabs.flow.api.PaginationRequest.getDefaultInstance(); + } + + @java.lang.Override + public io.provlabs.flow.api.PaginationRequest build() { + io.provlabs.flow.api.PaginationRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public io.provlabs.flow.api.PaginationRequest buildPartial() { + io.provlabs.flow.api.PaginationRequest result = new io.provlabs.flow.api.PaginationRequest(this); + result.page_ = page_; + result.pageSize_ = pageSize_; + 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.PaginationRequest) { + return mergeFrom((io.provlabs.flow.api.PaginationRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.provlabs.flow.api.PaginationRequest other) { + if (other == io.provlabs.flow.api.PaginationRequest.getDefaultInstance()) return this; + if (other.getPage() != 0) { + setPage(other.getPage()); + } + if (other.getPageSize() != 0) { + setPageSize(other.getPageSize()); + } + 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.PaginationRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.provlabs.flow.api.PaginationRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int page_ ; + /** + *
+     * The page number
+     * 
+ * + * int32 page = 1; + * @return The page. + */ + @java.lang.Override + public int getPage() { + return page_; + } + /** + *
+     * The page number
+     * 
+ * + * int32 page = 1; + * @param value The page to set. + * @return This builder for chaining. + */ + public Builder setPage(int value) { + + page_ = value; + onChanged(); + return this; + } + /** + *
+     * The page number
+     * 
+ * + * int32 page = 1; + * @return This builder for chaining. + */ + public Builder clearPage() { + + page_ = 0; + onChanged(); + return this; + } + + private int pageSize_ ; + /** + *
+     * The size of each page
+     * 
+ * + * int32 page_size = 2; + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + /** + *
+     * The size of each page
+     * 
+ * + * int32 page_size = 2; + * @param value The pageSize to set. + * @return This builder for chaining. + */ + public Builder setPageSize(int value) { + + pageSize_ = value; + onChanged(); + return this; + } + /** + *
+     * The size of each page
+     * 
+ * + * int32 page_size = 2; + * @return This builder for chaining. + */ + public Builder clearPageSize() { + + pageSize_ = 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.PaginationRequest) + } + + // @@protoc_insertion_point(class_scope:nav.PaginationRequest) + private static final io.provlabs.flow.api.PaginationRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new io.provlabs.flow.api.PaginationRequest(); + } + + public static io.provlabs.flow.api.PaginationRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PaginationRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PaginationRequest(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.PaginationRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/service/src/main/java/io/provlabs/flow/api/PaginationRequestOrBuilder.java b/service/src/main/java/io/provlabs/flow/api/PaginationRequestOrBuilder.java new file mode 100644 index 00000000..a199fab3 --- /dev/null +++ b/service/src/main/java/io/provlabs/flow/api/PaginationRequestOrBuilder.java @@ -0,0 +1,29 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: nav_event.proto + +package io.provlabs.flow.api; + +public interface PaginationRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:nav.PaginationRequest) + com.google.protobuf.MessageOrBuilder { + + /** + *
+   * The page number
+   * 
+ * + * int32 page = 1; + * @return The page. + */ + int getPage(); + + /** + *
+   * The size of each page
+   * 
+ * + * int32 page_size = 2; + * @return The pageSize. + */ + int getPageSize(); +} diff --git a/service/src/main/java/io/provlabs/flow/api/PaginationResponse.java b/service/src/main/java/io/provlabs/flow/api/PaginationResponse.java new file mode 100644 index 00000000..6d0fd784 --- /dev/null +++ b/service/src/main/java/io/provlabs/flow/api/PaginationResponse.java @@ -0,0 +1,667 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: nav_event.proto + +package io.provlabs.flow.api; + +/** + *
+ * Pagination response to provide pagination details in responses
+ * 
+ * + * Protobuf type {@code nav.PaginationResponse} + */ +public final class PaginationResponse extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:nav.PaginationResponse) + PaginationResponseOrBuilder { +private static final long serialVersionUID = 0L; + // Use PaginationResponse.newBuilder() to construct. + private PaginationResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private PaginationResponse() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new PaginationResponse(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private PaginationResponse( + 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: { + + currentPage_ = input.readInt32(); + break; + } + case 16: { + + totalPages_ = input.readInt32(); + break; + } + case 24: { + + totalItems_ = 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 { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_PaginationResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_PaginationResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.provlabs.flow.api.PaginationResponse.class, io.provlabs.flow.api.PaginationResponse.Builder.class); + } + + public static final int CURRENT_PAGE_FIELD_NUMBER = 1; + private int currentPage_; + /** + *
+   * The current page being returned
+   * 
+ * + * int32 current_page = 1; + * @return The currentPage. + */ + @java.lang.Override + public int getCurrentPage() { + return currentPage_; + } + + public static final int TOTAL_PAGES_FIELD_NUMBER = 2; + private int totalPages_; + /** + *
+   * The total number of pages available
+   * 
+ * + * int32 total_pages = 2; + * @return The totalPages. + */ + @java.lang.Override + public int getTotalPages() { + return totalPages_; + } + + public static final int TOTAL_ITEMS_FIELD_NUMBER = 3; + private int totalItems_; + /** + *
+   * The total number of items available across all pages
+   * 
+ * + * int32 total_items = 3; + * @return The totalItems. + */ + @java.lang.Override + public int getTotalItems() { + return totalItems_; + } + + 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 (currentPage_ != 0) { + output.writeInt32(1, currentPage_); + } + if (totalPages_ != 0) { + output.writeInt32(2, totalPages_); + } + if (totalItems_ != 0) { + output.writeInt32(3, totalItems_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (currentPage_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, currentPage_); + } + if (totalPages_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, totalPages_); + } + if (totalItems_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, totalItems_); + } + 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.PaginationResponse)) { + return super.equals(obj); + } + io.provlabs.flow.api.PaginationResponse other = (io.provlabs.flow.api.PaginationResponse) obj; + + if (getCurrentPage() + != other.getCurrentPage()) return false; + if (getTotalPages() + != other.getTotalPages()) return false; + if (getTotalItems() + != other.getTotalItems()) 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) + CURRENT_PAGE_FIELD_NUMBER; + hash = (53 * hash) + getCurrentPage(); + hash = (37 * hash) + TOTAL_PAGES_FIELD_NUMBER; + hash = (53 * hash) + getTotalPages(); + hash = (37 * hash) + TOTAL_ITEMS_FIELD_NUMBER; + hash = (53 * hash) + getTotalItems(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static io.provlabs.flow.api.PaginationResponse parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.provlabs.flow.api.PaginationResponse 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.PaginationResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.provlabs.flow.api.PaginationResponse 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.PaginationResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.provlabs.flow.api.PaginationResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.provlabs.flow.api.PaginationResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.provlabs.flow.api.PaginationResponse 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.PaginationResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static io.provlabs.flow.api.PaginationResponse 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.PaginationResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.provlabs.flow.api.PaginationResponse 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.PaginationResponse 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; + } + /** + *
+   * Pagination response to provide pagination details in responses
+   * 
+ * + * Protobuf type {@code nav.PaginationResponse} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:nav.PaginationResponse) + io.provlabs.flow.api.PaginationResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_PaginationResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_PaginationResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.provlabs.flow.api.PaginationResponse.class, io.provlabs.flow.api.PaginationResponse.Builder.class); + } + + // Construct using io.provlabs.flow.api.PaginationResponse.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(); + currentPage_ = 0; + + totalPages_ = 0; + + totalItems_ = 0; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.provlabs.flow.api.NavEventOuterClass.internal_static_nav_PaginationResponse_descriptor; + } + + @java.lang.Override + public io.provlabs.flow.api.PaginationResponse getDefaultInstanceForType() { + return io.provlabs.flow.api.PaginationResponse.getDefaultInstance(); + } + + @java.lang.Override + public io.provlabs.flow.api.PaginationResponse build() { + io.provlabs.flow.api.PaginationResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public io.provlabs.flow.api.PaginationResponse buildPartial() { + io.provlabs.flow.api.PaginationResponse result = new io.provlabs.flow.api.PaginationResponse(this); + result.currentPage_ = currentPage_; + result.totalPages_ = totalPages_; + result.totalItems_ = totalItems_; + 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.PaginationResponse) { + return mergeFrom((io.provlabs.flow.api.PaginationResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.provlabs.flow.api.PaginationResponse other) { + if (other == io.provlabs.flow.api.PaginationResponse.getDefaultInstance()) return this; + if (other.getCurrentPage() != 0) { + setCurrentPage(other.getCurrentPage()); + } + if (other.getTotalPages() != 0) { + setTotalPages(other.getTotalPages()); + } + if (other.getTotalItems() != 0) { + setTotalItems(other.getTotalItems()); + } + 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.PaginationResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.provlabs.flow.api.PaginationResponse) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int currentPage_ ; + /** + *
+     * The current page being returned
+     * 
+ * + * int32 current_page = 1; + * @return The currentPage. + */ + @java.lang.Override + public int getCurrentPage() { + return currentPage_; + } + /** + *
+     * The current page being returned
+     * 
+ * + * int32 current_page = 1; + * @param value The currentPage to set. + * @return This builder for chaining. + */ + public Builder setCurrentPage(int value) { + + currentPage_ = value; + onChanged(); + return this; + } + /** + *
+     * The current page being returned
+     * 
+ * + * int32 current_page = 1; + * @return This builder for chaining. + */ + public Builder clearCurrentPage() { + + currentPage_ = 0; + onChanged(); + return this; + } + + private int totalPages_ ; + /** + *
+     * The total number of pages available
+     * 
+ * + * int32 total_pages = 2; + * @return The totalPages. + */ + @java.lang.Override + public int getTotalPages() { + return totalPages_; + } + /** + *
+     * The total number of pages available
+     * 
+ * + * int32 total_pages = 2; + * @param value The totalPages to set. + * @return This builder for chaining. + */ + public Builder setTotalPages(int value) { + + totalPages_ = value; + onChanged(); + return this; + } + /** + *
+     * The total number of pages available
+     * 
+ * + * int32 total_pages = 2; + * @return This builder for chaining. + */ + public Builder clearTotalPages() { + + totalPages_ = 0; + onChanged(); + return this; + } + + private int totalItems_ ; + /** + *
+     * The total number of items available across all pages
+     * 
+ * + * int32 total_items = 3; + * @return The totalItems. + */ + @java.lang.Override + public int getTotalItems() { + return totalItems_; + } + /** + *
+     * The total number of items available across all pages
+     * 
+ * + * int32 total_items = 3; + * @param value The totalItems to set. + * @return This builder for chaining. + */ + public Builder setTotalItems(int value) { + + totalItems_ = value; + onChanged(); + return this; + } + /** + *
+     * The total number of items available across all pages
+     * 
+ * + * int32 total_items = 3; + * @return This builder for chaining. + */ + public Builder clearTotalItems() { + + totalItems_ = 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.PaginationResponse) + } + + // @@protoc_insertion_point(class_scope:nav.PaginationResponse) + private static final io.provlabs.flow.api.PaginationResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new io.provlabs.flow.api.PaginationResponse(); + } + + public static io.provlabs.flow.api.PaginationResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PaginationResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PaginationResponse(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.PaginationResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/service/src/main/java/io/provlabs/flow/api/PaginationResponseOrBuilder.java b/service/src/main/java/io/provlabs/flow/api/PaginationResponseOrBuilder.java new file mode 100644 index 00000000..b5ff783c --- /dev/null +++ b/service/src/main/java/io/provlabs/flow/api/PaginationResponseOrBuilder.java @@ -0,0 +1,39 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: nav_event.proto + +package io.provlabs.flow.api; + +public interface PaginationResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:nav.PaginationResponse) + com.google.protobuf.MessageOrBuilder { + + /** + *
+   * The current page being returned
+   * 
+ * + * int32 current_page = 1; + * @return The currentPage. + */ + int getCurrentPage(); + + /** + *
+   * The total number of pages available
+   * 
+ * + * int32 total_pages = 2; + * @return The totalPages. + */ + int getTotalPages(); + + /** + *
+   * The total number of items available across all pages
+   * 
+ * + * int32 total_items = 3; + * @return The totalItems. + */ + int getTotalItems(); +} diff --git a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Markers.kt b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Markers.kt index e2450dde..568bedf2 100644 --- a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Markers.kt +++ b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Markers.kt @@ -7,7 +7,6 @@ import io.provenance.explorer.domain.core.sql.jsonb import io.provenance.explorer.domain.core.sql.nullsLast import io.provenance.explorer.domain.core.sql.toDbQueryList import io.provenance.explorer.domain.extensions.execAndMap -import io.provenance.explorer.domain.extensions.toDateTime import io.provenance.explorer.domain.models.explorer.AssetPricing import io.provenance.explorer.domain.models.explorer.TokenDistributionPaginatedResults import io.provenance.explorer.domain.models.explorer.toCoinStrWithPrice @@ -226,27 +225,25 @@ object AssetPricingTable : IdTable(name = "asset_pricing") { class AssetPricingRecord(id: EntityID) : IntEntity(id) { companion object : IntEntityClass(AssetPricingTable) { - private fun findUnique(data: AssetPricing) = transaction { + private fun findUnique(markerDenom: String, pricingDenom: String): AssetPricingRecord? = transaction { AssetPricingRecord.find { - (AssetPricingTable.denom eq data.markerDenom) and - (AssetPricingTable.pricingDenom eq data.priceDenomination) + (AssetPricingTable.denom eq markerDenom) and + (AssetPricingTable.pricingDenom eq pricingDenom) } + .limit(1) .firstOrNull() } - - fun upsert(markerId: Int, data: AssetPricing) = transaction { - findUnique(data)?.apply { - this.pricing = data.usdPrice ?: data.price!! - this.lastUpdated = data.priceTimestamp.toDateTime() - this.data = data + fun upsert(markerId: Int, markerDenom: String, markerAddress: String?, pricingDenom: String, pricingAmount: BigDecimal, timestamp: DateTime) = transaction { + findUnique(markerDenom, pricingDenom)?.apply { + this.pricing = pricingAmount + this.lastUpdated = timestamp } ?: AssetPricingTable.insert { it[this.markerId] = markerId - it[this.markerAddress] = data.markerAddress - it[this.denom] = data.markerDenom - it[this.pricing] = data.usdPrice ?: data.price!! - it[this.pricingDenom] = data.priceDenomination - it[this.lastUpdated] = data.priceTimestamp.toDateTime() - it[this.data] = data + it[this.markerAddress] = markerAddress ?: "" + it[this.denom] = markerDenom + it[this.pricing] = pricingAmount + it[this.pricingDenom] = pricingDenom + it[this.lastUpdated] = timestamp } } diff --git a/service/src/main/kotlin/io/provenance/explorer/domain/extensions/NavEventExtensions.kt b/service/src/main/kotlin/io/provenance/explorer/domain/extensions/NavEventExtensions.kt new file mode 100644 index 00000000..62ac09bd --- /dev/null +++ b/service/src/main/kotlin/io/provenance/explorer/domain/extensions/NavEventExtensions.kt @@ -0,0 +1,29 @@ +package io.provenance.explorer.domain.extensions + +import io.provenance.explorer.model.base.USD_LOWER +import io.provlabs.flow.api.NavEvent +import java.math.BigDecimal +import java.math.RoundingMode + +/** + * Calculates the USD price per unit for a NAV event. + * + * The `priceAmount` is in dollar millis (e.g., 1234 = $1.234) and is divided by the volume to get the price per unit. + * If the `priceDenom` is not "usd" or the volume is 0, it returns `BigDecimal.ZERO`. + * + * @return The USD price per unit or `BigDecimal.ZERO` if not a USD event or volume is 0. + */ +fun NavEvent.calculateUsdPricePerUnit(): BigDecimal { + if (this.priceDenom != USD_LOWER) { + return BigDecimal.ZERO + } + + if (this.volume == 0L) { + return BigDecimal.ZERO + } + + return BigDecimal(this.priceAmount) + .setScale(3, RoundingMode.DOWN) + .divide(BigDecimal(1000), RoundingMode.DOWN) + .divide(BigDecimal(this.volume), 3, RoundingMode.DOWN) +} 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 index f7eefcd0..eca02a3d 100644 --- a/service/src/main/kotlin/io/provenance/explorer/grpc/flow/FlowApiGrpcClient.kt +++ b/service/src/main/kotlin/io/provenance/explorer/grpc/flow/FlowApiGrpcClient.kt @@ -3,10 +3,12 @@ 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.LatestNavEventRequest 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 io.provlabs.flow.api.PaginationRequest import kotlinx.coroutines.runBlocking import org.joda.time.DateTime import org.joda.time.format.DateTimeFormat @@ -38,12 +40,13 @@ class FlowApiGrpcClient(flowApiChannelUri: URI) { navService = NavServiceGrpc.newBlockingStub(channel) } - fun getMarkerNavByPriceDenoms(denom: String, priceDenoms: List, fromDate: DateTime?, limit: Int = 100): List = runBlocking { + fun getMarkerNavByPriceDenoms(denom: String, priceDenoms: List, fromDate: DateTime?, pageCount: Int = 100, page: Int = 0): List = runBlocking { val fromDateString = fromDate?.toString(DateTimeFormat.forPattern("yyyy-MM-dd")) ?: "" + val pagination = PaginationRequest.newBuilder().setPage(page).setPageSize(pageCount).build() val requestBuilder = NavEventRequest.newBuilder() .setDenom(denom) .setFromDate(fromDateString) - .setLimit(limit) + .setPagination(pagination) priceDenoms.forEach { requestBuilder.addPriceDenoms(it) } val request = requestBuilder.build() @@ -56,4 +59,93 @@ class FlowApiGrpcClient(flowApiChannelUri: URI) { emptyList() } } + + fun getAllMarkerNavByPriceDenoms(denom: String, priceDenoms: List, fromDate: DateTime?, requestSize: Int = 10000): List = runBlocking { + val fromDateString = fromDate?.toString(DateTimeFormat.forPattern("yyyy-MM-dd")) ?: "" + val allNavEvents = mutableListOf() + var currentPage = 0 + var hasMorePages = true + + while (hasMorePages) { + val pagination = PaginationRequest.newBuilder().setPage(currentPage).setPageSize(requestSize).build() + val requestBuilder = NavEventRequest.newBuilder() + .setDenom(denom) + .setFromDate(fromDateString) + .setPagination(pagination) + + priceDenoms.forEach { requestBuilder.addPriceDenoms(it) } + val request = requestBuilder.build() + + try { + logger().debug("getAllMarkerNavByPriceDenoms $request") + val response: NavEventResponse = navService.getNavEvents(request) + allNavEvents.addAll(response.navEventsList) + + if (response.pagination.currentPage >= response.pagination.totalPages) { + hasMorePages = false + } else { + currentPage++ + } + } catch (e: Exception) { + logger().error("Error fetching Nav Events: ${e.message}", e) + hasMorePages = false + } + } + + return@runBlocking allNavEvents + } + + fun getLatestNavPrices(priceDenom: String, includeMarkers: Boolean = true, includeScopes: Boolean = true, fromDate: DateTime?, pageCount: Int = 100, page: Int = 0): List = runBlocking { + val fromDateString = fromDate?.toString(DateTimeFormat.forPattern("yyyy-MM-dd")) ?: "" + val pagination = PaginationRequest.newBuilder().setPage(page).setPageSize(pageCount).build() + val request = LatestNavEventRequest.newBuilder() + .setPriceDenom(priceDenom) + .setFromDate(fromDateString) + .setIncludeMarkers(includeMarkers) + .setIncludeScope(includeScopes) + .setPagination(pagination) + .build() + try { + logger().debug("getLatestNavEvents $request") + val response: NavEventResponse = navService.getLatestNavEvents(request) + return@runBlocking response.navEventsList + } catch (e: Exception) { + logger().error("Error fetching latest Nav Events: ${e.message}", e) + emptyList() + } + } + + fun getAllLatestNavPrices(priceDenom: String, includeMarkers: Boolean = true, includeScopes: Boolean = true, fromDate: DateTime?, requestSize: Int = 10000): List = runBlocking { + val fromDateString = fromDate?.toString(DateTimeFormat.forPattern("yyyy-MM-dd")) ?: "" + var currentPage = 1 + var totalPages = 1 + val allNavEvents = mutableListOf() + + try { + while (currentPage <= totalPages) { + val pagination = PaginationRequest.newBuilder().setPage(currentPage).setPageSize(requestSize).build() + val request = LatestNavEventRequest.newBuilder() + .setPriceDenom(priceDenom) + .setFromDate(fromDateString) + .setIncludeMarkers(includeMarkers) + .setIncludeScope(includeScopes) + .setPagination(pagination) + .build() + + logger().debug("getLatestNavEvents $request") + + val response: NavEventResponse = navService.getLatestNavEvents(request) + + allNavEvents.addAll(response.navEventsList) + + currentPage++ + totalPages = response.pagination.totalPages + } + logger().debug("getLatestNavEvents finished total pages requested: $currentPage total navs: ${allNavEvents.size}") + return@runBlocking allNavEvents + } catch (e: Exception) { + logger().error("Error fetching latest Nav Events: ${e.message}", e) + emptyList() + } + } } diff --git a/service/src/main/kotlin/io/provenance/explorer/service/AssetService.kt b/service/src/main/kotlin/io/provenance/explorer/service/AssetService.kt index dcf5903c..435ae8f2 100644 --- a/service/src/main/kotlin/io/provenance/explorer/service/AssetService.kt +++ b/service/src/main/kotlin/io/provenance/explorer/service/AssetService.kt @@ -3,15 +3,18 @@ package io.provenance.explorer.service import com.google.protobuf.Timestamp import com.google.protobuf.util.JsonFormat import cosmos.bank.v1beta1.denomUnit +import io.provenance.explorer.config.ExplorerProperties import io.provenance.explorer.config.ExplorerProperties.Companion.UTILITY_TOKEN import io.provenance.explorer.config.ResourceNotFoundException import io.provenance.explorer.domain.core.logger import io.provenance.explorer.domain.entities.AccountRecord +import io.provenance.explorer.domain.entities.AssetPricingRecord import io.provenance.explorer.domain.entities.BaseDenomType import io.provenance.explorer.domain.entities.MarkerCacheRecord import io.provenance.explorer.domain.entities.MarkerUnitRecord import io.provenance.explorer.domain.entities.TxMarkerJoinRecord import io.provenance.explorer.domain.exceptions.requireNotNullToMessage +import io.provenance.explorer.domain.extensions.calculateUsdPricePerUnit import io.provenance.explorer.domain.extensions.pageCountOfResults import io.provenance.explorer.domain.extensions.toDateTime import io.provenance.explorer.domain.extensions.toObjectNode @@ -19,6 +22,7 @@ import io.provenance.explorer.domain.extensions.toOffset import io.provenance.explorer.domain.models.explorer.toCoinStrWithPrice import io.provenance.explorer.grpc.extensions.getManagingAccounts import io.provenance.explorer.grpc.extensions.isMintable +import io.provenance.explorer.grpc.flow.FlowApiGrpcClient import io.provenance.explorer.grpc.v1.AccountGrpcClient import io.provenance.explorer.grpc.v1.AttributeGrpcClient import io.provenance.explorer.grpc.v1.MarkerGrpcClient @@ -29,14 +33,21 @@ import io.provenance.explorer.model.AssetManagement import io.provenance.explorer.model.TokenCounts import io.provenance.explorer.model.base.CountStrTotal import io.provenance.explorer.model.base.PagedResults +import io.provenance.explorer.model.base.USD_LOWER +import io.provenance.explorer.model.base.USD_UPPER import io.provenance.marker.v1.MarkerStatus import kotlinx.coroutines.async import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking +import org.jetbrains.exposed.dao.id.EntityID import org.jetbrains.exposed.sql.transactions.transaction +import org.joda.time.DateTime import org.springframework.stereotype.Service +import java.math.BigDecimal +import java.time.OffsetDateTime +import java.time.ZoneOffset @Service class AssetService( @@ -45,10 +56,13 @@ class AssetService( private val accountClient: AccountGrpcClient, private val protoPrinter: JsonFormat.Printer, private val pricingService: PricingService, - private val tokenService: TokenService + private val tokenService: TokenService, + private val flowApiGrpcClient: FlowApiGrpcClient ) { protected val logger = logger(AssetService::class) + private var assetPricinglastRun: OffsetDateTime? = null + fun validateDenom(denom: String) = requireNotNullToMessage(MarkerCacheRecord.findByDenom(denom)) { "Denom $denom does not exist." } @@ -225,8 +239,67 @@ class AssetService( ) } } + + fun updateAssetPricingFromLatestNav() = runBlocking { + val now = OffsetDateTime.now().withOffsetSameInstant(ZoneOffset.UTC) + logger.info("Updating asset pricing, last run at: $assetPricinglastRun") + + val latestPrices = flowApiGrpcClient.getAllLatestNavPrices( + priceDenom = USD_LOWER, + includeMarkers = true, + includeScopes = false, + fromDate = assetPricinglastRun?.toDateTime() + ) + + latestPrices.forEach { price -> + if (price.denom != UTILITY_TOKEN) { + val marker = getAssetRaw(price.denom) + insertAssetPricing( + marker = marker, + markerDenom = price.denom, + markerAddress = marker.second.markerAddress, + pricingDenom = price.priceDenom, + pricingAmount = price.calculateUsdPricePerUnit(), + timestamp = DateTime(price.blockTime * 1000) + ) + } + } + + val tokenLatest = tokenService.getTokenLatest() + val quote = tokenLatest?.quote?.get(USD_UPPER) + if (quote != null) { + val cmcPrice = quote.price?.let { + val scale = it.scale() + it.setScale(scale + ExplorerProperties.UTILITY_TOKEN_BASE_DECIMAL_PLACES) + .div(ExplorerProperties.UTILITY_TOKEN_BASE_MULTIPLIER) + } + + val lastUpdated = quote.last_updated + + if (cmcPrice != null && lastUpdated != null) { + val marker = getAssetRaw(UTILITY_TOKEN) + insertAssetPricing( + marker = marker, + markerDenom = UTILITY_TOKEN, + markerAddress = marker.second.markerAddress, + pricingDenom = USD_LOWER, + pricingAmount = cmcPrice, + timestamp = lastUpdated + ) + } else { + logger.warn("CMC Price or Last Updated is null for $UTILITY_TOKEN") + } + } else { + logger.warn("No USD_UPPER price found in tokenLatest for $UTILITY_TOKEN") + } + + assetPricinglastRun = now + } } +fun insertAssetPricing(marker: Pair, MarkerCacheRecord>, markerDenom: String, markerAddress: String?, pricingDenom: String, pricingAmount: BigDecimal, timestamp: DateTime) = transaction { + marker.first.value.let { AssetPricingRecord.upsert(it, markerDenom, markerAddress, pricingDenom, pricingAmount, timestamp) } +} fun String.getDenomByAddress() = MarkerCacheRecord.findByAddress(this)?.denom fun String.prettyStatus() = this.substringAfter("MARKER_STATUS_") diff --git a/service/src/main/kotlin/io/provenance/explorer/service/PricingService.kt b/service/src/main/kotlin/io/provenance/explorer/service/PricingService.kt index 26924e8d..4786add9 100644 --- a/service/src/main/kotlin/io/provenance/explorer/service/PricingService.kt +++ b/service/src/main/kotlin/io/provenance/explorer/service/PricingService.kt @@ -1,19 +1,13 @@ package io.provenance.explorer.service -import io.ktor.client.call.body -import io.ktor.client.request.get -import io.ktor.client.request.parameter -import io.provenance.explorer.KTOR_CLIENT_JAVA import io.provenance.explorer.config.ExplorerProperties import io.provenance.explorer.config.ExplorerProperties.Companion.UTILITY_TOKEN import io.provenance.explorer.domain.core.logger import io.provenance.explorer.domain.entities.AssetPricingRecord import io.provenance.explorer.domain.entities.MarkerCacheRecord import io.provenance.explorer.domain.entities.MarkerCacheTable -import io.provenance.explorer.domain.models.explorer.AssetPricing import io.provenance.marker.v1.MarkerStatus import kotlinx.coroutines.runBlocking -import org.jetbrains.exposed.dao.id.EntityID import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.transactions.transaction import org.springframework.stereotype.Service @@ -54,19 +48,4 @@ class PricingService( } fun getPricingInfoSingle(denom: String) = AssetPricingRecord.findByDenom(denom)?.pricing - - fun insertAssetPricing(marker: Pair, MarkerCacheRecord>, data: AssetPricing) = transaction { - marker.first.value.let { AssetPricingRecord.upsert(it, data) } - } - - fun getPricingAsync(time: String, comingFrom: String) = runBlocking { - try { - KTOR_CLIENT_JAVA.get("${props.pricingUrl}/api/v1/pricing/marker/new") { - parameter("time", time) - }.body() - } catch (e: Exception) { - return@runBlocking listOf() - .also { logger.error("Error coming from $comingFrom: ${e.message}") } - } - } } 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 85f10a9e..791d5aad 100644 --- a/service/src/main/kotlin/io/provenance/explorer/service/TokenService.kt +++ b/service/src/main/kotlin/io/provenance/explorer/service/TokenService.kt @@ -298,7 +298,6 @@ class TokenService( fun updateAndSaveLatestTokenData(startDate: DateTime, today: DateTime) { val list = fetchHistoricalPriceData(startDate)?.sortedBy { it.time } - list?.let { val latestData = processLatestTokenData(it, today) latestData?.let { data -> 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 438ffa0a..9f55f9a1 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 @@ -5,8 +5,6 @@ import cosmos.authz.v1beta1.msgGrant import cosmos.authz.v1beta1.msgRevoke 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 -import io.provenance.explorer.config.ExplorerProperties.Companion.UTILITY_TOKEN_BASE_MULTIPLIER import io.provenance.explorer.domain.core.logger import io.provenance.explorer.domain.entities.BlockCacheRecord import io.provenance.explorer.domain.entities.BlockTxCountsCacheRecord @@ -38,7 +36,6 @@ import io.provenance.explorer.domain.extensions.startOfDay import io.provenance.explorer.domain.extensions.toDateTime import io.provenance.explorer.grpc.extensions.getMsgSubTypes import io.provenance.explorer.grpc.extensions.getMsgType -import io.provenance.explorer.model.base.USD_UPPER import io.provenance.explorer.service.AccountService import io.provenance.explorer.service.AssetService import io.provenance.explorer.service.BlockService @@ -46,7 +43,6 @@ import io.provenance.explorer.service.CacheService import io.provenance.explorer.service.ExplorerService import io.provenance.explorer.service.GovService import io.provenance.explorer.service.MetricsService -import io.provenance.explorer.service.PricingService import io.provenance.explorer.service.TokenService import io.provenance.explorer.service.ValidatorService import io.provenance.explorer.service.getBlock @@ -66,24 +62,21 @@ import org.springframework.scheduling.annotation.Scheduled import org.springframework.stereotype.Service import tendermint.types.BlockOuterClass import java.math.BigDecimal -import java.time.OffsetDateTime -import java.time.ZoneOffset import javax.annotation.PostConstruct @Service class ScheduledTaskService( private val props: ExplorerProperties, private val blockService: BlockService, - private val assetService: AssetService, private val govService: GovService, private val blockAndTxProcessor: BlockAndTxProcessor, private val explorerService: ExplorerService, private val cacheService: CacheService, private val tokenService: TokenService, - private val pricingService: PricingService, private val accountService: AccountService, private val valService: ValidatorService, - private val metricsService: MetricsService + private val metricsService: MetricsService, + private val assetService: AssetService ) { protected val logger = logger(ScheduledTaskService::class) @@ -252,34 +245,9 @@ class ScheduledTaskService( }.let { if (it.isNotEmpty()) BlockTxRetryRecord.deleteRecords(it) } } - @Scheduled(cron = "0 0/15 * * * ?") // Every 15 minutes + @Scheduled(initialDelay = 0L, fixedDelay = 300000L) // Every 5 minutes fun updateAssetPricing() { - logger.info("Updating asset pricing") - val key = CacheKeys.PRICING_UPDATE.key - val now = OffsetDateTime.now().withOffsetSameInstant(ZoneOffset.UTC).toString() - cacheService.getCacheValue(key)!!.let { cache -> - pricingService.getPricingAsync(cache.cacheValue!!, "async pricing update").forEach { price -> - // don't set price from PE - if (price.markerDenom != UTILITY_TOKEN) { - assetService.getAssetRaw(price.markerDenom).let { pricingService.insertAssetPricing(it, price) } - } else { - // Pull price from CMC, calculate to the true base denom price - val cmcPrice = - tokenService.getTokenLatest()?.quote?.get(USD_UPPER)?.price - ?.let { - val scale = it.scale() - it.setScale(scale + UTILITY_TOKEN_BASE_DECIMAL_PLACES) - .div(UTILITY_TOKEN_BASE_MULTIPLIER) - } - // If CMC data exists, use that, else use the PE value - val newPriceObj = price.copy(usdPrice = cmcPrice ?: price.usdPrice!!) - // Save it - assetService.getAssetRaw(price.markerDenom).let { - pricingService.insertAssetPricing(it, newPriceObj) - } - } - } - }.let { cacheService.updateCacheValue(key, now) } + assetService.updateAssetPricingFromLatestNav() } @Scheduled(cron = "0 0/15 * * * ?") // Every 15 minutes @@ -299,7 +267,7 @@ class ScheduledTaskService( tokenService.updateAndSaveTokenHistoricalData(startDate, today) } - @Scheduled(cron = "0 0/5 * * * ?") // Every 5 minutes + @Scheduled(initialDelay = 0L, fixedDelay = 300000L) // Every 5 minutes fun updateTokenLatest() { val today = DateTime.now().withZone(DateTimeZone.UTC) val startDate = today.minusDays(1) 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 index 686a6390..0dd4841e 100644 --- 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 @@ -18,7 +18,7 @@ class FlowApiPriceFetcher( return "flow-api" } override fun fetchHistoricalPrice(fromDate: DateTime?): List { - val onChainNavEvents = getMarkerNavByPriceDenoms(fromDate, 17800) + val onChainNavEvents = getMarkerNavByPriceDenoms(fromDate) return onChainNavEvents.map { navEvent -> val volumeHash = calculateVolumeHash(navEvent.volume) val pricePerHash = getPricePerHashFromMicroUsd(navEvent.priceAmount, navEvent.volume) @@ -34,8 +34,8 @@ class FlowApiPriceFetcher( } } - fun getMarkerNavByPriceDenoms(fromDate: DateTime?, limit: Int): List { - return flowApiGrpcClient.getMarkerNavByPriceDenoms(denom, pricingDenoms, fromDate, limit) + fun getMarkerNavByPriceDenoms(fromDate: DateTime?): List { + return flowApiGrpcClient.getAllMarkerNavByPriceDenoms(denom, pricingDenoms, fromDate, 10000) } fun calculateVolumeHash(volumeNhash: Long): BigDecimal { diff --git a/service/src/main/resources/application-development.properties b/service/src/main/resources/application-development.properties index 993079bd..d08fd66f 100644 --- a/service/src/main/resources/application-development.properties +++ b/service/src/main/resources/application-development.properties @@ -24,16 +24,16 @@ explorer.voting-power-padding=1000000 #### MAINNET SETTINGS -#explorer.mainnet=true -#explorer.pb-url=grpcs://grpc.provenance.io:443 -#explorer.pricing-url=https://figure.tech/service-pricing-engine/external +explorer.mainnet=true +explorer.pb-url=grpc://192.168.86.232:9093 +explorer.pricing-url=https://figure.tech/service-pricing-engine/external #explorer.genesis-version-url=https://github.com/provenance-io/provenance/releases/download/v1.0.1/plan-v1.0.1.json #explorer.fee-bug-range-one-eleven=6512577,7334443 #### TESTNET SETTINGS -explorer.mainnet=false -explorer.pricing-url=https://test.figure.tech/service-pricing-engine/external -explorer.pb-url=grpcs://grpc.test.provenance.io:443 +#explorer.mainnet=false +#explorer.pricing-url=https://test.figure.tech/service-pricing-engine/external +#explorer.pb-url=grpcs://grpc.test.provenance.io:443 explorer.genesis-version-url=https://github.com/provenance-io/provenance/releases/download/v0.2.0/plan-v0.2.0.json explorer.fee-bug-range-one-eleven=8721085,10046412 diff --git a/service/src/test/kotlin/io/provenance/explorer/domain/extensions/NavEventExtensionsKtTest.kt b/service/src/test/kotlin/io/provenance/explorer/domain/extensions/NavEventExtensionsKtTest.kt new file mode 100644 index 00000000..62611a62 --- /dev/null +++ b/service/src/test/kotlin/io/provenance/explorer/domain/extensions/NavEventExtensionsKtTest.kt @@ -0,0 +1,58 @@ +package io.provenance.explorer.domain.extensions + +import io.provlabs.flow.api.NavEvent +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test +import java.math.BigDecimal + +class NavEventExtensionsKtTest { + + @Test + fun `test calculateUsdPricePerUnit for flow nav events`() { + val usdDenom = "usd" + val nonUsdDenom = "non-usd" + + val navEventUsdVolume1Price1 = NavEvent.newBuilder() + .setPriceAmount(1) + .setPriceDenom(usdDenom) + .setVolume(1L) + .build() + + val navEventUsdVolume1Price12 = NavEvent.newBuilder() + .setPriceAmount(12) + .setPriceDenom(usdDenom) + .setVolume(1L) + .build() + + val navEventUsdVolume1Price123 = NavEvent.newBuilder() + .setPriceAmount(123) + .setPriceDenom(usdDenom) + .setVolume(1L) + .build() + + val navEventUsdVolume1Price1234 = NavEvent.newBuilder() + .setPriceAmount(1234) + .setPriceDenom(usdDenom) + .setVolume(1L) + .build() + + val navEventNonUsd = NavEvent.newBuilder() + .setPriceAmount(1234) + .setPriceDenom(nonUsdDenom) + .setVolume(1L) + .build() + + val navEventZeroVolume = NavEvent.newBuilder() + .setPriceAmount(1234) + .setPriceDenom(usdDenom) + .setVolume(0L) + .build() + + assertEquals(BigDecimal("0.001"), navEventUsdVolume1Price1.calculateUsdPricePerUnit(), "Price amount 1 should be converted to 0.001") + assertEquals(BigDecimal("0.012"), navEventUsdVolume1Price12.calculateUsdPricePerUnit(), "Price amount 12 should be converted to 0.012") + assertEquals(BigDecimal("0.123"), navEventUsdVolume1Price123.calculateUsdPricePerUnit(), "Price amount 123 should be converted to 0.123") + assertEquals(BigDecimal("1.234"), navEventUsdVolume1Price1234.calculateUsdPricePerUnit(), "Price amount 1234 should be converted to 1.234") + assertEquals(BigDecimal.ZERO, navEventNonUsd.calculateUsdPricePerUnit(), "Non-USD denomination should return 0") + assertEquals(BigDecimal.ZERO, navEventZeroVolume.calculateUsdPricePerUnit(), "Zero volume should return 0") + } +} diff --git a/service/src/test/kotlin/io/provenance/explorer/grpc/flow/FlowApiGrpcClientTest.kt b/service/src/test/kotlin/io/provenance/explorer/grpc/flow/FlowApiGrpcClientTest.kt new file mode 100644 index 00000000..ad6bb64f --- /dev/null +++ b/service/src/test/kotlin/io/provenance/explorer/grpc/flow/FlowApiGrpcClientTest.kt @@ -0,0 +1,83 @@ +package io.provenance.explorer.grpc.flow + +import io.provenance.explorer.config.ExplorerProperties.Companion.UTILITY_TOKEN +import io.provlabs.flow.api.NavEvent +import org.joda.time.DateTime +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.assertNotNull +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.BeforeAll +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import java.net.URI + +class FlowApiGrpcClientTest { + + companion object { + private lateinit var grpcClient: FlowApiGrpcClient + + @BeforeAll + @JvmStatic + fun setup() { + val testGrpcUri = URI.create("grpc://localhost:50051") + grpcClient = FlowApiGrpcClient(testGrpcUri) + } + } + + @Test + @Disabled("This test is used for manually executing the grpc endpoint") + fun `test getLatestNavPrices with valid data`() { + val priceDenom = "usd" + val includeMarkers = true + val includeScopes = true + val fromDate = DateTime.now().minusDays(7) + val limit = 5 + + val navEvents: List = grpcClient.getLatestNavPrices(priceDenom, includeMarkers, includeScopes, fromDate, limit) + + assertNotNull(navEvents) + assertFalse(navEvents.isEmpty(), "Expected non-empty list of NAV events") + assertTrue(navEvents.size <= limit, "Expected results within the specified limit") + + navEvents.forEach { event -> + assertEquals(priceDenom, event.priceDenom, "Price denomination mismatch") + } + } + + @Test + @Disabled("This test is used for manually executing the grpc endpoint") + fun `test getAllLatestNavPrices with valid data`() { + val priceDenom = "usd" + val includeMarkers = true + val includeScopes = true + val fromDate = DateTime.now().minusDays(1) + + val navEvents: List = grpcClient.getAllLatestNavPrices(priceDenom, includeMarkers, includeScopes, fromDate) + + assertNotNull(navEvents) + assertFalse(navEvents.isEmpty(), "Expected non-empty list of NAV events") + + navEvents.forEach { event -> + assertEquals(priceDenom, event.priceDenom, "Price denomination mismatch") + } + } + + @Test + @Disabled("This test is used for manually executing the grpc endpoint") + fun `test getAllMarkerNavByPriceDenoms with valid data`() { + val denom = UTILITY_TOKEN + val priceDenoms = listOf("uusd.trading", "uusdc.figure.se", "uusdt.figure.se") + val fromDate = DateTime.now().minusDays(7) + + val navEvents: List = grpcClient.getAllMarkerNavByPriceDenoms(denom, priceDenoms, fromDate) + + assertNotNull(navEvents) + assertFalse(navEvents.isEmpty(), "Expected non-empty list of NAV events") + + navEvents.forEach { event -> + assertEquals(denom, event.denom, "Nav denomination mismatch") + assertTrue(priceDenoms.contains(event.priceDenom), "Price denom mismatch") + } + } +} 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 index f1669505..39d29f4d 100644 --- 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 @@ -43,9 +43,8 @@ class FlowApiPriceFetcherTest { @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 result: List = flowApiPriceFetcher.getMarkerNavByPriceDenoms(fromDate) val groupedByPriceDenom = result.groupBy { it.priceDenom }