// Code generated by ent, DO NOT EDIT.

package utxoswap

import (
	"fmt"
	"time"

	"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 utxoswap type in the database.
	Label = "utxo_swap"
	// 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"
	// FieldStatus holds the string denoting the status field in the database.
	FieldStatus = "status"
	// FieldRequestType holds the string denoting the request_type field in the database.
	FieldRequestType = "request_type"
	// FieldCreditAmountSats holds the string denoting the credit_amount_sats field in the database.
	FieldCreditAmountSats = "credit_amount_sats"
	// FieldMaxFeeSats holds the string denoting the max_fee_sats field in the database.
	FieldMaxFeeSats = "max_fee_sats"
	// FieldSspSignature holds the string denoting the ssp_signature field in the database.
	FieldSspSignature = "ssp_signature"
	// FieldSspIdentityPublicKey holds the string denoting the ssp_identity_public_key field in the database.
	FieldSspIdentityPublicKey = "ssp_identity_public_key"
	// FieldUserSignature holds the string denoting the user_signature field in the database.
	FieldUserSignature = "user_signature"
	// FieldUserIdentityPublicKey holds the string denoting the user_identity_public_key field in the database.
	FieldUserIdentityPublicKey = "user_identity_public_key"
	// FieldCoordinatorIdentityPublicKey holds the string denoting the coordinator_identity_public_key field in the database.
	FieldCoordinatorIdentityPublicKey = "coordinator_identity_public_key"
	// FieldRequestedTransferID holds the string denoting the requested_transfer_id field in the database.
	FieldRequestedTransferID = "requested_transfer_id"
	// FieldSpendTxSigningResult holds the string denoting the spend_tx_signing_result field in the database.
	FieldSpendTxSigningResult = "spend_tx_signing_result"
	// EdgeUtxo holds the string denoting the utxo edge name in mutations.
	EdgeUtxo = "utxo"
	// EdgeTransfer holds the string denoting the transfer edge name in mutations.
	EdgeTransfer = "transfer"
	// Table holds the table name of the utxoswap in the database.
	Table = "utxo_swaps"
	// UtxoTable is the table that holds the utxo relation/edge.
	UtxoTable = "utxo_swaps"
	// UtxoInverseTable is the table name for the Utxo entity.
	// It exists in this package in order to avoid circular dependency with the "utxo" package.
	UtxoInverseTable = "utxos"
	// UtxoColumn is the table column denoting the utxo relation/edge.
	UtxoColumn = "utxo_swap_utxo"
	// TransferTable is the table that holds the transfer relation/edge.
	TransferTable = "utxo_swaps"
	// TransferInverseTable is the table name for the Transfer entity.
	// It exists in this package in order to avoid circular dependency with the "transfer" package.
	TransferInverseTable = "transfers"
	// TransferColumn is the table column denoting the transfer relation/edge.
	TransferColumn = "utxo_swap_transfer"
)

// Columns holds all SQL columns for utxoswap fields.
var Columns = []string{
	FieldID,
	FieldCreateTime,
	FieldUpdateTime,
	FieldStatus,
	FieldRequestType,
	FieldCreditAmountSats,
	FieldMaxFeeSats,
	FieldSspSignature,
	FieldSspIdentityPublicKey,
	FieldUserSignature,
	FieldUserIdentityPublicKey,
	FieldCoordinatorIdentityPublicKey,
	FieldRequestedTransferID,
	FieldSpendTxSigningResult,
}

// ForeignKeys holds the SQL foreign-keys that are owned by the "utxo_swaps"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
	"deposit_address_utxoswaps",
	"utxo_swap_utxo",
	"utxo_swap_transfer",
}

// 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
}

var (
	// 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
	// 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.UtxoSwapStatus) error {
	switch s {
	case "CREATED", "COMPLETED", "CANCELLED":
		return nil
	default:
		return fmt.Errorf("utxoswap: invalid enum value for status field: %q", s)
	}
}

// RequestTypeValidator is a validator for the "request_type" field enum values. It is called by the builders before save.
func RequestTypeValidator(rt schematype.UtxoSwapRequestType) error {
	switch rt {
	case "FIXED_AMOUNT", "MAX_FEE", "REFUND":
		return nil
	default:
		return fmt.Errorf("utxoswap: invalid enum value for request_type field: %q", rt)
	}
}

// OrderOption defines the ordering options for the UtxoSwap 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()
}

// ByRequestType orders the results by the request_type field.
func ByRequestType(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldRequestType, opts...).ToFunc()
}

// ByCreditAmountSats orders the results by the credit_amount_sats field.
func ByCreditAmountSats(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCreditAmountSats, opts...).ToFunc()
}

// ByMaxFeeSats orders the results by the max_fee_sats field.
func ByMaxFeeSats(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldMaxFeeSats, opts...).ToFunc()
}

// ByRequestedTransferID orders the results by the requested_transfer_id field.
func ByRequestedTransferID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldRequestedTransferID, opts...).ToFunc()
}

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

// ByTransferField orders the results by transfer field.
func ByTransferField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newTransferStep(), sql.OrderByField(field, opts...))
	}
}
func newUtxoStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(UtxoInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, UtxoTable, UtxoColumn),
	)
}
func newTransferStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(TransferInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, TransferTable, TransferColumn),
	)
}
