// Code generated by ent, DO NOT EDIT.

package tokentransaction

import (
	"fmt"
	"time"

	"entgo.io/ent"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"github.com/google/uuid"
	"github.com/lightsparkdev/spark/so/ent/schema/schematype"
)

const (
	// Label holds the string label denoting the tokentransaction type in the database.
	Label = "token_transaction"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldCreateTime holds the string denoting the create_time field in the database.
	FieldCreateTime = "create_time"
	// FieldUpdateTime holds the string denoting the update_time field in the database.
	FieldUpdateTime = "update_time"
	// FieldPartialTokenTransactionHash holds the string denoting the partial_token_transaction_hash field in the database.
	FieldPartialTokenTransactionHash = "partial_token_transaction_hash"
	// FieldFinalizedTokenTransactionHash holds the string denoting the finalized_token_transaction_hash field in the database.
	FieldFinalizedTokenTransactionHash = "finalized_token_transaction_hash"
	// FieldOperatorSignature holds the string denoting the operator_signature field in the database.
	FieldOperatorSignature = "operator_signature"
	// FieldStatus holds the string denoting the status field in the database.
	FieldStatus = "status"
	// FieldExpiryTime holds the string denoting the expiry_time field in the database.
	FieldExpiryTime = "expiry_time"
	// FieldCoordinatorPublicKey holds the string denoting the coordinator_public_key field in the database.
	FieldCoordinatorPublicKey = "coordinator_public_key"
	// FieldClientCreatedTimestamp holds the string denoting the client_created_timestamp field in the database.
	FieldClientCreatedTimestamp = "client_created_timestamp"
	// FieldVersion holds the string denoting the version field in the database.
	FieldVersion = "version"
	// EdgeSpentOutput holds the string denoting the spent_output edge name in mutations.
	EdgeSpentOutput = "spent_output"
	// EdgeSpentOutputV2 holds the string denoting the spent_output_v2 edge name in mutations.
	EdgeSpentOutputV2 = "spent_output_v2"
	// EdgeCreatedOutput holds the string denoting the created_output edge name in mutations.
	EdgeCreatedOutput = "created_output"
	// EdgeMint holds the string denoting the mint edge name in mutations.
	EdgeMint = "mint"
	// EdgeCreate holds the string denoting the create edge name in mutations.
	EdgeCreate = "create"
	// EdgePaymentIntent holds the string denoting the payment_intent edge name in mutations.
	EdgePaymentIntent = "payment_intent"
	// EdgePeerSignatures holds the string denoting the peer_signatures edge name in mutations.
	EdgePeerSignatures = "peer_signatures"
	// EdgeSparkInvoice holds the string denoting the spark_invoice edge name in mutations.
	EdgeSparkInvoice = "spark_invoice"
	// Table holds the table name of the tokentransaction in the database.
	Table = "token_transactions"
	// SpentOutputTable is the table that holds the spent_output relation/edge.
	SpentOutputTable = "token_outputs"
	// SpentOutputInverseTable is the table name for the TokenOutput entity.
	// It exists in this package in order to avoid circular dependency with the "tokenoutput" package.
	SpentOutputInverseTable = "token_outputs"
	// SpentOutputColumn is the table column denoting the spent_output relation/edge.
	SpentOutputColumn = "token_output_output_spent_token_transaction"
	// SpentOutputV2Table is the table that holds the spent_output_v2 relation/edge. The primary key declared below.
	SpentOutputV2Table = "token_output_output_spent_started_token_transactions"
	// SpentOutputV2InverseTable is the table name for the TokenOutput entity.
	// It exists in this package in order to avoid circular dependency with the "tokenoutput" package.
	SpentOutputV2InverseTable = "token_outputs"
	// CreatedOutputTable is the table that holds the created_output relation/edge.
	CreatedOutputTable = "token_outputs"
	// CreatedOutputInverseTable is the table name for the TokenOutput entity.
	// It exists in this package in order to avoid circular dependency with the "tokenoutput" package.
	CreatedOutputInverseTable = "token_outputs"
	// CreatedOutputColumn is the table column denoting the created_output relation/edge.
	CreatedOutputColumn = "token_output_output_created_token_transaction"
	// MintTable is the table that holds the mint relation/edge.
	MintTable = "token_transactions"
	// MintInverseTable is the table name for the TokenMint entity.
	// It exists in this package in order to avoid circular dependency with the "tokenmint" package.
	MintInverseTable = "token_mints"
	// MintColumn is the table column denoting the mint relation/edge.
	MintColumn = "token_transaction_mint"
	// CreateTable is the table that holds the create relation/edge.
	CreateTable = "token_transactions"
	// CreateInverseTable is the table name for the TokenCreate entity.
	// It exists in this package in order to avoid circular dependency with the "tokencreate" package.
	CreateInverseTable = "token_creates"
	// CreateColumn is the table column denoting the create relation/edge.
	CreateColumn = "token_transaction_create"
	// PaymentIntentTable is the table that holds the payment_intent relation/edge.
	PaymentIntentTable = "token_transactions"
	// PaymentIntentInverseTable is the table name for the PaymentIntent entity.
	// It exists in this package in order to avoid circular dependency with the "paymentintent" package.
	PaymentIntentInverseTable = "payment_intents"
	// PaymentIntentColumn is the table column denoting the payment_intent relation/edge.
	PaymentIntentColumn = "token_transaction_payment_intent"
	// PeerSignaturesTable is the table that holds the peer_signatures relation/edge.
	PeerSignaturesTable = "token_transaction_peer_signatures"
	// PeerSignaturesInverseTable is the table name for the TokenTransactionPeerSignature entity.
	// It exists in this package in order to avoid circular dependency with the "tokentransactionpeersignature" package.
	PeerSignaturesInverseTable = "token_transaction_peer_signatures"
	// PeerSignaturesColumn is the table column denoting the peer_signatures relation/edge.
	PeerSignaturesColumn = "token_transaction_peer_signatures"
	// SparkInvoiceTable is the table that holds the spark_invoice relation/edge. The primary key declared below.
	SparkInvoiceTable = "token_transaction_spark_invoice"
	// SparkInvoiceInverseTable is the table name for the SparkInvoice entity.
	// It exists in this package in order to avoid circular dependency with the "sparkinvoice" package.
	SparkInvoiceInverseTable = "spark_invoices"
)

