All Downloads are FREE. Search and download functionalities are using the official Maven repository.

indexer.indexer_models.proto Maven / Gradle / Ivy

The newest version!
syntax = "proto3";
import "scalapb/scalapb.proto";
import "scalapb/validate.proto";



///////////////////////////////////////////////////////////////////////////////
// Message definitions for data created by indexer
///////////////////////////////////////////////////////////////////////////////

import 'sdk/models/address.proto';
import 'sdk/models/transaction/io_transaction.proto';
import 'sdk/models/transaction/unspent_transaction_output.proto';
import 'sdk/models/transaction/spent_transaction_output.proto';
import 'consensus/models/block_id.proto';
import 'consensus/models/block_header.proto';
import 'node/models/block.proto';
import 'google/protobuf/wrappers.proto';

import "validate/validate.proto";

package org.plasmalabs.indexer.services;

// Used to identify the status of a Txo.
enum TxoState {
  SPENT = 0;   // The TxO is spent
  UNSPENT = 1; // The TxO is not spent
  PENDING = 2; // A transaction is pending that may spend the TXO. This state should only appear in node clients.
}

// A Txo and its status
message Txo {
  sdk.models.transaction.UnspentTransactionOutput transactionOutput = 1 [(validate.rules).message.required = true];
  TxoState state = 2;
  sdk.models.TransactionOutputAddress outputAddress = 3 [(validate.rules).message.required = true];
  // When 'state' is "SPENT", this field points to the transaction (input) that spent it.
  // Otherwise, this field is empty.
  Spender spender = 4;

  message Spender {
    sdk.models.TransactionInputAddress inputAddress = 1 [(validate.rules).message.required = true];
    sdk.models.transaction.SpentTransactionOutput input = 2 [(validate.rules).message.required = true];
  }
}

// Specify the order of data for indexes.
enum SortOrder {
  ASCENDING = 0;
  DESCENDING = 1;
  UNSORTED = 2;
}

// 1 - the probability that something will be subject to a reorg.
// Defaults to 0.9999999
message ConfidenceFactor {
  double value = 1;
}

// The distance between blocks
message ChainDistance {
  int64 value = 1;
}

// Types of assets that can be identified by an AssetLabel
enum LabelType {
  EMPTY = 0;
  LVL = 1;
  TOPL = 2;
  V1 = 3;
  TAM2 = 4;
}

// An identifier for a TAM2 asset type
message AssetLabel {
  LabelType labelType = 1;
  oneof label {
    Empty empty = 2; // Since this is a one-of we need to have a field to use for the label types such as LVL that don't need them.
    V1Label v1Label = 3;
    Tam2Label tam2Label = 4;
  }

  message Empty {};

  message V1Label {
    uint32 version = 1;
    sdk.models.LockAddress mintingAddress = 2 [(validate.rules).message.required = true];
  }

  message Tam2Label {
    fixed64 groupHashMostSignificant = 1;
    fixed64 groupHashMoreSignificant = 2;
    fixed64 groupHashLessSignificant = 3;
    fixed64 groupHashLeastSignificant = 4;
    fixed64 seriesHashMostSignificant = 5;
    fixed64 seriesHashMoreSignificant = 6;
    fixed64 seriesHashLessSignificant = 7;
    fixed64 seriesHashLeastSignificant = 8;
  }
}

// A request to create an index of transaction based on their on-chain metadata
message IndexSpec {
  // The name of the index
  string indexName = 1;
  // A description of the fields to be indexed
  IndexFieldSpec indexFieldSpec = 2 [(validate.rules).message.required = true];
  // Filter to determine which transactions are included in the index. Only records that match the filter will be included in the index.
  IndexFilter indexFilter = 3;
}

// A specification to identify the field(s) in data to be indexed
message IndexFieldSpec {
  oneof spec {
    JsonIndexSpecs jsonSpecs = 1;
    CsvIndexSpecs csvSpecs = 2;
    //TODO ways to specify indexes for other types of data
  }
}

// a sequence of csv field references to identify the values in data to be indexed
message CsvIndexSpecs {
  repeated CsvIndexSpec specs = 1;
  uint32 separatorChar = 2; // The character code that is used to separate fields.
  google.protobuf.UInt32Value quoteChar = 3; // If this is present, the specified character appears at the beginning and end of each field.
}

// a sequence of csv field references to identify the values in data to be indexed
message CsvIndexSpec {
  // Origin 1 field index
  uint32 fieldIndex = 1;
  SortOrder sortOrder = 2;
  bool isNumeric = 3; // If this is true, the field is sorted numerically; otherwise lexically.
}

// A sequence of JSONPath strings to identify the values in data to be indexed (https://datatracker.ietf.org/doc/id/draft-goessner-dispatch-jsonpath-00.html)
message JsonIndexSpecs {
  repeated JsonIndexSpec specs = 1;
}

// A JSONPath string to identify a value in data to be indexed (https://datatracker.ietf.org/doc/id/draft-goessner-dispatch-jsonpath-00.html)
message JsonIndexSpec {
  string jsonPath = 1;
  SortOrder sortOrder = 2;
}

// How records should be filtered to determine which ones to include in an index.
message IndexFilter {
  oneof filter {
    string regexIndexFilter = 1;
  }
}

message TransactionReceipt {
  sdk.models.transaction.IoTransaction transaction = 1 [(validate.rules).message.required = true];
  ConfidenceFactor confidenceFactor = 2 [(validate.rules).message.required = true];
  consensus.models.BlockId blockId = 3 [(validate.rules).message.required = true];
  ChainDistance depth = 4 [(validate.rules).message.required = true];
}

// Data structure that encapsulates relation between a possible block data and its height.
message HeightData {
  int64 height = 1;
  BlockData blockData = 2;
}

// Data structure with the most important parts of a Block. Equivalent to a denormalized Full Block.
message BlockData {
  consensus.models.BlockHeader header = 1 [(validate.rules).message.required = true];
  node.models.FullBlockBody body = 4 [(validate.rules).message.required = true];
}

option (scalapb.options) = {
  [scalapb.validate.file] {
    validate_at_construction: true
  }
  field_transformations: [
    {
      when: {options: {[validate.rules] {message: {required: true}}}}
      set: {
        [scalapb.field] {
          required: true
        }
      }
    }
  ]
};




© 2015 - 2024 Weber Informatics LLC | Privacy Policy