Packages
services
Mode

mode

import "command-line-arguments"

Index

func AggregateKey (opens in a new tab)

func AggregateKey(key [][32]byte) []byte

AggregateKey concatenates the elements of the provided byte arrays into a single byte array. It returns the concatenated byte array.

Parameters: - key ([][32]byte): The byte array to concatenate.

Returns: - ([]byte): The concatenated byte array.

func CapitalizeColNames (opens in a new tab)

func CapitalizeColNames(colNames []string, tableSchema *TableSchema) []string

CapitalizeColNames capitalizes the column names and returns them in a slice.

Parameters: - colNames ([]string): A slice of column names. - tableSchema (*TableSchema): A pointer to the schema of the table.

Returns: - ([]string): A slice of capitalized column names.

func EncodeParameters (opens in a new tab)

func EncodeParameters(parameters []string, data []interface{}) ([]byte, error)

func FieldToString (opens in a new tab)

func FieldToString(field *mode.Field) string

FieldToString converts a field struct to a string.

Parameters: - field (*mode.Field): a pointer to a field struct that contains information about the field.

Returns: - (string) a string that represents the table name and table field, concatenated with a dot (.)

func KeyElementToString (opens in a new tab)

func KeyElementToString(keyElement [32]byte) string

KeyElementToString encodes the given byte array into a hexadecimal string. It returns the encoded hexadecimal string.

Parameters: - keyElement ([32]byte): The byte array to encode.

Returns: - (string): The hexadecimal string encoded from the provided byte array.

func KeyToFilter (opens in a new tab)

func KeyToFilter(tableSchema *TableSchema, key [][32]byte) []*pb_mode.Filter

KeyToFilter converts the given byte array keys into filter objects for use in queries. It returns a slice of filter objects, one for each key name in the tableSchema.

Parameters: - tableSchema (*TableSchema): A pointer to the schema of the table containing the keys. - key ([][32]byte): The byte array keys to convert.

Returns: - ([]*pb_mode.Filter): A slice of filter objects.

func KeyToString (opens in a new tab)

func KeyToString(keys [][32]byte) []string

KeyToString encodes each byte array element into a hexadecimal string and stores them in a slice. It returns the slice of hexadecimal encoded strings.

Parameters: - keys ([][32]byte): The byte arrays to encode.

Returns: - ([]string): The slice of hexadecimal encoded strings.

func PrepareForScan (opens in a new tab)

func PrepareForScan(rows *sqlx.Rows) (colNames []string, row []interface{}, rowInterface []interface{})

PrepareForScan prepares the rows object for scanning and returns the column names, row, and rowInterface.

Parameters: - rows (*sqlx.Rows): The sqlx.Rows object.

Returns: - (colNames []string): A slice of column names. - (row []interface{}): A slice of row interfaces. - (rowInterface []interface{}): A slice of row interfaces.

func SerializeRow (opens in a new tab)

func SerializeRow(row []interface{}, colNames []string, colEncodingTypes []*abi.Type) (*mode.Row, error)

SerializeRow serializes a single row with all fields encoded and returns it as a mode.Row.

Parameters: - row ([]interface{}): A slice of fields for a single row. - colNames ([]string): A slice of column names. - colEncodingTypes ([]*abi.Type): A slice of column encoding types.

Returns: - (*mode.Row): A pointer to the mode.Row containing the serialized row. - (error): An error, if any occurred during serialization.

func SerializeRows (opens in a new tab)

func SerializeRows(rows *sqlx.Rows, tableSchema *TableSchema, fieldProjections map[string]string) (*mode.GenericTable, error)

SerializeRows serializes multiple rows from the provided sqlx.Rows object and returns a mode.GenericTable.

Parameters: - rows (*sqlx.Rows): The sqlx.Rows object. - tableSchema (*TableSchema): A pointer to the schema of the table. - fieldProjections (map[string]string): A map of field projections.

Returns: - (*mode.GenericTable): A pointer to the mode.GenericTable containing the serialized rows. - (error): An error, if any occurred during serialization.

func SerializeStreamEvent (opens in a new tab)

func SerializeStreamEvent(event *db.StreamEvent, tableSchema *TableSchema, fieldProjections map[string]string) (*mode.GenericTable, error)

SerializeStreamEvent serializes a single stream event and returns it as a mode.GenericTable.

Parameters: - event (*db.StreamEvent): The stream event to serialize. - tableSchema (*TableSchema): A pointer to the schema of the table. - fieldProjections (map[string]string): A map of field projections.

Returns: - (*mode.GenericTable): A pointer to the mode.GenericTable containing the serialized stream event. - (error): An error, if any occurred during serialization.

type DataSchema (opens in a new tab)