// Columns holds all SQL columns for tokentransaction fields.
var Columns = []string{
	FieldID,
	FieldCreateTime,
	FieldUpdateTime,
	FieldPartialTokenTransactionHash,
	FieldFinalizedTokenTransactionHash,
	FieldOperatorSignature,
	FieldStatus,
	FieldExpiryTime,
	FieldCoordinatorPublicKey,
	FieldClientCreatedTimestamp,
	FieldVersion,
}

// ForeignKeys holds the SQL foreign-keys that are owned by the "token_transactions"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
	"token_transaction_mint",
	"token_transaction_create",
	"token_transaction_payment_intent",
}

var (
	// SpentOutputV2PrimaryKey and SpentOutputV2Column2 are the table columns denoting the
	// primary key for the spent_output_v2 relation (M2M).
	SpentOutputV2PrimaryKey = []string{"token_output_id", "token_transaction_id"}
	// SparkInvoicePrimaryKey and SparkInvoiceColumn2 are the table columns denoting the
	// primary key for the spark_invoice relation (M2M).
	SparkInvoicePrimaryKey = []string{"token_transaction_id", "spark_invoice_id"}
)

// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
	for i := range Columns {
		if column == Columns[i] {
			return true
		}
	}
	for i := range ForeignKeys {
		if column == ForeignKeys[i] {
			return true
		}
	}
	return false
}

// Note that the variables below are initialized by the runtime
// package on the initialization of the application. Therefore,
// it should be imported in the main as follows:
//
//	import _ "github.com/lightsparkdev/spark/so/ent/runtime"
var (
	Hooks [1]ent.Hook
	// DefaultCreateTime holds the default value on creation for the "create_time" field.
	DefaultCreateTime func() time.Time
	// DefaultUpdateTime holds the default value on creation for the "update_time" field.
	DefaultUpdateTime func() time.Time
	// UpdateDefaultUpdateTime holds the default value on update for the "update_time" field.
	UpdateDefaultUpdateTime func() time.Time
	// PartialTokenTransactionHashValidator is a validator for the "partial_token_transaction_hash" field. It is called by the builders before save.
	PartialTokenTransactionHashValidator func([]byte) error
	// FinalizedTokenTransactionHashValidator is a validator for the "finalized_token_transaction_hash" field. It is called by the builders before save.
	FinalizedTokenTransactionHashValidator func([]byte) error
	// DefaultVersion holds the default value on creation for the "version" field.
	DefaultVersion schematype.TokenTransactionVersion
	// VersionValidator is a validator for the "version" field. It is called by the builders before save.
	VersionValidator func(int) error
	// DefaultID holds the default value on creation for the "id" field.
	DefaultID func() uuid.UUID
)

// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save.
func StatusValidator(s schematype.TokenTransactionStatus) error {
	switch s {
	case "STARTED", "STARTED_CANCELLED", "SIGNED", "REVEALED", "SIGNED_CANCELLED", "FINALIZED":
		return nil
	default:
		return fmt.Errorf("tokentransaction: invalid enum value for status field: %q", s)
	}
}

// OrderOption defines the ordering options for the TokenTransaction queries.
type OrderOption func(*sql.Selector)

// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldID, opts...).ToFunc()
}

// ByCreateTime orders the results by the create_time field.
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
}

// ByUpdateTime orders the results by the update_time field.
func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldUpdateTime, opts...).ToFunc()
}

// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldStatus, opts...).ToFunc()
}

// ByExpiryTime orders the results by the expiry_time field.
func ByExpiryTime(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldExpiryTime, opts...).ToFunc()
}

// ByClientCreatedTimestamp orders the results by the client_created_timestamp field.
func ByClientCreatedTimestamp(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldClientCreatedTimestamp, opts...).ToFunc()
}

// ByVersion orders the results by the version field.
func ByVersion(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldVersion, opts...).ToFunc()
}

// BySpentOutputCount orders the results by spent_output count.
func BySpentOutputCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newSpentOutputStep(), opts...)
	}
}

// BySpentOutput orders the results by spent_output terms.
func BySpentOutput(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newSpentOutputStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}

// BySpentOutputV2Count orders the results by spent_output_v2 count.
func BySpentOutputV2Count(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newSpentOutputV2Step(), opts...)
	}
}

// BySpentOutputV2 orders the results by spent_output_v2 terms.
func BySpentOutputV2(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newSpentOutputV2Step(), append([]sql.OrderTerm{term}, terms...)...)
	}
}

// ByCreatedOutputCount orders the results by created_output count.
func ByCreatedOutputCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newCreatedOutputStep(), opts...)
	}
}

// ByCreatedOutput orders the results by created_output terms.
func ByCreatedOutput(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newCreatedOutputStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}

// ByMintField orders the results by mint field.
func ByMintField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newMintStep(), sql.OrderByField(field, opts...))
	}
}

// ByCreateField orders the results by create field.
func ByCreateField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newCreateStep(), sql.OrderByField(field, opts...))
	}
}

// ByPaymentIntentField orders the results by payment_intent field.
func ByPaymentIntentField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newPaymentIntentStep(), sql.OrderByField(field, opts...))
	}
}

// ByPeerSignaturesCount orders the results by peer_signatures count.
func ByPeerSignaturesCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newPeerSignaturesStep(), opts...)
	}
}

// ByPeerSignatures orders the results by peer_signatures terms.
func ByPeerSignatures(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newPeerSignaturesStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}

// BySparkInvoiceCount orders the results by spark_invoice count.
func BySparkInvoiceCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newSparkInvoiceStep(), opts...)
	}
}

// BySparkInvoice orders the results by spark_invoice terms.
func BySparkInvoice(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newSparkInvoiceStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}
func newSpentOutputStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(SpentOutputInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, true, SpentOutputTable, SpentOutputColumn),
	)
}
func newSpentOutputV2Step() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(SpentOutputV2InverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2M, true, SpentOutputV2Table, SpentOutputV2PrimaryKey...),
	)
}
func newCreatedOutputStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(CreatedOutputInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, true, CreatedOutputTable, CreatedOutputColumn),
	)
}
func newMintStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(MintInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, MintTable, MintColumn),
	)
}
func newCreateStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(CreateInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, CreateTable, CreateColumn),
	)
}
func newPaymentIntentStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(PaymentIntentInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, PaymentIntentTable, PaymentIntentColumn),
	)
}
func newPeerSignaturesStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(PeerSignaturesInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, PeerSignaturesTable, PeerSignaturesColumn),
	)
}
func newSparkInvoiceStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(SparkInvoiceInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2M, false, SparkInvoiceTable, SparkInvoicePrimaryKey...),
	)
}
