// Code generated by ent, DO NOT EDIT.

package depositaddress

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 depositaddress type in the database.
	Label = "deposit_address"
	// 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"
	// FieldAddress holds the string denoting the address field in the database.
	FieldAddress = "address"
	// FieldNetwork holds the string denoting the network field in the database.
	FieldNetwork = "network"
	// FieldOwnerIdentityPubkey holds the string denoting the owner_identity_pubkey field in the database.
	FieldOwnerIdentityPubkey = "owner_identity_pubkey"
	// FieldOwnerSigningPubkey holds the string denoting the owner_signing_pubkey field in the database.
	FieldOwnerSigningPubkey = "owner_signing_pubkey"
	// FieldConfirmationHeight holds the string denoting the confirmation_height field in the database.
	FieldConfirmationHeight = "confirmation_height"
	// FieldConfirmationTxid holds the string denoting the confirmation_txid field in the database.
	FieldConfirmationTxid = "confirmation_txid"
	// FieldAddressSignatures holds the string denoting the address_signatures field in the database.
	FieldAddressSignatures = "address_signatures"
	// FieldPossessionSignature holds the string denoting the possession_signature field in the database.
	FieldPossessionSignature = "possession_signature"
	// FieldNodeID holds the string denoting the node_id field in the database.
	FieldNodeID = "node_id"
	// FieldIsStatic holds the string denoting the is_static field in the database.
	FieldIsStatic = "is_static"
	// FieldIsDefault holds the string denoting the is_default field in the database.
	FieldIsDefault = "is_default"
	// EdgeSigningKeyshare holds the string denoting the signing_keyshare edge name in mutations.
	EdgeSigningKeyshare = "signing_keyshare"
	// EdgeUtxo holds the string denoting the utxo edge name in mutations.
	EdgeUtxo = "utxo"
	// EdgeUtxoswaps holds the string denoting the utxoswaps edge name in mutations.
	EdgeUtxoswaps = "utxoswaps"
	// EdgeTree holds the string denoting the tree edge name in mutations.
	EdgeTree = "tree"
	// Table holds the table name of the depositaddress in the database.
	Table = "deposit_addresses"
	// SigningKeyshareTable is the table that holds the signing_keyshare relation/edge.
	SigningKeyshareTable = "deposit_addresses"
	// SigningKeyshareInverseTable is the table name for the SigningKeyshare entity.
	// It exists in this package in order to avoid circular dependency with the "signingkeyshare" package.
	SigningKeyshareInverseTable = "signing_keyshares"
	// SigningKeyshareColumn is the table column denoting the signing_keyshare relation/edge.
	SigningKeyshareColumn = "deposit_address_signing_keyshare"
	// UtxoTable is the table that holds the utxo relation/edge.
	UtxoTable = "utxos"
	// 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 = "deposit_address_utxo"
	// UtxoswapsTable is the table that holds the utxoswaps relation/edge.
	UtxoswapsTable = "utxo_swaps"
	// UtxoswapsInverseTable is the table name for the UtxoSwap entity.
	// It exists in this package in order to avoid circular dependency with the "utxoswap" package.
	UtxoswapsInverseTable = "utxo_swaps"
	// UtxoswapsColumn is the table column denoting the utxoswaps relation/edge.
	UtxoswapsColumn = "deposit_address_utxoswaps"
	// TreeTable is the table that holds the tree relation/edge.
	TreeTable = "trees"
	// TreeInverseTable is the table name for the Tree entity.
	// It exists in this package in order to avoid circular dependency with the "tree" package.
	TreeInverseTable = "trees"
	// TreeColumn is the table column denoting the tree relation/edge.
	TreeColumn = "deposit_address_tree"
)

// Columns holds all SQL columns for depositaddress fields.
var Columns = []string{
	FieldID,
	FieldCreateTime,
	FieldUpdateTime,
	FieldAddress,
	FieldNetwork,
	FieldOwnerIdentityPubkey,
	FieldOwnerSigningPubkey,
	FieldConfirmationHeight,
	FieldConfirmationTxid,
	FieldAddressSignatures,
	FieldPossessionSignature,
	FieldNodeID,
	FieldIsStatic,
	FieldIsDefault,
}

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

// 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
	// AddressValidator is a validator for the "address" field. It is called by the builders before save.
	AddressValidator func(string) error
	// DefaultIsStatic holds the default value on creation for the "is_static" field.
	DefaultIsStatic bool
	// DefaultIsDefault holds the default value on creation for the "is_default" field.
	DefaultIsDefault bool
	// DefaultID holds the default value on creation for the "id" field.
	DefaultID func() uuid.UUID
)

// NetworkValidator is a validator for the "network" field enum values. It is called by the builders before save.
func NetworkValidator(n schematype.Network) error {
	switch n {
	case "UNSPECIFIED", "MAINNET", "REGTEST", "TESTNET", "SIGNET":
		return nil
	default:
		return fmt.Errorf("depositaddress: invalid enum value for network field: %q", n)
	}
}

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

// ByAddress orders the results by the address field.
func ByAddress(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldAddress, opts...).ToFunc()
}

// ByNetwork orders the results by the network field.
func ByNetwork(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldNetwork, opts...).ToFunc()
}

// ByConfirmationHeight orders the results by the confirmation_height field.
func ByConfirmationHeight(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldConfirmationHeight, opts...).ToFunc()
}

// ByConfirmationTxid orders the results by the confirmation_txid field.
func ByConfirmationTxid(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldConfirmationTxid, opts...).ToFunc()
}

// ByNodeID orders the results by the node_id field.
func ByNodeID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldNodeID, opts...).ToFunc()
}

// ByIsStatic orders the results by the is_static field.
func ByIsStatic(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldIsStatic, opts...).ToFunc()
}

// ByIsDefault orders the results by the is_default field.
func ByIsDefault(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldIsDefault, opts...).ToFunc()
}

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

// ByUtxoCount orders the results by utxo count.
func ByUtxoCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newUtxoStep(), opts...)
	}
}

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

// ByUtxoswapsCount orders the results by utxoswaps count.
func ByUtxoswapsCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newUtxoswapsStep(), opts...)
	}
}

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

// ByTreeField orders the results by tree field.
func ByTreeField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newTreeStep(), sql.OrderByField(field, opts...))
	}
}
func newSigningKeyshareStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(SigningKeyshareInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, SigningKeyshareTable, SigningKeyshareColumn),
	)
}
func newUtxoStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(UtxoInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, UtxoTable, UtxoColumn),
	)
}
func newUtxoswapsStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(UtxoswapsInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, UtxoswapsTable, UtxoswapsColumn),
	)
}
func newTreeStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(TreeInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2O, false, TreeTable, TreeColumn),
	)
}