type DataSchema struct {
    ComponentMapping             map[string]string                        `json:"component_keccak_mapping"`
    ComponentValueSchema         map[string]map[string]DataSchemaTypePair `json:"component_value_schema"`
    ComponentSolidityTypeMapping map[string]string                        `json:"component_solidity_type_mapping"`
    ComponentDefaultSchema       map[string]DataSchemaTypePair            `json:"component_default_schema"`
}

func NewDataSchemaFromJSON (opens in a new tab)

func NewDataSchemaFromJSON(jsonPath string) *DataSchema

NewDataSchemaFromJSON creates a new DataSchema instance from a JSON file at the specified path.

Parameters: - jsonPath (string): The path to the JSON file.

Returns: - (*DataSchema): A pointer to the new DataSchema instance.

func (*DataSchema) BuildTableSchemas (opens in a new tab)

func (dataSchema *DataSchema) BuildTableSchemas() map[string]*TableSchema

BuildTableSchemas builds table schemas for each table in the DataSchema.

Returns: - (map[string]*TableSchema): A map of table schemas keyed by table name.

type DataSchemaTypePair (opens in a new tab)

type DataSchemaTypePair struct {
    SolidityType string `json:"solidity"`
    PostgresType string `json:"postgres"`
}

type TableSchema (opens in a new tab)

type TableSchema struct {
    TableId    string   `json:"id"`   // Table ID as it comes from chain.
    TableName  string   `json:"name"` // Table name is table ID but with naming adjustments to work with the database.
    FieldNames []string `json:"field_names"`
    KeyNames   []string `json:"key_names"` // Key names are separte from field names and are used for searching.
 
    SolidityTypes map[string]string `json:"solidity_types"` // Field name -> Solidity type
    PostgresTypes map[string]string `json:"postgres_types"` // Field name -> Postgres type
 
    // Auxiliary data about the table.
    Namespace             string                  `json:"namespace"`
    StoreCoreSchemaTypeKV *storecore.SchemaTypeKV `json:"store_core_schema_type_kv"`
    PrimaryKey            string                  `json:"primary_key"`
    OnChainReadableName   string                  `json:"on_chain_readable_name"`
    OnChainColNames       map[string]string       `json:"on_chain_col_names"`
}

func CombineSchemas (opens in a new tab)

func CombineSchemas(schemas []*TableSchema) *TableSchema

CombineSchemas combines multiple table schemas into a single schema with the combined table name.

Parameters: - schemas ([]*TableSchema): A slice of table schemas to combine.

Returns: - (*TableSchema): A pointer to the combined table schema.

func (*TableSchema) FilterFromKV (opens in a new tab)

func (schema *TableSchema) FilterFromKV(key, value string) *pb_mode.Filter

FilterFromKV creates a Filter object for a given key-value pair, where the filter checks if the value of a field in the TableSchema is equal to the given value.

Parameters: - key (string): the name of the field in the table that the filter is checking against - value (string): the value that the filter is checking for

Returns: - (*pb_mode.Filter): a pointer to a Filter object that represents the filter condition where a specific field in the table is equal to a given value.

func (*TableSchema) FilterFromMap (opens in a new tab)

func (schema *TableSchema) FilterFromMap(filter map[string]string) []*pb_mode.Filter

FilterFromMap creates an array of Filter objects from a map of key-value pairs, where each filter checks if the value of a field in the TableSchema is equal to the given value.

Parameters: - filter (map[string]string): a map where each key is the name of a field in the table that the filter is checking against, and each value is the value that the filter is checking for

Returns: - ([]*pb_mode.Filter): an array of pointers to Filter objects that represent the filter conditions where specific fields in the table are equal to given values.

func (*TableSchema) GetEncodingTypes (opens in a new tab)

func (schema *TableSchema) GetEncodingTypes(fieldNames []string, fieldProjections map[string]string) ([]*abi.Type, []string)

GetEncodingTypes returns the encoding types for the specified field names and projections.

Parameters: - fieldNames ([]string): A slice of field names. - fieldProjections (map[string]string): A map of field projections.

Returns: - ([]*abi.Type): A slice of encoding types. - ([]string): A slice of encoding type strings.

func (*TableSchema) NamespacedTableName (opens in a new tab)

func (schema *TableSchema) NamespacedTableName() string

NamespacedTableName returns the fully-qualified table name in the format "namespace.table_name".

Returns: - (string): The fully-qualified table name.

func (*TableSchema) ToSolidityTupleString (opens in a new tab)

func (schema *TableSchema) ToSolidityTupleString() string

ToSolidityTupleString returns the Solidity tuple string for the table schema.

Returns: - (string): The Solidity tuple string for the table schema.

Generated by gomarkdoc (opens in a new tab)