diff --git a/.env b/z1/.env similarity index 100% rename from .env rename to z1/.env diff --git a/z1/.gitignore b/z1/.gitignore new file mode 100644 index 0000000..962f948 --- /dev/null +++ b/z1/.gitignore @@ -0,0 +1,7 @@ +frontend/node_modules +go.sum +social-network +users.db +fiber +frontend/.next/ +/out/ \ No newline at end of file diff --git a/Dockerfile b/z1/Dockerfile similarity index 100% rename from Dockerfile rename to z1/Dockerfile diff --git a/README.md b/z1/README.md similarity index 100% rename from README.md rename to z1/README.md diff --git a/backend/Dockerfile b/z1/backend/Dockerfile similarity index 100% rename from backend/Dockerfile rename to z1/backend/Dockerfile diff --git a/backend/README.md b/z1/backend/README.md similarity index 100% rename from backend/README.md rename to z1/backend/README.md diff --git a/backend/auth.go b/z1/backend/auth.go similarity index 100% rename from backend/auth.go rename to z1/backend/auth.go diff --git a/backend/db.go b/z1/backend/db.go similarity index 100% rename from backend/db.go rename to z1/backend/db.go diff --git a/backend/go.mod b/z1/backend/go.mod similarity index 100% rename from backend/go.mod rename to z1/backend/go.mod diff --git a/backend/server.go b/z1/backend/server.go similarity index 100% rename from backend/server.go rename to z1/backend/server.go diff --git a/docker-compose.yml b/z1/docker-compose.yml similarity index 100% rename from docker-compose.yml rename to z1/docker-compose.yml diff --git a/frontend/.dockerignore b/z1/frontend/.dockerignore similarity index 100% rename from frontend/.dockerignore rename to z1/frontend/.dockerignore diff --git a/frontend/.env b/z1/frontend/.env similarity index 100% rename from frontend/.env rename to z1/frontend/.env diff --git a/frontend/Dockerfile b/z1/frontend/Dockerfile similarity index 100% rename from frontend/Dockerfile rename to z1/frontend/Dockerfile diff --git a/frontend/README.md b/z1/frontend/README.md similarity index 100% rename from frontend/README.md rename to z1/frontend/README.md diff --git a/frontend/components/comment.tsx b/z1/frontend/components/comment.tsx similarity index 100% rename from frontend/components/comment.tsx rename to z1/frontend/components/comment.tsx diff --git a/frontend/components/post.tsx b/z1/frontend/components/post.tsx similarity index 100% rename from frontend/components/post.tsx rename to z1/frontend/components/post.tsx diff --git a/frontend/components/ui.tsx b/z1/frontend/components/ui.tsx similarity index 100% rename from frontend/components/ui.tsx rename to z1/frontend/components/ui.tsx diff --git a/frontend/next-env.d.ts b/z1/frontend/next-env.d.ts similarity index 100% rename from frontend/next-env.d.ts rename to z1/frontend/next-env.d.ts diff --git a/frontend/next.config.js b/z1/frontend/next.config.js similarity index 100% rename from frontend/next.config.js rename to z1/frontend/next.config.js diff --git a/frontend/package-lock.json b/z1/frontend/package-lock.json similarity index 100% rename from frontend/package-lock.json rename to z1/frontend/package-lock.json diff --git a/frontend/package.json b/z1/frontend/package.json similarity index 100% rename from frontend/package.json rename to z1/frontend/package.json diff --git a/frontend/pages/_app.tsx b/z1/frontend/pages/_app.tsx similarity index 100% rename from frontend/pages/_app.tsx rename to z1/frontend/pages/_app.tsx diff --git a/frontend/pages/index.tsx b/z1/frontend/pages/index.tsx similarity index 100% rename from frontend/pages/index.tsx rename to z1/frontend/pages/index.tsx diff --git a/frontend/pages/login.tsx b/z1/frontend/pages/login.tsx similarity index 100% rename from frontend/pages/login.tsx rename to z1/frontend/pages/login.tsx diff --git a/frontend/pages/logout.tsx b/z1/frontend/pages/logout.tsx similarity index 100% rename from frontend/pages/logout.tsx rename to z1/frontend/pages/logout.tsx diff --git a/frontend/pages/post/[pid].tsx b/z1/frontend/pages/post/[pid].tsx similarity index 100% rename from frontend/pages/post/[pid].tsx rename to z1/frontend/pages/post/[pid].tsx diff --git a/frontend/pages/profile.tsx b/z1/frontend/pages/profile.tsx similarity index 100% rename from frontend/pages/profile.tsx rename to z1/frontend/pages/profile.tsx diff --git a/frontend/pages/profile/[pid].tsx b/z1/frontend/pages/profile/[pid].tsx similarity index 100% rename from frontend/pages/profile/[pid].tsx rename to z1/frontend/pages/profile/[pid].tsx diff --git a/frontend/pages/signup.tsx b/z1/frontend/pages/signup.tsx similarity index 100% rename from frontend/pages/signup.tsx rename to z1/frontend/pages/signup.tsx diff --git a/frontend/postcss.config.js b/z1/frontend/postcss.config.js similarity index 100% rename from frontend/postcss.config.js rename to z1/frontend/postcss.config.js diff --git a/frontend/public/facebook_cover_photo_1.png b/z1/frontend/public/facebook_cover_photo_1.png similarity index 100% rename from frontend/public/facebook_cover_photo_1.png rename to z1/frontend/public/facebook_cover_photo_1.png diff --git a/frontend/public/facebook_cover_photo_2.png b/z1/frontend/public/facebook_cover_photo_2.png similarity index 100% rename from frontend/public/facebook_cover_photo_2.png rename to z1/frontend/public/facebook_cover_photo_2.png diff --git a/frontend/public/facebook_profile_image.png b/z1/frontend/public/facebook_profile_image.png similarity index 100% rename from frontend/public/facebook_profile_image.png rename to z1/frontend/public/facebook_profile_image.png diff --git a/frontend/public/favicon.png b/z1/frontend/public/favicon.png similarity index 100% rename from frontend/public/favicon.png rename to z1/frontend/public/favicon.png diff --git a/frontend/public/instagram_profile_image.png b/z1/frontend/public/instagram_profile_image.png similarity index 100% rename from frontend/public/instagram_profile_image.png rename to z1/frontend/public/instagram_profile_image.png diff --git a/frontend/public/linkedin_banner_image_1.png b/z1/frontend/public/linkedin_banner_image_1.png similarity index 100% rename from frontend/public/linkedin_banner_image_1.png rename to z1/frontend/public/linkedin_banner_image_1.png diff --git a/frontend/public/linkedin_banner_image_2.png b/z1/frontend/public/linkedin_banner_image_2.png similarity index 100% rename from frontend/public/linkedin_banner_image_2.png rename to z1/frontend/public/linkedin_banner_image_2.png diff --git a/frontend/public/linkedin_profile_image.png b/z1/frontend/public/linkedin_profile_image.png similarity index 100% rename from frontend/public/linkedin_profile_image.png rename to z1/frontend/public/linkedin_profile_image.png diff --git a/frontend/public/logo.png b/z1/frontend/public/logo.png similarity index 100% rename from frontend/public/logo.png rename to z1/frontend/public/logo.png diff --git a/frontend/public/logo_transparent.png b/z1/frontend/public/logo_transparent.png similarity index 100% rename from frontend/public/logo_transparent.png rename to z1/frontend/public/logo_transparent.png diff --git a/frontend/public/pinterest_board_photo.png b/z1/frontend/public/pinterest_board_photo.png similarity index 100% rename from frontend/public/pinterest_board_photo.png rename to z1/frontend/public/pinterest_board_photo.png diff --git a/frontend/public/pinterest_profile_image.png b/z1/frontend/public/pinterest_profile_image.png similarity index 100% rename from frontend/public/pinterest_profile_image.png rename to z1/frontend/public/pinterest_profile_image.png diff --git a/frontend/public/twitter_header_photo_1.png b/z1/frontend/public/twitter_header_photo_1.png similarity index 100% rename from frontend/public/twitter_header_photo_1.png rename to z1/frontend/public/twitter_header_photo_1.png diff --git a/frontend/public/twitter_header_photo_2.png b/z1/frontend/public/twitter_header_photo_2.png similarity index 100% rename from frontend/public/twitter_header_photo_2.png rename to z1/frontend/public/twitter_header_photo_2.png diff --git a/frontend/public/twitter_profile_image.png b/z1/frontend/public/twitter_profile_image.png similarity index 100% rename from frontend/public/twitter_profile_image.png rename to z1/frontend/public/twitter_profile_image.png diff --git a/frontend/public/youtube_profile_image.png b/z1/frontend/public/youtube_profile_image.png similarity index 100% rename from frontend/public/youtube_profile_image.png rename to z1/frontend/public/youtube_profile_image.png diff --git a/frontend/styles/Home.module.css b/z1/frontend/styles/Home.module.css similarity index 100% rename from frontend/styles/Home.module.css rename to z1/frontend/styles/Home.module.css diff --git a/frontend/styles/globals.css b/z1/frontend/styles/globals.css similarity index 100% rename from frontend/styles/globals.css rename to z1/frontend/styles/globals.css diff --git a/frontend/tailwind.config.js b/z1/frontend/tailwind.config.js similarity index 100% rename from frontend/tailwind.config.js rename to z1/frontend/tailwind.config.js diff --git a/frontend/tsconfig.json b/z1/frontend/tsconfig.json similarity index 100% rename from frontend/tsconfig.json rename to z1/frontend/tsconfig.json diff --git a/nginx.conf b/z1/nginx.conf similarity index 100% rename from nginx.conf rename to z1/nginx.conf diff --git a/remove-app.sh b/z1/remove-app.sh similarity index 100% rename from remove-app.sh rename to z1/remove-app.sh diff --git a/screenshots/1.png b/z1/screenshots/1.png similarity index 100% rename from screenshots/1.png rename to z1/screenshots/1.png diff --git a/screenshots/2.png b/z1/screenshots/2.png similarity index 100% rename from screenshots/2.png rename to z1/screenshots/2.png diff --git a/screenshots/3.png b/z1/screenshots/3.png similarity index 100% rename from screenshots/3.png rename to z1/screenshots/3.png diff --git a/screenshots/4.png b/z1/screenshots/4.png similarity index 100% rename from screenshots/4.png rename to z1/screenshots/4.png diff --git a/start-app.sh b/z1/start-app.sh similarity index 100% rename from start-app.sh rename to z1/start-app.sh diff --git a/stop-app.sh b/z1/stop-app.sh similarity index 100% rename from stop-app.sh rename to z1/stop-app.sh diff --git a/z2/README.md b/z2/README.md new file mode 100644 index 0000000..7faa439 --- /dev/null +++ b/z2/README.md @@ -0,0 +1,108 @@ +# Veritas Revelata + +The aim is to establish a robust framwork to combat +misinfomation, disinformation, and fake news, thereby providing a more re- +liable information system. This paper outlines the key components of the +proposal, including source evaluation, fact-checking, technological require- +ments, while also addressing the challenges and the ethical consideration +associated with such system. + +the app contains of 2 main components a golang p2p node that runs the consesnsus algorithm for the blockchain + +A decentralized frontend served over the internet or locally + + +# Containers used +- golang build: compliation container for compilling the app +- golang runner: runs the p2p node and the rpc server +- fe builder: compile and build the nodejs app for serving +- fe runner: serves the static files through SSR techonology for + +# DEVOPS +The app requires a local registry running for develpoment use cases +The minikube local registry can be ran with: +```sh +minikube addons enable registry +``` +running the applications requires +```sh +./start-app.sh +``` +stopping it requires +```sh +./stop-app.sh +``` + +for checking the cluster with minikube you can run: +```sh +minikube dashboard +``` + +## Kubernetes +first we have the deployments: +### p2p-node Deployment: + +- **Metadata**: The name of the deployment is p2p-node and it resides in the veritas namespace. + +- **Replicas**: The desired number of replicas for this deployment is 1, meaning there should be one Pod running at any given time. + +- **Pod Template**: This is the specification for creating Pods. It includes a single container. + +- **Container**: The container is named p2pnode and uses the image localhost:5000/veritasnode. The image pull policy is IfNotPresent, meaning the image will be pulled only if it's not already present on the node. + +- **Environment Variable**: There's an environment variable PORT set to 6000. + +- **Ports**: The container exposes port 6000 for TCP traffic, and this port is also mapped to the host's port 6000. + +- **Volume** Mounts: There's a volume mounted at /app using the volume named node-data. + +- **Volumes**: The volume node-data is a PersistentVolumeClaim using the claim node-data. +### veritasfe Deployment: + +- **Metadata**: The name of the deployment is veritasfe and it also resides in the veritas namespace. +- **Replicas**: The desired number of replicas for this deployment is also 1. +- **Selector**: The selector is looking for Pods with the label app: veritasfe. +- **Pod Template**: +- **Labels**: The Pod labels are app: veritasfe. +- **Container**: The container is named frontend and uses the image localhost:5000/veritasfe. +- **Ports**: The container exposes port 3000 for TCP traffic, and this port is also mapped to the host's port 3000. +- **Restart Policy**: The restart policy for the Pod is Always, meaning the containers in the Pod will always be restarted if they terminate. + +### p2p-node Service + +The `p2p-node` service is a service resource that exposes the `p2p-node` + +- **Metadata:** + - Labels: `app: p2p-node` + - Name: `p2p-node` + - Namespace: `veritas` + +- **Spec:** + - The service listens on port `6000` and forwards traffic to the target port `6000` on the `p2p-node` Pod. + + - **Ports:** + - Name: `6000` + Port: `6000` + Target Port: `6000` + +### frontend Service + +The `frontend` service is a ervice resource that exposes the `frontend` deployment + +- **Metadata:** + - Labels: `app: frontend` + - Name: `frontend` + - Namespace: `veritas` + +- **Spec:** + - The service listens on port `3000` and forwards traffic to the target port `3000` on the `frontend` Pod. + + - **Ports:** + - Name: `3000` + Port: `3000` + Target Port: `3000` + +# Accessibility +the frontend can be accessed through localhost:3000 on any web browser +and the rpc server runs on localhost:6000 + diff --git a/z2/backend/Dockerfile b/z2/backend/Dockerfile new file mode 100644 index 0000000..0a43793 --- /dev/null +++ b/z2/backend/Dockerfile @@ -0,0 +1,14 @@ +FROM golang AS build +# RUN apk --no-cache add gcc g++ make git +WORKDIR /go/src/app +COPY . . +RUN go mod tidy +# RUN GOOS=linux go build -ldflags="-s -w" -o ./bin/web-app +RUN GOOS=linux go build -o ./bin/veritas + +FROM ubuntu +RUN mkdir /app +WORKDIR /app +COPY --from=build /go/src/app/bin /go/bin +EXPOSE 6000 +ENTRYPOINT /go/bin/veritas \ No newline at end of file diff --git a/z2/backend/core/block.go b/z2/backend/core/block.go new file mode 100644 index 0000000..80a5f11 --- /dev/null +++ b/z2/backend/core/block.go @@ -0,0 +1,12 @@ +package core + +type Block struct { + Hash string + Nonce int + Length int + PreviousHash string +} + +func (b Block) Serialize() ([]byte, error) { + return []byte(b.Hash), nil +} diff --git a/z2/backend/core/consensus.go b/z2/backend/core/consensus.go new file mode 100644 index 0000000..a38a836 --- /dev/null +++ b/z2/backend/core/consensus.go @@ -0,0 +1,193 @@ +package core + +import ( + "context" + "crypto/sha256" + "encoding/hex" + "encoding/json" + "errors" + "fmt" + "hash" + "log" + "time" + + "thesis/crypto" + "thesis/ent" +) + +/* +** Type 1: Transaction sync +** Type 2: New Transaction cast + */ +type DataPacket struct { + Type int + Data []byte +} + +func (p DataPacket) Serialize() []byte { + data, err := json.Marshal(p) + if err != nil { + panic(err) + } + return data +} + +func DeSerialize(p []byte) DataPacket { + + var msg DataPacket + err := json.Unmarshal(p, &msg) + if err != nil { + panic(err) + } + return msg +} + +func SyncContent(msg DataPacket) { + if msg.Type == 1 { + fmt.Println("got a tx sync") + } +} + +func ValidateContent(client *ent.Client, pk *crypto.PublicKey) error { + txs, err := client.Transactions.Query().All(context.Background()) + handleError(err) + for i := 0; i < len(txs); i++ { + currentTx := &Transaction{ + Type: txs[i].Type, + Timestamp: int64(txs[i].Timestamp), + Comment: txs[i].Comment, + Content: txs[i].Content, + Hash: txs[i].Hash, + Signature: txs[i].Signature, + } + // fmt.Println(currentTx) + err := crypto.ValidateSignature(currentTx.Signature, pk, []byte(currentTx.Hash)) + handleError(err) + log.Printf("Valid signature for tx: %s", currentTx.Hash) + } + + blocks, err := client.Blocks.Query().All(context.Background()) + handleError(err) + for i := 0; i < len(blocks); i++ { + // currentBlock := &core.Block{ + // Hash: blocks[i].Hash, + // Nonce: blocks[i].ID, + // Length: blocks[i].Length, + // PreviousHash: blocks[i].PreviousHash, + // } + + txs, err := blocks[i].QueryMinedTxs().All(context.Background()) + handleError(err) + var hash hash.Hash + for j := 0; j < len(txs); j++ { + tx := &Transaction{ + Type: txs[j].Type, + Timestamp: int64(txs[j].Timestamp), + Comment: txs[j].Comment, + Content: txs[j].Content, + Hash: txs[j].Hash, + Signature: txs[j].Signature, + } + txBytes, err := json.Marshal(tx) + handleError(err) + hash = sha256.New() + hash.Write(txBytes) + } + if fmt.Sprintf("0x%x", string(hash.Sum(nil))) == blocks[i].Hash { + log.Printf("Block %d validated \n", blocks[i].ID) + } else { + log.Printf("Block %d is invalid !!!\n", blocks[i].ID) + return errors.New("invalid block detected") + } + } + return nil +} + +func AddNewTx(client *ent.Client, content []byte, commit string, sig string, key *ent.Key) error { + + // key := db.GetKeyFromHex(pk) + // if key == nil { + // return + // } + tx := &Transaction{ + Type: 2, + Timestamp: time.Now().Unix(), + Comment: "regular tx", + Content: content, + Signature: sig, + } + txBytes, err := json.Marshal(tx) + handleError(err) + hash := sha256.New() + hash.Write(txBytes) + tx.Hash = fmt.Sprintf("0x%x", string(hash.Sum(nil))) + pubBytes, err := hex.DecodeString(key.PublicKey[2:]) + handleError(err) + pk := new(crypto.PublicKey).Uncompress(pubBytes) + fmt.Println(hash) + err = crypto.ValidateSignature(sig, pk, []byte(fmt.Sprintf("%s%s%s", key.PublicKey, tx.Comment, commit))) + if err != nil { + fmt.Println("Invalid data submitted") + // return nil + } + txContent := &TransactionContent{ + Signer: key.PublicKey, + Commitment: commit, + } + contentBytes, err := json.Marshal(txContent) + handleError(err) + dbTX, err := client.Transactions.Create(). + SetComment(tx.Comment). + SetHash(tx.Hash). + SetTimestamp(int(tx.Timestamp)). + SetSignature(tx.Signature). + SetType(tx.Type). + SetContent(contentBytes). + Save(context.Background()) + handleError(err) + // db.AddTx(client, txObj) + txBytes, err = json.Marshal(tx) + handleError(err) + hash = sha256.New() + hash.Write(txBytes) + + blocks, err := client.Blocks.Query().All(context.Background()) + handleError(err) + var block Block + + if len(blocks) == 0 { + block = Block{ + Hash: fmt.Sprintf("0x%x", string(hash.Sum(nil))), + Nonce: 0, + Length: 1, + PreviousHash: "0x000", + } + } else { + lastBlock := blocks[len(blocks)-1] + + block = Block{ + Hash: fmt.Sprintf("0x%x", string(hash.Sum(nil))), + Nonce: lastBlock.ID, + Length: 1, + PreviousHash: lastBlock.Hash, + } + } + + dbBlock, err := client.Blocks.Create(). + SetHash(block.Hash). + SetID(block.Nonce). + SetLength(block.Length). + SetPreviousHash(block.PreviousHash). + Save(context.Background()) + handleError(err) + _, err = dbTX.Update().AddBlock(dbBlock).Save(context.Background()) + handleError(err) + + return nil +} + +func handleError(err error) { + if err != nil { + panic(err) + } +} diff --git a/z2/backend/core/transaction.go b/z2/backend/core/transaction.go new file mode 100644 index 0000000..36c37cb --- /dev/null +++ b/z2/backend/core/transaction.go @@ -0,0 +1,16 @@ +package core + +type Transaction struct { + Type int + Timestamp int64 + Comment string + Content []byte + Hash string + Signature string +} + +// {"Signer": 0x0deadbeef, "commitment": 0x0000} +type TransactionContent struct { + Signer string + Commitment string +} diff --git a/z2/backend/crypto/keys.go b/z2/backend/crypto/keys.go new file mode 100644 index 0000000..e548a7c --- /dev/null +++ b/z2/backend/crypto/keys.go @@ -0,0 +1,93 @@ +package crypto + +import ( + "crypto/rand" + "encoding/hex" + "errors" + "fmt" + + blst "github.com/supranational/blst/bindings/go" +) + +type PublicKey = blst.P1Affine +type Signature = blst.P2Affine +type AggregateSignature = blst.P2Aggregate +type AggregatePublicKey = blst.P1Aggregate + +func GenerateKeys() (*blst.SecretKey, *PublicKey) { + var ikm [32]byte + _, _ = rand.Read(ikm[:]) + + sk := blst.KeyGen(ikm[:]) + pk := new(PublicKey).From(sk) + // fmt.Printf("The public key is: 0x%s\n", hex.EncodeToString(pk.Compress())) + // fmt.Printf("The private key is: 0x%s\n", hex.EncodeToString(sk.Serialize())) + // sk.Print(private) + return sk, pk +} + +func ImportKeyFromHex(s string) (*blst.SecretKey, string) { + bytesKey, err := hex.DecodeString(s[2:]) + if err != nil { + panic(err) + } + + sk := new(blst.SecretKey).Deserialize(bytesKey) + pk := new(PublicKey).From(sk) + // fmt.Printf("The public key is: 0x%s\n", hex.EncodeToString(pk.Compress())) + return sk, hex.EncodeToString(pk.Compress()) +} + +func SignMessage(msg string, sk *blst.SecretKey) string { + // var dst = []byte("BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_") + var dst = []byte("BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_") + sig := new(Signature).Sign(sk, []byte(msg), dst) + return hex.EncodeToString(sig.Compress()) +} + +func ValidateSignature(sigTxt string, pk *PublicKey, msg []byte) error { + byteSig, err := hex.DecodeString(sigTxt) + if err != nil { + panic(err) + } + sig := new(Signature).Uncompress(byteSig) + var dst = []byte("BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_") + if sig.Verify(false, pk, true, msg, dst) { + return nil + } else { + return errors.New("invalid signature found") + } +} + +func POC() { + + var keys []*blst.SecretKey + var pubs []*PublicKey + var sigs []*Signature + + for i := 0; i < 20; i++ { + var ikm [32]byte + _, _ = rand.Read(ikm[:]) + sk := blst.KeyGen(ikm[:]) + keys = append(keys, sk) + pk := new(PublicKey).From(sk) + pubs = append(pubs, pk) + var dst = []byte("BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_") + msg := []byte("testing bls signatures") + sig := new(Signature).Sign(sk, msg, dst) + + if !sig.Verify(true, pk, true, msg, dst) { + fmt.Println("ERROR: Invalid signature!") + } else { + sigs = append(sigs, sig) + } + } + + aggPk := new(AggregatePublicKey) + aggPk.Aggregate(pubs, false) + aggSig := new(AggregateSignature) + aggSig.Aggregate(sigs, false) + + fmt.Printf("the pk: 0x%s\n", hex.EncodeToString(aggPk.ToAffine().Compress())) + fmt.Printf("the sig: 0x%s\n", hex.EncodeToString(aggSig.ToAffine().Compress())) +} diff --git a/z2/backend/db/db.go b/z2/backend/db/db.go new file mode 100644 index 0000000..e297c24 --- /dev/null +++ b/z2/backend/db/db.go @@ -0,0 +1,65 @@ +package db + +import ( + "context" + + "thesis/core" + "thesis/ent" + "thesis/ent/key" +) + +func AddTx(client *ent.Client, tx *core.Transaction, signerKey *ent.Key) *ent.Transactions { + dbtx, err := client.Transactions.Create(). + SetType(tx.Type). + SetTimestamp(int(tx.Timestamp)). + SetComment(tx.Comment). + SetContent(tx.Content). + SetHash(tx.Hash). + SetSignature(tx.Signature).AddSigner(signerKey).Save(context.Background()) + + handleError(err) + return dbtx +} + +func AddBlock(client *ent.Client, block *core.Block) *ent.Blocks { + dbBlock, err := client.Blocks.Create(). + SetHash(block.Hash). + SetID(block.Nonce). + SetLength(block.Length). + SetPreviousHash(block.PreviousHash). + Save(context.Background()) + handleError(err) + return dbBlock +} + +func AddKey(client *ent.Client, pk string, owner string) error { + _, err := client.Key.Create().SetPublicKey(pk).SetOwner(owner).Save(context.Background()) + return err +} + +func GetKeyFromHex(client *ent.Client, pk string) *ent.Key { + k, err := client.Key.Query().Where(key.PublicKeyEQ(pk)).All(context.Background()) + handleError(err) + return k[0] +} + +func GetTxCount(client *ent.Client) int { + count, err := client.Transactions.Query().Count(context.Background()) + handleError(err) + return count +} + +func GetLatestBlock(client *ent.Client) *ent.Blocks { + blocks, err := client.Blocks.Query().All(context.Background()) + handleError(err) + if len(blocks) == 0 { + return nil + } + return blocks[len(blocks)-1] +} + +func handleError(err error) { + if err != nil { + panic(err) + } +} diff --git a/z2/backend/ent/blocks.go b/z2/backend/ent/blocks.go new file mode 100644 index 0000000..bf7c2c6 --- /dev/null +++ b/z2/backend/ent/blocks.go @@ -0,0 +1,167 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "thesis/ent/blocks" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// Blocks is the model entity for the Blocks schema. +type Blocks struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Hash holds the value of the "hash" field. + Hash string `json:"hash,omitempty"` + // Length holds the value of the "length" field. + Length int `json:"length,omitempty"` + // PreviousHash holds the value of the "previousHash" field. + PreviousHash string `json:"previousHash,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the BlocksQuery when eager-loading is set. + Edges BlocksEdges `json:"edges"` + selectValues sql.SelectValues +} + +// BlocksEdges holds the relations/edges for other nodes in the graph. +type BlocksEdges struct { + // Caster holds the value of the Caster edge. + Caster []*Validators `json:"Caster,omitempty"` + // MinedTxs holds the value of the MinedTxs edge. + MinedTxs []*Transactions `json:"MinedTxs,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// CasterOrErr returns the Caster value or an error if the edge +// was not loaded in eager-loading. +func (e BlocksEdges) CasterOrErr() ([]*Validators, error) { + if e.loadedTypes[0] { + return e.Caster, nil + } + return nil, &NotLoadedError{edge: "Caster"} +} + +// MinedTxsOrErr returns the MinedTxs value or an error if the edge +// was not loaded in eager-loading. +func (e BlocksEdges) MinedTxsOrErr() ([]*Transactions, error) { + if e.loadedTypes[1] { + return e.MinedTxs, nil + } + return nil, &NotLoadedError{edge: "MinedTxs"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Blocks) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case blocks.FieldID, blocks.FieldLength: + values[i] = new(sql.NullInt64) + case blocks.FieldHash, blocks.FieldPreviousHash: + values[i] = new(sql.NullString) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Blocks fields. +func (b *Blocks) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case blocks.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + b.ID = int(value.Int64) + case blocks.FieldHash: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field hash", values[i]) + } else if value.Valid { + b.Hash = value.String + } + case blocks.FieldLength: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field length", values[i]) + } else if value.Valid { + b.Length = int(value.Int64) + } + case blocks.FieldPreviousHash: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field previousHash", values[i]) + } else if value.Valid { + b.PreviousHash = value.String + } + default: + b.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Blocks. +// This includes values selected through modifiers, order, etc. +func (b *Blocks) Value(name string) (ent.Value, error) { + return b.selectValues.Get(name) +} + +// QueryCaster queries the "Caster" edge of the Blocks entity. +func (b *Blocks) QueryCaster() *ValidatorsQuery { + return NewBlocksClient(b.config).QueryCaster(b) +} + +// QueryMinedTxs queries the "MinedTxs" edge of the Blocks entity. +func (b *Blocks) QueryMinedTxs() *TransactionsQuery { + return NewBlocksClient(b.config).QueryMinedTxs(b) +} + +// Update returns a builder for updating this Blocks. +// Note that you need to call Blocks.Unwrap() before calling this method if this Blocks +// was returned from a transaction, and the transaction was committed or rolled back. +func (b *Blocks) Update() *BlocksUpdateOne { + return NewBlocksClient(b.config).UpdateOne(b) +} + +// Unwrap unwraps the Blocks entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (b *Blocks) Unwrap() *Blocks { + _tx, ok := b.config.driver.(*txDriver) + if !ok { + panic("ent: Blocks is not a transactional entity") + } + b.config.driver = _tx.drv + return b +} + +// String implements the fmt.Stringer. +func (b *Blocks) String() string { + var builder strings.Builder + builder.WriteString("Blocks(") + builder.WriteString(fmt.Sprintf("id=%v, ", b.ID)) + builder.WriteString("hash=") + builder.WriteString(b.Hash) + builder.WriteString(", ") + builder.WriteString("length=") + builder.WriteString(fmt.Sprintf("%v", b.Length)) + builder.WriteString(", ") + builder.WriteString("previousHash=") + builder.WriteString(b.PreviousHash) + builder.WriteByte(')') + return builder.String() +} + +// BlocksSlice is a parsable slice of Blocks. +type BlocksSlice []*Blocks diff --git a/z2/backend/ent/blocks/blocks.go b/z2/backend/ent/blocks/blocks.go new file mode 100644 index 0000000..db44461 --- /dev/null +++ b/z2/backend/ent/blocks/blocks.go @@ -0,0 +1,128 @@ +// Code generated by ent, DO NOT EDIT. + +package blocks + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the blocks type in the database. + Label = "blocks" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldHash holds the string denoting the hash field in the database. + FieldHash = "hash" + // FieldLength holds the string denoting the length field in the database. + FieldLength = "length" + // FieldPreviousHash holds the string denoting the previoushash field in the database. + FieldPreviousHash = "previous_hash" + // EdgeCaster holds the string denoting the caster edge name in mutations. + EdgeCaster = "Caster" + // EdgeMinedTxs holds the string denoting the minedtxs edge name in mutations. + EdgeMinedTxs = "MinedTxs" + // Table holds the table name of the blocks in the database. + Table = "blocks" + // CasterTable is the table that holds the Caster relation/edge. + CasterTable = "validators" + // CasterInverseTable is the table name for the Validators entity. + // It exists in this package in order to avoid circular dependency with the "validators" package. + CasterInverseTable = "validators" + // CasterColumn is the table column denoting the Caster relation/edge. + CasterColumn = "blocks_caster" + // MinedTxsTable is the table that holds the MinedTxs relation/edge. The primary key declared below. + MinedTxsTable = "blocks_MinedTxs" + // MinedTxsInverseTable is the table name for the Transactions entity. + // It exists in this package in order to avoid circular dependency with the "transactions" package. + MinedTxsInverseTable = "transactions" +) + +// Columns holds all SQL columns for blocks fields. +var Columns = []string{ + FieldID, + FieldHash, + FieldLength, + FieldPreviousHash, +} + +var ( + // MinedTxsPrimaryKey and MinedTxsColumn2 are the table columns denoting the + // primary key for the MinedTxs relation (M2M). + MinedTxsPrimaryKey = []string{"blocks_id", "transactions_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 + } + } + return false +} + +// OrderOption defines the ordering options for the Blocks 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() +} + +// ByHash orders the results by the hash field. +func ByHash(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHash, opts...).ToFunc() +} + +// ByLength orders the results by the length field. +func ByLength(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLength, opts...).ToFunc() +} + +// ByPreviousHash orders the results by the previousHash field. +func ByPreviousHash(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPreviousHash, opts...).ToFunc() +} + +// ByCasterCount orders the results by Caster count. +func ByCasterCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newCasterStep(), opts...) + } +} + +// ByCaster orders the results by Caster terms. +func ByCaster(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newCasterStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByMinedTxsCount orders the results by MinedTxs count. +func ByMinedTxsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newMinedTxsStep(), opts...) + } +} + +// ByMinedTxs orders the results by MinedTxs terms. +func ByMinedTxs(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newMinedTxsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newCasterStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(CasterInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, CasterTable, CasterColumn), + ) +} +func newMinedTxsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(MinedTxsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, MinedTxsTable, MinedTxsPrimaryKey...), + ) +} diff --git a/z2/backend/ent/blocks/where.go b/z2/backend/ent/blocks/where.go new file mode 100644 index 0000000..8b8f1cd --- /dev/null +++ b/z2/backend/ent/blocks/where.go @@ -0,0 +1,301 @@ +// Code generated by ent, DO NOT EDIT. + +package blocks + +import ( + "thesis/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.Blocks { + return predicate.Blocks(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Blocks { + return predicate.Blocks(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Blocks { + return predicate.Blocks(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Blocks { + return predicate.Blocks(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Blocks { + return predicate.Blocks(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Blocks { + return predicate.Blocks(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Blocks { + return predicate.Blocks(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Blocks { + return predicate.Blocks(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Blocks { + return predicate.Blocks(sql.FieldLTE(FieldID, id)) +} + +// Hash applies equality check predicate on the "hash" field. It's identical to HashEQ. +func Hash(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldEQ(FieldHash, v)) +} + +// Length applies equality check predicate on the "length" field. It's identical to LengthEQ. +func Length(v int) predicate.Blocks { + return predicate.Blocks(sql.FieldEQ(FieldLength, v)) +} + +// PreviousHash applies equality check predicate on the "previousHash" field. It's identical to PreviousHashEQ. +func PreviousHash(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldEQ(FieldPreviousHash, v)) +} + +// HashEQ applies the EQ predicate on the "hash" field. +func HashEQ(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldEQ(FieldHash, v)) +} + +// HashNEQ applies the NEQ predicate on the "hash" field. +func HashNEQ(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldNEQ(FieldHash, v)) +} + +// HashIn applies the In predicate on the "hash" field. +func HashIn(vs ...string) predicate.Blocks { + return predicate.Blocks(sql.FieldIn(FieldHash, vs...)) +} + +// HashNotIn applies the NotIn predicate on the "hash" field. +func HashNotIn(vs ...string) predicate.Blocks { + return predicate.Blocks(sql.FieldNotIn(FieldHash, vs...)) +} + +// HashGT applies the GT predicate on the "hash" field. +func HashGT(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldGT(FieldHash, v)) +} + +// HashGTE applies the GTE predicate on the "hash" field. +func HashGTE(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldGTE(FieldHash, v)) +} + +// HashLT applies the LT predicate on the "hash" field. +func HashLT(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldLT(FieldHash, v)) +} + +// HashLTE applies the LTE predicate on the "hash" field. +func HashLTE(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldLTE(FieldHash, v)) +} + +// HashContains applies the Contains predicate on the "hash" field. +func HashContains(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldContains(FieldHash, v)) +} + +// HashHasPrefix applies the HasPrefix predicate on the "hash" field. +func HashHasPrefix(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldHasPrefix(FieldHash, v)) +} + +// HashHasSuffix applies the HasSuffix predicate on the "hash" field. +func HashHasSuffix(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldHasSuffix(FieldHash, v)) +} + +// HashEqualFold applies the EqualFold predicate on the "hash" field. +func HashEqualFold(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldEqualFold(FieldHash, v)) +} + +// HashContainsFold applies the ContainsFold predicate on the "hash" field. +func HashContainsFold(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldContainsFold(FieldHash, v)) +} + +// LengthEQ applies the EQ predicate on the "length" field. +func LengthEQ(v int) predicate.Blocks { + return predicate.Blocks(sql.FieldEQ(FieldLength, v)) +} + +// LengthNEQ applies the NEQ predicate on the "length" field. +func LengthNEQ(v int) predicate.Blocks { + return predicate.Blocks(sql.FieldNEQ(FieldLength, v)) +} + +// LengthIn applies the In predicate on the "length" field. +func LengthIn(vs ...int) predicate.Blocks { + return predicate.Blocks(sql.FieldIn(FieldLength, vs...)) +} + +// LengthNotIn applies the NotIn predicate on the "length" field. +func LengthNotIn(vs ...int) predicate.Blocks { + return predicate.Blocks(sql.FieldNotIn(FieldLength, vs...)) +} + +// LengthGT applies the GT predicate on the "length" field. +func LengthGT(v int) predicate.Blocks { + return predicate.Blocks(sql.FieldGT(FieldLength, v)) +} + +// LengthGTE applies the GTE predicate on the "length" field. +func LengthGTE(v int) predicate.Blocks { + return predicate.Blocks(sql.FieldGTE(FieldLength, v)) +} + +// LengthLT applies the LT predicate on the "length" field. +func LengthLT(v int) predicate.Blocks { + return predicate.Blocks(sql.FieldLT(FieldLength, v)) +} + +// LengthLTE applies the LTE predicate on the "length" field. +func LengthLTE(v int) predicate.Blocks { + return predicate.Blocks(sql.FieldLTE(FieldLength, v)) +} + +// PreviousHashEQ applies the EQ predicate on the "previousHash" field. +func PreviousHashEQ(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldEQ(FieldPreviousHash, v)) +} + +// PreviousHashNEQ applies the NEQ predicate on the "previousHash" field. +func PreviousHashNEQ(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldNEQ(FieldPreviousHash, v)) +} + +// PreviousHashIn applies the In predicate on the "previousHash" field. +func PreviousHashIn(vs ...string) predicate.Blocks { + return predicate.Blocks(sql.FieldIn(FieldPreviousHash, vs...)) +} + +// PreviousHashNotIn applies the NotIn predicate on the "previousHash" field. +func PreviousHashNotIn(vs ...string) predicate.Blocks { + return predicate.Blocks(sql.FieldNotIn(FieldPreviousHash, vs...)) +} + +// PreviousHashGT applies the GT predicate on the "previousHash" field. +func PreviousHashGT(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldGT(FieldPreviousHash, v)) +} + +// PreviousHashGTE applies the GTE predicate on the "previousHash" field. +func PreviousHashGTE(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldGTE(FieldPreviousHash, v)) +} + +// PreviousHashLT applies the LT predicate on the "previousHash" field. +func PreviousHashLT(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldLT(FieldPreviousHash, v)) +} + +// PreviousHashLTE applies the LTE predicate on the "previousHash" field. +func PreviousHashLTE(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldLTE(FieldPreviousHash, v)) +} + +// PreviousHashContains applies the Contains predicate on the "previousHash" field. +func PreviousHashContains(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldContains(FieldPreviousHash, v)) +} + +// PreviousHashHasPrefix applies the HasPrefix predicate on the "previousHash" field. +func PreviousHashHasPrefix(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldHasPrefix(FieldPreviousHash, v)) +} + +// PreviousHashHasSuffix applies the HasSuffix predicate on the "previousHash" field. +func PreviousHashHasSuffix(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldHasSuffix(FieldPreviousHash, v)) +} + +// PreviousHashEqualFold applies the EqualFold predicate on the "previousHash" field. +func PreviousHashEqualFold(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldEqualFold(FieldPreviousHash, v)) +} + +// PreviousHashContainsFold applies the ContainsFold predicate on the "previousHash" field. +func PreviousHashContainsFold(v string) predicate.Blocks { + return predicate.Blocks(sql.FieldContainsFold(FieldPreviousHash, v)) +} + +// HasCaster applies the HasEdge predicate on the "Caster" edge. +func HasCaster() predicate.Blocks { + return predicate.Blocks(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, CasterTable, CasterColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasCasterWith applies the HasEdge predicate on the "Caster" edge with a given conditions (other predicates). +func HasCasterWith(preds ...predicate.Validators) predicate.Blocks { + return predicate.Blocks(func(s *sql.Selector) { + step := newCasterStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasMinedTxs applies the HasEdge predicate on the "MinedTxs" edge. +func HasMinedTxs() predicate.Blocks { + return predicate.Blocks(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, MinedTxsTable, MinedTxsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasMinedTxsWith applies the HasEdge predicate on the "MinedTxs" edge with a given conditions (other predicates). +func HasMinedTxsWith(preds ...predicate.Transactions) predicate.Blocks { + return predicate.Blocks(func(s *sql.Selector) { + step := newMinedTxsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Blocks) predicate.Blocks { + return predicate.Blocks(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Blocks) predicate.Blocks { + return predicate.Blocks(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Blocks) predicate.Blocks { + return predicate.Blocks(sql.NotPredicates(p)) +} diff --git a/z2/backend/ent/blocks_create.go b/z2/backend/ent/blocks_create.go new file mode 100644 index 0000000..45f3e59 --- /dev/null +++ b/z2/backend/ent/blocks_create.go @@ -0,0 +1,285 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "thesis/ent/blocks" + "thesis/ent/transactions" + "thesis/ent/validators" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// BlocksCreate is the builder for creating a Blocks entity. +type BlocksCreate struct { + config + mutation *BlocksMutation + hooks []Hook +} + +// SetHash sets the "hash" field. +func (bc *BlocksCreate) SetHash(s string) *BlocksCreate { + bc.mutation.SetHash(s) + return bc +} + +// SetLength sets the "length" field. +func (bc *BlocksCreate) SetLength(i int) *BlocksCreate { + bc.mutation.SetLength(i) + return bc +} + +// SetPreviousHash sets the "previousHash" field. +func (bc *BlocksCreate) SetPreviousHash(s string) *BlocksCreate { + bc.mutation.SetPreviousHash(s) + return bc +} + +// SetID sets the "id" field. +func (bc *BlocksCreate) SetID(i int) *BlocksCreate { + bc.mutation.SetID(i) + return bc +} + +// AddCasterIDs adds the "Caster" edge to the Validators entity by IDs. +func (bc *BlocksCreate) AddCasterIDs(ids ...int) *BlocksCreate { + bc.mutation.AddCasterIDs(ids...) + return bc +} + +// AddCaster adds the "Caster" edges to the Validators entity. +func (bc *BlocksCreate) AddCaster(v ...*Validators) *BlocksCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return bc.AddCasterIDs(ids...) +} + +// AddMinedTxIDs adds the "MinedTxs" edge to the Transactions entity by IDs. +func (bc *BlocksCreate) AddMinedTxIDs(ids ...int) *BlocksCreate { + bc.mutation.AddMinedTxIDs(ids...) + return bc +} + +// AddMinedTxs adds the "MinedTxs" edges to the Transactions entity. +func (bc *BlocksCreate) AddMinedTxs(t ...*Transactions) *BlocksCreate { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return bc.AddMinedTxIDs(ids...) +} + +// Mutation returns the BlocksMutation object of the builder. +func (bc *BlocksCreate) Mutation() *BlocksMutation { + return bc.mutation +} + +// Save creates the Blocks in the database. +func (bc *BlocksCreate) Save(ctx context.Context) (*Blocks, error) { + return withHooks(ctx, bc.sqlSave, bc.mutation, bc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (bc *BlocksCreate) SaveX(ctx context.Context) *Blocks { + v, err := bc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (bc *BlocksCreate) Exec(ctx context.Context) error { + _, err := bc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bc *BlocksCreate) ExecX(ctx context.Context) { + if err := bc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (bc *BlocksCreate) check() error { + if _, ok := bc.mutation.Hash(); !ok { + return &ValidationError{Name: "hash", err: errors.New(`ent: missing required field "Blocks.hash"`)} + } + if _, ok := bc.mutation.Length(); !ok { + return &ValidationError{Name: "length", err: errors.New(`ent: missing required field "Blocks.length"`)} + } + if _, ok := bc.mutation.PreviousHash(); !ok { + return &ValidationError{Name: "previousHash", err: errors.New(`ent: missing required field "Blocks.previousHash"`)} + } + return nil +} + +func (bc *BlocksCreate) sqlSave(ctx context.Context) (*Blocks, error) { + if err := bc.check(); err != nil { + return nil, err + } + _node, _spec := bc.createSpec() + if err := sqlgraph.CreateNode(ctx, bc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int(id) + } + bc.mutation.id = &_node.ID + bc.mutation.done = true + return _node, nil +} + +func (bc *BlocksCreate) createSpec() (*Blocks, *sqlgraph.CreateSpec) { + var ( + _node = &Blocks{config: bc.config} + _spec = sqlgraph.NewCreateSpec(blocks.Table, sqlgraph.NewFieldSpec(blocks.FieldID, field.TypeInt)) + ) + if id, ok := bc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := bc.mutation.Hash(); ok { + _spec.SetField(blocks.FieldHash, field.TypeString, value) + _node.Hash = value + } + if value, ok := bc.mutation.Length(); ok { + _spec.SetField(blocks.FieldLength, field.TypeInt, value) + _node.Length = value + } + if value, ok := bc.mutation.PreviousHash(); ok { + _spec.SetField(blocks.FieldPreviousHash, field.TypeString, value) + _node.PreviousHash = value + } + if nodes := bc.mutation.CasterIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: blocks.CasterTable, + Columns: []string{blocks.CasterColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := bc.mutation.MinedTxsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: blocks.MinedTxsTable, + Columns: blocks.MinedTxsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// BlocksCreateBulk is the builder for creating many Blocks entities in bulk. +type BlocksCreateBulk struct { + config + err error + builders []*BlocksCreate +} + +// Save creates the Blocks entities in the database. +func (bcb *BlocksCreateBulk) Save(ctx context.Context) ([]*Blocks, error) { + if bcb.err != nil { + return nil, bcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(bcb.builders)) + nodes := make([]*Blocks, len(bcb.builders)) + mutators := make([]Mutator, len(bcb.builders)) + for i := range bcb.builders { + func(i int, root context.Context) { + builder := bcb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*BlocksMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, bcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, bcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, bcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (bcb *BlocksCreateBulk) SaveX(ctx context.Context) []*Blocks { + v, err := bcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (bcb *BlocksCreateBulk) Exec(ctx context.Context) error { + _, err := bcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bcb *BlocksCreateBulk) ExecX(ctx context.Context) { + if err := bcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/z2/backend/ent/blocks_delete.go b/z2/backend/ent/blocks_delete.go new file mode 100644 index 0000000..9167797 --- /dev/null +++ b/z2/backend/ent/blocks_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "thesis/ent/blocks" + "thesis/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// BlocksDelete is the builder for deleting a Blocks entity. +type BlocksDelete struct { + config + hooks []Hook + mutation *BlocksMutation +} + +// Where appends a list predicates to the BlocksDelete builder. +func (bd *BlocksDelete) Where(ps ...predicate.Blocks) *BlocksDelete { + bd.mutation.Where(ps...) + return bd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (bd *BlocksDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, bd.sqlExec, bd.mutation, bd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (bd *BlocksDelete) ExecX(ctx context.Context) int { + n, err := bd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (bd *BlocksDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(blocks.Table, sqlgraph.NewFieldSpec(blocks.FieldID, field.TypeInt)) + if ps := bd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, bd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + bd.mutation.done = true + return affected, err +} + +// BlocksDeleteOne is the builder for deleting a single Blocks entity. +type BlocksDeleteOne struct { + bd *BlocksDelete +} + +// Where appends a list predicates to the BlocksDelete builder. +func (bdo *BlocksDeleteOne) Where(ps ...predicate.Blocks) *BlocksDeleteOne { + bdo.bd.mutation.Where(ps...) + return bdo +} + +// Exec executes the deletion query. +func (bdo *BlocksDeleteOne) Exec(ctx context.Context) error { + n, err := bdo.bd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{blocks.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (bdo *BlocksDeleteOne) ExecX(ctx context.Context) { + if err := bdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/z2/backend/ent/blocks_query.go b/z2/backend/ent/blocks_query.go new file mode 100644 index 0000000..15479f3 --- /dev/null +++ b/z2/backend/ent/blocks_query.go @@ -0,0 +1,711 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + "thesis/ent/blocks" + "thesis/ent/predicate" + "thesis/ent/transactions" + "thesis/ent/validators" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// BlocksQuery is the builder for querying Blocks entities. +type BlocksQuery struct { + config + ctx *QueryContext + order []blocks.OrderOption + inters []Interceptor + predicates []predicate.Blocks + withCaster *ValidatorsQuery + withMinedTxs *TransactionsQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the BlocksQuery builder. +func (bq *BlocksQuery) Where(ps ...predicate.Blocks) *BlocksQuery { + bq.predicates = append(bq.predicates, ps...) + return bq +} + +// Limit the number of records to be returned by this query. +func (bq *BlocksQuery) Limit(limit int) *BlocksQuery { + bq.ctx.Limit = &limit + return bq +} + +// Offset to start from. +func (bq *BlocksQuery) Offset(offset int) *BlocksQuery { + bq.ctx.Offset = &offset + return bq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (bq *BlocksQuery) Unique(unique bool) *BlocksQuery { + bq.ctx.Unique = &unique + return bq +} + +// Order specifies how the records should be ordered. +func (bq *BlocksQuery) Order(o ...blocks.OrderOption) *BlocksQuery { + bq.order = append(bq.order, o...) + return bq +} + +// QueryCaster chains the current query on the "Caster" edge. +func (bq *BlocksQuery) QueryCaster() *ValidatorsQuery { + query := (&ValidatorsClient{config: bq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := bq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := bq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(blocks.Table, blocks.FieldID, selector), + sqlgraph.To(validators.Table, validators.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, blocks.CasterTable, blocks.CasterColumn), + ) + fromU = sqlgraph.SetNeighbors(bq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryMinedTxs chains the current query on the "MinedTxs" edge. +func (bq *BlocksQuery) QueryMinedTxs() *TransactionsQuery { + query := (&TransactionsClient{config: bq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := bq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := bq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(blocks.Table, blocks.FieldID, selector), + sqlgraph.To(transactions.Table, transactions.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, blocks.MinedTxsTable, blocks.MinedTxsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(bq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Blocks entity from the query. +// Returns a *NotFoundError when no Blocks was found. +func (bq *BlocksQuery) First(ctx context.Context) (*Blocks, error) { + nodes, err := bq.Limit(1).All(setContextOp(ctx, bq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{blocks.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (bq *BlocksQuery) FirstX(ctx context.Context) *Blocks { + node, err := bq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Blocks ID from the query. +// Returns a *NotFoundError when no Blocks ID was found. +func (bq *BlocksQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = bq.Limit(1).IDs(setContextOp(ctx, bq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{blocks.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (bq *BlocksQuery) FirstIDX(ctx context.Context) int { + id, err := bq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Blocks entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Blocks entity is found. +// Returns a *NotFoundError when no Blocks entities are found. +func (bq *BlocksQuery) Only(ctx context.Context) (*Blocks, error) { + nodes, err := bq.Limit(2).All(setContextOp(ctx, bq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{blocks.Label} + default: + return nil, &NotSingularError{blocks.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (bq *BlocksQuery) OnlyX(ctx context.Context) *Blocks { + node, err := bq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Blocks ID in the query. +// Returns a *NotSingularError when more than one Blocks ID is found. +// Returns a *NotFoundError when no entities are found. +func (bq *BlocksQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = bq.Limit(2).IDs(setContextOp(ctx, bq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{blocks.Label} + default: + err = &NotSingularError{blocks.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (bq *BlocksQuery) OnlyIDX(ctx context.Context) int { + id, err := bq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of BlocksSlice. +func (bq *BlocksQuery) All(ctx context.Context) ([]*Blocks, error) { + ctx = setContextOp(ctx, bq.ctx, "All") + if err := bq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Blocks, *BlocksQuery]() + return withInterceptors[[]*Blocks](ctx, bq, qr, bq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (bq *BlocksQuery) AllX(ctx context.Context) []*Blocks { + nodes, err := bq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Blocks IDs. +func (bq *BlocksQuery) IDs(ctx context.Context) (ids []int, err error) { + if bq.ctx.Unique == nil && bq.path != nil { + bq.Unique(true) + } + ctx = setContextOp(ctx, bq.ctx, "IDs") + if err = bq.Select(blocks.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (bq *BlocksQuery) IDsX(ctx context.Context) []int { + ids, err := bq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (bq *BlocksQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, bq.ctx, "Count") + if err := bq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, bq, querierCount[*BlocksQuery](), bq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (bq *BlocksQuery) CountX(ctx context.Context) int { + count, err := bq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (bq *BlocksQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, bq.ctx, "Exist") + switch _, err := bq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (bq *BlocksQuery) ExistX(ctx context.Context) bool { + exist, err := bq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the BlocksQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (bq *BlocksQuery) Clone() *BlocksQuery { + if bq == nil { + return nil + } + return &BlocksQuery{ + config: bq.config, + ctx: bq.ctx.Clone(), + order: append([]blocks.OrderOption{}, bq.order...), + inters: append([]Interceptor{}, bq.inters...), + predicates: append([]predicate.Blocks{}, bq.predicates...), + withCaster: bq.withCaster.Clone(), + withMinedTxs: bq.withMinedTxs.Clone(), + // clone intermediate query. + sql: bq.sql.Clone(), + path: bq.path, + } +} + +// WithCaster tells the query-builder to eager-load the nodes that are connected to +// the "Caster" edge. The optional arguments are used to configure the query builder of the edge. +func (bq *BlocksQuery) WithCaster(opts ...func(*ValidatorsQuery)) *BlocksQuery { + query := (&ValidatorsClient{config: bq.config}).Query() + for _, opt := range opts { + opt(query) + } + bq.withCaster = query + return bq +} + +// WithMinedTxs tells the query-builder to eager-load the nodes that are connected to +// the "MinedTxs" edge. The optional arguments are used to configure the query builder of the edge. +func (bq *BlocksQuery) WithMinedTxs(opts ...func(*TransactionsQuery)) *BlocksQuery { + query := (&TransactionsClient{config: bq.config}).Query() + for _, opt := range opts { + opt(query) + } + bq.withMinedTxs = query + return bq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Hash string `json:"hash,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Blocks.Query(). +// GroupBy(blocks.FieldHash). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (bq *BlocksQuery) GroupBy(field string, fields ...string) *BlocksGroupBy { + bq.ctx.Fields = append([]string{field}, fields...) + grbuild := &BlocksGroupBy{build: bq} + grbuild.flds = &bq.ctx.Fields + grbuild.label = blocks.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Hash string `json:"hash,omitempty"` +// } +// +// client.Blocks.Query(). +// Select(blocks.FieldHash). +// Scan(ctx, &v) +func (bq *BlocksQuery) Select(fields ...string) *BlocksSelect { + bq.ctx.Fields = append(bq.ctx.Fields, fields...) + sbuild := &BlocksSelect{BlocksQuery: bq} + sbuild.label = blocks.Label + sbuild.flds, sbuild.scan = &bq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a BlocksSelect configured with the given aggregations. +func (bq *BlocksQuery) Aggregate(fns ...AggregateFunc) *BlocksSelect { + return bq.Select().Aggregate(fns...) +} + +func (bq *BlocksQuery) prepareQuery(ctx context.Context) error { + for _, inter := range bq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, bq); err != nil { + return err + } + } + } + for _, f := range bq.ctx.Fields { + if !blocks.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if bq.path != nil { + prev, err := bq.path(ctx) + if err != nil { + return err + } + bq.sql = prev + } + return nil +} + +func (bq *BlocksQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Blocks, error) { + var ( + nodes = []*Blocks{} + _spec = bq.querySpec() + loadedTypes = [2]bool{ + bq.withCaster != nil, + bq.withMinedTxs != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Blocks).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Blocks{config: bq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, bq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := bq.withCaster; query != nil { + if err := bq.loadCaster(ctx, query, nodes, + func(n *Blocks) { n.Edges.Caster = []*Validators{} }, + func(n *Blocks, e *Validators) { n.Edges.Caster = append(n.Edges.Caster, e) }); err != nil { + return nil, err + } + } + if query := bq.withMinedTxs; query != nil { + if err := bq.loadMinedTxs(ctx, query, nodes, + func(n *Blocks) { n.Edges.MinedTxs = []*Transactions{} }, + func(n *Blocks, e *Transactions) { n.Edges.MinedTxs = append(n.Edges.MinedTxs, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (bq *BlocksQuery) loadCaster(ctx context.Context, query *ValidatorsQuery, nodes []*Blocks, init func(*Blocks), assign func(*Blocks, *Validators)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*Blocks) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.Validators(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(blocks.CasterColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.blocks_caster + if fk == nil { + return fmt.Errorf(`foreign-key "blocks_caster" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "blocks_caster" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} +func (bq *BlocksQuery) loadMinedTxs(ctx context.Context, query *TransactionsQuery, nodes []*Blocks, init func(*Blocks), assign func(*Blocks, *Transactions)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[int]*Blocks) + nids := make(map[int]map[*Blocks]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(blocks.MinedTxsTable) + s.Join(joinT).On(s.C(transactions.FieldID), joinT.C(blocks.MinedTxsPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(blocks.MinedTxsPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(blocks.MinedTxsPrimaryKey[0])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullInt64)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := int(values[0].(*sql.NullInt64).Int64) + inValue := int(values[1].(*sql.NullInt64).Int64) + if nids[inValue] == nil { + nids[inValue] = map[*Blocks]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Transactions](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "MinedTxs" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} + +func (bq *BlocksQuery) sqlCount(ctx context.Context) (int, error) { + _spec := bq.querySpec() + _spec.Node.Columns = bq.ctx.Fields + if len(bq.ctx.Fields) > 0 { + _spec.Unique = bq.ctx.Unique != nil && *bq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, bq.driver, _spec) +} + +func (bq *BlocksQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(blocks.Table, blocks.Columns, sqlgraph.NewFieldSpec(blocks.FieldID, field.TypeInt)) + _spec.From = bq.sql + if unique := bq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if bq.path != nil { + _spec.Unique = true + } + if fields := bq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, blocks.FieldID) + for i := range fields { + if fields[i] != blocks.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := bq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := bq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := bq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := bq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (bq *BlocksQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(bq.driver.Dialect()) + t1 := builder.Table(blocks.Table) + columns := bq.ctx.Fields + if len(columns) == 0 { + columns = blocks.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if bq.sql != nil { + selector = bq.sql + selector.Select(selector.Columns(columns...)...) + } + if bq.ctx.Unique != nil && *bq.ctx.Unique { + selector.Distinct() + } + for _, p := range bq.predicates { + p(selector) + } + for _, p := range bq.order { + p(selector) + } + if offset := bq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := bq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// BlocksGroupBy is the group-by builder for Blocks entities. +type BlocksGroupBy struct { + selector + build *BlocksQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (bgb *BlocksGroupBy) Aggregate(fns ...AggregateFunc) *BlocksGroupBy { + bgb.fns = append(bgb.fns, fns...) + return bgb +} + +// Scan applies the selector query and scans the result into the given value. +func (bgb *BlocksGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, bgb.build.ctx, "GroupBy") + if err := bgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*BlocksQuery, *BlocksGroupBy](ctx, bgb.build, bgb, bgb.build.inters, v) +} + +func (bgb *BlocksGroupBy) sqlScan(ctx context.Context, root *BlocksQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(bgb.fns)) + for _, fn := range bgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*bgb.flds)+len(bgb.fns)) + for _, f := range *bgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*bgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := bgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// BlocksSelect is the builder for selecting fields of Blocks entities. +type BlocksSelect struct { + *BlocksQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (bs *BlocksSelect) Aggregate(fns ...AggregateFunc) *BlocksSelect { + bs.fns = append(bs.fns, fns...) + return bs +} + +// Scan applies the selector query and scans the result into the given value. +func (bs *BlocksSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, bs.ctx, "Select") + if err := bs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*BlocksQuery, *BlocksSelect](ctx, bs.BlocksQuery, bs, bs.inters, v) +} + +func (bs *BlocksSelect) sqlScan(ctx context.Context, root *BlocksQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(bs.fns)) + for _, fn := range bs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*bs.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := bs.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/z2/backend/ent/blocks_update.go b/z2/backend/ent/blocks_update.go new file mode 100644 index 0000000..9735dfe --- /dev/null +++ b/z2/backend/ent/blocks_update.go @@ -0,0 +1,623 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "thesis/ent/blocks" + "thesis/ent/predicate" + "thesis/ent/transactions" + "thesis/ent/validators" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// BlocksUpdate is the builder for updating Blocks entities. +type BlocksUpdate struct { + config + hooks []Hook + mutation *BlocksMutation +} + +// Where appends a list predicates to the BlocksUpdate builder. +func (bu *BlocksUpdate) Where(ps ...predicate.Blocks) *BlocksUpdate { + bu.mutation.Where(ps...) + return bu +} + +// SetHash sets the "hash" field. +func (bu *BlocksUpdate) SetHash(s string) *BlocksUpdate { + bu.mutation.SetHash(s) + return bu +} + +// SetNillableHash sets the "hash" field if the given value is not nil. +func (bu *BlocksUpdate) SetNillableHash(s *string) *BlocksUpdate { + if s != nil { + bu.SetHash(*s) + } + return bu +} + +// SetLength sets the "length" field. +func (bu *BlocksUpdate) SetLength(i int) *BlocksUpdate { + bu.mutation.ResetLength() + bu.mutation.SetLength(i) + return bu +} + +// SetNillableLength sets the "length" field if the given value is not nil. +func (bu *BlocksUpdate) SetNillableLength(i *int) *BlocksUpdate { + if i != nil { + bu.SetLength(*i) + } + return bu +} + +// AddLength adds i to the "length" field. +func (bu *BlocksUpdate) AddLength(i int) *BlocksUpdate { + bu.mutation.AddLength(i) + return bu +} + +// SetPreviousHash sets the "previousHash" field. +func (bu *BlocksUpdate) SetPreviousHash(s string) *BlocksUpdate { + bu.mutation.SetPreviousHash(s) + return bu +} + +// SetNillablePreviousHash sets the "previousHash" field if the given value is not nil. +func (bu *BlocksUpdate) SetNillablePreviousHash(s *string) *BlocksUpdate { + if s != nil { + bu.SetPreviousHash(*s) + } + return bu +} + +// AddCasterIDs adds the "Caster" edge to the Validators entity by IDs. +func (bu *BlocksUpdate) AddCasterIDs(ids ...int) *BlocksUpdate { + bu.mutation.AddCasterIDs(ids...) + return bu +} + +// AddCaster adds the "Caster" edges to the Validators entity. +func (bu *BlocksUpdate) AddCaster(v ...*Validators) *BlocksUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return bu.AddCasterIDs(ids...) +} + +// AddMinedTxIDs adds the "MinedTxs" edge to the Transactions entity by IDs. +func (bu *BlocksUpdate) AddMinedTxIDs(ids ...int) *BlocksUpdate { + bu.mutation.AddMinedTxIDs(ids...) + return bu +} + +// AddMinedTxs adds the "MinedTxs" edges to the Transactions entity. +func (bu *BlocksUpdate) AddMinedTxs(t ...*Transactions) *BlocksUpdate { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return bu.AddMinedTxIDs(ids...) +} + +// Mutation returns the BlocksMutation object of the builder. +func (bu *BlocksUpdate) Mutation() *BlocksMutation { + return bu.mutation +} + +// ClearCaster clears all "Caster" edges to the Validators entity. +func (bu *BlocksUpdate) ClearCaster() *BlocksUpdate { + bu.mutation.ClearCaster() + return bu +} + +// RemoveCasterIDs removes the "Caster" edge to Validators entities by IDs. +func (bu *BlocksUpdate) RemoveCasterIDs(ids ...int) *BlocksUpdate { + bu.mutation.RemoveCasterIDs(ids...) + return bu +} + +// RemoveCaster removes "Caster" edges to Validators entities. +func (bu *BlocksUpdate) RemoveCaster(v ...*Validators) *BlocksUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return bu.RemoveCasterIDs(ids...) +} + +// ClearMinedTxs clears all "MinedTxs" edges to the Transactions entity. +func (bu *BlocksUpdate) ClearMinedTxs() *BlocksUpdate { + bu.mutation.ClearMinedTxs() + return bu +} + +// RemoveMinedTxIDs removes the "MinedTxs" edge to Transactions entities by IDs. +func (bu *BlocksUpdate) RemoveMinedTxIDs(ids ...int) *BlocksUpdate { + bu.mutation.RemoveMinedTxIDs(ids...) + return bu +} + +// RemoveMinedTxs removes "MinedTxs" edges to Transactions entities. +func (bu *BlocksUpdate) RemoveMinedTxs(t ...*Transactions) *BlocksUpdate { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return bu.RemoveMinedTxIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (bu *BlocksUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, bu.sqlSave, bu.mutation, bu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (bu *BlocksUpdate) SaveX(ctx context.Context) int { + affected, err := bu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (bu *BlocksUpdate) Exec(ctx context.Context) error { + _, err := bu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bu *BlocksUpdate) ExecX(ctx context.Context) { + if err := bu.Exec(ctx); err != nil { + panic(err) + } +} + +func (bu *BlocksUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := sqlgraph.NewUpdateSpec(blocks.Table, blocks.Columns, sqlgraph.NewFieldSpec(blocks.FieldID, field.TypeInt)) + if ps := bu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := bu.mutation.Hash(); ok { + _spec.SetField(blocks.FieldHash, field.TypeString, value) + } + if value, ok := bu.mutation.Length(); ok { + _spec.SetField(blocks.FieldLength, field.TypeInt, value) + } + if value, ok := bu.mutation.AddedLength(); ok { + _spec.AddField(blocks.FieldLength, field.TypeInt, value) + } + if value, ok := bu.mutation.PreviousHash(); ok { + _spec.SetField(blocks.FieldPreviousHash, field.TypeString, value) + } + if bu.mutation.CasterCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: blocks.CasterTable, + Columns: []string{blocks.CasterColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := bu.mutation.RemovedCasterIDs(); len(nodes) > 0 && !bu.mutation.CasterCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: blocks.CasterTable, + Columns: []string{blocks.CasterColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := bu.mutation.CasterIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: blocks.CasterTable, + Columns: []string{blocks.CasterColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if bu.mutation.MinedTxsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: blocks.MinedTxsTable, + Columns: blocks.MinedTxsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := bu.mutation.RemovedMinedTxsIDs(); len(nodes) > 0 && !bu.mutation.MinedTxsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: blocks.MinedTxsTable, + Columns: blocks.MinedTxsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := bu.mutation.MinedTxsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: blocks.MinedTxsTable, + Columns: blocks.MinedTxsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, bu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{blocks.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + bu.mutation.done = true + return n, nil +} + +// BlocksUpdateOne is the builder for updating a single Blocks entity. +type BlocksUpdateOne struct { + config + fields []string + hooks []Hook + mutation *BlocksMutation +} + +// SetHash sets the "hash" field. +func (buo *BlocksUpdateOne) SetHash(s string) *BlocksUpdateOne { + buo.mutation.SetHash(s) + return buo +} + +// SetNillableHash sets the "hash" field if the given value is not nil. +func (buo *BlocksUpdateOne) SetNillableHash(s *string) *BlocksUpdateOne { + if s != nil { + buo.SetHash(*s) + } + return buo +} + +// SetLength sets the "length" field. +func (buo *BlocksUpdateOne) SetLength(i int) *BlocksUpdateOne { + buo.mutation.ResetLength() + buo.mutation.SetLength(i) + return buo +} + +// SetNillableLength sets the "length" field if the given value is not nil. +func (buo *BlocksUpdateOne) SetNillableLength(i *int) *BlocksUpdateOne { + if i != nil { + buo.SetLength(*i) + } + return buo +} + +// AddLength adds i to the "length" field. +func (buo *BlocksUpdateOne) AddLength(i int) *BlocksUpdateOne { + buo.mutation.AddLength(i) + return buo +} + +// SetPreviousHash sets the "previousHash" field. +func (buo *BlocksUpdateOne) SetPreviousHash(s string) *BlocksUpdateOne { + buo.mutation.SetPreviousHash(s) + return buo +} + +// SetNillablePreviousHash sets the "previousHash" field if the given value is not nil. +func (buo *BlocksUpdateOne) SetNillablePreviousHash(s *string) *BlocksUpdateOne { + if s != nil { + buo.SetPreviousHash(*s) + } + return buo +} + +// AddCasterIDs adds the "Caster" edge to the Validators entity by IDs. +func (buo *BlocksUpdateOne) AddCasterIDs(ids ...int) *BlocksUpdateOne { + buo.mutation.AddCasterIDs(ids...) + return buo +} + +// AddCaster adds the "Caster" edges to the Validators entity. +func (buo *BlocksUpdateOne) AddCaster(v ...*Validators) *BlocksUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return buo.AddCasterIDs(ids...) +} + +// AddMinedTxIDs adds the "MinedTxs" edge to the Transactions entity by IDs. +func (buo *BlocksUpdateOne) AddMinedTxIDs(ids ...int) *BlocksUpdateOne { + buo.mutation.AddMinedTxIDs(ids...) + return buo +} + +// AddMinedTxs adds the "MinedTxs" edges to the Transactions entity. +func (buo *BlocksUpdateOne) AddMinedTxs(t ...*Transactions) *BlocksUpdateOne { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return buo.AddMinedTxIDs(ids...) +} + +// Mutation returns the BlocksMutation object of the builder. +func (buo *BlocksUpdateOne) Mutation() *BlocksMutation { + return buo.mutation +} + +// ClearCaster clears all "Caster" edges to the Validators entity. +func (buo *BlocksUpdateOne) ClearCaster() *BlocksUpdateOne { + buo.mutation.ClearCaster() + return buo +} + +// RemoveCasterIDs removes the "Caster" edge to Validators entities by IDs. +func (buo *BlocksUpdateOne) RemoveCasterIDs(ids ...int) *BlocksUpdateOne { + buo.mutation.RemoveCasterIDs(ids...) + return buo +} + +// RemoveCaster removes "Caster" edges to Validators entities. +func (buo *BlocksUpdateOne) RemoveCaster(v ...*Validators) *BlocksUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return buo.RemoveCasterIDs(ids...) +} + +// ClearMinedTxs clears all "MinedTxs" edges to the Transactions entity. +func (buo *BlocksUpdateOne) ClearMinedTxs() *BlocksUpdateOne { + buo.mutation.ClearMinedTxs() + return buo +} + +// RemoveMinedTxIDs removes the "MinedTxs" edge to Transactions entities by IDs. +func (buo *BlocksUpdateOne) RemoveMinedTxIDs(ids ...int) *BlocksUpdateOne { + buo.mutation.RemoveMinedTxIDs(ids...) + return buo +} + +// RemoveMinedTxs removes "MinedTxs" edges to Transactions entities. +func (buo *BlocksUpdateOne) RemoveMinedTxs(t ...*Transactions) *BlocksUpdateOne { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return buo.RemoveMinedTxIDs(ids...) +} + +// Where appends a list predicates to the BlocksUpdate builder. +func (buo *BlocksUpdateOne) Where(ps ...predicate.Blocks) *BlocksUpdateOne { + buo.mutation.Where(ps...) + return buo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (buo *BlocksUpdateOne) Select(field string, fields ...string) *BlocksUpdateOne { + buo.fields = append([]string{field}, fields...) + return buo +} + +// Save executes the query and returns the updated Blocks entity. +func (buo *BlocksUpdateOne) Save(ctx context.Context) (*Blocks, error) { + return withHooks(ctx, buo.sqlSave, buo.mutation, buo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (buo *BlocksUpdateOne) SaveX(ctx context.Context) *Blocks { + node, err := buo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (buo *BlocksUpdateOne) Exec(ctx context.Context) error { + _, err := buo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (buo *BlocksUpdateOne) ExecX(ctx context.Context) { + if err := buo.Exec(ctx); err != nil { + panic(err) + } +} + +func (buo *BlocksUpdateOne) sqlSave(ctx context.Context) (_node *Blocks, err error) { + _spec := sqlgraph.NewUpdateSpec(blocks.Table, blocks.Columns, sqlgraph.NewFieldSpec(blocks.FieldID, field.TypeInt)) + id, ok := buo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Blocks.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := buo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, blocks.FieldID) + for _, f := range fields { + if !blocks.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != blocks.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := buo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := buo.mutation.Hash(); ok { + _spec.SetField(blocks.FieldHash, field.TypeString, value) + } + if value, ok := buo.mutation.Length(); ok { + _spec.SetField(blocks.FieldLength, field.TypeInt, value) + } + if value, ok := buo.mutation.AddedLength(); ok { + _spec.AddField(blocks.FieldLength, field.TypeInt, value) + } + if value, ok := buo.mutation.PreviousHash(); ok { + _spec.SetField(blocks.FieldPreviousHash, field.TypeString, value) + } + if buo.mutation.CasterCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: blocks.CasterTable, + Columns: []string{blocks.CasterColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := buo.mutation.RemovedCasterIDs(); len(nodes) > 0 && !buo.mutation.CasterCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: blocks.CasterTable, + Columns: []string{blocks.CasterColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := buo.mutation.CasterIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: blocks.CasterTable, + Columns: []string{blocks.CasterColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if buo.mutation.MinedTxsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: blocks.MinedTxsTable, + Columns: blocks.MinedTxsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := buo.mutation.RemovedMinedTxsIDs(); len(nodes) > 0 && !buo.mutation.MinedTxsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: blocks.MinedTxsTable, + Columns: blocks.MinedTxsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := buo.mutation.MinedTxsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: blocks.MinedTxsTable, + Columns: blocks.MinedTxsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &Blocks{config: buo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, buo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{blocks.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + buo.mutation.done = true + return _node, nil +} diff --git a/z2/backend/ent/client.go b/z2/backend/ent/client.go new file mode 100644 index 0000000..f5c199e --- /dev/null +++ b/z2/backend/ent/client.go @@ -0,0 +1,1042 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "log" + "reflect" + + "thesis/ent/migrate" + + "thesis/ent/blocks" + "thesis/ent/key" + "thesis/ent/transactions" + "thesis/ent/validators" + "thesis/ent/whitelist" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// Client is the client that holds all ent builders. +type Client struct { + config + // Schema is the client for creating, migrating and dropping schema. + Schema *migrate.Schema + // Blocks is the client for interacting with the Blocks builders. + Blocks *BlocksClient + // Key is the client for interacting with the Key builders. + Key *KeyClient + // Transactions is the client for interacting with the Transactions builders. + Transactions *TransactionsClient + // Validators is the client for interacting with the Validators builders. + Validators *ValidatorsClient + // WhiteList is the client for interacting with the WhiteList builders. + WhiteList *WhiteListClient +} + +// NewClient creates a new client configured with the given options. +func NewClient(opts ...Option) *Client { + client := &Client{config: newConfig(opts...)} + client.init() + return client +} + +func (c *Client) init() { + c.Schema = migrate.NewSchema(c.driver) + c.Blocks = NewBlocksClient(c.config) + c.Key = NewKeyClient(c.config) + c.Transactions = NewTransactionsClient(c.config) + c.Validators = NewValidatorsClient(c.config) + c.WhiteList = NewWhiteListClient(c.config) +} + +type ( + // config is the configuration for the client and its builder. + config struct { + // driver used for executing database requests. + driver dialect.Driver + // debug enable a debug logging. + debug bool + // log used for logging on debug mode. + log func(...any) + // hooks to execute on mutations. + hooks *hooks + // interceptors to execute on queries. + inters *inters + } + // Option function to configure the client. + Option func(*config) +) + +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + +// options applies the options on the config object. +func (c *config) options(opts ...Option) { + for _, opt := range opts { + opt(c) + } + if c.debug { + c.driver = dialect.Debug(c.driver, c.log) + } +} + +// Debug enables debug logging on the ent.Driver. +func Debug() Option { + return func(c *config) { + c.debug = true + } +} + +// Log sets the logging function for debug mode. +func Log(fn func(...any)) Option { + return func(c *config) { + c.log = fn + } +} + +// Driver configures the client driver. +func Driver(driver dialect.Driver) Option { + return func(c *config) { + c.driver = driver + } +} + +// Open opens a database/sql.DB specified by the driver name and +// the data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.Postgres, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + +// Tx returns a new transactional client. The provided context +// is used until the transaction is committed or rolled back. +func (c *Client) Tx(ctx context.Context) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, ErrTxStarted + } + tx, err := newTx(ctx, c.driver) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = tx + return &Tx{ + ctx: ctx, + config: cfg, + Blocks: NewBlocksClient(cfg), + Key: NewKeyClient(cfg), + Transactions: NewTransactionsClient(cfg), + Validators: NewValidatorsClient(cfg), + WhiteList: NewWhiteListClient(cfg), + }, nil +} + +// BeginTx returns a transactional client with specified options. +func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, errors.New("ent: cannot start a transaction within a transaction") + } + tx, err := c.driver.(interface { + BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error) + }).BeginTx(ctx, opts) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = &txDriver{tx: tx, drv: c.driver} + return &Tx{ + ctx: ctx, + config: cfg, + Blocks: NewBlocksClient(cfg), + Key: NewKeyClient(cfg), + Transactions: NewTransactionsClient(cfg), + Validators: NewValidatorsClient(cfg), + WhiteList: NewWhiteListClient(cfg), + }, nil +} + +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// Blocks. +// Query(). +// Count(ctx) +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := c.config + cfg.driver = dialect.Debug(c.driver, c.log) + client := &Client{config: cfg} + client.init() + return client +} + +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + +// Use adds the mutation hooks to all the entity clients. +// In order to add hooks to a specific client, call: `client.Node.Use(...)`. +func (c *Client) Use(hooks ...Hook) { + c.Blocks.Use(hooks...) + c.Key.Use(hooks...) + c.Transactions.Use(hooks...) + c.Validators.Use(hooks...) + c.WhiteList.Use(hooks...) +} + +// Intercept adds the query interceptors to all the entity clients. +// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. +func (c *Client) Intercept(interceptors ...Interceptor) { + c.Blocks.Intercept(interceptors...) + c.Key.Intercept(interceptors...) + c.Transactions.Intercept(interceptors...) + c.Validators.Intercept(interceptors...) + c.WhiteList.Intercept(interceptors...) +} + +// Mutate implements the ent.Mutator interface. +func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { + switch m := m.(type) { + case *BlocksMutation: + return c.Blocks.mutate(ctx, m) + case *KeyMutation: + return c.Key.mutate(ctx, m) + case *TransactionsMutation: + return c.Transactions.mutate(ctx, m) + case *ValidatorsMutation: + return c.Validators.mutate(ctx, m) + case *WhiteListMutation: + return c.WhiteList.mutate(ctx, m) + default: + return nil, fmt.Errorf("ent: unknown mutation type %T", m) + } +} + +// BlocksClient is a client for the Blocks schema. +type BlocksClient struct { + config +} + +// NewBlocksClient returns a client for the Blocks from the given config. +func NewBlocksClient(c config) *BlocksClient { + return &BlocksClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `blocks.Hooks(f(g(h())))`. +func (c *BlocksClient) Use(hooks ...Hook) { + c.hooks.Blocks = append(c.hooks.Blocks, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `blocks.Intercept(f(g(h())))`. +func (c *BlocksClient) Intercept(interceptors ...Interceptor) { + c.inters.Blocks = append(c.inters.Blocks, interceptors...) +} + +// Create returns a builder for creating a Blocks entity. +func (c *BlocksClient) Create() *BlocksCreate { + mutation := newBlocksMutation(c.config, OpCreate) + return &BlocksCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Blocks entities. +func (c *BlocksClient) CreateBulk(builders ...*BlocksCreate) *BlocksCreateBulk { + return &BlocksCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *BlocksClient) MapCreateBulk(slice any, setFunc func(*BlocksCreate, int)) *BlocksCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &BlocksCreateBulk{err: fmt.Errorf("calling to BlocksClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*BlocksCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &BlocksCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Blocks. +func (c *BlocksClient) Update() *BlocksUpdate { + mutation := newBlocksMutation(c.config, OpUpdate) + return &BlocksUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *BlocksClient) UpdateOne(b *Blocks) *BlocksUpdateOne { + mutation := newBlocksMutation(c.config, OpUpdateOne, withBlocks(b)) + return &BlocksUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *BlocksClient) UpdateOneID(id int) *BlocksUpdateOne { + mutation := newBlocksMutation(c.config, OpUpdateOne, withBlocksID(id)) + return &BlocksUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Blocks. +func (c *BlocksClient) Delete() *BlocksDelete { + mutation := newBlocksMutation(c.config, OpDelete) + return &BlocksDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *BlocksClient) DeleteOne(b *Blocks) *BlocksDeleteOne { + return c.DeleteOneID(b.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *BlocksClient) DeleteOneID(id int) *BlocksDeleteOne { + builder := c.Delete().Where(blocks.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &BlocksDeleteOne{builder} +} + +// Query returns a query builder for Blocks. +func (c *BlocksClient) Query() *BlocksQuery { + return &BlocksQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeBlocks}, + inters: c.Interceptors(), + } +} + +// Get returns a Blocks entity by its id. +func (c *BlocksClient) Get(ctx context.Context, id int) (*Blocks, error) { + return c.Query().Where(blocks.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *BlocksClient) GetX(ctx context.Context, id int) *Blocks { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryCaster queries the Caster edge of a Blocks. +func (c *BlocksClient) QueryCaster(b *Blocks) *ValidatorsQuery { + query := (&ValidatorsClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := b.ID + step := sqlgraph.NewStep( + sqlgraph.From(blocks.Table, blocks.FieldID, id), + sqlgraph.To(validators.Table, validators.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, blocks.CasterTable, blocks.CasterColumn), + ) + fromV = sqlgraph.Neighbors(b.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryMinedTxs queries the MinedTxs edge of a Blocks. +func (c *BlocksClient) QueryMinedTxs(b *Blocks) *TransactionsQuery { + query := (&TransactionsClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := b.ID + step := sqlgraph.NewStep( + sqlgraph.From(blocks.Table, blocks.FieldID, id), + sqlgraph.To(transactions.Table, transactions.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, blocks.MinedTxsTable, blocks.MinedTxsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(b.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *BlocksClient) Hooks() []Hook { + return c.hooks.Blocks +} + +// Interceptors returns the client interceptors. +func (c *BlocksClient) Interceptors() []Interceptor { + return c.inters.Blocks +} + +func (c *BlocksClient) mutate(ctx context.Context, m *BlocksMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&BlocksCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&BlocksUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&BlocksUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&BlocksDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Blocks mutation op: %q", m.Op()) + } +} + +// KeyClient is a client for the Key schema. +type KeyClient struct { + config +} + +// NewKeyClient returns a client for the Key from the given config. +func NewKeyClient(c config) *KeyClient { + return &KeyClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `key.Hooks(f(g(h())))`. +func (c *KeyClient) Use(hooks ...Hook) { + c.hooks.Key = append(c.hooks.Key, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `key.Intercept(f(g(h())))`. +func (c *KeyClient) Intercept(interceptors ...Interceptor) { + c.inters.Key = append(c.inters.Key, interceptors...) +} + +// Create returns a builder for creating a Key entity. +func (c *KeyClient) Create() *KeyCreate { + mutation := newKeyMutation(c.config, OpCreate) + return &KeyCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Key entities. +func (c *KeyClient) CreateBulk(builders ...*KeyCreate) *KeyCreateBulk { + return &KeyCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *KeyClient) MapCreateBulk(slice any, setFunc func(*KeyCreate, int)) *KeyCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &KeyCreateBulk{err: fmt.Errorf("calling to KeyClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*KeyCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &KeyCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Key. +func (c *KeyClient) Update() *KeyUpdate { + mutation := newKeyMutation(c.config, OpUpdate) + return &KeyUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *KeyClient) UpdateOne(k *Key) *KeyUpdateOne { + mutation := newKeyMutation(c.config, OpUpdateOne, withKey(k)) + return &KeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *KeyClient) UpdateOneID(id int) *KeyUpdateOne { + mutation := newKeyMutation(c.config, OpUpdateOne, withKeyID(id)) + return &KeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Key. +func (c *KeyClient) Delete() *KeyDelete { + mutation := newKeyMutation(c.config, OpDelete) + return &KeyDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *KeyClient) DeleteOne(k *Key) *KeyDeleteOne { + return c.DeleteOneID(k.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *KeyClient) DeleteOneID(id int) *KeyDeleteOne { + builder := c.Delete().Where(key.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &KeyDeleteOne{builder} +} + +// Query returns a query builder for Key. +func (c *KeyClient) Query() *KeyQuery { + return &KeyQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeKey}, + inters: c.Interceptors(), + } +} + +// Get returns a Key entity by its id. +func (c *KeyClient) Get(ctx context.Context, id int) (*Key, error) { + return c.Query().Where(key.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *KeyClient) GetX(ctx context.Context, id int) *Key { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QuerySigned queries the Signed edge of a Key. +func (c *KeyClient) QuerySigned(k *Key) *TransactionsQuery { + query := (&TransactionsClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := k.ID + step := sqlgraph.NewStep( + sqlgraph.From(key.Table, key.FieldID, id), + sqlgraph.To(transactions.Table, transactions.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, key.SignedTable, key.SignedPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(k.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *KeyClient) Hooks() []Hook { + return c.hooks.Key +} + +// Interceptors returns the client interceptors. +func (c *KeyClient) Interceptors() []Interceptor { + return c.inters.Key +} + +func (c *KeyClient) mutate(ctx context.Context, m *KeyMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&KeyCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&KeyUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&KeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&KeyDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Key mutation op: %q", m.Op()) + } +} + +// TransactionsClient is a client for the Transactions schema. +type TransactionsClient struct { + config +} + +// NewTransactionsClient returns a client for the Transactions from the given config. +func NewTransactionsClient(c config) *TransactionsClient { + return &TransactionsClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `transactions.Hooks(f(g(h())))`. +func (c *TransactionsClient) Use(hooks ...Hook) { + c.hooks.Transactions = append(c.hooks.Transactions, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `transactions.Intercept(f(g(h())))`. +func (c *TransactionsClient) Intercept(interceptors ...Interceptor) { + c.inters.Transactions = append(c.inters.Transactions, interceptors...) +} + +// Create returns a builder for creating a Transactions entity. +func (c *TransactionsClient) Create() *TransactionsCreate { + mutation := newTransactionsMutation(c.config, OpCreate) + return &TransactionsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Transactions entities. +func (c *TransactionsClient) CreateBulk(builders ...*TransactionsCreate) *TransactionsCreateBulk { + return &TransactionsCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *TransactionsClient) MapCreateBulk(slice any, setFunc func(*TransactionsCreate, int)) *TransactionsCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &TransactionsCreateBulk{err: fmt.Errorf("calling to TransactionsClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*TransactionsCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &TransactionsCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Transactions. +func (c *TransactionsClient) Update() *TransactionsUpdate { + mutation := newTransactionsMutation(c.config, OpUpdate) + return &TransactionsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *TransactionsClient) UpdateOne(t *Transactions) *TransactionsUpdateOne { + mutation := newTransactionsMutation(c.config, OpUpdateOne, withTransactions(t)) + return &TransactionsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *TransactionsClient) UpdateOneID(id int) *TransactionsUpdateOne { + mutation := newTransactionsMutation(c.config, OpUpdateOne, withTransactionsID(id)) + return &TransactionsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Transactions. +func (c *TransactionsClient) Delete() *TransactionsDelete { + mutation := newTransactionsMutation(c.config, OpDelete) + return &TransactionsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *TransactionsClient) DeleteOne(t *Transactions) *TransactionsDeleteOne { + return c.DeleteOneID(t.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *TransactionsClient) DeleteOneID(id int) *TransactionsDeleteOne { + builder := c.Delete().Where(transactions.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &TransactionsDeleteOne{builder} +} + +// Query returns a query builder for Transactions. +func (c *TransactionsClient) Query() *TransactionsQuery { + return &TransactionsQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeTransactions}, + inters: c.Interceptors(), + } +} + +// Get returns a Transactions entity by its id. +func (c *TransactionsClient) Get(ctx context.Context, id int) (*Transactions, error) { + return c.Query().Where(transactions.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *TransactionsClient) GetX(ctx context.Context, id int) *Transactions { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QuerySigner queries the Signer edge of a Transactions. +func (c *TransactionsClient) QuerySigner(t *Transactions) *KeyQuery { + query := (&KeyClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := t.ID + step := sqlgraph.NewStep( + sqlgraph.From(transactions.Table, transactions.FieldID, id), + sqlgraph.To(key.Table, key.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, transactions.SignerTable, transactions.SignerPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(t.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryBlock queries the Block edge of a Transactions. +func (c *TransactionsClient) QueryBlock(t *Transactions) *BlocksQuery { + query := (&BlocksClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := t.ID + step := sqlgraph.NewStep( + sqlgraph.From(transactions.Table, transactions.FieldID, id), + sqlgraph.To(blocks.Table, blocks.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, transactions.BlockTable, transactions.BlockPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(t.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *TransactionsClient) Hooks() []Hook { + return c.hooks.Transactions +} + +// Interceptors returns the client interceptors. +func (c *TransactionsClient) Interceptors() []Interceptor { + return c.inters.Transactions +} + +func (c *TransactionsClient) mutate(ctx context.Context, m *TransactionsMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&TransactionsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&TransactionsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&TransactionsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&TransactionsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Transactions mutation op: %q", m.Op()) + } +} + +// ValidatorsClient is a client for the Validators schema. +type ValidatorsClient struct { + config +} + +// NewValidatorsClient returns a client for the Validators from the given config. +func NewValidatorsClient(c config) *ValidatorsClient { + return &ValidatorsClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `validators.Hooks(f(g(h())))`. +func (c *ValidatorsClient) Use(hooks ...Hook) { + c.hooks.Validators = append(c.hooks.Validators, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `validators.Intercept(f(g(h())))`. +func (c *ValidatorsClient) Intercept(interceptors ...Interceptor) { + c.inters.Validators = append(c.inters.Validators, interceptors...) +} + +// Create returns a builder for creating a Validators entity. +func (c *ValidatorsClient) Create() *ValidatorsCreate { + mutation := newValidatorsMutation(c.config, OpCreate) + return &ValidatorsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Validators entities. +func (c *ValidatorsClient) CreateBulk(builders ...*ValidatorsCreate) *ValidatorsCreateBulk { + return &ValidatorsCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ValidatorsClient) MapCreateBulk(slice any, setFunc func(*ValidatorsCreate, int)) *ValidatorsCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ValidatorsCreateBulk{err: fmt.Errorf("calling to ValidatorsClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ValidatorsCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ValidatorsCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Validators. +func (c *ValidatorsClient) Update() *ValidatorsUpdate { + mutation := newValidatorsMutation(c.config, OpUpdate) + return &ValidatorsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ValidatorsClient) UpdateOne(v *Validators) *ValidatorsUpdateOne { + mutation := newValidatorsMutation(c.config, OpUpdateOne, withValidators(v)) + return &ValidatorsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ValidatorsClient) UpdateOneID(id int) *ValidatorsUpdateOne { + mutation := newValidatorsMutation(c.config, OpUpdateOne, withValidatorsID(id)) + return &ValidatorsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Validators. +func (c *ValidatorsClient) Delete() *ValidatorsDelete { + mutation := newValidatorsMutation(c.config, OpDelete) + return &ValidatorsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ValidatorsClient) DeleteOne(v *Validators) *ValidatorsDeleteOne { + return c.DeleteOneID(v.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ValidatorsClient) DeleteOneID(id int) *ValidatorsDeleteOne { + builder := c.Delete().Where(validators.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ValidatorsDeleteOne{builder} +} + +// Query returns a query builder for Validators. +func (c *ValidatorsClient) Query() *ValidatorsQuery { + return &ValidatorsQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeValidators}, + inters: c.Interceptors(), + } +} + +// Get returns a Validators entity by its id. +func (c *ValidatorsClient) Get(ctx context.Context, id int) (*Validators, error) { + return c.Query().Where(validators.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ValidatorsClient) GetX(ctx context.Context, id int) *Validators { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryKey queries the key edge of a Validators. +func (c *ValidatorsClient) QueryKey(v *Validators) *KeyQuery { + query := (&KeyClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := v.ID + step := sqlgraph.NewStep( + sqlgraph.From(validators.Table, validators.FieldID, id), + sqlgraph.To(key.Table, key.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, validators.KeyTable, validators.KeyColumn), + ) + fromV = sqlgraph.Neighbors(v.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ValidatorsClient) Hooks() []Hook { + return c.hooks.Validators +} + +// Interceptors returns the client interceptors. +func (c *ValidatorsClient) Interceptors() []Interceptor { + return c.inters.Validators +} + +func (c *ValidatorsClient) mutate(ctx context.Context, m *ValidatorsMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ValidatorsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ValidatorsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ValidatorsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ValidatorsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Validators mutation op: %q", m.Op()) + } +} + +// WhiteListClient is a client for the WhiteList schema. +type WhiteListClient struct { + config +} + +// NewWhiteListClient returns a client for the WhiteList from the given config. +func NewWhiteListClient(c config) *WhiteListClient { + return &WhiteListClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `whitelist.Hooks(f(g(h())))`. +func (c *WhiteListClient) Use(hooks ...Hook) { + c.hooks.WhiteList = append(c.hooks.WhiteList, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `whitelist.Intercept(f(g(h())))`. +func (c *WhiteListClient) Intercept(interceptors ...Interceptor) { + c.inters.WhiteList = append(c.inters.WhiteList, interceptors...) +} + +// Create returns a builder for creating a WhiteList entity. +func (c *WhiteListClient) Create() *WhiteListCreate { + mutation := newWhiteListMutation(c.config, OpCreate) + return &WhiteListCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of WhiteList entities. +func (c *WhiteListClient) CreateBulk(builders ...*WhiteListCreate) *WhiteListCreateBulk { + return &WhiteListCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *WhiteListClient) MapCreateBulk(slice any, setFunc func(*WhiteListCreate, int)) *WhiteListCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &WhiteListCreateBulk{err: fmt.Errorf("calling to WhiteListClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*WhiteListCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &WhiteListCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for WhiteList. +func (c *WhiteListClient) Update() *WhiteListUpdate { + mutation := newWhiteListMutation(c.config, OpUpdate) + return &WhiteListUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *WhiteListClient) UpdateOne(wl *WhiteList) *WhiteListUpdateOne { + mutation := newWhiteListMutation(c.config, OpUpdateOne, withWhiteList(wl)) + return &WhiteListUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *WhiteListClient) UpdateOneID(id int) *WhiteListUpdateOne { + mutation := newWhiteListMutation(c.config, OpUpdateOne, withWhiteListID(id)) + return &WhiteListUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for WhiteList. +func (c *WhiteListClient) Delete() *WhiteListDelete { + mutation := newWhiteListMutation(c.config, OpDelete) + return &WhiteListDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *WhiteListClient) DeleteOne(wl *WhiteList) *WhiteListDeleteOne { + return c.DeleteOneID(wl.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *WhiteListClient) DeleteOneID(id int) *WhiteListDeleteOne { + builder := c.Delete().Where(whitelist.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &WhiteListDeleteOne{builder} +} + +// Query returns a query builder for WhiteList. +func (c *WhiteListClient) Query() *WhiteListQuery { + return &WhiteListQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeWhiteList}, + inters: c.Interceptors(), + } +} + +// Get returns a WhiteList entity by its id. +func (c *WhiteListClient) Get(ctx context.Context, id int) (*WhiteList, error) { + return c.Query().Where(whitelist.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *WhiteListClient) GetX(ctx context.Context, id int) *WhiteList { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QuerySponsor queries the Sponsor edge of a WhiteList. +func (c *WhiteListClient) QuerySponsor(wl *WhiteList) *ValidatorsQuery { + query := (&ValidatorsClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := wl.ID + step := sqlgraph.NewStep( + sqlgraph.From(whitelist.Table, whitelist.FieldID, id), + sqlgraph.To(validators.Table, validators.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, whitelist.SponsorTable, whitelist.SponsorColumn), + ) + fromV = sqlgraph.Neighbors(wl.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryAccount queries the Account edge of a WhiteList. +func (c *WhiteListClient) QueryAccount(wl *WhiteList) *KeyQuery { + query := (&KeyClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := wl.ID + step := sqlgraph.NewStep( + sqlgraph.From(whitelist.Table, whitelist.FieldID, id), + sqlgraph.To(key.Table, key.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, whitelist.AccountTable, whitelist.AccountColumn), + ) + fromV = sqlgraph.Neighbors(wl.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *WhiteListClient) Hooks() []Hook { + return c.hooks.WhiteList +} + +// Interceptors returns the client interceptors. +func (c *WhiteListClient) Interceptors() []Interceptor { + return c.inters.WhiteList +} + +func (c *WhiteListClient) mutate(ctx context.Context, m *WhiteListMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&WhiteListCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&WhiteListUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&WhiteListUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&WhiteListDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown WhiteList mutation op: %q", m.Op()) + } +} + +// hooks and interceptors per client, for fast access. +type ( + hooks struct { + Blocks, Key, Transactions, Validators, WhiteList []ent.Hook + } + inters struct { + Blocks, Key, Transactions, Validators, WhiteList []ent.Interceptor + } +) diff --git a/z2/backend/ent/ent.go b/z2/backend/ent/ent.go new file mode 100644 index 0000000..d50db04 --- /dev/null +++ b/z2/backend/ent/ent.go @@ -0,0 +1,616 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "reflect" + "sync" + "thesis/ent/blocks" + "thesis/ent/key" + "thesis/ent/transactions" + "thesis/ent/validators" + "thesis/ent/whitelist" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ent aliases to avoid import conflicts in user's code. +type ( + Op = ent.Op + Hook = ent.Hook + Value = ent.Value + Query = ent.Query + QueryContext = ent.QueryContext + Querier = ent.Querier + QuerierFunc = ent.QuerierFunc + Interceptor = ent.Interceptor + InterceptFunc = ent.InterceptFunc + Traverser = ent.Traverser + TraverseFunc = ent.TraverseFunc + Policy = ent.Policy + Mutator = ent.Mutator + Mutation = ent.Mutation + MutateFunc = ent.MutateFunc +) + +type clientCtxKey struct{} + +// FromContext returns a Client stored inside a context, or nil if there isn't one. +func FromContext(ctx context.Context) *Client { + c, _ := ctx.Value(clientCtxKey{}).(*Client) + return c +} + +// NewContext returns a new context with the given Client attached. +func NewContext(parent context.Context, c *Client) context.Context { + return context.WithValue(parent, clientCtxKey{}, c) +} + +type txCtxKey struct{} + +// TxFromContext returns a Tx stored inside a context, or nil if there isn't one. +func TxFromContext(ctx context.Context) *Tx { + tx, _ := ctx.Value(txCtxKey{}).(*Tx) + return tx +} + +// NewTxContext returns a new context with the given Tx attached. +func NewTxContext(parent context.Context, tx *Tx) context.Context { + return context.WithValue(parent, txCtxKey{}, tx) +} + +// OrderFunc applies an ordering on the sql selector. +// Deprecated: Use Asc/Desc functions or the package builders instead. +type OrderFunc func(*sql.Selector) + +var ( + initCheck sync.Once + columnCheck sql.ColumnCheck +) + +// columnChecker checks if the column exists in the given table. +func checkColumn(table, column string) error { + initCheck.Do(func() { + columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ + blocks.Table: blocks.ValidColumn, + key.Table: key.ValidColumn, + transactions.Table: transactions.ValidColumn, + validators.Table: validators.ValidColumn, + whitelist.Table: whitelist.ValidColumn, + }) + }) + return columnCheck(table, column) +} + +// Asc applies the given fields in ASC order. +func Asc(fields ...string) func(*sql.Selector) { + return func(s *sql.Selector) { + for _, f := range fields { + if err := checkColumn(s.TableName(), f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Asc(s.C(f))) + } + } +} + +// Desc applies the given fields in DESC order. +func Desc(fields ...string) func(*sql.Selector) { + return func(s *sql.Selector) { + for _, f := range fields { + if err := checkColumn(s.TableName(), f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Desc(s.C(f))) + } + } +} + +// AggregateFunc applies an aggregation step on the group-by traversal/selector. +type AggregateFunc func(*sql.Selector) string + +// As is a pseudo aggregation function for renaming another other functions with custom names. For example: +// +// GroupBy(field1, field2). +// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")). +// Scan(ctx, &v) +func As(fn AggregateFunc, end string) AggregateFunc { + return func(s *sql.Selector) string { + return sql.As(fn(s), end) + } +} + +// Count applies the "count" aggregation function on each group. +func Count() AggregateFunc { + return func(s *sql.Selector) string { + return sql.Count("*") + } +} + +// Max applies the "max" aggregation function on the given field of each group. +func Max(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Max(s.C(field)) + } +} + +// Mean applies the "mean" aggregation function on the given field of each group. +func Mean(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Avg(s.C(field)) + } +} + +// Min applies the "min" aggregation function on the given field of each group. +func Min(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Min(s.C(field)) + } +} + +// Sum applies the "sum" aggregation function on the given field of each group. +func Sum(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Sum(s.C(field)) + } +} + +// ValidationError returns when validating a field or edge fails. +type ValidationError struct { + Name string // Field or edge name. + err error +} + +// Error implements the error interface. +func (e *ValidationError) Error() string { + return e.err.Error() +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ValidationError) Unwrap() error { + return e.err +} + +// IsValidationError returns a boolean indicating whether the error is a validation error. +func IsValidationError(err error) bool { + if err == nil { + return false + } + var e *ValidationError + return errors.As(err, &e) +} + +// NotFoundError returns when trying to fetch a specific entity and it was not found in the database. +type NotFoundError struct { + label string +} + +// Error implements the error interface. +func (e *NotFoundError) Error() string { + return "ent: " + e.label + " not found" +} + +// IsNotFound returns a boolean indicating whether the error is a not found error. +func IsNotFound(err error) bool { + if err == nil { + return false + } + var e *NotFoundError + return errors.As(err, &e) +} + +// MaskNotFound masks not found error. +func MaskNotFound(err error) error { + if IsNotFound(err) { + return nil + } + return err +} + +// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database. +type NotSingularError struct { + label string +} + +// Error implements the error interface. +func (e *NotSingularError) Error() string { + return "ent: " + e.label + " not singular" +} + +// IsNotSingular returns a boolean indicating whether the error is a not singular error. +func IsNotSingular(err error) bool { + if err == nil { + return false + } + var e *NotSingularError + return errors.As(err, &e) +} + +// NotLoadedError returns when trying to get a node that was not loaded by the query. +type NotLoadedError struct { + edge string +} + +// Error implements the error interface. +func (e *NotLoadedError) Error() string { + return "ent: " + e.edge + " edge was not loaded" +} + +// IsNotLoaded returns a boolean indicating whether the error is a not loaded error. +func IsNotLoaded(err error) bool { + if err == nil { + return false + } + var e *NotLoadedError + return errors.As(err, &e) +} + +// ConstraintError returns when trying to create/update one or more entities and +// one or more of their constraints failed. For example, violation of edge or +// field uniqueness. +type ConstraintError struct { + msg string + wrap error +} + +// Error implements the error interface. +func (e ConstraintError) Error() string { + return "ent: constraint failed: " + e.msg +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ConstraintError) Unwrap() error { + return e.wrap +} + +// IsConstraintError returns a boolean indicating whether the error is a constraint failure. +func IsConstraintError(err error) bool { + if err == nil { + return false + } + var e *ConstraintError + return errors.As(err, &e) +} + +// selector embedded by the different Select/GroupBy builders. +type selector struct { + label string + flds *[]string + fns []AggregateFunc + scan func(context.Context, any) error +} + +// ScanX is like Scan, but panics if an error occurs. +func (s *selector) ScanX(ctx context.Context, v any) { + if err := s.scan(ctx, v); err != nil { + panic(err) + } +} + +// Strings returns list of strings from a selector. It is only allowed when selecting one field. +func (s *selector) Strings(ctx context.Context) ([]string, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field") + } + var v []string + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// StringsX is like Strings, but panics if an error occurs. +func (s *selector) StringsX(ctx context.Context) []string { + v, err := s.Strings(ctx) + if err != nil { + panic(err) + } + return v +} + +// String returns a single string from a selector. It is only allowed when selecting one field. +func (s *selector) String(ctx context.Context) (_ string, err error) { + var v []string + if v, err = s.Strings(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v)) + } + return +} + +// StringX is like String, but panics if an error occurs. +func (s *selector) StringX(ctx context.Context) string { + v, err := s.String(ctx) + if err != nil { + panic(err) + } + return v +} + +// Ints returns list of ints from a selector. It is only allowed when selecting one field. +func (s *selector) Ints(ctx context.Context) ([]int, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field") + } + var v []int + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// IntsX is like Ints, but panics if an error occurs. +func (s *selector) IntsX(ctx context.Context) []int { + v, err := s.Ints(ctx) + if err != nil { + panic(err) + } + return v +} + +// Int returns a single int from a selector. It is only allowed when selecting one field. +func (s *selector) Int(ctx context.Context) (_ int, err error) { + var v []int + if v, err = s.Ints(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v)) + } + return +} + +// IntX is like Int, but panics if an error occurs. +func (s *selector) IntX(ctx context.Context) int { + v, err := s.Int(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64s returns list of float64s from a selector. It is only allowed when selecting one field. +func (s *selector) Float64s(ctx context.Context) ([]float64, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field") + } + var v []float64 + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// Float64sX is like Float64s, but panics if an error occurs. +func (s *selector) Float64sX(ctx context.Context) []float64 { + v, err := s.Float64s(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64 returns a single float64 from a selector. It is only allowed when selecting one field. +func (s *selector) Float64(ctx context.Context) (_ float64, err error) { + var v []float64 + if v, err = s.Float64s(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v)) + } + return +} + +// Float64X is like Float64, but panics if an error occurs. +func (s *selector) Float64X(ctx context.Context) float64 { + v, err := s.Float64(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bools returns list of bools from a selector. It is only allowed when selecting one field. +func (s *selector) Bools(ctx context.Context) ([]bool, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field") + } + var v []bool + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// BoolsX is like Bools, but panics if an error occurs. +func (s *selector) BoolsX(ctx context.Context) []bool { + v, err := s.Bools(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bool returns a single bool from a selector. It is only allowed when selecting one field. +func (s *selector) Bool(ctx context.Context) (_ bool, err error) { + var v []bool + if v, err = s.Bools(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v)) + } + return +} + +// BoolX is like Bool, but panics if an error occurs. +func (s *selector) BoolX(ctx context.Context) bool { + v, err := s.Bool(ctx) + if err != nil { + panic(err) + } + return v +} + +// withHooks invokes the builder operation with the given hooks, if any. +func withHooks[V Value, M any, PM interface { + *M + Mutation +}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) { + if len(hooks) == 0 { + return exec(ctx) + } + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutationT, ok := any(m).(PM) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + // Set the mutation to the builder. + *mutation = *mutationT + return exec(ctx) + }) + for i := len(hooks) - 1; i >= 0; i-- { + if hooks[i] == nil { + return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = hooks[i](mut) + } + v, err := mut.Mutate(ctx, mutation) + if err != nil { + return value, err + } + nv, ok := v.(V) + if !ok { + return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation) + } + return nv, nil +} + +// setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist. +func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context { + if ent.QueryFromContext(ctx) == nil { + qc.Op = op + ctx = ent.NewQueryContext(ctx, qc) + } + return ctx +} + +func querierAll[V Value, Q interface { + sqlAll(context.Context, ...queryHook) (V, error) +}]() Querier { + return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + return query.sqlAll(ctx) + }) +} + +func querierCount[Q interface { + sqlCount(context.Context) (int, error) +}]() Querier { + return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + return query.sqlCount(ctx) + }) +} + +func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) { + for i := len(inters) - 1; i >= 0; i-- { + qr = inters[i].Intercept(qr) + } + rv, err := qr.Query(ctx, q) + if err != nil { + return v, err + } + vt, ok := rv.(V) + if !ok { + return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v) + } + return vt, nil +} + +func scanWithInterceptors[Q1 ent.Query, Q2 interface { + sqlScan(context.Context, Q1, any) error +}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error { + rv := reflect.ValueOf(v) + var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q1) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + if err := selectOrGroup.sqlScan(ctx, query, v); err != nil { + return nil, err + } + if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() { + return rv.Elem().Interface(), nil + } + return v, nil + }) + for i := len(inters) - 1; i >= 0; i-- { + qr = inters[i].Intercept(qr) + } + vv, err := qr.Query(ctx, rootQuery) + if err != nil { + return err + } + switch rv2 := reflect.ValueOf(vv); { + case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer: + case rv.Type() == rv2.Type(): + rv.Elem().Set(rv2.Elem()) + case rv.Elem().Type() == rv2.Type(): + rv.Elem().Set(rv2) + } + return nil +} + +// queryHook describes an internal hook for the different sqlAll methods. +type queryHook func(context.Context, *sqlgraph.QuerySpec) diff --git a/z2/backend/ent/enttest/enttest.go b/z2/backend/ent/enttest/enttest.go new file mode 100644 index 0000000..dbaa13c --- /dev/null +++ b/z2/backend/ent/enttest/enttest.go @@ -0,0 +1,84 @@ +// Code generated by ent, DO NOT EDIT. + +package enttest + +import ( + "context" + "thesis/ent" + // required by schema hooks. + _ "thesis/ent/runtime" + + "thesis/ent/migrate" + + "entgo.io/ent/dialect/sql/schema" +) + +type ( + // TestingT is the interface that is shared between + // testing.T and testing.B and used by enttest. + TestingT interface { + FailNow() + Error(...any) + } + + // Option configures client creation. + Option func(*options) + + options struct { + opts []ent.Option + migrateOpts []schema.MigrateOption + } +) + +// WithOptions forwards options to client creation. +func WithOptions(opts ...ent.Option) Option { + return func(o *options) { + o.opts = append(o.opts, opts...) + } +} + +// WithMigrateOptions forwards options to auto migration. +func WithMigrateOptions(opts ...schema.MigrateOption) Option { + return func(o *options) { + o.migrateOpts = append(o.migrateOpts, opts...) + } +} + +func newOptions(opts []Option) *options { + o := &options{} + for _, opt := range opts { + opt(o) + } + return o +} + +// Open calls ent.Open and auto-run migration. +func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client { + o := newOptions(opts) + c, err := ent.Open(driverName, dataSourceName, o.opts...) + if err != nil { + t.Error(err) + t.FailNow() + } + migrateSchema(t, c, o) + return c +} + +// NewClient calls ent.NewClient and auto-run migration. +func NewClient(t TestingT, opts ...Option) *ent.Client { + o := newOptions(opts) + c := ent.NewClient(o.opts...) + migrateSchema(t, c, o) + return c +} +func migrateSchema(t TestingT, c *ent.Client, o *options) { + tables, err := schema.CopyTables(migrate.Tables) + if err != nil { + t.Error(err) + t.FailNow() + } + if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil { + t.Error(err) + t.FailNow() + } +} diff --git a/z2/backend/ent/generate.go b/z2/backend/ent/generate.go new file mode 100644 index 0000000..8d3fdfd --- /dev/null +++ b/z2/backend/ent/generate.go @@ -0,0 +1,3 @@ +package ent + +//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate ./schema diff --git a/z2/backend/ent/hook/hook.go b/z2/backend/ent/hook/hook.go new file mode 100644 index 0000000..db1292c --- /dev/null +++ b/z2/backend/ent/hook/hook.go @@ -0,0 +1,246 @@ +// Code generated by ent, DO NOT EDIT. + +package hook + +import ( + "context" + "fmt" + "thesis/ent" +) + +// The BlocksFunc type is an adapter to allow the use of ordinary +// function as Blocks mutator. +type BlocksFunc func(context.Context, *ent.BlocksMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f BlocksFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.BlocksMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.BlocksMutation", m) +} + +// The KeyFunc type is an adapter to allow the use of ordinary +// function as Key mutator. +type KeyFunc func(context.Context, *ent.KeyMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f KeyFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.KeyMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.KeyMutation", m) +} + +// The TransactionsFunc type is an adapter to allow the use of ordinary +// function as Transactions mutator. +type TransactionsFunc func(context.Context, *ent.TransactionsMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f TransactionsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.TransactionsMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.TransactionsMutation", m) +} + +// The ValidatorsFunc type is an adapter to allow the use of ordinary +// function as Validators mutator. +type ValidatorsFunc func(context.Context, *ent.ValidatorsMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ValidatorsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ValidatorsMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ValidatorsMutation", m) +} + +// The WhiteListFunc type is an adapter to allow the use of ordinary +// function as WhiteList mutator. +type WhiteListFunc func(context.Context, *ent.WhiteListMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f WhiteListFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.WhiteListMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.WhiteListMutation", m) +} + +// Condition is a hook condition function. +type Condition func(context.Context, ent.Mutation) bool + +// And groups conditions with the AND operator. +func And(first, second Condition, rest ...Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + if !first(ctx, m) || !second(ctx, m) { + return false + } + for _, cond := range rest { + if !cond(ctx, m) { + return false + } + } + return true + } +} + +// Or groups conditions with the OR operator. +func Or(first, second Condition, rest ...Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + if first(ctx, m) || second(ctx, m) { + return true + } + for _, cond := range rest { + if cond(ctx, m) { + return true + } + } + return false + } +} + +// Not negates a given condition. +func Not(cond Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + return !cond(ctx, m) + } +} + +// HasOp is a condition testing mutation operation. +func HasOp(op ent.Op) Condition { + return func(_ context.Context, m ent.Mutation) bool { + return m.Op().Is(op) + } +} + +// HasAddedFields is a condition validating `.AddedField` on fields. +func HasAddedFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if _, exists := m.AddedField(field); !exists { + return false + } + for _, field := range fields { + if _, exists := m.AddedField(field); !exists { + return false + } + } + return true + } +} + +// HasClearedFields is a condition validating `.FieldCleared` on fields. +func HasClearedFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if exists := m.FieldCleared(field); !exists { + return false + } + for _, field := range fields { + if exists := m.FieldCleared(field); !exists { + return false + } + } + return true + } +} + +// HasFields is a condition validating `.Field` on fields. +func HasFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if _, exists := m.Field(field); !exists { + return false + } + for _, field := range fields { + if _, exists := m.Field(field); !exists { + return false + } + } + return true + } +} + +// If executes the given hook under condition. +// +// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...))) +func If(hk ent.Hook, cond Condition) ent.Hook { + return func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if cond(ctx, m) { + return hk(next).Mutate(ctx, m) + } + return next.Mutate(ctx, m) + }) + } +} + +// On executes the given hook only for the given operation. +// +// hook.On(Log, ent.Delete|ent.Create) +func On(hk ent.Hook, op ent.Op) ent.Hook { + return If(hk, HasOp(op)) +} + +// Unless skips the given hook only for the given operation. +// +// hook.Unless(Log, ent.Update|ent.UpdateOne) +func Unless(hk ent.Hook, op ent.Op) ent.Hook { + return If(hk, Not(HasOp(op))) +} + +// FixedError is a hook returning a fixed error. +func FixedError(err error) ent.Hook { + return func(ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) { + return nil, err + }) + } +} + +// Reject returns a hook that rejects all operations that match op. +// +// func (T) Hooks() []ent.Hook { +// return []ent.Hook{ +// Reject(ent.Delete|ent.Update), +// } +// } +func Reject(op ent.Op) ent.Hook { + hk := FixedError(fmt.Errorf("%s operation is not allowed", op)) + return On(hk, op) +} + +// Chain acts as a list of hooks and is effectively immutable. +// Once created, it will always hold the same set of hooks in the same order. +type Chain struct { + hooks []ent.Hook +} + +// NewChain creates a new chain of hooks. +func NewChain(hooks ...ent.Hook) Chain { + return Chain{append([]ent.Hook(nil), hooks...)} +} + +// Hook chains the list of hooks and returns the final hook. +func (c Chain) Hook() ent.Hook { + return func(mutator ent.Mutator) ent.Mutator { + for i := len(c.hooks) - 1; i >= 0; i-- { + mutator = c.hooks[i](mutator) + } + return mutator + } +} + +// Append extends a chain, adding the specified hook +// as the last ones in the mutation flow. +func (c Chain) Append(hooks ...ent.Hook) Chain { + newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks)) + newHooks = append(newHooks, c.hooks...) + newHooks = append(newHooks, hooks...) + return Chain{newHooks} +} + +// Extend extends a chain, adding the specified chain +// as the last ones in the mutation flow. +func (c Chain) Extend(chain Chain) Chain { + return c.Append(chain.hooks...) +} diff --git a/z2/backend/ent/key.go b/z2/backend/ent/key.go new file mode 100644 index 0000000..41b3b28 --- /dev/null +++ b/z2/backend/ent/key.go @@ -0,0 +1,173 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "thesis/ent/key" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// Key is the model entity for the Key schema. +type Key struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // PublicKey holds the value of the "publicKey" field. + PublicKey string `json:"publicKey,omitempty"` + // Owner holds the value of the "Owner" field. + Owner string `json:"Owner,omitempty"` + // TrustScore holds the value of the "trustScore" field. + TrustScore float64 `json:"trustScore,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the KeyQuery when eager-loading is set. + Edges KeyEdges `json:"edges"` + validators_key *int + white_list_account *int + selectValues sql.SelectValues +} + +// KeyEdges holds the relations/edges for other nodes in the graph. +type KeyEdges struct { + // Signed holds the value of the Signed edge. + Signed []*Transactions `json:"Signed,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// SignedOrErr returns the Signed value or an error if the edge +// was not loaded in eager-loading. +func (e KeyEdges) SignedOrErr() ([]*Transactions, error) { + if e.loadedTypes[0] { + return e.Signed, nil + } + return nil, &NotLoadedError{edge: "Signed"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Key) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case key.FieldTrustScore: + values[i] = new(sql.NullFloat64) + case key.FieldID: + values[i] = new(sql.NullInt64) + case key.FieldPublicKey, key.FieldOwner: + values[i] = new(sql.NullString) + case key.ForeignKeys[0]: // validators_key + values[i] = new(sql.NullInt64) + case key.ForeignKeys[1]: // white_list_account + values[i] = new(sql.NullInt64) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Key fields. +func (k *Key) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case key.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + k.ID = int(value.Int64) + case key.FieldPublicKey: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field publicKey", values[i]) + } else if value.Valid { + k.PublicKey = value.String + } + case key.FieldOwner: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field Owner", values[i]) + } else if value.Valid { + k.Owner = value.String + } + case key.FieldTrustScore: + if value, ok := values[i].(*sql.NullFloat64); !ok { + return fmt.Errorf("unexpected type %T for field trustScore", values[i]) + } else if value.Valid { + k.TrustScore = value.Float64 + } + case key.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field validators_key", value) + } else if value.Valid { + k.validators_key = new(int) + *k.validators_key = int(value.Int64) + } + case key.ForeignKeys[1]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field white_list_account", value) + } else if value.Valid { + k.white_list_account = new(int) + *k.white_list_account = int(value.Int64) + } + default: + k.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Key. +// This includes values selected through modifiers, order, etc. +func (k *Key) Value(name string) (ent.Value, error) { + return k.selectValues.Get(name) +} + +// QuerySigned queries the "Signed" edge of the Key entity. +func (k *Key) QuerySigned() *TransactionsQuery { + return NewKeyClient(k.config).QuerySigned(k) +} + +// Update returns a builder for updating this Key. +// Note that you need to call Key.Unwrap() before calling this method if this Key +// was returned from a transaction, and the transaction was committed or rolled back. +func (k *Key) Update() *KeyUpdateOne { + return NewKeyClient(k.config).UpdateOne(k) +} + +// Unwrap unwraps the Key entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (k *Key) Unwrap() *Key { + _tx, ok := k.config.driver.(*txDriver) + if !ok { + panic("ent: Key is not a transactional entity") + } + k.config.driver = _tx.drv + return k +} + +// String implements the fmt.Stringer. +func (k *Key) String() string { + var builder strings.Builder + builder.WriteString("Key(") + builder.WriteString(fmt.Sprintf("id=%v, ", k.ID)) + builder.WriteString("publicKey=") + builder.WriteString(k.PublicKey) + builder.WriteString(", ") + builder.WriteString("Owner=") + builder.WriteString(k.Owner) + builder.WriteString(", ") + builder.WriteString("trustScore=") + builder.WriteString(fmt.Sprintf("%v", k.TrustScore)) + builder.WriteByte(')') + return builder.String() +} + +// Keys is a parsable slice of Key. +type Keys []*Key diff --git a/z2/backend/ent/key/key.go b/z2/backend/ent/key/key.go new file mode 100644 index 0000000..d860659 --- /dev/null +++ b/z2/backend/ent/key/key.go @@ -0,0 +1,119 @@ +// Code generated by ent, DO NOT EDIT. + +package key + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the key type in the database. + Label = "key" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldPublicKey holds the string denoting the publickey field in the database. + FieldPublicKey = "public_key" + // FieldOwner holds the string denoting the owner field in the database. + FieldOwner = "owner" + // FieldTrustScore holds the string denoting the trustscore field in the database. + FieldTrustScore = "trust_score" + // EdgeSigned holds the string denoting the signed edge name in mutations. + EdgeSigned = "Signed" + // Table holds the table name of the key in the database. + Table = "keys" + // SignedTable is the table that holds the Signed relation/edge. The primary key declared below. + SignedTable = "key_Signed" + // SignedInverseTable is the table name for the Transactions entity. + // It exists in this package in order to avoid circular dependency with the "transactions" package. + SignedInverseTable = "transactions" +) + +// Columns holds all SQL columns for key fields. +var Columns = []string{ + FieldID, + FieldPublicKey, + FieldOwner, + FieldTrustScore, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "keys" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "validators_key", + "white_list_account", +} + +var ( + // SignedPrimaryKey and SignedColumn2 are the table columns denoting the + // primary key for the Signed relation (M2M). + SignedPrimaryKey = []string{"key_id", "transactions_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 +} + +var ( + // PublicKeyValidator is a validator for the "publicKey" field. It is called by the builders before save. + PublicKeyValidator func(string) error + // OwnerValidator is a validator for the "Owner" field. It is called by the builders before save. + OwnerValidator func(string) error + // DefaultTrustScore holds the default value on creation for the "trustScore" field. + DefaultTrustScore float64 +) + +// OrderOption defines the ordering options for the Key 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() +} + +// ByPublicKey orders the results by the publicKey field. +func ByPublicKey(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPublicKey, opts...).ToFunc() +} + +// ByOwner orders the results by the Owner field. +func ByOwner(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOwner, opts...).ToFunc() +} + +// ByTrustScore orders the results by the trustScore field. +func ByTrustScore(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTrustScore, opts...).ToFunc() +} + +// BySignedCount orders the results by Signed count. +func BySignedCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newSignedStep(), opts...) + } +} + +// BySigned orders the results by Signed terms. +func BySigned(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newSignedStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newSignedStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(SignedInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, SignedTable, SignedPrimaryKey...), + ) +} diff --git a/z2/backend/ent/key/where.go b/z2/backend/ent/key/where.go new file mode 100644 index 0000000..3dd2867 --- /dev/null +++ b/z2/backend/ent/key/where.go @@ -0,0 +1,278 @@ +// Code generated by ent, DO NOT EDIT. + +package key + +import ( + "thesis/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.Key { + return predicate.Key(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Key { + return predicate.Key(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Key { + return predicate.Key(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Key { + return predicate.Key(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Key { + return predicate.Key(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Key { + return predicate.Key(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Key { + return predicate.Key(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Key { + return predicate.Key(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Key { + return predicate.Key(sql.FieldLTE(FieldID, id)) +} + +// PublicKey applies equality check predicate on the "publicKey" field. It's identical to PublicKeyEQ. +func PublicKey(v string) predicate.Key { + return predicate.Key(sql.FieldEQ(FieldPublicKey, v)) +} + +// Owner applies equality check predicate on the "Owner" field. It's identical to OwnerEQ. +func Owner(v string) predicate.Key { + return predicate.Key(sql.FieldEQ(FieldOwner, v)) +} + +// TrustScore applies equality check predicate on the "trustScore" field. It's identical to TrustScoreEQ. +func TrustScore(v float64) predicate.Key { + return predicate.Key(sql.FieldEQ(FieldTrustScore, v)) +} + +// PublicKeyEQ applies the EQ predicate on the "publicKey" field. +func PublicKeyEQ(v string) predicate.Key { + return predicate.Key(sql.FieldEQ(FieldPublicKey, v)) +} + +// PublicKeyNEQ applies the NEQ predicate on the "publicKey" field. +func PublicKeyNEQ(v string) predicate.Key { + return predicate.Key(sql.FieldNEQ(FieldPublicKey, v)) +} + +// PublicKeyIn applies the In predicate on the "publicKey" field. +func PublicKeyIn(vs ...string) predicate.Key { + return predicate.Key(sql.FieldIn(FieldPublicKey, vs...)) +} + +// PublicKeyNotIn applies the NotIn predicate on the "publicKey" field. +func PublicKeyNotIn(vs ...string) predicate.Key { + return predicate.Key(sql.FieldNotIn(FieldPublicKey, vs...)) +} + +// PublicKeyGT applies the GT predicate on the "publicKey" field. +func PublicKeyGT(v string) predicate.Key { + return predicate.Key(sql.FieldGT(FieldPublicKey, v)) +} + +// PublicKeyGTE applies the GTE predicate on the "publicKey" field. +func PublicKeyGTE(v string) predicate.Key { + return predicate.Key(sql.FieldGTE(FieldPublicKey, v)) +} + +// PublicKeyLT applies the LT predicate on the "publicKey" field. +func PublicKeyLT(v string) predicate.Key { + return predicate.Key(sql.FieldLT(FieldPublicKey, v)) +} + +// PublicKeyLTE applies the LTE predicate on the "publicKey" field. +func PublicKeyLTE(v string) predicate.Key { + return predicate.Key(sql.FieldLTE(FieldPublicKey, v)) +} + +// PublicKeyContains applies the Contains predicate on the "publicKey" field. +func PublicKeyContains(v string) predicate.Key { + return predicate.Key(sql.FieldContains(FieldPublicKey, v)) +} + +// PublicKeyHasPrefix applies the HasPrefix predicate on the "publicKey" field. +func PublicKeyHasPrefix(v string) predicate.Key { + return predicate.Key(sql.FieldHasPrefix(FieldPublicKey, v)) +} + +// PublicKeyHasSuffix applies the HasSuffix predicate on the "publicKey" field. +func PublicKeyHasSuffix(v string) predicate.Key { + return predicate.Key(sql.FieldHasSuffix(FieldPublicKey, v)) +} + +// PublicKeyEqualFold applies the EqualFold predicate on the "publicKey" field. +func PublicKeyEqualFold(v string) predicate.Key { + return predicate.Key(sql.FieldEqualFold(FieldPublicKey, v)) +} + +// PublicKeyContainsFold applies the ContainsFold predicate on the "publicKey" field. +func PublicKeyContainsFold(v string) predicate.Key { + return predicate.Key(sql.FieldContainsFold(FieldPublicKey, v)) +} + +// OwnerEQ applies the EQ predicate on the "Owner" field. +func OwnerEQ(v string) predicate.Key { + return predicate.Key(sql.FieldEQ(FieldOwner, v)) +} + +// OwnerNEQ applies the NEQ predicate on the "Owner" field. +func OwnerNEQ(v string) predicate.Key { + return predicate.Key(sql.FieldNEQ(FieldOwner, v)) +} + +// OwnerIn applies the In predicate on the "Owner" field. +func OwnerIn(vs ...string) predicate.Key { + return predicate.Key(sql.FieldIn(FieldOwner, vs...)) +} + +// OwnerNotIn applies the NotIn predicate on the "Owner" field. +func OwnerNotIn(vs ...string) predicate.Key { + return predicate.Key(sql.FieldNotIn(FieldOwner, vs...)) +} + +// OwnerGT applies the GT predicate on the "Owner" field. +func OwnerGT(v string) predicate.Key { + return predicate.Key(sql.FieldGT(FieldOwner, v)) +} + +// OwnerGTE applies the GTE predicate on the "Owner" field. +func OwnerGTE(v string) predicate.Key { + return predicate.Key(sql.FieldGTE(FieldOwner, v)) +} + +// OwnerLT applies the LT predicate on the "Owner" field. +func OwnerLT(v string) predicate.Key { + return predicate.Key(sql.FieldLT(FieldOwner, v)) +} + +// OwnerLTE applies the LTE predicate on the "Owner" field. +func OwnerLTE(v string) predicate.Key { + return predicate.Key(sql.FieldLTE(FieldOwner, v)) +} + +// OwnerContains applies the Contains predicate on the "Owner" field. +func OwnerContains(v string) predicate.Key { + return predicate.Key(sql.FieldContains(FieldOwner, v)) +} + +// OwnerHasPrefix applies the HasPrefix predicate on the "Owner" field. +func OwnerHasPrefix(v string) predicate.Key { + return predicate.Key(sql.FieldHasPrefix(FieldOwner, v)) +} + +// OwnerHasSuffix applies the HasSuffix predicate on the "Owner" field. +func OwnerHasSuffix(v string) predicate.Key { + return predicate.Key(sql.FieldHasSuffix(FieldOwner, v)) +} + +// OwnerEqualFold applies the EqualFold predicate on the "Owner" field. +func OwnerEqualFold(v string) predicate.Key { + return predicate.Key(sql.FieldEqualFold(FieldOwner, v)) +} + +// OwnerContainsFold applies the ContainsFold predicate on the "Owner" field. +func OwnerContainsFold(v string) predicate.Key { + return predicate.Key(sql.FieldContainsFold(FieldOwner, v)) +} + +// TrustScoreEQ applies the EQ predicate on the "trustScore" field. +func TrustScoreEQ(v float64) predicate.Key { + return predicate.Key(sql.FieldEQ(FieldTrustScore, v)) +} + +// TrustScoreNEQ applies the NEQ predicate on the "trustScore" field. +func TrustScoreNEQ(v float64) predicate.Key { + return predicate.Key(sql.FieldNEQ(FieldTrustScore, v)) +} + +// TrustScoreIn applies the In predicate on the "trustScore" field. +func TrustScoreIn(vs ...float64) predicate.Key { + return predicate.Key(sql.FieldIn(FieldTrustScore, vs...)) +} + +// TrustScoreNotIn applies the NotIn predicate on the "trustScore" field. +func TrustScoreNotIn(vs ...float64) predicate.Key { + return predicate.Key(sql.FieldNotIn(FieldTrustScore, vs...)) +} + +// TrustScoreGT applies the GT predicate on the "trustScore" field. +func TrustScoreGT(v float64) predicate.Key { + return predicate.Key(sql.FieldGT(FieldTrustScore, v)) +} + +// TrustScoreGTE applies the GTE predicate on the "trustScore" field. +func TrustScoreGTE(v float64) predicate.Key { + return predicate.Key(sql.FieldGTE(FieldTrustScore, v)) +} + +// TrustScoreLT applies the LT predicate on the "trustScore" field. +func TrustScoreLT(v float64) predicate.Key { + return predicate.Key(sql.FieldLT(FieldTrustScore, v)) +} + +// TrustScoreLTE applies the LTE predicate on the "trustScore" field. +func TrustScoreLTE(v float64) predicate.Key { + return predicate.Key(sql.FieldLTE(FieldTrustScore, v)) +} + +// HasSigned applies the HasEdge predicate on the "Signed" edge. +func HasSigned() predicate.Key { + return predicate.Key(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, SignedTable, SignedPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasSignedWith applies the HasEdge predicate on the "Signed" edge with a given conditions (other predicates). +func HasSignedWith(preds ...predicate.Transactions) predicate.Key { + return predicate.Key(func(s *sql.Selector) { + step := newSignedStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Key) predicate.Key { + return predicate.Key(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Key) predicate.Key { + return predicate.Key(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Key) predicate.Key { + return predicate.Key(sql.NotPredicates(p)) +} diff --git a/z2/backend/ent/key_create.go b/z2/backend/ent/key_create.go new file mode 100644 index 0000000..cb2c955 --- /dev/null +++ b/z2/backend/ent/key_create.go @@ -0,0 +1,269 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "thesis/ent/key" + "thesis/ent/transactions" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// KeyCreate is the builder for creating a Key entity. +type KeyCreate struct { + config + mutation *KeyMutation + hooks []Hook +} + +// SetPublicKey sets the "publicKey" field. +func (kc *KeyCreate) SetPublicKey(s string) *KeyCreate { + kc.mutation.SetPublicKey(s) + return kc +} + +// SetOwner sets the "Owner" field. +func (kc *KeyCreate) SetOwner(s string) *KeyCreate { + kc.mutation.SetOwner(s) + return kc +} + +// SetTrustScore sets the "trustScore" field. +func (kc *KeyCreate) SetTrustScore(f float64) *KeyCreate { + kc.mutation.SetTrustScore(f) + return kc +} + +// SetNillableTrustScore sets the "trustScore" field if the given value is not nil. +func (kc *KeyCreate) SetNillableTrustScore(f *float64) *KeyCreate { + if f != nil { + kc.SetTrustScore(*f) + } + return kc +} + +// AddSignedIDs adds the "Signed" edge to the Transactions entity by IDs. +func (kc *KeyCreate) AddSignedIDs(ids ...int) *KeyCreate { + kc.mutation.AddSignedIDs(ids...) + return kc +} + +// AddSigned adds the "Signed" edges to the Transactions entity. +func (kc *KeyCreate) AddSigned(t ...*Transactions) *KeyCreate { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return kc.AddSignedIDs(ids...) +} + +// Mutation returns the KeyMutation object of the builder. +func (kc *KeyCreate) Mutation() *KeyMutation { + return kc.mutation +} + +// Save creates the Key in the database. +func (kc *KeyCreate) Save(ctx context.Context) (*Key, error) { + kc.defaults() + return withHooks(ctx, kc.sqlSave, kc.mutation, kc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (kc *KeyCreate) SaveX(ctx context.Context) *Key { + v, err := kc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (kc *KeyCreate) Exec(ctx context.Context) error { + _, err := kc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (kc *KeyCreate) ExecX(ctx context.Context) { + if err := kc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (kc *KeyCreate) defaults() { + if _, ok := kc.mutation.TrustScore(); !ok { + v := key.DefaultTrustScore + kc.mutation.SetTrustScore(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (kc *KeyCreate) check() error { + if _, ok := kc.mutation.PublicKey(); !ok { + return &ValidationError{Name: "publicKey", err: errors.New(`ent: missing required field "Key.publicKey"`)} + } + if v, ok := kc.mutation.PublicKey(); ok { + if err := key.PublicKeyValidator(v); err != nil { + return &ValidationError{Name: "publicKey", err: fmt.Errorf(`ent: validator failed for field "Key.publicKey": %w`, err)} + } + } + if _, ok := kc.mutation.Owner(); !ok { + return &ValidationError{Name: "Owner", err: errors.New(`ent: missing required field "Key.Owner"`)} + } + if v, ok := kc.mutation.Owner(); ok { + if err := key.OwnerValidator(v); err != nil { + return &ValidationError{Name: "Owner", err: fmt.Errorf(`ent: validator failed for field "Key.Owner": %w`, err)} + } + } + if _, ok := kc.mutation.TrustScore(); !ok { + return &ValidationError{Name: "trustScore", err: errors.New(`ent: missing required field "Key.trustScore"`)} + } + return nil +} + +func (kc *KeyCreate) sqlSave(ctx context.Context) (*Key, error) { + if err := kc.check(); err != nil { + return nil, err + } + _node, _spec := kc.createSpec() + if err := sqlgraph.CreateNode(ctx, kc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + kc.mutation.id = &_node.ID + kc.mutation.done = true + return _node, nil +} + +func (kc *KeyCreate) createSpec() (*Key, *sqlgraph.CreateSpec) { + var ( + _node = &Key{config: kc.config} + _spec = sqlgraph.NewCreateSpec(key.Table, sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt)) + ) + if value, ok := kc.mutation.PublicKey(); ok { + _spec.SetField(key.FieldPublicKey, field.TypeString, value) + _node.PublicKey = value + } + if value, ok := kc.mutation.Owner(); ok { + _spec.SetField(key.FieldOwner, field.TypeString, value) + _node.Owner = value + } + if value, ok := kc.mutation.TrustScore(); ok { + _spec.SetField(key.FieldTrustScore, field.TypeFloat64, value) + _node.TrustScore = value + } + if nodes := kc.mutation.SignedIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: key.SignedTable, + Columns: key.SignedPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// KeyCreateBulk is the builder for creating many Key entities in bulk. +type KeyCreateBulk struct { + config + err error + builders []*KeyCreate +} + +// Save creates the Key entities in the database. +func (kcb *KeyCreateBulk) Save(ctx context.Context) ([]*Key, error) { + if kcb.err != nil { + return nil, kcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(kcb.builders)) + nodes := make([]*Key, len(kcb.builders)) + mutators := make([]Mutator, len(kcb.builders)) + for i := range kcb.builders { + func(i int, root context.Context) { + builder := kcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*KeyMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, kcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, kcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, kcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (kcb *KeyCreateBulk) SaveX(ctx context.Context) []*Key { + v, err := kcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (kcb *KeyCreateBulk) Exec(ctx context.Context) error { + _, err := kcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (kcb *KeyCreateBulk) ExecX(ctx context.Context) { + if err := kcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/z2/backend/ent/key_delete.go b/z2/backend/ent/key_delete.go new file mode 100644 index 0000000..1e0b557 --- /dev/null +++ b/z2/backend/ent/key_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "thesis/ent/key" + "thesis/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// KeyDelete is the builder for deleting a Key entity. +type KeyDelete struct { + config + hooks []Hook + mutation *KeyMutation +} + +// Where appends a list predicates to the KeyDelete builder. +func (kd *KeyDelete) Where(ps ...predicate.Key) *KeyDelete { + kd.mutation.Where(ps...) + return kd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (kd *KeyDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, kd.sqlExec, kd.mutation, kd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (kd *KeyDelete) ExecX(ctx context.Context) int { + n, err := kd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (kd *KeyDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(key.Table, sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt)) + if ps := kd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, kd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + kd.mutation.done = true + return affected, err +} + +// KeyDeleteOne is the builder for deleting a single Key entity. +type KeyDeleteOne struct { + kd *KeyDelete +} + +// Where appends a list predicates to the KeyDelete builder. +func (kdo *KeyDeleteOne) Where(ps ...predicate.Key) *KeyDeleteOne { + kdo.kd.mutation.Where(ps...) + return kdo +} + +// Exec executes the deletion query. +func (kdo *KeyDeleteOne) Exec(ctx context.Context) error { + n, err := kdo.kd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{key.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (kdo *KeyDeleteOne) ExecX(ctx context.Context) { + if err := kdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/z2/backend/ent/key_query.go b/z2/backend/ent/key_query.go new file mode 100644 index 0000000..4b40e01 --- /dev/null +++ b/z2/backend/ent/key_query.go @@ -0,0 +1,641 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + "thesis/ent/key" + "thesis/ent/predicate" + "thesis/ent/transactions" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// KeyQuery is the builder for querying Key entities. +type KeyQuery struct { + config + ctx *QueryContext + order []key.OrderOption + inters []Interceptor + predicates []predicate.Key + withSigned *TransactionsQuery + withFKs bool + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the KeyQuery builder. +func (kq *KeyQuery) Where(ps ...predicate.Key) *KeyQuery { + kq.predicates = append(kq.predicates, ps...) + return kq +} + +// Limit the number of records to be returned by this query. +func (kq *KeyQuery) Limit(limit int) *KeyQuery { + kq.ctx.Limit = &limit + return kq +} + +// Offset to start from. +func (kq *KeyQuery) Offset(offset int) *KeyQuery { + kq.ctx.Offset = &offset + return kq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (kq *KeyQuery) Unique(unique bool) *KeyQuery { + kq.ctx.Unique = &unique + return kq +} + +// Order specifies how the records should be ordered. +func (kq *KeyQuery) Order(o ...key.OrderOption) *KeyQuery { + kq.order = append(kq.order, o...) + return kq +} + +// QuerySigned chains the current query on the "Signed" edge. +func (kq *KeyQuery) QuerySigned() *TransactionsQuery { + query := (&TransactionsClient{config: kq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := kq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := kq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(key.Table, key.FieldID, selector), + sqlgraph.To(transactions.Table, transactions.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, key.SignedTable, key.SignedPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(kq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Key entity from the query. +// Returns a *NotFoundError when no Key was found. +func (kq *KeyQuery) First(ctx context.Context) (*Key, error) { + nodes, err := kq.Limit(1).All(setContextOp(ctx, kq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{key.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (kq *KeyQuery) FirstX(ctx context.Context) *Key { + node, err := kq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Key ID from the query. +// Returns a *NotFoundError when no Key ID was found. +func (kq *KeyQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = kq.Limit(1).IDs(setContextOp(ctx, kq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{key.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (kq *KeyQuery) FirstIDX(ctx context.Context) int { + id, err := kq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Key entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Key entity is found. +// Returns a *NotFoundError when no Key entities are found. +func (kq *KeyQuery) Only(ctx context.Context) (*Key, error) { + nodes, err := kq.Limit(2).All(setContextOp(ctx, kq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{key.Label} + default: + return nil, &NotSingularError{key.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (kq *KeyQuery) OnlyX(ctx context.Context) *Key { + node, err := kq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Key ID in the query. +// Returns a *NotSingularError when more than one Key ID is found. +// Returns a *NotFoundError when no entities are found. +func (kq *KeyQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = kq.Limit(2).IDs(setContextOp(ctx, kq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{key.Label} + default: + err = &NotSingularError{key.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (kq *KeyQuery) OnlyIDX(ctx context.Context) int { + id, err := kq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Keys. +func (kq *KeyQuery) All(ctx context.Context) ([]*Key, error) { + ctx = setContextOp(ctx, kq.ctx, "All") + if err := kq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Key, *KeyQuery]() + return withInterceptors[[]*Key](ctx, kq, qr, kq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (kq *KeyQuery) AllX(ctx context.Context) []*Key { + nodes, err := kq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Key IDs. +func (kq *KeyQuery) IDs(ctx context.Context) (ids []int, err error) { + if kq.ctx.Unique == nil && kq.path != nil { + kq.Unique(true) + } + ctx = setContextOp(ctx, kq.ctx, "IDs") + if err = kq.Select(key.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (kq *KeyQuery) IDsX(ctx context.Context) []int { + ids, err := kq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (kq *KeyQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, kq.ctx, "Count") + if err := kq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, kq, querierCount[*KeyQuery](), kq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (kq *KeyQuery) CountX(ctx context.Context) int { + count, err := kq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (kq *KeyQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, kq.ctx, "Exist") + switch _, err := kq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (kq *KeyQuery) ExistX(ctx context.Context) bool { + exist, err := kq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the KeyQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (kq *KeyQuery) Clone() *KeyQuery { + if kq == nil { + return nil + } + return &KeyQuery{ + config: kq.config, + ctx: kq.ctx.Clone(), + order: append([]key.OrderOption{}, kq.order...), + inters: append([]Interceptor{}, kq.inters...), + predicates: append([]predicate.Key{}, kq.predicates...), + withSigned: kq.withSigned.Clone(), + // clone intermediate query. + sql: kq.sql.Clone(), + path: kq.path, + } +} + +// WithSigned tells the query-builder to eager-load the nodes that are connected to +// the "Signed" edge. The optional arguments are used to configure the query builder of the edge. +func (kq *KeyQuery) WithSigned(opts ...func(*TransactionsQuery)) *KeyQuery { + query := (&TransactionsClient{config: kq.config}).Query() + for _, opt := range opts { + opt(query) + } + kq.withSigned = query + return kq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// PublicKey string `json:"publicKey,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Key.Query(). +// GroupBy(key.FieldPublicKey). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (kq *KeyQuery) GroupBy(field string, fields ...string) *KeyGroupBy { + kq.ctx.Fields = append([]string{field}, fields...) + grbuild := &KeyGroupBy{build: kq} + grbuild.flds = &kq.ctx.Fields + grbuild.label = key.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// PublicKey string `json:"publicKey,omitempty"` +// } +// +// client.Key.Query(). +// Select(key.FieldPublicKey). +// Scan(ctx, &v) +func (kq *KeyQuery) Select(fields ...string) *KeySelect { + kq.ctx.Fields = append(kq.ctx.Fields, fields...) + sbuild := &KeySelect{KeyQuery: kq} + sbuild.label = key.Label + sbuild.flds, sbuild.scan = &kq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a KeySelect configured with the given aggregations. +func (kq *KeyQuery) Aggregate(fns ...AggregateFunc) *KeySelect { + return kq.Select().Aggregate(fns...) +} + +func (kq *KeyQuery) prepareQuery(ctx context.Context) error { + for _, inter := range kq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, kq); err != nil { + return err + } + } + } + for _, f := range kq.ctx.Fields { + if !key.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if kq.path != nil { + prev, err := kq.path(ctx) + if err != nil { + return err + } + kq.sql = prev + } + return nil +} + +func (kq *KeyQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Key, error) { + var ( + nodes = []*Key{} + withFKs = kq.withFKs + _spec = kq.querySpec() + loadedTypes = [1]bool{ + kq.withSigned != nil, + } + ) + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, key.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Key).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Key{config: kq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, kq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := kq.withSigned; query != nil { + if err := kq.loadSigned(ctx, query, nodes, + func(n *Key) { n.Edges.Signed = []*Transactions{} }, + func(n *Key, e *Transactions) { n.Edges.Signed = append(n.Edges.Signed, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (kq *KeyQuery) loadSigned(ctx context.Context, query *TransactionsQuery, nodes []*Key, init func(*Key), assign func(*Key, *Transactions)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[int]*Key) + nids := make(map[int]map[*Key]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(key.SignedTable) + s.Join(joinT).On(s.C(transactions.FieldID), joinT.C(key.SignedPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(key.SignedPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(key.SignedPrimaryKey[0])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullInt64)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := int(values[0].(*sql.NullInt64).Int64) + inValue := int(values[1].(*sql.NullInt64).Int64) + if nids[inValue] == nil { + nids[inValue] = map[*Key]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Transactions](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "Signed" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} + +func (kq *KeyQuery) sqlCount(ctx context.Context) (int, error) { + _spec := kq.querySpec() + _spec.Node.Columns = kq.ctx.Fields + if len(kq.ctx.Fields) > 0 { + _spec.Unique = kq.ctx.Unique != nil && *kq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, kq.driver, _spec) +} + +func (kq *KeyQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(key.Table, key.Columns, sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt)) + _spec.From = kq.sql + if unique := kq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if kq.path != nil { + _spec.Unique = true + } + if fields := kq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, key.FieldID) + for i := range fields { + if fields[i] != key.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := kq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := kq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := kq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := kq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (kq *KeyQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(kq.driver.Dialect()) + t1 := builder.Table(key.Table) + columns := kq.ctx.Fields + if len(columns) == 0 { + columns = key.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if kq.sql != nil { + selector = kq.sql + selector.Select(selector.Columns(columns...)...) + } + if kq.ctx.Unique != nil && *kq.ctx.Unique { + selector.Distinct() + } + for _, p := range kq.predicates { + p(selector) + } + for _, p := range kq.order { + p(selector) + } + if offset := kq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := kq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// KeyGroupBy is the group-by builder for Key entities. +type KeyGroupBy struct { + selector + build *KeyQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (kgb *KeyGroupBy) Aggregate(fns ...AggregateFunc) *KeyGroupBy { + kgb.fns = append(kgb.fns, fns...) + return kgb +} + +// Scan applies the selector query and scans the result into the given value. +func (kgb *KeyGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, kgb.build.ctx, "GroupBy") + if err := kgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*KeyQuery, *KeyGroupBy](ctx, kgb.build, kgb, kgb.build.inters, v) +} + +func (kgb *KeyGroupBy) sqlScan(ctx context.Context, root *KeyQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(kgb.fns)) + for _, fn := range kgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*kgb.flds)+len(kgb.fns)) + for _, f := range *kgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*kgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := kgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// KeySelect is the builder for selecting fields of Key entities. +type KeySelect struct { + *KeyQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (ks *KeySelect) Aggregate(fns ...AggregateFunc) *KeySelect { + ks.fns = append(ks.fns, fns...) + return ks +} + +// Scan applies the selector query and scans the result into the given value. +func (ks *KeySelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ks.ctx, "Select") + if err := ks.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*KeyQuery, *KeySelect](ctx, ks.KeyQuery, ks, ks.inters, v) +} + +func (ks *KeySelect) sqlScan(ctx context.Context, root *KeyQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(ks.fns)) + for _, fn := range ks.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*ks.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ks.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/z2/backend/ent/key_update.go b/z2/backend/ent/key_update.go new file mode 100644 index 0000000..934ee5f --- /dev/null +++ b/z2/backend/ent/key_update.go @@ -0,0 +1,496 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "thesis/ent/key" + "thesis/ent/predicate" + "thesis/ent/transactions" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// KeyUpdate is the builder for updating Key entities. +type KeyUpdate struct { + config + hooks []Hook + mutation *KeyMutation +} + +// Where appends a list predicates to the KeyUpdate builder. +func (ku *KeyUpdate) Where(ps ...predicate.Key) *KeyUpdate { + ku.mutation.Where(ps...) + return ku +} + +// SetPublicKey sets the "publicKey" field. +func (ku *KeyUpdate) SetPublicKey(s string) *KeyUpdate { + ku.mutation.SetPublicKey(s) + return ku +} + +// SetNillablePublicKey sets the "publicKey" field if the given value is not nil. +func (ku *KeyUpdate) SetNillablePublicKey(s *string) *KeyUpdate { + if s != nil { + ku.SetPublicKey(*s) + } + return ku +} + +// SetOwner sets the "Owner" field. +func (ku *KeyUpdate) SetOwner(s string) *KeyUpdate { + ku.mutation.SetOwner(s) + return ku +} + +// SetNillableOwner sets the "Owner" field if the given value is not nil. +func (ku *KeyUpdate) SetNillableOwner(s *string) *KeyUpdate { + if s != nil { + ku.SetOwner(*s) + } + return ku +} + +// SetTrustScore sets the "trustScore" field. +func (ku *KeyUpdate) SetTrustScore(f float64) *KeyUpdate { + ku.mutation.ResetTrustScore() + ku.mutation.SetTrustScore(f) + return ku +} + +// SetNillableTrustScore sets the "trustScore" field if the given value is not nil. +func (ku *KeyUpdate) SetNillableTrustScore(f *float64) *KeyUpdate { + if f != nil { + ku.SetTrustScore(*f) + } + return ku +} + +// AddTrustScore adds f to the "trustScore" field. +func (ku *KeyUpdate) AddTrustScore(f float64) *KeyUpdate { + ku.mutation.AddTrustScore(f) + return ku +} + +// AddSignedIDs adds the "Signed" edge to the Transactions entity by IDs. +func (ku *KeyUpdate) AddSignedIDs(ids ...int) *KeyUpdate { + ku.mutation.AddSignedIDs(ids...) + return ku +} + +// AddSigned adds the "Signed" edges to the Transactions entity. +func (ku *KeyUpdate) AddSigned(t ...*Transactions) *KeyUpdate { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return ku.AddSignedIDs(ids...) +} + +// Mutation returns the KeyMutation object of the builder. +func (ku *KeyUpdate) Mutation() *KeyMutation { + return ku.mutation +} + +// ClearSigned clears all "Signed" edges to the Transactions entity. +func (ku *KeyUpdate) ClearSigned() *KeyUpdate { + ku.mutation.ClearSigned() + return ku +} + +// RemoveSignedIDs removes the "Signed" edge to Transactions entities by IDs. +func (ku *KeyUpdate) RemoveSignedIDs(ids ...int) *KeyUpdate { + ku.mutation.RemoveSignedIDs(ids...) + return ku +} + +// RemoveSigned removes "Signed" edges to Transactions entities. +func (ku *KeyUpdate) RemoveSigned(t ...*Transactions) *KeyUpdate { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return ku.RemoveSignedIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (ku *KeyUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, ku.sqlSave, ku.mutation, ku.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (ku *KeyUpdate) SaveX(ctx context.Context) int { + affected, err := ku.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (ku *KeyUpdate) Exec(ctx context.Context) error { + _, err := ku.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ku *KeyUpdate) ExecX(ctx context.Context) { + if err := ku.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (ku *KeyUpdate) check() error { + if v, ok := ku.mutation.PublicKey(); ok { + if err := key.PublicKeyValidator(v); err != nil { + return &ValidationError{Name: "publicKey", err: fmt.Errorf(`ent: validator failed for field "Key.publicKey": %w`, err)} + } + } + if v, ok := ku.mutation.Owner(); ok { + if err := key.OwnerValidator(v); err != nil { + return &ValidationError{Name: "Owner", err: fmt.Errorf(`ent: validator failed for field "Key.Owner": %w`, err)} + } + } + return nil +} + +func (ku *KeyUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := ku.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(key.Table, key.Columns, sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt)) + if ps := ku.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := ku.mutation.PublicKey(); ok { + _spec.SetField(key.FieldPublicKey, field.TypeString, value) + } + if value, ok := ku.mutation.Owner(); ok { + _spec.SetField(key.FieldOwner, field.TypeString, value) + } + if value, ok := ku.mutation.TrustScore(); ok { + _spec.SetField(key.FieldTrustScore, field.TypeFloat64, value) + } + if value, ok := ku.mutation.AddedTrustScore(); ok { + _spec.AddField(key.FieldTrustScore, field.TypeFloat64, value) + } + if ku.mutation.SignedCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: key.SignedTable, + Columns: key.SignedPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ku.mutation.RemovedSignedIDs(); len(nodes) > 0 && !ku.mutation.SignedCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: key.SignedTable, + Columns: key.SignedPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := ku.mutation.SignedIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: key.SignedTable, + Columns: key.SignedPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, ku.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{key.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + ku.mutation.done = true + return n, nil +} + +// KeyUpdateOne is the builder for updating a single Key entity. +type KeyUpdateOne struct { + config + fields []string + hooks []Hook + mutation *KeyMutation +} + +// SetPublicKey sets the "publicKey" field. +func (kuo *KeyUpdateOne) SetPublicKey(s string) *KeyUpdateOne { + kuo.mutation.SetPublicKey(s) + return kuo +} + +// SetNillablePublicKey sets the "publicKey" field if the given value is not nil. +func (kuo *KeyUpdateOne) SetNillablePublicKey(s *string) *KeyUpdateOne { + if s != nil { + kuo.SetPublicKey(*s) + } + return kuo +} + +// SetOwner sets the "Owner" field. +func (kuo *KeyUpdateOne) SetOwner(s string) *KeyUpdateOne { + kuo.mutation.SetOwner(s) + return kuo +} + +// SetNillableOwner sets the "Owner" field if the given value is not nil. +func (kuo *KeyUpdateOne) SetNillableOwner(s *string) *KeyUpdateOne { + if s != nil { + kuo.SetOwner(*s) + } + return kuo +} + +// SetTrustScore sets the "trustScore" field. +func (kuo *KeyUpdateOne) SetTrustScore(f float64) *KeyUpdateOne { + kuo.mutation.ResetTrustScore() + kuo.mutation.SetTrustScore(f) + return kuo +} + +// SetNillableTrustScore sets the "trustScore" field if the given value is not nil. +func (kuo *KeyUpdateOne) SetNillableTrustScore(f *float64) *KeyUpdateOne { + if f != nil { + kuo.SetTrustScore(*f) + } + return kuo +} + +// AddTrustScore adds f to the "trustScore" field. +func (kuo *KeyUpdateOne) AddTrustScore(f float64) *KeyUpdateOne { + kuo.mutation.AddTrustScore(f) + return kuo +} + +// AddSignedIDs adds the "Signed" edge to the Transactions entity by IDs. +func (kuo *KeyUpdateOne) AddSignedIDs(ids ...int) *KeyUpdateOne { + kuo.mutation.AddSignedIDs(ids...) + return kuo +} + +// AddSigned adds the "Signed" edges to the Transactions entity. +func (kuo *KeyUpdateOne) AddSigned(t ...*Transactions) *KeyUpdateOne { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return kuo.AddSignedIDs(ids...) +} + +// Mutation returns the KeyMutation object of the builder. +func (kuo *KeyUpdateOne) Mutation() *KeyMutation { + return kuo.mutation +} + +// ClearSigned clears all "Signed" edges to the Transactions entity. +func (kuo *KeyUpdateOne) ClearSigned() *KeyUpdateOne { + kuo.mutation.ClearSigned() + return kuo +} + +// RemoveSignedIDs removes the "Signed" edge to Transactions entities by IDs. +func (kuo *KeyUpdateOne) RemoveSignedIDs(ids ...int) *KeyUpdateOne { + kuo.mutation.RemoveSignedIDs(ids...) + return kuo +} + +// RemoveSigned removes "Signed" edges to Transactions entities. +func (kuo *KeyUpdateOne) RemoveSigned(t ...*Transactions) *KeyUpdateOne { + ids := make([]int, len(t)) + for i := range t { + ids[i] = t[i].ID + } + return kuo.RemoveSignedIDs(ids...) +} + +// Where appends a list predicates to the KeyUpdate builder. +func (kuo *KeyUpdateOne) Where(ps ...predicate.Key) *KeyUpdateOne { + kuo.mutation.Where(ps...) + return kuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (kuo *KeyUpdateOne) Select(field string, fields ...string) *KeyUpdateOne { + kuo.fields = append([]string{field}, fields...) + return kuo +} + +// Save executes the query and returns the updated Key entity. +func (kuo *KeyUpdateOne) Save(ctx context.Context) (*Key, error) { + return withHooks(ctx, kuo.sqlSave, kuo.mutation, kuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (kuo *KeyUpdateOne) SaveX(ctx context.Context) *Key { + node, err := kuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (kuo *KeyUpdateOne) Exec(ctx context.Context) error { + _, err := kuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (kuo *KeyUpdateOne) ExecX(ctx context.Context) { + if err := kuo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (kuo *KeyUpdateOne) check() error { + if v, ok := kuo.mutation.PublicKey(); ok { + if err := key.PublicKeyValidator(v); err != nil { + return &ValidationError{Name: "publicKey", err: fmt.Errorf(`ent: validator failed for field "Key.publicKey": %w`, err)} + } + } + if v, ok := kuo.mutation.Owner(); ok { + if err := key.OwnerValidator(v); err != nil { + return &ValidationError{Name: "Owner", err: fmt.Errorf(`ent: validator failed for field "Key.Owner": %w`, err)} + } + } + return nil +} + +func (kuo *KeyUpdateOne) sqlSave(ctx context.Context) (_node *Key, err error) { + if err := kuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(key.Table, key.Columns, sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt)) + id, ok := kuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Key.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := kuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, key.FieldID) + for _, f := range fields { + if !key.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != key.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := kuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := kuo.mutation.PublicKey(); ok { + _spec.SetField(key.FieldPublicKey, field.TypeString, value) + } + if value, ok := kuo.mutation.Owner(); ok { + _spec.SetField(key.FieldOwner, field.TypeString, value) + } + if value, ok := kuo.mutation.TrustScore(); ok { + _spec.SetField(key.FieldTrustScore, field.TypeFloat64, value) + } + if value, ok := kuo.mutation.AddedTrustScore(); ok { + _spec.AddField(key.FieldTrustScore, field.TypeFloat64, value) + } + if kuo.mutation.SignedCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: key.SignedTable, + Columns: key.SignedPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := kuo.mutation.RemovedSignedIDs(); len(nodes) > 0 && !kuo.mutation.SignedCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: key.SignedTable, + Columns: key.SignedPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := kuo.mutation.SignedIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: key.SignedTable, + Columns: key.SignedPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &Key{config: kuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, kuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{key.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + kuo.mutation.done = true + return _node, nil +} diff --git a/z2/backend/ent/migrate/migrate.go b/z2/backend/ent/migrate/migrate.go new file mode 100644 index 0000000..1956a6b --- /dev/null +++ b/z2/backend/ent/migrate/migrate.go @@ -0,0 +1,64 @@ +// Code generated by ent, DO NOT EDIT. + +package migrate + +import ( + "context" + "fmt" + "io" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql/schema" +) + +var ( + // WithGlobalUniqueID sets the universal ids options to the migration. + // If this option is enabled, ent migration will allocate a 1<<32 range + // for the ids of each entity (table). + // Note that this option cannot be applied on tables that already exist. + WithGlobalUniqueID = schema.WithGlobalUniqueID + // WithDropColumn sets the drop column option to the migration. + // If this option is enabled, ent migration will drop old columns + // that were used for both fields and edges. This defaults to false. + WithDropColumn = schema.WithDropColumn + // WithDropIndex sets the drop index option to the migration. + // If this option is enabled, ent migration will drop old indexes + // that were defined in the schema. This defaults to false. + // Note that unique constraints are defined using `UNIQUE INDEX`, + // and therefore, it's recommended to enable this option to get more + // flexibility in the schema changes. + WithDropIndex = schema.WithDropIndex + // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. + WithForeignKeys = schema.WithForeignKeys +) + +// Schema is the API for creating, migrating and dropping a schema. +type Schema struct { + drv dialect.Driver +} + +// NewSchema creates a new schema client. +func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} } + +// Create creates all schema resources. +func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error { + return Create(ctx, s, Tables, opts...) +} + +// Create creates all table resources using the given schema driver. +func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error { + migrate, err := schema.NewMigrate(s.drv, opts...) + if err != nil { + return fmt.Errorf("ent/migrate: %w", err) + } + return migrate.Create(ctx, tables...) +} + +// WriteTo writes the schema changes to w instead of running them against the database. +// +// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil { +// log.Fatal(err) +// } +func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error { + return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...) +} diff --git a/z2/backend/ent/migrate/schema.go b/z2/backend/ent/migrate/schema.go new file mode 100644 index 0000000..fc04f44 --- /dev/null +++ b/z2/backend/ent/migrate/schema.go @@ -0,0 +1,177 @@ +// Code generated by ent, DO NOT EDIT. + +package migrate + +import ( + "entgo.io/ent/dialect/sql/schema" + "entgo.io/ent/schema/field" +) + +var ( + // BlocksColumns holds the columns for the "blocks" table. + BlocksColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "hash", Type: field.TypeString, Unique: true}, + {Name: "length", Type: field.TypeInt}, + {Name: "previous_hash", Type: field.TypeString, Unique: true}, + } + // BlocksTable holds the schema information for the "blocks" table. + BlocksTable = &schema.Table{ + Name: "blocks", + Columns: BlocksColumns, + PrimaryKey: []*schema.Column{BlocksColumns[0]}, + } + // KeysColumns holds the columns for the "keys" table. + KeysColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "public_key", Type: field.TypeString, Unique: true}, + {Name: "owner", Type: field.TypeString}, + {Name: "trust_score", Type: field.TypeFloat64, Default: 0.2}, + {Name: "validators_key", Type: field.TypeInt, Nullable: true}, + {Name: "white_list_account", Type: field.TypeInt, Nullable: true}, + } + // KeysTable holds the schema information for the "keys" table. + KeysTable = &schema.Table{ + Name: "keys", + Columns: KeysColumns, + PrimaryKey: []*schema.Column{KeysColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "keys_validators_key", + Columns: []*schema.Column{KeysColumns[4]}, + RefColumns: []*schema.Column{ValidatorsColumns[0]}, + OnDelete: schema.SetNull, + }, + { + Symbol: "keys_white_lists_Account", + Columns: []*schema.Column{KeysColumns[5]}, + RefColumns: []*schema.Column{WhiteListsColumns[0]}, + OnDelete: schema.SetNull, + }, + }, + } + // TransactionsColumns holds the columns for the "transactions" table. + TransactionsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "type", Type: field.TypeInt}, + {Name: "timestamp", Type: field.TypeInt}, + {Name: "comment", Type: field.TypeString}, + {Name: "content", Type: field.TypeBytes}, + {Name: "hash", Type: field.TypeString, Unique: true}, + {Name: "signature", Type: field.TypeString, Unique: true}, + } + // TransactionsTable holds the schema information for the "transactions" table. + TransactionsTable = &schema.Table{ + Name: "transactions", + Columns: TransactionsColumns, + PrimaryKey: []*schema.Column{TransactionsColumns[0]}, + } + // ValidatorsColumns holds the columns for the "validators" table. + ValidatorsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "facilitator", Type: field.TypeString}, + {Name: "blocks_caster", Type: field.TypeInt, Nullable: true}, + {Name: "white_list_sponsor", Type: field.TypeInt, Nullable: true}, + } + // ValidatorsTable holds the schema information for the "validators" table. + ValidatorsTable = &schema.Table{ + Name: "validators", + Columns: ValidatorsColumns, + PrimaryKey: []*schema.Column{ValidatorsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "validators_blocks_Caster", + Columns: []*schema.Column{ValidatorsColumns[2]}, + RefColumns: []*schema.Column{BlocksColumns[0]}, + OnDelete: schema.SetNull, + }, + { + Symbol: "validators_white_lists_Sponsor", + Columns: []*schema.Column{ValidatorsColumns[3]}, + RefColumns: []*schema.Column{WhiteListsColumns[0]}, + OnDelete: schema.SetNull, + }, + }, + } + // WhiteListsColumns holds the columns for the "white_lists" table. + WhiteListsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + } + // WhiteListsTable holds the schema information for the "white_lists" table. + WhiteListsTable = &schema.Table{ + Name: "white_lists", + Columns: WhiteListsColumns, + PrimaryKey: []*schema.Column{WhiteListsColumns[0]}, + } + // BlocksMinedTxsColumns holds the columns for the "blocks_MinedTxs" table. + BlocksMinedTxsColumns = []*schema.Column{ + {Name: "blocks_id", Type: field.TypeInt}, + {Name: "transactions_id", Type: field.TypeInt}, + } + // BlocksMinedTxsTable holds the schema information for the "blocks_MinedTxs" table. + BlocksMinedTxsTable = &schema.Table{ + Name: "blocks_MinedTxs", + Columns: BlocksMinedTxsColumns, + PrimaryKey: []*schema.Column{BlocksMinedTxsColumns[0], BlocksMinedTxsColumns[1]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "blocks_MinedTxs_blocks_id", + Columns: []*schema.Column{BlocksMinedTxsColumns[0]}, + RefColumns: []*schema.Column{BlocksColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "blocks_MinedTxs_transactions_id", + Columns: []*schema.Column{BlocksMinedTxsColumns[1]}, + RefColumns: []*schema.Column{TransactionsColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } + // KeySignedColumns holds the columns for the "key_Signed" table. + KeySignedColumns = []*schema.Column{ + {Name: "key_id", Type: field.TypeInt}, + {Name: "transactions_id", Type: field.TypeInt}, + } + // KeySignedTable holds the schema information for the "key_Signed" table. + KeySignedTable = &schema.Table{ + Name: "key_Signed", + Columns: KeySignedColumns, + PrimaryKey: []*schema.Column{KeySignedColumns[0], KeySignedColumns[1]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "key_Signed_key_id", + Columns: []*schema.Column{KeySignedColumns[0]}, + RefColumns: []*schema.Column{KeysColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "key_Signed_transactions_id", + Columns: []*schema.Column{KeySignedColumns[1]}, + RefColumns: []*schema.Column{TransactionsColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } + // Tables holds all the tables in the schema. + Tables = []*schema.Table{ + BlocksTable, + KeysTable, + TransactionsTable, + ValidatorsTable, + WhiteListsTable, + BlocksMinedTxsTable, + KeySignedTable, + } +) + +func init() { + KeysTable.ForeignKeys[0].RefTable = ValidatorsTable + KeysTable.ForeignKeys[1].RefTable = WhiteListsTable + ValidatorsTable.ForeignKeys[0].RefTable = BlocksTable + ValidatorsTable.ForeignKeys[1].RefTable = WhiteListsTable + BlocksMinedTxsTable.ForeignKeys[0].RefTable = BlocksTable + BlocksMinedTxsTable.ForeignKeys[1].RefTable = TransactionsTable + KeySignedTable.ForeignKeys[0].RefTable = KeysTable + KeySignedTable.ForeignKeys[1].RefTable = TransactionsTable +} diff --git a/z2/backend/ent/mutation.go b/z2/backend/ent/mutation.go new file mode 100644 index 0000000..9b2a256 --- /dev/null +++ b/z2/backend/ent/mutation.go @@ -0,0 +1,2950 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "sync" + "thesis/ent/blocks" + "thesis/ent/key" + "thesis/ent/predicate" + "thesis/ent/transactions" + "thesis/ent/validators" + "thesis/ent/whitelist" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +const ( + // Operation types. + OpCreate = ent.OpCreate + OpDelete = ent.OpDelete + OpDeleteOne = ent.OpDeleteOne + OpUpdate = ent.OpUpdate + OpUpdateOne = ent.OpUpdateOne + + // Node types. + TypeBlocks = "Blocks" + TypeKey = "Key" + TypeTransactions = "Transactions" + TypeValidators = "Validators" + TypeWhiteList = "WhiteList" +) + +// BlocksMutation represents an operation that mutates the Blocks nodes in the graph. +type BlocksMutation struct { + config + op Op + typ string + id *int + hash *string + length *int + addlength *int + previousHash *string + clearedFields map[string]struct{} + _Caster map[int]struct{} + removed_Caster map[int]struct{} + cleared_Caster bool + _MinedTxs map[int]struct{} + removed_MinedTxs map[int]struct{} + cleared_MinedTxs bool + done bool + oldValue func(context.Context) (*Blocks, error) + predicates []predicate.Blocks +} + +var _ ent.Mutation = (*BlocksMutation)(nil) + +// blocksOption allows management of the mutation configuration using functional options. +type blocksOption func(*BlocksMutation) + +// newBlocksMutation creates new mutation for the Blocks entity. +func newBlocksMutation(c config, op Op, opts ...blocksOption) *BlocksMutation { + m := &BlocksMutation{ + config: c, + op: op, + typ: TypeBlocks, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withBlocksID sets the ID field of the mutation. +func withBlocksID(id int) blocksOption { + return func(m *BlocksMutation) { + var ( + err error + once sync.Once + value *Blocks + ) + m.oldValue = func(ctx context.Context) (*Blocks, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Blocks.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withBlocks sets the old Blocks of the mutation. +func withBlocks(node *Blocks) blocksOption { + return func(m *BlocksMutation) { + m.oldValue = func(context.Context) (*Blocks, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m BlocksMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m BlocksMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Blocks entities. +func (m *BlocksMutation) SetID(id int) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *BlocksMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *BlocksMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Blocks.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetHash sets the "hash" field. +func (m *BlocksMutation) SetHash(s string) { + m.hash = &s +} + +// Hash returns the value of the "hash" field in the mutation. +func (m *BlocksMutation) Hash() (r string, exists bool) { + v := m.hash + if v == nil { + return + } + return *v, true +} + +// OldHash returns the old "hash" field's value of the Blocks entity. +// If the Blocks object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BlocksMutation) OldHash(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHash is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHash requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHash: %w", err) + } + return oldValue.Hash, nil +} + +// ResetHash resets all changes to the "hash" field. +func (m *BlocksMutation) ResetHash() { + m.hash = nil +} + +// SetLength sets the "length" field. +func (m *BlocksMutation) SetLength(i int) { + m.length = &i + m.addlength = nil +} + +// Length returns the value of the "length" field in the mutation. +func (m *BlocksMutation) Length() (r int, exists bool) { + v := m.length + if v == nil { + return + } + return *v, true +} + +// OldLength returns the old "length" field's value of the Blocks entity. +// If the Blocks object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BlocksMutation) OldLength(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLength is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLength requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLength: %w", err) + } + return oldValue.Length, nil +} + +// AddLength adds i to the "length" field. +func (m *BlocksMutation) AddLength(i int) { + if m.addlength != nil { + *m.addlength += i + } else { + m.addlength = &i + } +} + +// AddedLength returns the value that was added to the "length" field in this mutation. +func (m *BlocksMutation) AddedLength() (r int, exists bool) { + v := m.addlength + if v == nil { + return + } + return *v, true +} + +// ResetLength resets all changes to the "length" field. +func (m *BlocksMutation) ResetLength() { + m.length = nil + m.addlength = nil +} + +// SetPreviousHash sets the "previousHash" field. +func (m *BlocksMutation) SetPreviousHash(s string) { + m.previousHash = &s +} + +// PreviousHash returns the value of the "previousHash" field in the mutation. +func (m *BlocksMutation) PreviousHash() (r string, exists bool) { + v := m.previousHash + if v == nil { + return + } + return *v, true +} + +// OldPreviousHash returns the old "previousHash" field's value of the Blocks entity. +// If the Blocks object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BlocksMutation) OldPreviousHash(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPreviousHash is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPreviousHash requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPreviousHash: %w", err) + } + return oldValue.PreviousHash, nil +} + +// ResetPreviousHash resets all changes to the "previousHash" field. +func (m *BlocksMutation) ResetPreviousHash() { + m.previousHash = nil +} + +// AddCasterIDs adds the "Caster" edge to the Validators entity by ids. +func (m *BlocksMutation) AddCasterIDs(ids ...int) { + if m._Caster == nil { + m._Caster = make(map[int]struct{}) + } + for i := range ids { + m._Caster[ids[i]] = struct{}{} + } +} + +// ClearCaster clears the "Caster" edge to the Validators entity. +func (m *BlocksMutation) ClearCaster() { + m.cleared_Caster = true +} + +// CasterCleared reports if the "Caster" edge to the Validators entity was cleared. +func (m *BlocksMutation) CasterCleared() bool { + return m.cleared_Caster +} + +// RemoveCasterIDs removes the "Caster" edge to the Validators entity by IDs. +func (m *BlocksMutation) RemoveCasterIDs(ids ...int) { + if m.removed_Caster == nil { + m.removed_Caster = make(map[int]struct{}) + } + for i := range ids { + delete(m._Caster, ids[i]) + m.removed_Caster[ids[i]] = struct{}{} + } +} + +// RemovedCaster returns the removed IDs of the "Caster" edge to the Validators entity. +func (m *BlocksMutation) RemovedCasterIDs() (ids []int) { + for id := range m.removed_Caster { + ids = append(ids, id) + } + return +} + +// CasterIDs returns the "Caster" edge IDs in the mutation. +func (m *BlocksMutation) CasterIDs() (ids []int) { + for id := range m._Caster { + ids = append(ids, id) + } + return +} + +// ResetCaster resets all changes to the "Caster" edge. +func (m *BlocksMutation) ResetCaster() { + m._Caster = nil + m.cleared_Caster = false + m.removed_Caster = nil +} + +// AddMinedTxIDs adds the "MinedTxs" edge to the Transactions entity by ids. +func (m *BlocksMutation) AddMinedTxIDs(ids ...int) { + if m._MinedTxs == nil { + m._MinedTxs = make(map[int]struct{}) + } + for i := range ids { + m._MinedTxs[ids[i]] = struct{}{} + } +} + +// ClearMinedTxs clears the "MinedTxs" edge to the Transactions entity. +func (m *BlocksMutation) ClearMinedTxs() { + m.cleared_MinedTxs = true +} + +// MinedTxsCleared reports if the "MinedTxs" edge to the Transactions entity was cleared. +func (m *BlocksMutation) MinedTxsCleared() bool { + return m.cleared_MinedTxs +} + +// RemoveMinedTxIDs removes the "MinedTxs" edge to the Transactions entity by IDs. +func (m *BlocksMutation) RemoveMinedTxIDs(ids ...int) { + if m.removed_MinedTxs == nil { + m.removed_MinedTxs = make(map[int]struct{}) + } + for i := range ids { + delete(m._MinedTxs, ids[i]) + m.removed_MinedTxs[ids[i]] = struct{}{} + } +} + +// RemovedMinedTxs returns the removed IDs of the "MinedTxs" edge to the Transactions entity. +func (m *BlocksMutation) RemovedMinedTxsIDs() (ids []int) { + for id := range m.removed_MinedTxs { + ids = append(ids, id) + } + return +} + +// MinedTxsIDs returns the "MinedTxs" edge IDs in the mutation. +func (m *BlocksMutation) MinedTxsIDs() (ids []int) { + for id := range m._MinedTxs { + ids = append(ids, id) + } + return +} + +// ResetMinedTxs resets all changes to the "MinedTxs" edge. +func (m *BlocksMutation) ResetMinedTxs() { + m._MinedTxs = nil + m.cleared_MinedTxs = false + m.removed_MinedTxs = nil +} + +// Where appends a list predicates to the BlocksMutation builder. +func (m *BlocksMutation) Where(ps ...predicate.Blocks) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the BlocksMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *BlocksMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Blocks, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *BlocksMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *BlocksMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Blocks). +func (m *BlocksMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *BlocksMutation) Fields() []string { + fields := make([]string, 0, 3) + if m.hash != nil { + fields = append(fields, blocks.FieldHash) + } + if m.length != nil { + fields = append(fields, blocks.FieldLength) + } + if m.previousHash != nil { + fields = append(fields, blocks.FieldPreviousHash) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *BlocksMutation) Field(name string) (ent.Value, bool) { + switch name { + case blocks.FieldHash: + return m.Hash() + case blocks.FieldLength: + return m.Length() + case blocks.FieldPreviousHash: + return m.PreviousHash() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *BlocksMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case blocks.FieldHash: + return m.OldHash(ctx) + case blocks.FieldLength: + return m.OldLength(ctx) + case blocks.FieldPreviousHash: + return m.OldPreviousHash(ctx) + } + return nil, fmt.Errorf("unknown Blocks field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *BlocksMutation) SetField(name string, value ent.Value) error { + switch name { + case blocks.FieldHash: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHash(v) + return nil + case blocks.FieldLength: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLength(v) + return nil + case blocks.FieldPreviousHash: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPreviousHash(v) + return nil + } + return fmt.Errorf("unknown Blocks field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *BlocksMutation) AddedFields() []string { + var fields []string + if m.addlength != nil { + fields = append(fields, blocks.FieldLength) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *BlocksMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case blocks.FieldLength: + return m.AddedLength() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *BlocksMutation) AddField(name string, value ent.Value) error { + switch name { + case blocks.FieldLength: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddLength(v) + return nil + } + return fmt.Errorf("unknown Blocks numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *BlocksMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *BlocksMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *BlocksMutation) ClearField(name string) error { + return fmt.Errorf("unknown Blocks nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *BlocksMutation) ResetField(name string) error { + switch name { + case blocks.FieldHash: + m.ResetHash() + return nil + case blocks.FieldLength: + m.ResetLength() + return nil + case blocks.FieldPreviousHash: + m.ResetPreviousHash() + return nil + } + return fmt.Errorf("unknown Blocks field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *BlocksMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m._Caster != nil { + edges = append(edges, blocks.EdgeCaster) + } + if m._MinedTxs != nil { + edges = append(edges, blocks.EdgeMinedTxs) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *BlocksMutation) AddedIDs(name string) []ent.Value { + switch name { + case blocks.EdgeCaster: + ids := make([]ent.Value, 0, len(m._Caster)) + for id := range m._Caster { + ids = append(ids, id) + } + return ids + case blocks.EdgeMinedTxs: + ids := make([]ent.Value, 0, len(m._MinedTxs)) + for id := range m._MinedTxs { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *BlocksMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removed_Caster != nil { + edges = append(edges, blocks.EdgeCaster) + } + if m.removed_MinedTxs != nil { + edges = append(edges, blocks.EdgeMinedTxs) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *BlocksMutation) RemovedIDs(name string) []ent.Value { + switch name { + case blocks.EdgeCaster: + ids := make([]ent.Value, 0, len(m.removed_Caster)) + for id := range m.removed_Caster { + ids = append(ids, id) + } + return ids + case blocks.EdgeMinedTxs: + ids := make([]ent.Value, 0, len(m.removed_MinedTxs)) + for id := range m.removed_MinedTxs { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *BlocksMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.cleared_Caster { + edges = append(edges, blocks.EdgeCaster) + } + if m.cleared_MinedTxs { + edges = append(edges, blocks.EdgeMinedTxs) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *BlocksMutation) EdgeCleared(name string) bool { + switch name { + case blocks.EdgeCaster: + return m.cleared_Caster + case blocks.EdgeMinedTxs: + return m.cleared_MinedTxs + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *BlocksMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown Blocks unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *BlocksMutation) ResetEdge(name string) error { + switch name { + case blocks.EdgeCaster: + m.ResetCaster() + return nil + case blocks.EdgeMinedTxs: + m.ResetMinedTxs() + return nil + } + return fmt.Errorf("unknown Blocks edge %s", name) +} + +// KeyMutation represents an operation that mutates the Key nodes in the graph. +type KeyMutation struct { + config + op Op + typ string + id *int + publicKey *string + _Owner *string + trustScore *float64 + addtrustScore *float64 + clearedFields map[string]struct{} + _Signed map[int]struct{} + removed_Signed map[int]struct{} + cleared_Signed bool + done bool + oldValue func(context.Context) (*Key, error) + predicates []predicate.Key +} + +var _ ent.Mutation = (*KeyMutation)(nil) + +// keyOption allows management of the mutation configuration using functional options. +type keyOption func(*KeyMutation) + +// newKeyMutation creates new mutation for the Key entity. +func newKeyMutation(c config, op Op, opts ...keyOption) *KeyMutation { + m := &KeyMutation{ + config: c, + op: op, + typ: TypeKey, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withKeyID sets the ID field of the mutation. +func withKeyID(id int) keyOption { + return func(m *KeyMutation) { + var ( + err error + once sync.Once + value *Key + ) + m.oldValue = func(ctx context.Context) (*Key, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Key.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withKey sets the old Key of the mutation. +func withKey(node *Key) keyOption { + return func(m *KeyMutation) { + m.oldValue = func(context.Context) (*Key, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m KeyMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m KeyMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *KeyMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *KeyMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Key.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetPublicKey sets the "publicKey" field. +func (m *KeyMutation) SetPublicKey(s string) { + m.publicKey = &s +} + +// PublicKey returns the value of the "publicKey" field in the mutation. +func (m *KeyMutation) PublicKey() (r string, exists bool) { + v := m.publicKey + if v == nil { + return + } + return *v, true +} + +// OldPublicKey returns the old "publicKey" field's value of the Key entity. +// If the Key object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *KeyMutation) OldPublicKey(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPublicKey is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPublicKey requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPublicKey: %w", err) + } + return oldValue.PublicKey, nil +} + +// ResetPublicKey resets all changes to the "publicKey" field. +func (m *KeyMutation) ResetPublicKey() { + m.publicKey = nil +} + +// SetOwner sets the "Owner" field. +func (m *KeyMutation) SetOwner(s string) { + m._Owner = &s +} + +// Owner returns the value of the "Owner" field in the mutation. +func (m *KeyMutation) Owner() (r string, exists bool) { + v := m._Owner + if v == nil { + return + } + return *v, true +} + +// OldOwner returns the old "Owner" field's value of the Key entity. +// If the Key object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *KeyMutation) OldOwner(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOwner is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOwner requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOwner: %w", err) + } + return oldValue.Owner, nil +} + +// ResetOwner resets all changes to the "Owner" field. +func (m *KeyMutation) ResetOwner() { + m._Owner = nil +} + +// SetTrustScore sets the "trustScore" field. +func (m *KeyMutation) SetTrustScore(f float64) { + m.trustScore = &f + m.addtrustScore = nil +} + +// TrustScore returns the value of the "trustScore" field in the mutation. +func (m *KeyMutation) TrustScore() (r float64, exists bool) { + v := m.trustScore + if v == nil { + return + } + return *v, true +} + +// OldTrustScore returns the old "trustScore" field's value of the Key entity. +// If the Key object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *KeyMutation) OldTrustScore(ctx context.Context) (v float64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTrustScore is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTrustScore requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTrustScore: %w", err) + } + return oldValue.TrustScore, nil +} + +// AddTrustScore adds f to the "trustScore" field. +func (m *KeyMutation) AddTrustScore(f float64) { + if m.addtrustScore != nil { + *m.addtrustScore += f + } else { + m.addtrustScore = &f + } +} + +// AddedTrustScore returns the value that was added to the "trustScore" field in this mutation. +func (m *KeyMutation) AddedTrustScore() (r float64, exists bool) { + v := m.addtrustScore + if v == nil { + return + } + return *v, true +} + +// ResetTrustScore resets all changes to the "trustScore" field. +func (m *KeyMutation) ResetTrustScore() { + m.trustScore = nil + m.addtrustScore = nil +} + +// AddSignedIDs adds the "Signed" edge to the Transactions entity by ids. +func (m *KeyMutation) AddSignedIDs(ids ...int) { + if m._Signed == nil { + m._Signed = make(map[int]struct{}) + } + for i := range ids { + m._Signed[ids[i]] = struct{}{} + } +} + +// ClearSigned clears the "Signed" edge to the Transactions entity. +func (m *KeyMutation) ClearSigned() { + m.cleared_Signed = true +} + +// SignedCleared reports if the "Signed" edge to the Transactions entity was cleared. +func (m *KeyMutation) SignedCleared() bool { + return m.cleared_Signed +} + +// RemoveSignedIDs removes the "Signed" edge to the Transactions entity by IDs. +func (m *KeyMutation) RemoveSignedIDs(ids ...int) { + if m.removed_Signed == nil { + m.removed_Signed = make(map[int]struct{}) + } + for i := range ids { + delete(m._Signed, ids[i]) + m.removed_Signed[ids[i]] = struct{}{} + } +} + +// RemovedSigned returns the removed IDs of the "Signed" edge to the Transactions entity. +func (m *KeyMutation) RemovedSignedIDs() (ids []int) { + for id := range m.removed_Signed { + ids = append(ids, id) + } + return +} + +// SignedIDs returns the "Signed" edge IDs in the mutation. +func (m *KeyMutation) SignedIDs() (ids []int) { + for id := range m._Signed { + ids = append(ids, id) + } + return +} + +// ResetSigned resets all changes to the "Signed" edge. +func (m *KeyMutation) ResetSigned() { + m._Signed = nil + m.cleared_Signed = false + m.removed_Signed = nil +} + +// Where appends a list predicates to the KeyMutation builder. +func (m *KeyMutation) Where(ps ...predicate.Key) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the KeyMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *KeyMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Key, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *KeyMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *KeyMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Key). +func (m *KeyMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *KeyMutation) Fields() []string { + fields := make([]string, 0, 3) + if m.publicKey != nil { + fields = append(fields, key.FieldPublicKey) + } + if m._Owner != nil { + fields = append(fields, key.FieldOwner) + } + if m.trustScore != nil { + fields = append(fields, key.FieldTrustScore) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *KeyMutation) Field(name string) (ent.Value, bool) { + switch name { + case key.FieldPublicKey: + return m.PublicKey() + case key.FieldOwner: + return m.Owner() + case key.FieldTrustScore: + return m.TrustScore() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *KeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case key.FieldPublicKey: + return m.OldPublicKey(ctx) + case key.FieldOwner: + return m.OldOwner(ctx) + case key.FieldTrustScore: + return m.OldTrustScore(ctx) + } + return nil, fmt.Errorf("unknown Key field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *KeyMutation) SetField(name string, value ent.Value) error { + switch name { + case key.FieldPublicKey: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPublicKey(v) + return nil + case key.FieldOwner: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOwner(v) + return nil + case key.FieldTrustScore: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTrustScore(v) + return nil + } + return fmt.Errorf("unknown Key field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *KeyMutation) AddedFields() []string { + var fields []string + if m.addtrustScore != nil { + fields = append(fields, key.FieldTrustScore) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *KeyMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case key.FieldTrustScore: + return m.AddedTrustScore() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *KeyMutation) AddField(name string, value ent.Value) error { + switch name { + case key.FieldTrustScore: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTrustScore(v) + return nil + } + return fmt.Errorf("unknown Key numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *KeyMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *KeyMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *KeyMutation) ClearField(name string) error { + return fmt.Errorf("unknown Key nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *KeyMutation) ResetField(name string) error { + switch name { + case key.FieldPublicKey: + m.ResetPublicKey() + return nil + case key.FieldOwner: + m.ResetOwner() + return nil + case key.FieldTrustScore: + m.ResetTrustScore() + return nil + } + return fmt.Errorf("unknown Key field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *KeyMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m._Signed != nil { + edges = append(edges, key.EdgeSigned) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *KeyMutation) AddedIDs(name string) []ent.Value { + switch name { + case key.EdgeSigned: + ids := make([]ent.Value, 0, len(m._Signed)) + for id := range m._Signed { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *KeyMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + if m.removed_Signed != nil { + edges = append(edges, key.EdgeSigned) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *KeyMutation) RemovedIDs(name string) []ent.Value { + switch name { + case key.EdgeSigned: + ids := make([]ent.Value, 0, len(m.removed_Signed)) + for id := range m.removed_Signed { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *KeyMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.cleared_Signed { + edges = append(edges, key.EdgeSigned) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *KeyMutation) EdgeCleared(name string) bool { + switch name { + case key.EdgeSigned: + return m.cleared_Signed + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *KeyMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown Key unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *KeyMutation) ResetEdge(name string) error { + switch name { + case key.EdgeSigned: + m.ResetSigned() + return nil + } + return fmt.Errorf("unknown Key edge %s", name) +} + +// TransactionsMutation represents an operation that mutates the Transactions nodes in the graph. +type TransactionsMutation struct { + config + op Op + typ string + id *int + _type *int + add_type *int + timestamp *int + addtimestamp *int + comment *string + content *[]byte + hash *string + signature *string + clearedFields map[string]struct{} + _Signer map[int]struct{} + removed_Signer map[int]struct{} + cleared_Signer bool + _Block map[int]struct{} + removed_Block map[int]struct{} + cleared_Block bool + done bool + oldValue func(context.Context) (*Transactions, error) + predicates []predicate.Transactions +} + +var _ ent.Mutation = (*TransactionsMutation)(nil) + +// transactionsOption allows management of the mutation configuration using functional options. +type transactionsOption func(*TransactionsMutation) + +// newTransactionsMutation creates new mutation for the Transactions entity. +func newTransactionsMutation(c config, op Op, opts ...transactionsOption) *TransactionsMutation { + m := &TransactionsMutation{ + config: c, + op: op, + typ: TypeTransactions, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withTransactionsID sets the ID field of the mutation. +func withTransactionsID(id int) transactionsOption { + return func(m *TransactionsMutation) { + var ( + err error + once sync.Once + value *Transactions + ) + m.oldValue = func(ctx context.Context) (*Transactions, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Transactions.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withTransactions sets the old Transactions of the mutation. +func withTransactions(node *Transactions) transactionsOption { + return func(m *TransactionsMutation) { + m.oldValue = func(context.Context) (*Transactions, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m TransactionsMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m TransactionsMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *TransactionsMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *TransactionsMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Transactions.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetType sets the "type" field. +func (m *TransactionsMutation) SetType(i int) { + m._type = &i + m.add_type = nil +} + +// GetType returns the value of the "type" field in the mutation. +func (m *TransactionsMutation) GetType() (r int, exists bool) { + v := m._type + if v == nil { + return + } + return *v, true +} + +// OldType returns the old "type" field's value of the Transactions entity. +// If the Transactions object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TransactionsMutation) OldType(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldType: %w", err) + } + return oldValue.Type, nil +} + +// AddType adds i to the "type" field. +func (m *TransactionsMutation) AddType(i int) { + if m.add_type != nil { + *m.add_type += i + } else { + m.add_type = &i + } +} + +// AddedType returns the value that was added to the "type" field in this mutation. +func (m *TransactionsMutation) AddedType() (r int, exists bool) { + v := m.add_type + if v == nil { + return + } + return *v, true +} + +// ResetType resets all changes to the "type" field. +func (m *TransactionsMutation) ResetType() { + m._type = nil + m.add_type = nil +} + +// SetTimestamp sets the "timestamp" field. +func (m *TransactionsMutation) SetTimestamp(i int) { + m.timestamp = &i + m.addtimestamp = nil +} + +// Timestamp returns the value of the "timestamp" field in the mutation. +func (m *TransactionsMutation) Timestamp() (r int, exists bool) { + v := m.timestamp + if v == nil { + return + } + return *v, true +} + +// OldTimestamp returns the old "timestamp" field's value of the Transactions entity. +// If the Transactions object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TransactionsMutation) OldTimestamp(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTimestamp is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTimestamp requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTimestamp: %w", err) + } + return oldValue.Timestamp, nil +} + +// AddTimestamp adds i to the "timestamp" field. +func (m *TransactionsMutation) AddTimestamp(i int) { + if m.addtimestamp != nil { + *m.addtimestamp += i + } else { + m.addtimestamp = &i + } +} + +// AddedTimestamp returns the value that was added to the "timestamp" field in this mutation. +func (m *TransactionsMutation) AddedTimestamp() (r int, exists bool) { + v := m.addtimestamp + if v == nil { + return + } + return *v, true +} + +// ResetTimestamp resets all changes to the "timestamp" field. +func (m *TransactionsMutation) ResetTimestamp() { + m.timestamp = nil + m.addtimestamp = nil +} + +// SetComment sets the "comment" field. +func (m *TransactionsMutation) SetComment(s string) { + m.comment = &s +} + +// Comment returns the value of the "comment" field in the mutation. +func (m *TransactionsMutation) Comment() (r string, exists bool) { + v := m.comment + if v == nil { + return + } + return *v, true +} + +// OldComment returns the old "comment" field's value of the Transactions entity. +// If the Transactions object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TransactionsMutation) OldComment(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldComment is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldComment requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldComment: %w", err) + } + return oldValue.Comment, nil +} + +// ResetComment resets all changes to the "comment" field. +func (m *TransactionsMutation) ResetComment() { + m.comment = nil +} + +// SetContent sets the "content" field. +func (m *TransactionsMutation) SetContent(b []byte) { + m.content = &b +} + +// Content returns the value of the "content" field in the mutation. +func (m *TransactionsMutation) Content() (r []byte, exists bool) { + v := m.content + if v == nil { + return + } + return *v, true +} + +// OldContent returns the old "content" field's value of the Transactions entity. +// If the Transactions object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TransactionsMutation) OldContent(ctx context.Context) (v []byte, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldContent is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldContent requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldContent: %w", err) + } + return oldValue.Content, nil +} + +// ResetContent resets all changes to the "content" field. +func (m *TransactionsMutation) ResetContent() { + m.content = nil +} + +// SetHash sets the "hash" field. +func (m *TransactionsMutation) SetHash(s string) { + m.hash = &s +} + +// Hash returns the value of the "hash" field in the mutation. +func (m *TransactionsMutation) Hash() (r string, exists bool) { + v := m.hash + if v == nil { + return + } + return *v, true +} + +// OldHash returns the old "hash" field's value of the Transactions entity. +// If the Transactions object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TransactionsMutation) OldHash(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHash is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHash requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHash: %w", err) + } + return oldValue.Hash, nil +} + +// ResetHash resets all changes to the "hash" field. +func (m *TransactionsMutation) ResetHash() { + m.hash = nil +} + +// SetSignature sets the "signature" field. +func (m *TransactionsMutation) SetSignature(s string) { + m.signature = &s +} + +// Signature returns the value of the "signature" field in the mutation. +func (m *TransactionsMutation) Signature() (r string, exists bool) { + v := m.signature + if v == nil { + return + } + return *v, true +} + +// OldSignature returns the old "signature" field's value of the Transactions entity. +// If the Transactions object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TransactionsMutation) OldSignature(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSignature is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSignature requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSignature: %w", err) + } + return oldValue.Signature, nil +} + +// ResetSignature resets all changes to the "signature" field. +func (m *TransactionsMutation) ResetSignature() { + m.signature = nil +} + +// AddSignerIDs adds the "Signer" edge to the Key entity by ids. +func (m *TransactionsMutation) AddSignerIDs(ids ...int) { + if m._Signer == nil { + m._Signer = make(map[int]struct{}) + } + for i := range ids { + m._Signer[ids[i]] = struct{}{} + } +} + +// ClearSigner clears the "Signer" edge to the Key entity. +func (m *TransactionsMutation) ClearSigner() { + m.cleared_Signer = true +} + +// SignerCleared reports if the "Signer" edge to the Key entity was cleared. +func (m *TransactionsMutation) SignerCleared() bool { + return m.cleared_Signer +} + +// RemoveSignerIDs removes the "Signer" edge to the Key entity by IDs. +func (m *TransactionsMutation) RemoveSignerIDs(ids ...int) { + if m.removed_Signer == nil { + m.removed_Signer = make(map[int]struct{}) + } + for i := range ids { + delete(m._Signer, ids[i]) + m.removed_Signer[ids[i]] = struct{}{} + } +} + +// RemovedSigner returns the removed IDs of the "Signer" edge to the Key entity. +func (m *TransactionsMutation) RemovedSignerIDs() (ids []int) { + for id := range m.removed_Signer { + ids = append(ids, id) + } + return +} + +// SignerIDs returns the "Signer" edge IDs in the mutation. +func (m *TransactionsMutation) SignerIDs() (ids []int) { + for id := range m._Signer { + ids = append(ids, id) + } + return +} + +// ResetSigner resets all changes to the "Signer" edge. +func (m *TransactionsMutation) ResetSigner() { + m._Signer = nil + m.cleared_Signer = false + m.removed_Signer = nil +} + +// AddBlockIDs adds the "Block" edge to the Blocks entity by ids. +func (m *TransactionsMutation) AddBlockIDs(ids ...int) { + if m._Block == nil { + m._Block = make(map[int]struct{}) + } + for i := range ids { + m._Block[ids[i]] = struct{}{} + } +} + +// ClearBlock clears the "Block" edge to the Blocks entity. +func (m *TransactionsMutation) ClearBlock() { + m.cleared_Block = true +} + +// BlockCleared reports if the "Block" edge to the Blocks entity was cleared. +func (m *TransactionsMutation) BlockCleared() bool { + return m.cleared_Block +} + +// RemoveBlockIDs removes the "Block" edge to the Blocks entity by IDs. +func (m *TransactionsMutation) RemoveBlockIDs(ids ...int) { + if m.removed_Block == nil { + m.removed_Block = make(map[int]struct{}) + } + for i := range ids { + delete(m._Block, ids[i]) + m.removed_Block[ids[i]] = struct{}{} + } +} + +// RemovedBlock returns the removed IDs of the "Block" edge to the Blocks entity. +func (m *TransactionsMutation) RemovedBlockIDs() (ids []int) { + for id := range m.removed_Block { + ids = append(ids, id) + } + return +} + +// BlockIDs returns the "Block" edge IDs in the mutation. +func (m *TransactionsMutation) BlockIDs() (ids []int) { + for id := range m._Block { + ids = append(ids, id) + } + return +} + +// ResetBlock resets all changes to the "Block" edge. +func (m *TransactionsMutation) ResetBlock() { + m._Block = nil + m.cleared_Block = false + m.removed_Block = nil +} + +// Where appends a list predicates to the TransactionsMutation builder. +func (m *TransactionsMutation) Where(ps ...predicate.Transactions) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the TransactionsMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *TransactionsMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Transactions, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *TransactionsMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *TransactionsMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Transactions). +func (m *TransactionsMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *TransactionsMutation) Fields() []string { + fields := make([]string, 0, 6) + if m._type != nil { + fields = append(fields, transactions.FieldType) + } + if m.timestamp != nil { + fields = append(fields, transactions.FieldTimestamp) + } + if m.comment != nil { + fields = append(fields, transactions.FieldComment) + } + if m.content != nil { + fields = append(fields, transactions.FieldContent) + } + if m.hash != nil { + fields = append(fields, transactions.FieldHash) + } + if m.signature != nil { + fields = append(fields, transactions.FieldSignature) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *TransactionsMutation) Field(name string) (ent.Value, bool) { + switch name { + case transactions.FieldType: + return m.GetType() + case transactions.FieldTimestamp: + return m.Timestamp() + case transactions.FieldComment: + return m.Comment() + case transactions.FieldContent: + return m.Content() + case transactions.FieldHash: + return m.Hash() + case transactions.FieldSignature: + return m.Signature() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *TransactionsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case transactions.FieldType: + return m.OldType(ctx) + case transactions.FieldTimestamp: + return m.OldTimestamp(ctx) + case transactions.FieldComment: + return m.OldComment(ctx) + case transactions.FieldContent: + return m.OldContent(ctx) + case transactions.FieldHash: + return m.OldHash(ctx) + case transactions.FieldSignature: + return m.OldSignature(ctx) + } + return nil, fmt.Errorf("unknown Transactions field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *TransactionsMutation) SetField(name string, value ent.Value) error { + switch name { + case transactions.FieldType: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case transactions.FieldTimestamp: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTimestamp(v) + return nil + case transactions.FieldComment: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetComment(v) + return nil + case transactions.FieldContent: + v, ok := value.([]byte) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetContent(v) + return nil + case transactions.FieldHash: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHash(v) + return nil + case transactions.FieldSignature: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSignature(v) + return nil + } + return fmt.Errorf("unknown Transactions field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *TransactionsMutation) AddedFields() []string { + var fields []string + if m.add_type != nil { + fields = append(fields, transactions.FieldType) + } + if m.addtimestamp != nil { + fields = append(fields, transactions.FieldTimestamp) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *TransactionsMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case transactions.FieldType: + return m.AddedType() + case transactions.FieldTimestamp: + return m.AddedTimestamp() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *TransactionsMutation) AddField(name string, value ent.Value) error { + switch name { + case transactions.FieldType: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddType(v) + return nil + case transactions.FieldTimestamp: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTimestamp(v) + return nil + } + return fmt.Errorf("unknown Transactions numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *TransactionsMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *TransactionsMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *TransactionsMutation) ClearField(name string) error { + return fmt.Errorf("unknown Transactions nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *TransactionsMutation) ResetField(name string) error { + switch name { + case transactions.FieldType: + m.ResetType() + return nil + case transactions.FieldTimestamp: + m.ResetTimestamp() + return nil + case transactions.FieldComment: + m.ResetComment() + return nil + case transactions.FieldContent: + m.ResetContent() + return nil + case transactions.FieldHash: + m.ResetHash() + return nil + case transactions.FieldSignature: + m.ResetSignature() + return nil + } + return fmt.Errorf("unknown Transactions field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *TransactionsMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m._Signer != nil { + edges = append(edges, transactions.EdgeSigner) + } + if m._Block != nil { + edges = append(edges, transactions.EdgeBlock) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *TransactionsMutation) AddedIDs(name string) []ent.Value { + switch name { + case transactions.EdgeSigner: + ids := make([]ent.Value, 0, len(m._Signer)) + for id := range m._Signer { + ids = append(ids, id) + } + return ids + case transactions.EdgeBlock: + ids := make([]ent.Value, 0, len(m._Block)) + for id := range m._Block { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *TransactionsMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removed_Signer != nil { + edges = append(edges, transactions.EdgeSigner) + } + if m.removed_Block != nil { + edges = append(edges, transactions.EdgeBlock) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *TransactionsMutation) RemovedIDs(name string) []ent.Value { + switch name { + case transactions.EdgeSigner: + ids := make([]ent.Value, 0, len(m.removed_Signer)) + for id := range m.removed_Signer { + ids = append(ids, id) + } + return ids + case transactions.EdgeBlock: + ids := make([]ent.Value, 0, len(m.removed_Block)) + for id := range m.removed_Block { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *TransactionsMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.cleared_Signer { + edges = append(edges, transactions.EdgeSigner) + } + if m.cleared_Block { + edges = append(edges, transactions.EdgeBlock) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *TransactionsMutation) EdgeCleared(name string) bool { + switch name { + case transactions.EdgeSigner: + return m.cleared_Signer + case transactions.EdgeBlock: + return m.cleared_Block + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *TransactionsMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown Transactions unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *TransactionsMutation) ResetEdge(name string) error { + switch name { + case transactions.EdgeSigner: + m.ResetSigner() + return nil + case transactions.EdgeBlock: + m.ResetBlock() + return nil + } + return fmt.Errorf("unknown Transactions edge %s", name) +} + +// ValidatorsMutation represents an operation that mutates the Validators nodes in the graph. +type ValidatorsMutation struct { + config + op Op + typ string + id *int + facilitator *string + clearedFields map[string]struct{} + key map[int]struct{} + removedkey map[int]struct{} + clearedkey bool + done bool + oldValue func(context.Context) (*Validators, error) + predicates []predicate.Validators +} + +var _ ent.Mutation = (*ValidatorsMutation)(nil) + +// validatorsOption allows management of the mutation configuration using functional options. +type validatorsOption func(*ValidatorsMutation) + +// newValidatorsMutation creates new mutation for the Validators entity. +func newValidatorsMutation(c config, op Op, opts ...validatorsOption) *ValidatorsMutation { + m := &ValidatorsMutation{ + config: c, + op: op, + typ: TypeValidators, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withValidatorsID sets the ID field of the mutation. +func withValidatorsID(id int) validatorsOption { + return func(m *ValidatorsMutation) { + var ( + err error + once sync.Once + value *Validators + ) + m.oldValue = func(ctx context.Context) (*Validators, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Validators.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withValidators sets the old Validators of the mutation. +func withValidators(node *Validators) validatorsOption { + return func(m *ValidatorsMutation) { + m.oldValue = func(context.Context) (*Validators, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ValidatorsMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ValidatorsMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ValidatorsMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ValidatorsMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Validators.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetFacilitator sets the "facilitator" field. +func (m *ValidatorsMutation) SetFacilitator(s string) { + m.facilitator = &s +} + +// Facilitator returns the value of the "facilitator" field in the mutation. +func (m *ValidatorsMutation) Facilitator() (r string, exists bool) { + v := m.facilitator + if v == nil { + return + } + return *v, true +} + +// OldFacilitator returns the old "facilitator" field's value of the Validators entity. +// If the Validators object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ValidatorsMutation) OldFacilitator(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFacilitator is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFacilitator requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFacilitator: %w", err) + } + return oldValue.Facilitator, nil +} + +// ResetFacilitator resets all changes to the "facilitator" field. +func (m *ValidatorsMutation) ResetFacilitator() { + m.facilitator = nil +} + +// AddKeyIDs adds the "key" edge to the Key entity by ids. +func (m *ValidatorsMutation) AddKeyIDs(ids ...int) { + if m.key == nil { + m.key = make(map[int]struct{}) + } + for i := range ids { + m.key[ids[i]] = struct{}{} + } +} + +// ClearKey clears the "key" edge to the Key entity. +func (m *ValidatorsMutation) ClearKey() { + m.clearedkey = true +} + +// KeyCleared reports if the "key" edge to the Key entity was cleared. +func (m *ValidatorsMutation) KeyCleared() bool { + return m.clearedkey +} + +// RemoveKeyIDs removes the "key" edge to the Key entity by IDs. +func (m *ValidatorsMutation) RemoveKeyIDs(ids ...int) { + if m.removedkey == nil { + m.removedkey = make(map[int]struct{}) + } + for i := range ids { + delete(m.key, ids[i]) + m.removedkey[ids[i]] = struct{}{} + } +} + +// RemovedKey returns the removed IDs of the "key" edge to the Key entity. +func (m *ValidatorsMutation) RemovedKeyIDs() (ids []int) { + for id := range m.removedkey { + ids = append(ids, id) + } + return +} + +// KeyIDs returns the "key" edge IDs in the mutation. +func (m *ValidatorsMutation) KeyIDs() (ids []int) { + for id := range m.key { + ids = append(ids, id) + } + return +} + +// ResetKey resets all changes to the "key" edge. +func (m *ValidatorsMutation) ResetKey() { + m.key = nil + m.clearedkey = false + m.removedkey = nil +} + +// Where appends a list predicates to the ValidatorsMutation builder. +func (m *ValidatorsMutation) Where(ps ...predicate.Validators) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ValidatorsMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ValidatorsMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Validators, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ValidatorsMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ValidatorsMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Validators). +func (m *ValidatorsMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ValidatorsMutation) Fields() []string { + fields := make([]string, 0, 1) + if m.facilitator != nil { + fields = append(fields, validators.FieldFacilitator) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ValidatorsMutation) Field(name string) (ent.Value, bool) { + switch name { + case validators.FieldFacilitator: + return m.Facilitator() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ValidatorsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case validators.FieldFacilitator: + return m.OldFacilitator(ctx) + } + return nil, fmt.Errorf("unknown Validators field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ValidatorsMutation) SetField(name string, value ent.Value) error { + switch name { + case validators.FieldFacilitator: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFacilitator(v) + return nil + } + return fmt.Errorf("unknown Validators field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ValidatorsMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ValidatorsMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ValidatorsMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Validators numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ValidatorsMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ValidatorsMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ValidatorsMutation) ClearField(name string) error { + return fmt.Errorf("unknown Validators nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ValidatorsMutation) ResetField(name string) error { + switch name { + case validators.FieldFacilitator: + m.ResetFacilitator() + return nil + } + return fmt.Errorf("unknown Validators field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ValidatorsMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.key != nil { + edges = append(edges, validators.EdgeKey) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ValidatorsMutation) AddedIDs(name string) []ent.Value { + switch name { + case validators.EdgeKey: + ids := make([]ent.Value, 0, len(m.key)) + for id := range m.key { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ValidatorsMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + if m.removedkey != nil { + edges = append(edges, validators.EdgeKey) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ValidatorsMutation) RemovedIDs(name string) []ent.Value { + switch name { + case validators.EdgeKey: + ids := make([]ent.Value, 0, len(m.removedkey)) + for id := range m.removedkey { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ValidatorsMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedkey { + edges = append(edges, validators.EdgeKey) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ValidatorsMutation) EdgeCleared(name string) bool { + switch name { + case validators.EdgeKey: + return m.clearedkey + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ValidatorsMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown Validators unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ValidatorsMutation) ResetEdge(name string) error { + switch name { + case validators.EdgeKey: + m.ResetKey() + return nil + } + return fmt.Errorf("unknown Validators edge %s", name) +} + +// WhiteListMutation represents an operation that mutates the WhiteList nodes in the graph. +type WhiteListMutation struct { + config + op Op + typ string + id *int + clearedFields map[string]struct{} + _Sponsor map[int]struct{} + removed_Sponsor map[int]struct{} + cleared_Sponsor bool + _Account map[int]struct{} + removed_Account map[int]struct{} + cleared_Account bool + done bool + oldValue func(context.Context) (*WhiteList, error) + predicates []predicate.WhiteList +} + +var _ ent.Mutation = (*WhiteListMutation)(nil) + +// whitelistOption allows management of the mutation configuration using functional options. +type whitelistOption func(*WhiteListMutation) + +// newWhiteListMutation creates new mutation for the WhiteList entity. +func newWhiteListMutation(c config, op Op, opts ...whitelistOption) *WhiteListMutation { + m := &WhiteListMutation{ + config: c, + op: op, + typ: TypeWhiteList, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withWhiteListID sets the ID field of the mutation. +func withWhiteListID(id int) whitelistOption { + return func(m *WhiteListMutation) { + var ( + err error + once sync.Once + value *WhiteList + ) + m.oldValue = func(ctx context.Context) (*WhiteList, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().WhiteList.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withWhiteList sets the old WhiteList of the mutation. +func withWhiteList(node *WhiteList) whitelistOption { + return func(m *WhiteListMutation) { + m.oldValue = func(context.Context) (*WhiteList, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m WhiteListMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m WhiteListMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *WhiteListMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *WhiteListMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().WhiteList.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// AddSponsorIDs adds the "Sponsor" edge to the Validators entity by ids. +func (m *WhiteListMutation) AddSponsorIDs(ids ...int) { + if m._Sponsor == nil { + m._Sponsor = make(map[int]struct{}) + } + for i := range ids { + m._Sponsor[ids[i]] = struct{}{} + } +} + +// ClearSponsor clears the "Sponsor" edge to the Validators entity. +func (m *WhiteListMutation) ClearSponsor() { + m.cleared_Sponsor = true +} + +// SponsorCleared reports if the "Sponsor" edge to the Validators entity was cleared. +func (m *WhiteListMutation) SponsorCleared() bool { + return m.cleared_Sponsor +} + +// RemoveSponsorIDs removes the "Sponsor" edge to the Validators entity by IDs. +func (m *WhiteListMutation) RemoveSponsorIDs(ids ...int) { + if m.removed_Sponsor == nil { + m.removed_Sponsor = make(map[int]struct{}) + } + for i := range ids { + delete(m._Sponsor, ids[i]) + m.removed_Sponsor[ids[i]] = struct{}{} + } +} + +// RemovedSponsor returns the removed IDs of the "Sponsor" edge to the Validators entity. +func (m *WhiteListMutation) RemovedSponsorIDs() (ids []int) { + for id := range m.removed_Sponsor { + ids = append(ids, id) + } + return +} + +// SponsorIDs returns the "Sponsor" edge IDs in the mutation. +func (m *WhiteListMutation) SponsorIDs() (ids []int) { + for id := range m._Sponsor { + ids = append(ids, id) + } + return +} + +// ResetSponsor resets all changes to the "Sponsor" edge. +func (m *WhiteListMutation) ResetSponsor() { + m._Sponsor = nil + m.cleared_Sponsor = false + m.removed_Sponsor = nil +} + +// AddAccountIDs adds the "Account" edge to the Key entity by ids. +func (m *WhiteListMutation) AddAccountIDs(ids ...int) { + if m._Account == nil { + m._Account = make(map[int]struct{}) + } + for i := range ids { + m._Account[ids[i]] = struct{}{} + } +} + +// ClearAccount clears the "Account" edge to the Key entity. +func (m *WhiteListMutation) ClearAccount() { + m.cleared_Account = true +} + +// AccountCleared reports if the "Account" edge to the Key entity was cleared. +func (m *WhiteListMutation) AccountCleared() bool { + return m.cleared_Account +} + +// RemoveAccountIDs removes the "Account" edge to the Key entity by IDs. +func (m *WhiteListMutation) RemoveAccountIDs(ids ...int) { + if m.removed_Account == nil { + m.removed_Account = make(map[int]struct{}) + } + for i := range ids { + delete(m._Account, ids[i]) + m.removed_Account[ids[i]] = struct{}{} + } +} + +// RemovedAccount returns the removed IDs of the "Account" edge to the Key entity. +func (m *WhiteListMutation) RemovedAccountIDs() (ids []int) { + for id := range m.removed_Account { + ids = append(ids, id) + } + return +} + +// AccountIDs returns the "Account" edge IDs in the mutation. +func (m *WhiteListMutation) AccountIDs() (ids []int) { + for id := range m._Account { + ids = append(ids, id) + } + return +} + +// ResetAccount resets all changes to the "Account" edge. +func (m *WhiteListMutation) ResetAccount() { + m._Account = nil + m.cleared_Account = false + m.removed_Account = nil +} + +// Where appends a list predicates to the WhiteListMutation builder. +func (m *WhiteListMutation) Where(ps ...predicate.WhiteList) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the WhiteListMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *WhiteListMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.WhiteList, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *WhiteListMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *WhiteListMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (WhiteList). +func (m *WhiteListMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *WhiteListMutation) Fields() []string { + fields := make([]string, 0, 0) + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *WhiteListMutation) Field(name string) (ent.Value, bool) { + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *WhiteListMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + return nil, fmt.Errorf("unknown WhiteList field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *WhiteListMutation) SetField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown WhiteList field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *WhiteListMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *WhiteListMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *WhiteListMutation) AddField(name string, value ent.Value) error { + return fmt.Errorf("unknown WhiteList numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *WhiteListMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *WhiteListMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *WhiteListMutation) ClearField(name string) error { + return fmt.Errorf("unknown WhiteList nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *WhiteListMutation) ResetField(name string) error { + return fmt.Errorf("unknown WhiteList field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *WhiteListMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m._Sponsor != nil { + edges = append(edges, whitelist.EdgeSponsor) + } + if m._Account != nil { + edges = append(edges, whitelist.EdgeAccount) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *WhiteListMutation) AddedIDs(name string) []ent.Value { + switch name { + case whitelist.EdgeSponsor: + ids := make([]ent.Value, 0, len(m._Sponsor)) + for id := range m._Sponsor { + ids = append(ids, id) + } + return ids + case whitelist.EdgeAccount: + ids := make([]ent.Value, 0, len(m._Account)) + for id := range m._Account { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *WhiteListMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removed_Sponsor != nil { + edges = append(edges, whitelist.EdgeSponsor) + } + if m.removed_Account != nil { + edges = append(edges, whitelist.EdgeAccount) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *WhiteListMutation) RemovedIDs(name string) []ent.Value { + switch name { + case whitelist.EdgeSponsor: + ids := make([]ent.Value, 0, len(m.removed_Sponsor)) + for id := range m.removed_Sponsor { + ids = append(ids, id) + } + return ids + case whitelist.EdgeAccount: + ids := make([]ent.Value, 0, len(m.removed_Account)) + for id := range m.removed_Account { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *WhiteListMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.cleared_Sponsor { + edges = append(edges, whitelist.EdgeSponsor) + } + if m.cleared_Account { + edges = append(edges, whitelist.EdgeAccount) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *WhiteListMutation) EdgeCleared(name string) bool { + switch name { + case whitelist.EdgeSponsor: + return m.cleared_Sponsor + case whitelist.EdgeAccount: + return m.cleared_Account + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *WhiteListMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown WhiteList unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *WhiteListMutation) ResetEdge(name string) error { + switch name { + case whitelist.EdgeSponsor: + m.ResetSponsor() + return nil + case whitelist.EdgeAccount: + m.ResetAccount() + return nil + } + return fmt.Errorf("unknown WhiteList edge %s", name) +} diff --git a/z2/backend/ent/predicate/predicate.go b/z2/backend/ent/predicate/predicate.go new file mode 100644 index 0000000..6517116 --- /dev/null +++ b/z2/backend/ent/predicate/predicate.go @@ -0,0 +1,22 @@ +// Code generated by ent, DO NOT EDIT. + +package predicate + +import ( + "entgo.io/ent/dialect/sql" +) + +// Blocks is the predicate function for blocks builders. +type Blocks func(*sql.Selector) + +// Key is the predicate function for key builders. +type Key func(*sql.Selector) + +// Transactions is the predicate function for transactions builders. +type Transactions func(*sql.Selector) + +// Validators is the predicate function for validators builders. +type Validators func(*sql.Selector) + +// WhiteList is the predicate function for whitelist builders. +type WhiteList func(*sql.Selector) diff --git a/z2/backend/ent/runtime.go b/z2/backend/ent/runtime.go new file mode 100644 index 0000000..3db1dd6 --- /dev/null +++ b/z2/backend/ent/runtime.go @@ -0,0 +1,35 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "thesis/ent/key" + "thesis/ent/schema" + "thesis/ent/validators" +) + +// The init function reads all schema descriptors with runtime code +// (default values, validators, hooks and policies) and stitches it +// to their package variables. +func init() { + keyFields := schema.Key{}.Fields() + _ = keyFields + // keyDescPublicKey is the schema descriptor for publicKey field. + keyDescPublicKey := keyFields[0].Descriptor() + // key.PublicKeyValidator is a validator for the "publicKey" field. It is called by the builders before save. + key.PublicKeyValidator = keyDescPublicKey.Validators[0].(func(string) error) + // keyDescOwner is the schema descriptor for Owner field. + keyDescOwner := keyFields[1].Descriptor() + // key.OwnerValidator is a validator for the "Owner" field. It is called by the builders before save. + key.OwnerValidator = keyDescOwner.Validators[0].(func(string) error) + // keyDescTrustScore is the schema descriptor for trustScore field. + keyDescTrustScore := keyFields[2].Descriptor() + // key.DefaultTrustScore holds the default value on creation for the trustScore field. + key.DefaultTrustScore = keyDescTrustScore.Default.(float64) + validatorsFields := schema.Validators{}.Fields() + _ = validatorsFields + // validatorsDescFacilitator is the schema descriptor for facilitator field. + validatorsDescFacilitator := validatorsFields[0].Descriptor() + // validators.FacilitatorValidator is a validator for the "facilitator" field. It is called by the builders before save. + validators.FacilitatorValidator = validatorsDescFacilitator.Validators[0].(func(string) error) +} diff --git a/z2/backend/ent/runtime/runtime.go b/z2/backend/ent/runtime/runtime.go new file mode 100644 index 0000000..da94f9c --- /dev/null +++ b/z2/backend/ent/runtime/runtime.go @@ -0,0 +1,10 @@ +// Code generated by ent, DO NOT EDIT. + +package runtime + +// The schema-stitching logic is generated in thesis/ent/runtime.go + +const ( + Version = "v0.13.1" // Version of ent codegen. + Sum = "h1:uD8QwN1h6SNphdCCzmkMN3feSUzNnVvV/WIkHKMbzOE=" // Sum of ent codegen. +) diff --git a/z2/backend/ent/schema/blocks.go b/z2/backend/ent/schema/blocks.go new file mode 100644 index 0000000..7b201f1 --- /dev/null +++ b/z2/backend/ent/schema/blocks.go @@ -0,0 +1,30 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +// Key holds the schema definition for the Key entity. +type Blocks struct { + ent.Schema +} + +// Fields of the Key. +func (Blocks) Fields() []ent.Field { + return []ent.Field{ + field.String("hash").Unique(), + field.Int("id").Unique(), + field.Int("length"), + field.String("previousHash").Unique(), + } +} + +// Edges of the Key. +func (Blocks) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("Caster", Validators.Type), + edge.To("MinedTxs", Transactions.Type), + } +} diff --git a/z2/backend/ent/schema/key.go b/z2/backend/ent/schema/key.go new file mode 100644 index 0000000..a4617e8 --- /dev/null +++ b/z2/backend/ent/schema/key.go @@ -0,0 +1,28 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +// Key holds the schema definition for the Key entity. +type Key struct { + ent.Schema +} + +// Fields of the Key. +func (Key) Fields() []ent.Field { + return []ent.Field{ + field.String("publicKey").NotEmpty().Unique(), + field.String("Owner").NotEmpty(), + field.Float("trustScore").Default(0.2), + } +} + +// Edges of the Key. +func (Key) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("Signed", Transactions.Type), + } +} diff --git a/z2/backend/ent/schema/transactions.go b/z2/backend/ent/schema/transactions.go new file mode 100644 index 0000000..c474583 --- /dev/null +++ b/z2/backend/ent/schema/transactions.go @@ -0,0 +1,32 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +// Transactions holds the schema definition for the Transactions entity. +type Transactions struct { + ent.Schema +} + +// Fields of the Transactions. +func (Transactions) Fields() []ent.Field { + return []ent.Field{ + field.Int("type"), + field.Int("timestamp"), + field.String("comment"), + field.Bytes("content"), + field.String("hash").Unique(), + field.String("signature").Unique(), + } +} + +// Edges of the Transactions. +func (Transactions) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("Signer", Key.Type).Ref("Signed"), + edge.From("Block", Blocks.Type).Ref("MinedTxs"), + } +} diff --git a/z2/backend/ent/schema/validators.go b/z2/backend/ent/schema/validators.go new file mode 100644 index 0000000..5b63e2c --- /dev/null +++ b/z2/backend/ent/schema/validators.go @@ -0,0 +1,26 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +// Validators holds the schema definition for the Validators entity. +type Validators struct { + ent.Schema +} + +// Fields of the Validators. +func (Validators) Fields() []ent.Field { + return []ent.Field{ + field.String("facilitator").NotEmpty(), + } +} + +// Edges of the Validators. +func (Validators) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("key", Key.Type), + } +} diff --git a/z2/backend/ent/schema/whitelist.go b/z2/backend/ent/schema/whitelist.go new file mode 100644 index 0000000..5dc821e --- /dev/null +++ b/z2/backend/ent/schema/whitelist.go @@ -0,0 +1,24 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" +) + +// Key holds the schema definition for the Key entity. +type WhiteList struct { + ent.Schema +} + +// Fields of the Key. +func (WhiteList) Fields() []ent.Field { + return []ent.Field{} +} + +// Edges of the Key. +func (WhiteList) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("Sponsor", Validators.Type), + edge.To("Account", Key.Type), + } +} diff --git a/z2/backend/ent/transactions.go b/z2/backend/ent/transactions.go new file mode 100644 index 0000000..d067f6f --- /dev/null +++ b/z2/backend/ent/transactions.go @@ -0,0 +1,202 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "thesis/ent/transactions" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// Transactions is the model entity for the Transactions schema. +type Transactions struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Type holds the value of the "type" field. + Type int `json:"type,omitempty"` + // Timestamp holds the value of the "timestamp" field. + Timestamp int `json:"timestamp,omitempty"` + // Comment holds the value of the "comment" field. + Comment string `json:"comment,omitempty"` + // Content holds the value of the "content" field. + Content []byte `json:"content,omitempty"` + // Hash holds the value of the "hash" field. + Hash string `json:"hash,omitempty"` + // Signature holds the value of the "signature" field. + Signature string `json:"signature,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the TransactionsQuery when eager-loading is set. + Edges TransactionsEdges `json:"edges"` + selectValues sql.SelectValues +} + +// TransactionsEdges holds the relations/edges for other nodes in the graph. +type TransactionsEdges struct { + // Signer holds the value of the Signer edge. + Signer []*Key `json:"Signer,omitempty"` + // Block holds the value of the Block edge. + Block []*Blocks `json:"Block,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// SignerOrErr returns the Signer value or an error if the edge +// was not loaded in eager-loading. +func (e TransactionsEdges) SignerOrErr() ([]*Key, error) { + if e.loadedTypes[0] { + return e.Signer, nil + } + return nil, &NotLoadedError{edge: "Signer"} +} + +// BlockOrErr returns the Block value or an error if the edge +// was not loaded in eager-loading. +func (e TransactionsEdges) BlockOrErr() ([]*Blocks, error) { + if e.loadedTypes[1] { + return e.Block, nil + } + return nil, &NotLoadedError{edge: "Block"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Transactions) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case transactions.FieldContent: + values[i] = new([]byte) + case transactions.FieldID, transactions.FieldType, transactions.FieldTimestamp: + values[i] = new(sql.NullInt64) + case transactions.FieldComment, transactions.FieldHash, transactions.FieldSignature: + values[i] = new(sql.NullString) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Transactions fields. +func (t *Transactions) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case transactions.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + t.ID = int(value.Int64) + case transactions.FieldType: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field type", values[i]) + } else if value.Valid { + t.Type = int(value.Int64) + } + case transactions.FieldTimestamp: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field timestamp", values[i]) + } else if value.Valid { + t.Timestamp = int(value.Int64) + } + case transactions.FieldComment: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field comment", values[i]) + } else if value.Valid { + t.Comment = value.String + } + case transactions.FieldContent: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field content", values[i]) + } else if value != nil { + t.Content = *value + } + case transactions.FieldHash: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field hash", values[i]) + } else if value.Valid { + t.Hash = value.String + } + case transactions.FieldSignature: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field signature", values[i]) + } else if value.Valid { + t.Signature = value.String + } + default: + t.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Transactions. +// This includes values selected through modifiers, order, etc. +func (t *Transactions) Value(name string) (ent.Value, error) { + return t.selectValues.Get(name) +} + +// QuerySigner queries the "Signer" edge of the Transactions entity. +func (t *Transactions) QuerySigner() *KeyQuery { + return NewTransactionsClient(t.config).QuerySigner(t) +} + +// QueryBlock queries the "Block" edge of the Transactions entity. +func (t *Transactions) QueryBlock() *BlocksQuery { + return NewTransactionsClient(t.config).QueryBlock(t) +} + +// Update returns a builder for updating this Transactions. +// Note that you need to call Transactions.Unwrap() before calling this method if this Transactions +// was returned from a transaction, and the transaction was committed or rolled back. +func (t *Transactions) Update() *TransactionsUpdateOne { + return NewTransactionsClient(t.config).UpdateOne(t) +} + +// Unwrap unwraps the Transactions entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (t *Transactions) Unwrap() *Transactions { + _tx, ok := t.config.driver.(*txDriver) + if !ok { + panic("ent: Transactions is not a transactional entity") + } + t.config.driver = _tx.drv + return t +} + +// String implements the fmt.Stringer. +func (t *Transactions) String() string { + var builder strings.Builder + builder.WriteString("Transactions(") + builder.WriteString(fmt.Sprintf("id=%v, ", t.ID)) + builder.WriteString("type=") + builder.WriteString(fmt.Sprintf("%v", t.Type)) + builder.WriteString(", ") + builder.WriteString("timestamp=") + builder.WriteString(fmt.Sprintf("%v", t.Timestamp)) + builder.WriteString(", ") + builder.WriteString("comment=") + builder.WriteString(t.Comment) + builder.WriteString(", ") + builder.WriteString("content=") + builder.WriteString(fmt.Sprintf("%v", t.Content)) + builder.WriteString(", ") + builder.WriteString("hash=") + builder.WriteString(t.Hash) + builder.WriteString(", ") + builder.WriteString("signature=") + builder.WriteString(t.Signature) + builder.WriteByte(')') + return builder.String() +} + +// TransactionsSlice is a parsable slice of Transactions. +type TransactionsSlice []*Transactions diff --git a/z2/backend/ent/transactions/transactions.go b/z2/backend/ent/transactions/transactions.go new file mode 100644 index 0000000..3bf02e6 --- /dev/null +++ b/z2/backend/ent/transactions/transactions.go @@ -0,0 +1,148 @@ +// Code generated by ent, DO NOT EDIT. + +package transactions + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the transactions type in the database. + Label = "transactions" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldType holds the string denoting the type field in the database. + FieldType = "type" + // FieldTimestamp holds the string denoting the timestamp field in the database. + FieldTimestamp = "timestamp" + // FieldComment holds the string denoting the comment field in the database. + FieldComment = "comment" + // FieldContent holds the string denoting the content field in the database. + FieldContent = "content" + // FieldHash holds the string denoting the hash field in the database. + FieldHash = "hash" + // FieldSignature holds the string denoting the signature field in the database. + FieldSignature = "signature" + // EdgeSigner holds the string denoting the signer edge name in mutations. + EdgeSigner = "Signer" + // EdgeBlock holds the string denoting the block edge name in mutations. + EdgeBlock = "Block" + // Table holds the table name of the transactions in the database. + Table = "transactions" + // SignerTable is the table that holds the Signer relation/edge. The primary key declared below. + SignerTable = "key_Signed" + // SignerInverseTable is the table name for the Key entity. + // It exists in this package in order to avoid circular dependency with the "key" package. + SignerInverseTable = "keys" + // BlockTable is the table that holds the Block relation/edge. The primary key declared below. + BlockTable = "blocks_MinedTxs" + // BlockInverseTable is the table name for the Blocks entity. + // It exists in this package in order to avoid circular dependency with the "blocks" package. + BlockInverseTable = "blocks" +) + +// Columns holds all SQL columns for transactions fields. +var Columns = []string{ + FieldID, + FieldType, + FieldTimestamp, + FieldComment, + FieldContent, + FieldHash, + FieldSignature, +} + +var ( + // SignerPrimaryKey and SignerColumn2 are the table columns denoting the + // primary key for the Signer relation (M2M). + SignerPrimaryKey = []string{"key_id", "transactions_id"} + // BlockPrimaryKey and BlockColumn2 are the table columns denoting the + // primary key for the Block relation (M2M). + BlockPrimaryKey = []string{"blocks_id", "transactions_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 + } + } + return false +} + +// OrderOption defines the ordering options for the Transactions 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() +} + +// ByType orders the results by the type field. +func ByType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldType, opts...).ToFunc() +} + +// ByTimestamp orders the results by the timestamp field. +func ByTimestamp(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTimestamp, opts...).ToFunc() +} + +// ByComment orders the results by the comment field. +func ByComment(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldComment, opts...).ToFunc() +} + +// ByHash orders the results by the hash field. +func ByHash(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHash, opts...).ToFunc() +} + +// BySignature orders the results by the signature field. +func BySignature(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSignature, opts...).ToFunc() +} + +// BySignerCount orders the results by Signer count. +func BySignerCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newSignerStep(), opts...) + } +} + +// BySigner orders the results by Signer terms. +func BySigner(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newSignerStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByBlockCount orders the results by Block count. +func ByBlockCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newBlockStep(), opts...) + } +} + +// ByBlock orders the results by Block terms. +func ByBlock(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newBlockStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newSignerStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(SignerInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, SignerTable, SignerPrimaryKey...), + ) +} +func newBlockStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(BlockInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, BlockTable, BlockPrimaryKey...), + ) +} diff --git a/z2/backend/ent/transactions/where.go b/z2/backend/ent/transactions/where.go new file mode 100644 index 0000000..1132eb5 --- /dev/null +++ b/z2/backend/ent/transactions/where.go @@ -0,0 +1,461 @@ +// Code generated by ent, DO NOT EDIT. + +package transactions + +import ( + "thesis/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.Transactions { + return predicate.Transactions(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Transactions { + return predicate.Transactions(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Transactions { + return predicate.Transactions(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Transactions { + return predicate.Transactions(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Transactions { + return predicate.Transactions(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Transactions { + return predicate.Transactions(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Transactions { + return predicate.Transactions(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Transactions { + return predicate.Transactions(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Transactions { + return predicate.Transactions(sql.FieldLTE(FieldID, id)) +} + +// Type applies equality check predicate on the "type" field. It's identical to TypeEQ. +func Type(v int) predicate.Transactions { + return predicate.Transactions(sql.FieldEQ(FieldType, v)) +} + +// Timestamp applies equality check predicate on the "timestamp" field. It's identical to TimestampEQ. +func Timestamp(v int) predicate.Transactions { + return predicate.Transactions(sql.FieldEQ(FieldTimestamp, v)) +} + +// Comment applies equality check predicate on the "comment" field. It's identical to CommentEQ. +func Comment(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldEQ(FieldComment, v)) +} + +// Content applies equality check predicate on the "content" field. It's identical to ContentEQ. +func Content(v []byte) predicate.Transactions { + return predicate.Transactions(sql.FieldEQ(FieldContent, v)) +} + +// Hash applies equality check predicate on the "hash" field. It's identical to HashEQ. +func Hash(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldEQ(FieldHash, v)) +} + +// Signature applies equality check predicate on the "signature" field. It's identical to SignatureEQ. +func Signature(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldEQ(FieldSignature, v)) +} + +// TypeEQ applies the EQ predicate on the "type" field. +func TypeEQ(v int) predicate.Transactions { + return predicate.Transactions(sql.FieldEQ(FieldType, v)) +} + +// TypeNEQ applies the NEQ predicate on the "type" field. +func TypeNEQ(v int) predicate.Transactions { + return predicate.Transactions(sql.FieldNEQ(FieldType, v)) +} + +// TypeIn applies the In predicate on the "type" field. +func TypeIn(vs ...int) predicate.Transactions { + return predicate.Transactions(sql.FieldIn(FieldType, vs...)) +} + +// TypeNotIn applies the NotIn predicate on the "type" field. +func TypeNotIn(vs ...int) predicate.Transactions { + return predicate.Transactions(sql.FieldNotIn(FieldType, vs...)) +} + +// TypeGT applies the GT predicate on the "type" field. +func TypeGT(v int) predicate.Transactions { + return predicate.Transactions(sql.FieldGT(FieldType, v)) +} + +// TypeGTE applies the GTE predicate on the "type" field. +func TypeGTE(v int) predicate.Transactions { + return predicate.Transactions(sql.FieldGTE(FieldType, v)) +} + +// TypeLT applies the LT predicate on the "type" field. +func TypeLT(v int) predicate.Transactions { + return predicate.Transactions(sql.FieldLT(FieldType, v)) +} + +// TypeLTE applies the LTE predicate on the "type" field. +func TypeLTE(v int) predicate.Transactions { + return predicate.Transactions(sql.FieldLTE(FieldType, v)) +} + +// TimestampEQ applies the EQ predicate on the "timestamp" field. +func TimestampEQ(v int) predicate.Transactions { + return predicate.Transactions(sql.FieldEQ(FieldTimestamp, v)) +} + +// TimestampNEQ applies the NEQ predicate on the "timestamp" field. +func TimestampNEQ(v int) predicate.Transactions { + return predicate.Transactions(sql.FieldNEQ(FieldTimestamp, v)) +} + +// TimestampIn applies the In predicate on the "timestamp" field. +func TimestampIn(vs ...int) predicate.Transactions { + return predicate.Transactions(sql.FieldIn(FieldTimestamp, vs...)) +} + +// TimestampNotIn applies the NotIn predicate on the "timestamp" field. +func TimestampNotIn(vs ...int) predicate.Transactions { + return predicate.Transactions(sql.FieldNotIn(FieldTimestamp, vs...)) +} + +// TimestampGT applies the GT predicate on the "timestamp" field. +func TimestampGT(v int) predicate.Transactions { + return predicate.Transactions(sql.FieldGT(FieldTimestamp, v)) +} + +// TimestampGTE applies the GTE predicate on the "timestamp" field. +func TimestampGTE(v int) predicate.Transactions { + return predicate.Transactions(sql.FieldGTE(FieldTimestamp, v)) +} + +// TimestampLT applies the LT predicate on the "timestamp" field. +func TimestampLT(v int) predicate.Transactions { + return predicate.Transactions(sql.FieldLT(FieldTimestamp, v)) +} + +// TimestampLTE applies the LTE predicate on the "timestamp" field. +func TimestampLTE(v int) predicate.Transactions { + return predicate.Transactions(sql.FieldLTE(FieldTimestamp, v)) +} + +// CommentEQ applies the EQ predicate on the "comment" field. +func CommentEQ(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldEQ(FieldComment, v)) +} + +// CommentNEQ applies the NEQ predicate on the "comment" field. +func CommentNEQ(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldNEQ(FieldComment, v)) +} + +// CommentIn applies the In predicate on the "comment" field. +func CommentIn(vs ...string) predicate.Transactions { + return predicate.Transactions(sql.FieldIn(FieldComment, vs...)) +} + +// CommentNotIn applies the NotIn predicate on the "comment" field. +func CommentNotIn(vs ...string) predicate.Transactions { + return predicate.Transactions(sql.FieldNotIn(FieldComment, vs...)) +} + +// CommentGT applies the GT predicate on the "comment" field. +func CommentGT(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldGT(FieldComment, v)) +} + +// CommentGTE applies the GTE predicate on the "comment" field. +func CommentGTE(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldGTE(FieldComment, v)) +} + +// CommentLT applies the LT predicate on the "comment" field. +func CommentLT(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldLT(FieldComment, v)) +} + +// CommentLTE applies the LTE predicate on the "comment" field. +func CommentLTE(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldLTE(FieldComment, v)) +} + +// CommentContains applies the Contains predicate on the "comment" field. +func CommentContains(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldContains(FieldComment, v)) +} + +// CommentHasPrefix applies the HasPrefix predicate on the "comment" field. +func CommentHasPrefix(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldHasPrefix(FieldComment, v)) +} + +// CommentHasSuffix applies the HasSuffix predicate on the "comment" field. +func CommentHasSuffix(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldHasSuffix(FieldComment, v)) +} + +// CommentEqualFold applies the EqualFold predicate on the "comment" field. +func CommentEqualFold(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldEqualFold(FieldComment, v)) +} + +// CommentContainsFold applies the ContainsFold predicate on the "comment" field. +func CommentContainsFold(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldContainsFold(FieldComment, v)) +} + +// ContentEQ applies the EQ predicate on the "content" field. +func ContentEQ(v []byte) predicate.Transactions { + return predicate.Transactions(sql.FieldEQ(FieldContent, v)) +} + +// ContentNEQ applies the NEQ predicate on the "content" field. +func ContentNEQ(v []byte) predicate.Transactions { + return predicate.Transactions(sql.FieldNEQ(FieldContent, v)) +} + +// ContentIn applies the In predicate on the "content" field. +func ContentIn(vs ...[]byte) predicate.Transactions { + return predicate.Transactions(sql.FieldIn(FieldContent, vs...)) +} + +// ContentNotIn applies the NotIn predicate on the "content" field. +func ContentNotIn(vs ...[]byte) predicate.Transactions { + return predicate.Transactions(sql.FieldNotIn(FieldContent, vs...)) +} + +// ContentGT applies the GT predicate on the "content" field. +func ContentGT(v []byte) predicate.Transactions { + return predicate.Transactions(sql.FieldGT(FieldContent, v)) +} + +// ContentGTE applies the GTE predicate on the "content" field. +func ContentGTE(v []byte) predicate.Transactions { + return predicate.Transactions(sql.FieldGTE(FieldContent, v)) +} + +// ContentLT applies the LT predicate on the "content" field. +func ContentLT(v []byte) predicate.Transactions { + return predicate.Transactions(sql.FieldLT(FieldContent, v)) +} + +// ContentLTE applies the LTE predicate on the "content" field. +func ContentLTE(v []byte) predicate.Transactions { + return predicate.Transactions(sql.FieldLTE(FieldContent, v)) +} + +// HashEQ applies the EQ predicate on the "hash" field. +func HashEQ(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldEQ(FieldHash, v)) +} + +// HashNEQ applies the NEQ predicate on the "hash" field. +func HashNEQ(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldNEQ(FieldHash, v)) +} + +// HashIn applies the In predicate on the "hash" field. +func HashIn(vs ...string) predicate.Transactions { + return predicate.Transactions(sql.FieldIn(FieldHash, vs...)) +} + +// HashNotIn applies the NotIn predicate on the "hash" field. +func HashNotIn(vs ...string) predicate.Transactions { + return predicate.Transactions(sql.FieldNotIn(FieldHash, vs...)) +} + +// HashGT applies the GT predicate on the "hash" field. +func HashGT(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldGT(FieldHash, v)) +} + +// HashGTE applies the GTE predicate on the "hash" field. +func HashGTE(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldGTE(FieldHash, v)) +} + +// HashLT applies the LT predicate on the "hash" field. +func HashLT(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldLT(FieldHash, v)) +} + +// HashLTE applies the LTE predicate on the "hash" field. +func HashLTE(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldLTE(FieldHash, v)) +} + +// HashContains applies the Contains predicate on the "hash" field. +func HashContains(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldContains(FieldHash, v)) +} + +// HashHasPrefix applies the HasPrefix predicate on the "hash" field. +func HashHasPrefix(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldHasPrefix(FieldHash, v)) +} + +// HashHasSuffix applies the HasSuffix predicate on the "hash" field. +func HashHasSuffix(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldHasSuffix(FieldHash, v)) +} + +// HashEqualFold applies the EqualFold predicate on the "hash" field. +func HashEqualFold(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldEqualFold(FieldHash, v)) +} + +// HashContainsFold applies the ContainsFold predicate on the "hash" field. +func HashContainsFold(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldContainsFold(FieldHash, v)) +} + +// SignatureEQ applies the EQ predicate on the "signature" field. +func SignatureEQ(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldEQ(FieldSignature, v)) +} + +// SignatureNEQ applies the NEQ predicate on the "signature" field. +func SignatureNEQ(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldNEQ(FieldSignature, v)) +} + +// SignatureIn applies the In predicate on the "signature" field. +func SignatureIn(vs ...string) predicate.Transactions { + return predicate.Transactions(sql.FieldIn(FieldSignature, vs...)) +} + +// SignatureNotIn applies the NotIn predicate on the "signature" field. +func SignatureNotIn(vs ...string) predicate.Transactions { + return predicate.Transactions(sql.FieldNotIn(FieldSignature, vs...)) +} + +// SignatureGT applies the GT predicate on the "signature" field. +func SignatureGT(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldGT(FieldSignature, v)) +} + +// SignatureGTE applies the GTE predicate on the "signature" field. +func SignatureGTE(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldGTE(FieldSignature, v)) +} + +// SignatureLT applies the LT predicate on the "signature" field. +func SignatureLT(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldLT(FieldSignature, v)) +} + +// SignatureLTE applies the LTE predicate on the "signature" field. +func SignatureLTE(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldLTE(FieldSignature, v)) +} + +// SignatureContains applies the Contains predicate on the "signature" field. +func SignatureContains(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldContains(FieldSignature, v)) +} + +// SignatureHasPrefix applies the HasPrefix predicate on the "signature" field. +func SignatureHasPrefix(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldHasPrefix(FieldSignature, v)) +} + +// SignatureHasSuffix applies the HasSuffix predicate on the "signature" field. +func SignatureHasSuffix(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldHasSuffix(FieldSignature, v)) +} + +// SignatureEqualFold applies the EqualFold predicate on the "signature" field. +func SignatureEqualFold(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldEqualFold(FieldSignature, v)) +} + +// SignatureContainsFold applies the ContainsFold predicate on the "signature" field. +func SignatureContainsFold(v string) predicate.Transactions { + return predicate.Transactions(sql.FieldContainsFold(FieldSignature, v)) +} + +// HasSigner applies the HasEdge predicate on the "Signer" edge. +func HasSigner() predicate.Transactions { + return predicate.Transactions(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, SignerTable, SignerPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasSignerWith applies the HasEdge predicate on the "Signer" edge with a given conditions (other predicates). +func HasSignerWith(preds ...predicate.Key) predicate.Transactions { + return predicate.Transactions(func(s *sql.Selector) { + step := newSignerStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasBlock applies the HasEdge predicate on the "Block" edge. +func HasBlock() predicate.Transactions { + return predicate.Transactions(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, BlockTable, BlockPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasBlockWith applies the HasEdge predicate on the "Block" edge with a given conditions (other predicates). +func HasBlockWith(preds ...predicate.Blocks) predicate.Transactions { + return predicate.Transactions(func(s *sql.Selector) { + step := newBlockStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Transactions) predicate.Transactions { + return predicate.Transactions(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Transactions) predicate.Transactions { + return predicate.Transactions(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Transactions) predicate.Transactions { + return predicate.Transactions(sql.NotPredicates(p)) +} diff --git a/z2/backend/ent/transactions_create.go b/z2/backend/ent/transactions_create.go new file mode 100644 index 0000000..fc90922 --- /dev/null +++ b/z2/backend/ent/transactions_create.go @@ -0,0 +1,312 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "thesis/ent/blocks" + "thesis/ent/key" + "thesis/ent/transactions" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// TransactionsCreate is the builder for creating a Transactions entity. +type TransactionsCreate struct { + config + mutation *TransactionsMutation + hooks []Hook +} + +// SetType sets the "type" field. +func (tc *TransactionsCreate) SetType(i int) *TransactionsCreate { + tc.mutation.SetType(i) + return tc +} + +// SetTimestamp sets the "timestamp" field. +func (tc *TransactionsCreate) SetTimestamp(i int) *TransactionsCreate { + tc.mutation.SetTimestamp(i) + return tc +} + +// SetComment sets the "comment" field. +func (tc *TransactionsCreate) SetComment(s string) *TransactionsCreate { + tc.mutation.SetComment(s) + return tc +} + +// SetContent sets the "content" field. +func (tc *TransactionsCreate) SetContent(b []byte) *TransactionsCreate { + tc.mutation.SetContent(b) + return tc +} + +// SetHash sets the "hash" field. +func (tc *TransactionsCreate) SetHash(s string) *TransactionsCreate { + tc.mutation.SetHash(s) + return tc +} + +// SetSignature sets the "signature" field. +func (tc *TransactionsCreate) SetSignature(s string) *TransactionsCreate { + tc.mutation.SetSignature(s) + return tc +} + +// AddSignerIDs adds the "Signer" edge to the Key entity by IDs. +func (tc *TransactionsCreate) AddSignerIDs(ids ...int) *TransactionsCreate { + tc.mutation.AddSignerIDs(ids...) + return tc +} + +// AddSigner adds the "Signer" edges to the Key entity. +func (tc *TransactionsCreate) AddSigner(k ...*Key) *TransactionsCreate { + ids := make([]int, len(k)) + for i := range k { + ids[i] = k[i].ID + } + return tc.AddSignerIDs(ids...) +} + +// AddBlockIDs adds the "Block" edge to the Blocks entity by IDs. +func (tc *TransactionsCreate) AddBlockIDs(ids ...int) *TransactionsCreate { + tc.mutation.AddBlockIDs(ids...) + return tc +} + +// AddBlock adds the "Block" edges to the Blocks entity. +func (tc *TransactionsCreate) AddBlock(b ...*Blocks) *TransactionsCreate { + ids := make([]int, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return tc.AddBlockIDs(ids...) +} + +// Mutation returns the TransactionsMutation object of the builder. +func (tc *TransactionsCreate) Mutation() *TransactionsMutation { + return tc.mutation +} + +// Save creates the Transactions in the database. +func (tc *TransactionsCreate) Save(ctx context.Context) (*Transactions, error) { + return withHooks(ctx, tc.sqlSave, tc.mutation, tc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (tc *TransactionsCreate) SaveX(ctx context.Context) *Transactions { + v, err := tc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (tc *TransactionsCreate) Exec(ctx context.Context) error { + _, err := tc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (tc *TransactionsCreate) ExecX(ctx context.Context) { + if err := tc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (tc *TransactionsCreate) check() error { + if _, ok := tc.mutation.GetType(); !ok { + return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Transactions.type"`)} + } + if _, ok := tc.mutation.Timestamp(); !ok { + return &ValidationError{Name: "timestamp", err: errors.New(`ent: missing required field "Transactions.timestamp"`)} + } + if _, ok := tc.mutation.Comment(); !ok { + return &ValidationError{Name: "comment", err: errors.New(`ent: missing required field "Transactions.comment"`)} + } + if _, ok := tc.mutation.Content(); !ok { + return &ValidationError{Name: "content", err: errors.New(`ent: missing required field "Transactions.content"`)} + } + if _, ok := tc.mutation.Hash(); !ok { + return &ValidationError{Name: "hash", err: errors.New(`ent: missing required field "Transactions.hash"`)} + } + if _, ok := tc.mutation.Signature(); !ok { + return &ValidationError{Name: "signature", err: errors.New(`ent: missing required field "Transactions.signature"`)} + } + return nil +} + +func (tc *TransactionsCreate) sqlSave(ctx context.Context) (*Transactions, error) { + if err := tc.check(); err != nil { + return nil, err + } + _node, _spec := tc.createSpec() + if err := sqlgraph.CreateNode(ctx, tc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + tc.mutation.id = &_node.ID + tc.mutation.done = true + return _node, nil +} + +func (tc *TransactionsCreate) createSpec() (*Transactions, *sqlgraph.CreateSpec) { + var ( + _node = &Transactions{config: tc.config} + _spec = sqlgraph.NewCreateSpec(transactions.Table, sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt)) + ) + if value, ok := tc.mutation.GetType(); ok { + _spec.SetField(transactions.FieldType, field.TypeInt, value) + _node.Type = value + } + if value, ok := tc.mutation.Timestamp(); ok { + _spec.SetField(transactions.FieldTimestamp, field.TypeInt, value) + _node.Timestamp = value + } + if value, ok := tc.mutation.Comment(); ok { + _spec.SetField(transactions.FieldComment, field.TypeString, value) + _node.Comment = value + } + if value, ok := tc.mutation.Content(); ok { + _spec.SetField(transactions.FieldContent, field.TypeBytes, value) + _node.Content = value + } + if value, ok := tc.mutation.Hash(); ok { + _spec.SetField(transactions.FieldHash, field.TypeString, value) + _node.Hash = value + } + if value, ok := tc.mutation.Signature(); ok { + _spec.SetField(transactions.FieldSignature, field.TypeString, value) + _node.Signature = value + } + if nodes := tc.mutation.SignerIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: transactions.SignerTable, + Columns: transactions.SignerPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := tc.mutation.BlockIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: transactions.BlockTable, + Columns: transactions.BlockPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(blocks.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// TransactionsCreateBulk is the builder for creating many Transactions entities in bulk. +type TransactionsCreateBulk struct { + config + err error + builders []*TransactionsCreate +} + +// Save creates the Transactions entities in the database. +func (tcb *TransactionsCreateBulk) Save(ctx context.Context) ([]*Transactions, error) { + if tcb.err != nil { + return nil, tcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(tcb.builders)) + nodes := make([]*Transactions, len(tcb.builders)) + mutators := make([]Mutator, len(tcb.builders)) + for i := range tcb.builders { + func(i int, root context.Context) { + builder := tcb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*TransactionsMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, tcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, tcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, tcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (tcb *TransactionsCreateBulk) SaveX(ctx context.Context) []*Transactions { + v, err := tcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (tcb *TransactionsCreateBulk) Exec(ctx context.Context) error { + _, err := tcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (tcb *TransactionsCreateBulk) ExecX(ctx context.Context) { + if err := tcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/z2/backend/ent/transactions_delete.go b/z2/backend/ent/transactions_delete.go new file mode 100644 index 0000000..6a89b20 --- /dev/null +++ b/z2/backend/ent/transactions_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "thesis/ent/predicate" + "thesis/ent/transactions" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// TransactionsDelete is the builder for deleting a Transactions entity. +type TransactionsDelete struct { + config + hooks []Hook + mutation *TransactionsMutation +} + +// Where appends a list predicates to the TransactionsDelete builder. +func (td *TransactionsDelete) Where(ps ...predicate.Transactions) *TransactionsDelete { + td.mutation.Where(ps...) + return td +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (td *TransactionsDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, td.sqlExec, td.mutation, td.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (td *TransactionsDelete) ExecX(ctx context.Context) int { + n, err := td.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (td *TransactionsDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(transactions.Table, sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt)) + if ps := td.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, td.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + td.mutation.done = true + return affected, err +} + +// TransactionsDeleteOne is the builder for deleting a single Transactions entity. +type TransactionsDeleteOne struct { + td *TransactionsDelete +} + +// Where appends a list predicates to the TransactionsDelete builder. +func (tdo *TransactionsDeleteOne) Where(ps ...predicate.Transactions) *TransactionsDeleteOne { + tdo.td.mutation.Where(ps...) + return tdo +} + +// Exec executes the deletion query. +func (tdo *TransactionsDeleteOne) Exec(ctx context.Context) error { + n, err := tdo.td.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{transactions.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (tdo *TransactionsDeleteOne) ExecX(ctx context.Context) { + if err := tdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/z2/backend/ent/transactions_query.go b/z2/backend/ent/transactions_query.go new file mode 100644 index 0000000..731f829 --- /dev/null +++ b/z2/backend/ent/transactions_query.go @@ -0,0 +1,741 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + "thesis/ent/blocks" + "thesis/ent/key" + "thesis/ent/predicate" + "thesis/ent/transactions" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// TransactionsQuery is the builder for querying Transactions entities. +type TransactionsQuery struct { + config + ctx *QueryContext + order []transactions.OrderOption + inters []Interceptor + predicates []predicate.Transactions + withSigner *KeyQuery + withBlock *BlocksQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the TransactionsQuery builder. +func (tq *TransactionsQuery) Where(ps ...predicate.Transactions) *TransactionsQuery { + tq.predicates = append(tq.predicates, ps...) + return tq +} + +// Limit the number of records to be returned by this query. +func (tq *TransactionsQuery) Limit(limit int) *TransactionsQuery { + tq.ctx.Limit = &limit + return tq +} + +// Offset to start from. +func (tq *TransactionsQuery) Offset(offset int) *TransactionsQuery { + tq.ctx.Offset = &offset + return tq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (tq *TransactionsQuery) Unique(unique bool) *TransactionsQuery { + tq.ctx.Unique = &unique + return tq +} + +// Order specifies how the records should be ordered. +func (tq *TransactionsQuery) Order(o ...transactions.OrderOption) *TransactionsQuery { + tq.order = append(tq.order, o...) + return tq +} + +// QuerySigner chains the current query on the "Signer" edge. +func (tq *TransactionsQuery) QuerySigner() *KeyQuery { + query := (&KeyClient{config: tq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := tq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := tq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(transactions.Table, transactions.FieldID, selector), + sqlgraph.To(key.Table, key.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, transactions.SignerTable, transactions.SignerPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(tq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryBlock chains the current query on the "Block" edge. +func (tq *TransactionsQuery) QueryBlock() *BlocksQuery { + query := (&BlocksClient{config: tq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := tq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := tq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(transactions.Table, transactions.FieldID, selector), + sqlgraph.To(blocks.Table, blocks.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, transactions.BlockTable, transactions.BlockPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(tq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Transactions entity from the query. +// Returns a *NotFoundError when no Transactions was found. +func (tq *TransactionsQuery) First(ctx context.Context) (*Transactions, error) { + nodes, err := tq.Limit(1).All(setContextOp(ctx, tq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{transactions.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (tq *TransactionsQuery) FirstX(ctx context.Context) *Transactions { + node, err := tq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Transactions ID from the query. +// Returns a *NotFoundError when no Transactions ID was found. +func (tq *TransactionsQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = tq.Limit(1).IDs(setContextOp(ctx, tq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{transactions.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (tq *TransactionsQuery) FirstIDX(ctx context.Context) int { + id, err := tq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Transactions entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Transactions entity is found. +// Returns a *NotFoundError when no Transactions entities are found. +func (tq *TransactionsQuery) Only(ctx context.Context) (*Transactions, error) { + nodes, err := tq.Limit(2).All(setContextOp(ctx, tq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{transactions.Label} + default: + return nil, &NotSingularError{transactions.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (tq *TransactionsQuery) OnlyX(ctx context.Context) *Transactions { + node, err := tq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Transactions ID in the query. +// Returns a *NotSingularError when more than one Transactions ID is found. +// Returns a *NotFoundError when no entities are found. +func (tq *TransactionsQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = tq.Limit(2).IDs(setContextOp(ctx, tq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{transactions.Label} + default: + err = &NotSingularError{transactions.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (tq *TransactionsQuery) OnlyIDX(ctx context.Context) int { + id, err := tq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of TransactionsSlice. +func (tq *TransactionsQuery) All(ctx context.Context) ([]*Transactions, error) { + ctx = setContextOp(ctx, tq.ctx, "All") + if err := tq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Transactions, *TransactionsQuery]() + return withInterceptors[[]*Transactions](ctx, tq, qr, tq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (tq *TransactionsQuery) AllX(ctx context.Context) []*Transactions { + nodes, err := tq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Transactions IDs. +func (tq *TransactionsQuery) IDs(ctx context.Context) (ids []int, err error) { + if tq.ctx.Unique == nil && tq.path != nil { + tq.Unique(true) + } + ctx = setContextOp(ctx, tq.ctx, "IDs") + if err = tq.Select(transactions.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (tq *TransactionsQuery) IDsX(ctx context.Context) []int { + ids, err := tq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (tq *TransactionsQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, tq.ctx, "Count") + if err := tq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, tq, querierCount[*TransactionsQuery](), tq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (tq *TransactionsQuery) CountX(ctx context.Context) int { + count, err := tq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (tq *TransactionsQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, tq.ctx, "Exist") + switch _, err := tq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (tq *TransactionsQuery) ExistX(ctx context.Context) bool { + exist, err := tq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the TransactionsQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (tq *TransactionsQuery) Clone() *TransactionsQuery { + if tq == nil { + return nil + } + return &TransactionsQuery{ + config: tq.config, + ctx: tq.ctx.Clone(), + order: append([]transactions.OrderOption{}, tq.order...), + inters: append([]Interceptor{}, tq.inters...), + predicates: append([]predicate.Transactions{}, tq.predicates...), + withSigner: tq.withSigner.Clone(), + withBlock: tq.withBlock.Clone(), + // clone intermediate query. + sql: tq.sql.Clone(), + path: tq.path, + } +} + +// WithSigner tells the query-builder to eager-load the nodes that are connected to +// the "Signer" edge. The optional arguments are used to configure the query builder of the edge. +func (tq *TransactionsQuery) WithSigner(opts ...func(*KeyQuery)) *TransactionsQuery { + query := (&KeyClient{config: tq.config}).Query() + for _, opt := range opts { + opt(query) + } + tq.withSigner = query + return tq +} + +// WithBlock tells the query-builder to eager-load the nodes that are connected to +// the "Block" edge. The optional arguments are used to configure the query builder of the edge. +func (tq *TransactionsQuery) WithBlock(opts ...func(*BlocksQuery)) *TransactionsQuery { + query := (&BlocksClient{config: tq.config}).Query() + for _, opt := range opts { + opt(query) + } + tq.withBlock = query + return tq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Type int `json:"type,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Transactions.Query(). +// GroupBy(transactions.FieldType). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (tq *TransactionsQuery) GroupBy(field string, fields ...string) *TransactionsGroupBy { + tq.ctx.Fields = append([]string{field}, fields...) + grbuild := &TransactionsGroupBy{build: tq} + grbuild.flds = &tq.ctx.Fields + grbuild.label = transactions.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Type int `json:"type,omitempty"` +// } +// +// client.Transactions.Query(). +// Select(transactions.FieldType). +// Scan(ctx, &v) +func (tq *TransactionsQuery) Select(fields ...string) *TransactionsSelect { + tq.ctx.Fields = append(tq.ctx.Fields, fields...) + sbuild := &TransactionsSelect{TransactionsQuery: tq} + sbuild.label = transactions.Label + sbuild.flds, sbuild.scan = &tq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a TransactionsSelect configured with the given aggregations. +func (tq *TransactionsQuery) Aggregate(fns ...AggregateFunc) *TransactionsSelect { + return tq.Select().Aggregate(fns...) +} + +func (tq *TransactionsQuery) prepareQuery(ctx context.Context) error { + for _, inter := range tq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, tq); err != nil { + return err + } + } + } + for _, f := range tq.ctx.Fields { + if !transactions.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if tq.path != nil { + prev, err := tq.path(ctx) + if err != nil { + return err + } + tq.sql = prev + } + return nil +} + +func (tq *TransactionsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Transactions, error) { + var ( + nodes = []*Transactions{} + _spec = tq.querySpec() + loadedTypes = [2]bool{ + tq.withSigner != nil, + tq.withBlock != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Transactions).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Transactions{config: tq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, tq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := tq.withSigner; query != nil { + if err := tq.loadSigner(ctx, query, nodes, + func(n *Transactions) { n.Edges.Signer = []*Key{} }, + func(n *Transactions, e *Key) { n.Edges.Signer = append(n.Edges.Signer, e) }); err != nil { + return nil, err + } + } + if query := tq.withBlock; query != nil { + if err := tq.loadBlock(ctx, query, nodes, + func(n *Transactions) { n.Edges.Block = []*Blocks{} }, + func(n *Transactions, e *Blocks) { n.Edges.Block = append(n.Edges.Block, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (tq *TransactionsQuery) loadSigner(ctx context.Context, query *KeyQuery, nodes []*Transactions, init func(*Transactions), assign func(*Transactions, *Key)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[int]*Transactions) + nids := make(map[int]map[*Transactions]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(transactions.SignerTable) + s.Join(joinT).On(s.C(key.FieldID), joinT.C(transactions.SignerPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(transactions.SignerPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(transactions.SignerPrimaryKey[1])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullInt64)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := int(values[0].(*sql.NullInt64).Int64) + inValue := int(values[1].(*sql.NullInt64).Int64) + if nids[inValue] == nil { + nids[inValue] = map[*Transactions]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Key](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "Signer" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (tq *TransactionsQuery) loadBlock(ctx context.Context, query *BlocksQuery, nodes []*Transactions, init func(*Transactions), assign func(*Transactions, *Blocks)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[int]*Transactions) + nids := make(map[int]map[*Transactions]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(transactions.BlockTable) + s.Join(joinT).On(s.C(blocks.FieldID), joinT.C(transactions.BlockPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(transactions.BlockPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(transactions.BlockPrimaryKey[1])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullInt64)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := int(values[0].(*sql.NullInt64).Int64) + inValue := int(values[1].(*sql.NullInt64).Int64) + if nids[inValue] == nil { + nids[inValue] = map[*Transactions]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Blocks](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "Block" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} + +func (tq *TransactionsQuery) sqlCount(ctx context.Context) (int, error) { + _spec := tq.querySpec() + _spec.Node.Columns = tq.ctx.Fields + if len(tq.ctx.Fields) > 0 { + _spec.Unique = tq.ctx.Unique != nil && *tq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, tq.driver, _spec) +} + +func (tq *TransactionsQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(transactions.Table, transactions.Columns, sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt)) + _spec.From = tq.sql + if unique := tq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if tq.path != nil { + _spec.Unique = true + } + if fields := tq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, transactions.FieldID) + for i := range fields { + if fields[i] != transactions.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := tq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := tq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := tq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := tq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (tq *TransactionsQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(tq.driver.Dialect()) + t1 := builder.Table(transactions.Table) + columns := tq.ctx.Fields + if len(columns) == 0 { + columns = transactions.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if tq.sql != nil { + selector = tq.sql + selector.Select(selector.Columns(columns...)...) + } + if tq.ctx.Unique != nil && *tq.ctx.Unique { + selector.Distinct() + } + for _, p := range tq.predicates { + p(selector) + } + for _, p := range tq.order { + p(selector) + } + if offset := tq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := tq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// TransactionsGroupBy is the group-by builder for Transactions entities. +type TransactionsGroupBy struct { + selector + build *TransactionsQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (tgb *TransactionsGroupBy) Aggregate(fns ...AggregateFunc) *TransactionsGroupBy { + tgb.fns = append(tgb.fns, fns...) + return tgb +} + +// Scan applies the selector query and scans the result into the given value. +func (tgb *TransactionsGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, tgb.build.ctx, "GroupBy") + if err := tgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*TransactionsQuery, *TransactionsGroupBy](ctx, tgb.build, tgb, tgb.build.inters, v) +} + +func (tgb *TransactionsGroupBy) sqlScan(ctx context.Context, root *TransactionsQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(tgb.fns)) + for _, fn := range tgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*tgb.flds)+len(tgb.fns)) + for _, f := range *tgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*tgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := tgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// TransactionsSelect is the builder for selecting fields of Transactions entities. +type TransactionsSelect struct { + *TransactionsQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (ts *TransactionsSelect) Aggregate(fns ...AggregateFunc) *TransactionsSelect { + ts.fns = append(ts.fns, fns...) + return ts +} + +// Scan applies the selector query and scans the result into the given value. +func (ts *TransactionsSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ts.ctx, "Select") + if err := ts.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*TransactionsQuery, *TransactionsSelect](ctx, ts.TransactionsQuery, ts, ts.inters, v) +} + +func (ts *TransactionsSelect) sqlScan(ctx context.Context, root *TransactionsQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(ts.fns)) + for _, fn := range ts.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*ts.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ts.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/z2/backend/ent/transactions_update.go b/z2/backend/ent/transactions_update.go new file mode 100644 index 0000000..ae9e04e --- /dev/null +++ b/z2/backend/ent/transactions_update.go @@ -0,0 +1,729 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "thesis/ent/blocks" + "thesis/ent/key" + "thesis/ent/predicate" + "thesis/ent/transactions" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// TransactionsUpdate is the builder for updating Transactions entities. +type TransactionsUpdate struct { + config + hooks []Hook + mutation *TransactionsMutation +} + +// Where appends a list predicates to the TransactionsUpdate builder. +func (tu *TransactionsUpdate) Where(ps ...predicate.Transactions) *TransactionsUpdate { + tu.mutation.Where(ps...) + return tu +} + +// SetType sets the "type" field. +func (tu *TransactionsUpdate) SetType(i int) *TransactionsUpdate { + tu.mutation.ResetType() + tu.mutation.SetType(i) + return tu +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (tu *TransactionsUpdate) SetNillableType(i *int) *TransactionsUpdate { + if i != nil { + tu.SetType(*i) + } + return tu +} + +// AddType adds i to the "type" field. +func (tu *TransactionsUpdate) AddType(i int) *TransactionsUpdate { + tu.mutation.AddType(i) + return tu +} + +// SetTimestamp sets the "timestamp" field. +func (tu *TransactionsUpdate) SetTimestamp(i int) *TransactionsUpdate { + tu.mutation.ResetTimestamp() + tu.mutation.SetTimestamp(i) + return tu +} + +// SetNillableTimestamp sets the "timestamp" field if the given value is not nil. +func (tu *TransactionsUpdate) SetNillableTimestamp(i *int) *TransactionsUpdate { + if i != nil { + tu.SetTimestamp(*i) + } + return tu +} + +// AddTimestamp adds i to the "timestamp" field. +func (tu *TransactionsUpdate) AddTimestamp(i int) *TransactionsUpdate { + tu.mutation.AddTimestamp(i) + return tu +} + +// SetComment sets the "comment" field. +func (tu *TransactionsUpdate) SetComment(s string) *TransactionsUpdate { + tu.mutation.SetComment(s) + return tu +} + +// SetNillableComment sets the "comment" field if the given value is not nil. +func (tu *TransactionsUpdate) SetNillableComment(s *string) *TransactionsUpdate { + if s != nil { + tu.SetComment(*s) + } + return tu +} + +// SetContent sets the "content" field. +func (tu *TransactionsUpdate) SetContent(b []byte) *TransactionsUpdate { + tu.mutation.SetContent(b) + return tu +} + +// SetHash sets the "hash" field. +func (tu *TransactionsUpdate) SetHash(s string) *TransactionsUpdate { + tu.mutation.SetHash(s) + return tu +} + +// SetNillableHash sets the "hash" field if the given value is not nil. +func (tu *TransactionsUpdate) SetNillableHash(s *string) *TransactionsUpdate { + if s != nil { + tu.SetHash(*s) + } + return tu +} + +// SetSignature sets the "signature" field. +func (tu *TransactionsUpdate) SetSignature(s string) *TransactionsUpdate { + tu.mutation.SetSignature(s) + return tu +} + +// SetNillableSignature sets the "signature" field if the given value is not nil. +func (tu *TransactionsUpdate) SetNillableSignature(s *string) *TransactionsUpdate { + if s != nil { + tu.SetSignature(*s) + } + return tu +} + +// AddSignerIDs adds the "Signer" edge to the Key entity by IDs. +func (tu *TransactionsUpdate) AddSignerIDs(ids ...int) *TransactionsUpdate { + tu.mutation.AddSignerIDs(ids...) + return tu +} + +// AddSigner adds the "Signer" edges to the Key entity. +func (tu *TransactionsUpdate) AddSigner(k ...*Key) *TransactionsUpdate { + ids := make([]int, len(k)) + for i := range k { + ids[i] = k[i].ID + } + return tu.AddSignerIDs(ids...) +} + +// AddBlockIDs adds the "Block" edge to the Blocks entity by IDs. +func (tu *TransactionsUpdate) AddBlockIDs(ids ...int) *TransactionsUpdate { + tu.mutation.AddBlockIDs(ids...) + return tu +} + +// AddBlock adds the "Block" edges to the Blocks entity. +func (tu *TransactionsUpdate) AddBlock(b ...*Blocks) *TransactionsUpdate { + ids := make([]int, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return tu.AddBlockIDs(ids...) +} + +// Mutation returns the TransactionsMutation object of the builder. +func (tu *TransactionsUpdate) Mutation() *TransactionsMutation { + return tu.mutation +} + +// ClearSigner clears all "Signer" edges to the Key entity. +func (tu *TransactionsUpdate) ClearSigner() *TransactionsUpdate { + tu.mutation.ClearSigner() + return tu +} + +// RemoveSignerIDs removes the "Signer" edge to Key entities by IDs. +func (tu *TransactionsUpdate) RemoveSignerIDs(ids ...int) *TransactionsUpdate { + tu.mutation.RemoveSignerIDs(ids...) + return tu +} + +// RemoveSigner removes "Signer" edges to Key entities. +func (tu *TransactionsUpdate) RemoveSigner(k ...*Key) *TransactionsUpdate { + ids := make([]int, len(k)) + for i := range k { + ids[i] = k[i].ID + } + return tu.RemoveSignerIDs(ids...) +} + +// ClearBlock clears all "Block" edges to the Blocks entity. +func (tu *TransactionsUpdate) ClearBlock() *TransactionsUpdate { + tu.mutation.ClearBlock() + return tu +} + +// RemoveBlockIDs removes the "Block" edge to Blocks entities by IDs. +func (tu *TransactionsUpdate) RemoveBlockIDs(ids ...int) *TransactionsUpdate { + tu.mutation.RemoveBlockIDs(ids...) + return tu +} + +// RemoveBlock removes "Block" edges to Blocks entities. +func (tu *TransactionsUpdate) RemoveBlock(b ...*Blocks) *TransactionsUpdate { + ids := make([]int, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return tu.RemoveBlockIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (tu *TransactionsUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, tu.sqlSave, tu.mutation, tu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (tu *TransactionsUpdate) SaveX(ctx context.Context) int { + affected, err := tu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (tu *TransactionsUpdate) Exec(ctx context.Context) error { + _, err := tu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (tu *TransactionsUpdate) ExecX(ctx context.Context) { + if err := tu.Exec(ctx); err != nil { + panic(err) + } +} + +func (tu *TransactionsUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := sqlgraph.NewUpdateSpec(transactions.Table, transactions.Columns, sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt)) + if ps := tu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := tu.mutation.GetType(); ok { + _spec.SetField(transactions.FieldType, field.TypeInt, value) + } + if value, ok := tu.mutation.AddedType(); ok { + _spec.AddField(transactions.FieldType, field.TypeInt, value) + } + if value, ok := tu.mutation.Timestamp(); ok { + _spec.SetField(transactions.FieldTimestamp, field.TypeInt, value) + } + if value, ok := tu.mutation.AddedTimestamp(); ok { + _spec.AddField(transactions.FieldTimestamp, field.TypeInt, value) + } + if value, ok := tu.mutation.Comment(); ok { + _spec.SetField(transactions.FieldComment, field.TypeString, value) + } + if value, ok := tu.mutation.Content(); ok { + _spec.SetField(transactions.FieldContent, field.TypeBytes, value) + } + if value, ok := tu.mutation.Hash(); ok { + _spec.SetField(transactions.FieldHash, field.TypeString, value) + } + if value, ok := tu.mutation.Signature(); ok { + _spec.SetField(transactions.FieldSignature, field.TypeString, value) + } + if tu.mutation.SignerCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: transactions.SignerTable, + Columns: transactions.SignerPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.RemovedSignerIDs(); len(nodes) > 0 && !tu.mutation.SignerCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: transactions.SignerTable, + Columns: transactions.SignerPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.SignerIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: transactions.SignerTable, + Columns: transactions.SignerPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if tu.mutation.BlockCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: transactions.BlockTable, + Columns: transactions.BlockPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(blocks.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.RemovedBlockIDs(); len(nodes) > 0 && !tu.mutation.BlockCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: transactions.BlockTable, + Columns: transactions.BlockPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(blocks.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.BlockIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: transactions.BlockTable, + Columns: transactions.BlockPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(blocks.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, tu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{transactions.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + tu.mutation.done = true + return n, nil +} + +// TransactionsUpdateOne is the builder for updating a single Transactions entity. +type TransactionsUpdateOne struct { + config + fields []string + hooks []Hook + mutation *TransactionsMutation +} + +// SetType sets the "type" field. +func (tuo *TransactionsUpdateOne) SetType(i int) *TransactionsUpdateOne { + tuo.mutation.ResetType() + tuo.mutation.SetType(i) + return tuo +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (tuo *TransactionsUpdateOne) SetNillableType(i *int) *TransactionsUpdateOne { + if i != nil { + tuo.SetType(*i) + } + return tuo +} + +// AddType adds i to the "type" field. +func (tuo *TransactionsUpdateOne) AddType(i int) *TransactionsUpdateOne { + tuo.mutation.AddType(i) + return tuo +} + +// SetTimestamp sets the "timestamp" field. +func (tuo *TransactionsUpdateOne) SetTimestamp(i int) *TransactionsUpdateOne { + tuo.mutation.ResetTimestamp() + tuo.mutation.SetTimestamp(i) + return tuo +} + +// SetNillableTimestamp sets the "timestamp" field if the given value is not nil. +func (tuo *TransactionsUpdateOne) SetNillableTimestamp(i *int) *TransactionsUpdateOne { + if i != nil { + tuo.SetTimestamp(*i) + } + return tuo +} + +// AddTimestamp adds i to the "timestamp" field. +func (tuo *TransactionsUpdateOne) AddTimestamp(i int) *TransactionsUpdateOne { + tuo.mutation.AddTimestamp(i) + return tuo +} + +// SetComment sets the "comment" field. +func (tuo *TransactionsUpdateOne) SetComment(s string) *TransactionsUpdateOne { + tuo.mutation.SetComment(s) + return tuo +} + +// SetNillableComment sets the "comment" field if the given value is not nil. +func (tuo *TransactionsUpdateOne) SetNillableComment(s *string) *TransactionsUpdateOne { + if s != nil { + tuo.SetComment(*s) + } + return tuo +} + +// SetContent sets the "content" field. +func (tuo *TransactionsUpdateOne) SetContent(b []byte) *TransactionsUpdateOne { + tuo.mutation.SetContent(b) + return tuo +} + +// SetHash sets the "hash" field. +func (tuo *TransactionsUpdateOne) SetHash(s string) *TransactionsUpdateOne { + tuo.mutation.SetHash(s) + return tuo +} + +// SetNillableHash sets the "hash" field if the given value is not nil. +func (tuo *TransactionsUpdateOne) SetNillableHash(s *string) *TransactionsUpdateOne { + if s != nil { + tuo.SetHash(*s) + } + return tuo +} + +// SetSignature sets the "signature" field. +func (tuo *TransactionsUpdateOne) SetSignature(s string) *TransactionsUpdateOne { + tuo.mutation.SetSignature(s) + return tuo +} + +// SetNillableSignature sets the "signature" field if the given value is not nil. +func (tuo *TransactionsUpdateOne) SetNillableSignature(s *string) *TransactionsUpdateOne { + if s != nil { + tuo.SetSignature(*s) + } + return tuo +} + +// AddSignerIDs adds the "Signer" edge to the Key entity by IDs. +func (tuo *TransactionsUpdateOne) AddSignerIDs(ids ...int) *TransactionsUpdateOne { + tuo.mutation.AddSignerIDs(ids...) + return tuo +} + +// AddSigner adds the "Signer" edges to the Key entity. +func (tuo *TransactionsUpdateOne) AddSigner(k ...*Key) *TransactionsUpdateOne { + ids := make([]int, len(k)) + for i := range k { + ids[i] = k[i].ID + } + return tuo.AddSignerIDs(ids...) +} + +// AddBlockIDs adds the "Block" edge to the Blocks entity by IDs. +func (tuo *TransactionsUpdateOne) AddBlockIDs(ids ...int) *TransactionsUpdateOne { + tuo.mutation.AddBlockIDs(ids...) + return tuo +} + +// AddBlock adds the "Block" edges to the Blocks entity. +func (tuo *TransactionsUpdateOne) AddBlock(b ...*Blocks) *TransactionsUpdateOne { + ids := make([]int, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return tuo.AddBlockIDs(ids...) +} + +// Mutation returns the TransactionsMutation object of the builder. +func (tuo *TransactionsUpdateOne) Mutation() *TransactionsMutation { + return tuo.mutation +} + +// ClearSigner clears all "Signer" edges to the Key entity. +func (tuo *TransactionsUpdateOne) ClearSigner() *TransactionsUpdateOne { + tuo.mutation.ClearSigner() + return tuo +} + +// RemoveSignerIDs removes the "Signer" edge to Key entities by IDs. +func (tuo *TransactionsUpdateOne) RemoveSignerIDs(ids ...int) *TransactionsUpdateOne { + tuo.mutation.RemoveSignerIDs(ids...) + return tuo +} + +// RemoveSigner removes "Signer" edges to Key entities. +func (tuo *TransactionsUpdateOne) RemoveSigner(k ...*Key) *TransactionsUpdateOne { + ids := make([]int, len(k)) + for i := range k { + ids[i] = k[i].ID + } + return tuo.RemoveSignerIDs(ids...) +} + +// ClearBlock clears all "Block" edges to the Blocks entity. +func (tuo *TransactionsUpdateOne) ClearBlock() *TransactionsUpdateOne { + tuo.mutation.ClearBlock() + return tuo +} + +// RemoveBlockIDs removes the "Block" edge to Blocks entities by IDs. +func (tuo *TransactionsUpdateOne) RemoveBlockIDs(ids ...int) *TransactionsUpdateOne { + tuo.mutation.RemoveBlockIDs(ids...) + return tuo +} + +// RemoveBlock removes "Block" edges to Blocks entities. +func (tuo *TransactionsUpdateOne) RemoveBlock(b ...*Blocks) *TransactionsUpdateOne { + ids := make([]int, len(b)) + for i := range b { + ids[i] = b[i].ID + } + return tuo.RemoveBlockIDs(ids...) +} + +// Where appends a list predicates to the TransactionsUpdate builder. +func (tuo *TransactionsUpdateOne) Where(ps ...predicate.Transactions) *TransactionsUpdateOne { + tuo.mutation.Where(ps...) + return tuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (tuo *TransactionsUpdateOne) Select(field string, fields ...string) *TransactionsUpdateOne { + tuo.fields = append([]string{field}, fields...) + return tuo +} + +// Save executes the query and returns the updated Transactions entity. +func (tuo *TransactionsUpdateOne) Save(ctx context.Context) (*Transactions, error) { + return withHooks(ctx, tuo.sqlSave, tuo.mutation, tuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (tuo *TransactionsUpdateOne) SaveX(ctx context.Context) *Transactions { + node, err := tuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (tuo *TransactionsUpdateOne) Exec(ctx context.Context) error { + _, err := tuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (tuo *TransactionsUpdateOne) ExecX(ctx context.Context) { + if err := tuo.Exec(ctx); err != nil { + panic(err) + } +} + +func (tuo *TransactionsUpdateOne) sqlSave(ctx context.Context) (_node *Transactions, err error) { + _spec := sqlgraph.NewUpdateSpec(transactions.Table, transactions.Columns, sqlgraph.NewFieldSpec(transactions.FieldID, field.TypeInt)) + id, ok := tuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Transactions.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := tuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, transactions.FieldID) + for _, f := range fields { + if !transactions.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != transactions.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := tuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := tuo.mutation.GetType(); ok { + _spec.SetField(transactions.FieldType, field.TypeInt, value) + } + if value, ok := tuo.mutation.AddedType(); ok { + _spec.AddField(transactions.FieldType, field.TypeInt, value) + } + if value, ok := tuo.mutation.Timestamp(); ok { + _spec.SetField(transactions.FieldTimestamp, field.TypeInt, value) + } + if value, ok := tuo.mutation.AddedTimestamp(); ok { + _spec.AddField(transactions.FieldTimestamp, field.TypeInt, value) + } + if value, ok := tuo.mutation.Comment(); ok { + _spec.SetField(transactions.FieldComment, field.TypeString, value) + } + if value, ok := tuo.mutation.Content(); ok { + _spec.SetField(transactions.FieldContent, field.TypeBytes, value) + } + if value, ok := tuo.mutation.Hash(); ok { + _spec.SetField(transactions.FieldHash, field.TypeString, value) + } + if value, ok := tuo.mutation.Signature(); ok { + _spec.SetField(transactions.FieldSignature, field.TypeString, value) + } + if tuo.mutation.SignerCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: transactions.SignerTable, + Columns: transactions.SignerPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.RemovedSignerIDs(); len(nodes) > 0 && !tuo.mutation.SignerCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: transactions.SignerTable, + Columns: transactions.SignerPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.SignerIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: transactions.SignerTable, + Columns: transactions.SignerPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if tuo.mutation.BlockCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: transactions.BlockTable, + Columns: transactions.BlockPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(blocks.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.RemovedBlockIDs(); len(nodes) > 0 && !tuo.mutation.BlockCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: transactions.BlockTable, + Columns: transactions.BlockPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(blocks.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.BlockIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: transactions.BlockTable, + Columns: transactions.BlockPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(blocks.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &Transactions{config: tuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, tuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{transactions.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + tuo.mutation.done = true + return _node, nil +} diff --git a/z2/backend/ent/tx.go b/z2/backend/ent/tx.go new file mode 100644 index 0000000..3d933b5 --- /dev/null +++ b/z2/backend/ent/tx.go @@ -0,0 +1,222 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "sync" + + "entgo.io/ent/dialect" +) + +// Tx is a transactional client that is created by calling Client.Tx(). +type Tx struct { + config + // Blocks is the client for interacting with the Blocks builders. + Blocks *BlocksClient + // Key is the client for interacting with the Key builders. + Key *KeyClient + // Transactions is the client for interacting with the Transactions builders. + Transactions *TransactionsClient + // Validators is the client for interacting with the Validators builders. + Validators *ValidatorsClient + // WhiteList is the client for interacting with the WhiteList builders. + WhiteList *WhiteListClient + + // lazily loaded. + client *Client + clientOnce sync.Once + // ctx lives for the life of the transaction. It is + // the same context used by the underlying connection. + ctx context.Context +} + +type ( + // Committer is the interface that wraps the Commit method. + Committer interface { + Commit(context.Context, *Tx) error + } + + // The CommitFunc type is an adapter to allow the use of ordinary + // function as a Committer. If f is a function with the appropriate + // signature, CommitFunc(f) is a Committer that calls f. + CommitFunc func(context.Context, *Tx) error + + // CommitHook defines the "commit middleware". A function that gets a Committer + // and returns a Committer. For example: + // + // hook := func(next ent.Committer) ent.Committer { + // return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error { + // // Do some stuff before. + // if err := next.Commit(ctx, tx); err != nil { + // return err + // } + // // Do some stuff after. + // return nil + // }) + // } + // + CommitHook func(Committer) Committer +) + +// Commit calls f(ctx, m). +func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error { + return f(ctx, tx) +} + +// Commit commits the transaction. +func (tx *Tx) Commit() error { + txDriver := tx.config.driver.(*txDriver) + var fn Committer = CommitFunc(func(context.Context, *Tx) error { + return txDriver.tx.Commit() + }) + txDriver.mu.Lock() + hooks := append([]CommitHook(nil), txDriver.onCommit...) + txDriver.mu.Unlock() + for i := len(hooks) - 1; i >= 0; i-- { + fn = hooks[i](fn) + } + return fn.Commit(tx.ctx, tx) +} + +// OnCommit adds a hook to call on commit. +func (tx *Tx) OnCommit(f CommitHook) { + txDriver := tx.config.driver.(*txDriver) + txDriver.mu.Lock() + txDriver.onCommit = append(txDriver.onCommit, f) + txDriver.mu.Unlock() +} + +type ( + // Rollbacker is the interface that wraps the Rollback method. + Rollbacker interface { + Rollback(context.Context, *Tx) error + } + + // The RollbackFunc type is an adapter to allow the use of ordinary + // function as a Rollbacker. If f is a function with the appropriate + // signature, RollbackFunc(f) is a Rollbacker that calls f. + RollbackFunc func(context.Context, *Tx) error + + // RollbackHook defines the "rollback middleware". A function that gets a Rollbacker + // and returns a Rollbacker. For example: + // + // hook := func(next ent.Rollbacker) ent.Rollbacker { + // return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error { + // // Do some stuff before. + // if err := next.Rollback(ctx, tx); err != nil { + // return err + // } + // // Do some stuff after. + // return nil + // }) + // } + // + RollbackHook func(Rollbacker) Rollbacker +) + +// Rollback calls f(ctx, m). +func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error { + return f(ctx, tx) +} + +// Rollback rollbacks the transaction. +func (tx *Tx) Rollback() error { + txDriver := tx.config.driver.(*txDriver) + var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error { + return txDriver.tx.Rollback() + }) + txDriver.mu.Lock() + hooks := append([]RollbackHook(nil), txDriver.onRollback...) + txDriver.mu.Unlock() + for i := len(hooks) - 1; i >= 0; i-- { + fn = hooks[i](fn) + } + return fn.Rollback(tx.ctx, tx) +} + +// OnRollback adds a hook to call on rollback. +func (tx *Tx) OnRollback(f RollbackHook) { + txDriver := tx.config.driver.(*txDriver) + txDriver.mu.Lock() + txDriver.onRollback = append(txDriver.onRollback, f) + txDriver.mu.Unlock() +} + +// Client returns a Client that binds to current transaction. +func (tx *Tx) Client() *Client { + tx.clientOnce.Do(func() { + tx.client = &Client{config: tx.config} + tx.client.init() + }) + return tx.client +} + +func (tx *Tx) init() { + tx.Blocks = NewBlocksClient(tx.config) + tx.Key = NewKeyClient(tx.config) + tx.Transactions = NewTransactionsClient(tx.config) + tx.Validators = NewValidatorsClient(tx.config) + tx.WhiteList = NewWhiteListClient(tx.config) +} + +// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. +// The idea is to support transactions without adding any extra code to the builders. +// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance. +// Commit and Rollback are nop for the internal builders and the user must call one +// of them in order to commit or rollback the transaction. +// +// If a closed transaction is embedded in one of the generated entities, and the entity +// applies a query, for example: Blocks.QueryXXX(), the query will be executed +// through the driver which created this transaction. +// +// Note that txDriver is not goroutine safe. +type txDriver struct { + // the driver we started the transaction from. + drv dialect.Driver + // tx is the underlying transaction. + tx dialect.Tx + // completion hooks. + mu sync.Mutex + onCommit []CommitHook + onRollback []RollbackHook +} + +// newTx creates a new transactional driver. +func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) { + tx, err := drv.Tx(ctx) + if err != nil { + return nil, err + } + return &txDriver{tx: tx, drv: drv}, nil +} + +// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls +// from the internal builders. Should be called only by the internal builders. +func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil } + +// Dialect returns the dialect of the driver we started the transaction from. +func (tx *txDriver) Dialect() string { return tx.drv.Dialect() } + +// Close is a nop close. +func (*txDriver) Close() error { return nil } + +// Commit is a nop commit for the internal builders. +// User must call `Tx.Commit` in order to commit the transaction. +func (*txDriver) Commit() error { return nil } + +// Rollback is a nop rollback for the internal builders. +// User must call `Tx.Rollback` in order to rollback the transaction. +func (*txDriver) Rollback() error { return nil } + +// Exec calls tx.Exec. +func (tx *txDriver) Exec(ctx context.Context, query string, args, v any) error { + return tx.tx.Exec(ctx, query, args, v) +} + +// Query calls tx.Query. +func (tx *txDriver) Query(ctx context.Context, query string, args, v any) error { + return tx.tx.Query(ctx, query, args, v) +} + +var _ dialect.Driver = (*txDriver)(nil) diff --git a/z2/backend/ent/validators.go b/z2/backend/ent/validators.go new file mode 100644 index 0000000..54a6c27 --- /dev/null +++ b/z2/backend/ent/validators.go @@ -0,0 +1,149 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "thesis/ent/validators" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// Validators is the model entity for the Validators schema. +type Validators struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Facilitator holds the value of the "facilitator" field. + Facilitator string `json:"facilitator,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ValidatorsQuery when eager-loading is set. + Edges ValidatorsEdges `json:"edges"` + blocks_caster *int + white_list_sponsor *int + selectValues sql.SelectValues +} + +// ValidatorsEdges holds the relations/edges for other nodes in the graph. +type ValidatorsEdges struct { + // Key holds the value of the key edge. + Key []*Key `json:"key,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// KeyOrErr returns the Key value or an error if the edge +// was not loaded in eager-loading. +func (e ValidatorsEdges) KeyOrErr() ([]*Key, error) { + if e.loadedTypes[0] { + return e.Key, nil + } + return nil, &NotLoadedError{edge: "key"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Validators) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case validators.FieldID: + values[i] = new(sql.NullInt64) + case validators.FieldFacilitator: + values[i] = new(sql.NullString) + case validators.ForeignKeys[0]: // blocks_caster + values[i] = new(sql.NullInt64) + case validators.ForeignKeys[1]: // white_list_sponsor + values[i] = new(sql.NullInt64) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Validators fields. +func (v *Validators) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case validators.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + v.ID = int(value.Int64) + case validators.FieldFacilitator: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field facilitator", values[i]) + } else if value.Valid { + v.Facilitator = value.String + } + case validators.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field blocks_caster", value) + } else if value.Valid { + v.blocks_caster = new(int) + *v.blocks_caster = int(value.Int64) + } + case validators.ForeignKeys[1]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field white_list_sponsor", value) + } else if value.Valid { + v.white_list_sponsor = new(int) + *v.white_list_sponsor = int(value.Int64) + } + default: + v.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Validators. +// This includes values selected through modifiers, order, etc. +func (v *Validators) Value(name string) (ent.Value, error) { + return v.selectValues.Get(name) +} + +// QueryKey queries the "key" edge of the Validators entity. +func (v *Validators) QueryKey() *KeyQuery { + return NewValidatorsClient(v.config).QueryKey(v) +} + +// Update returns a builder for updating this Validators. +// Note that you need to call Validators.Unwrap() before calling this method if this Validators +// was returned from a transaction, and the transaction was committed or rolled back. +func (v *Validators) Update() *ValidatorsUpdateOne { + return NewValidatorsClient(v.config).UpdateOne(v) +} + +// Unwrap unwraps the Validators entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (v *Validators) Unwrap() *Validators { + _tx, ok := v.config.driver.(*txDriver) + if !ok { + panic("ent: Validators is not a transactional entity") + } + v.config.driver = _tx.drv + return v +} + +// String implements the fmt.Stringer. +func (v *Validators) String() string { + var builder strings.Builder + builder.WriteString("Validators(") + builder.WriteString(fmt.Sprintf("id=%v, ", v.ID)) + builder.WriteString("facilitator=") + builder.WriteString(v.Facilitator) + builder.WriteByte(')') + return builder.String() +} + +// ValidatorsSlice is a parsable slice of Validators. +type ValidatorsSlice []*Validators diff --git a/z2/backend/ent/validators/validators.go b/z2/backend/ent/validators/validators.go new file mode 100644 index 0000000..8df4656 --- /dev/null +++ b/z2/backend/ent/validators/validators.go @@ -0,0 +1,95 @@ +// Code generated by ent, DO NOT EDIT. + +package validators + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the validators type in the database. + Label = "validators" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldFacilitator holds the string denoting the facilitator field in the database. + FieldFacilitator = "facilitator" + // EdgeKey holds the string denoting the key edge name in mutations. + EdgeKey = "key" + // Table holds the table name of the validators in the database. + Table = "validators" + // KeyTable is the table that holds the key relation/edge. + KeyTable = "keys" + // KeyInverseTable is the table name for the Key entity. + // It exists in this package in order to avoid circular dependency with the "key" package. + KeyInverseTable = "keys" + // KeyColumn is the table column denoting the key relation/edge. + KeyColumn = "validators_key" +) + +// Columns holds all SQL columns for validators fields. +var Columns = []string{ + FieldID, + FieldFacilitator, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "validators" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "blocks_caster", + "white_list_sponsor", +} + +// 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 ( + // FacilitatorValidator is a validator for the "facilitator" field. It is called by the builders before save. + FacilitatorValidator func(string) error +) + +// OrderOption defines the ordering options for the Validators 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() +} + +// ByFacilitator orders the results by the facilitator field. +func ByFacilitator(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFacilitator, opts...).ToFunc() +} + +// ByKeyCount orders the results by key count. +func ByKeyCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newKeyStep(), opts...) + } +} + +// ByKey orders the results by key terms. +func ByKey(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newKeyStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newKeyStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(KeyInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, KeyTable, KeyColumn), + ) +} diff --git a/z2/backend/ent/validators/where.go b/z2/backend/ent/validators/where.go new file mode 100644 index 0000000..187a411 --- /dev/null +++ b/z2/backend/ent/validators/where.go @@ -0,0 +1,163 @@ +// Code generated by ent, DO NOT EDIT. + +package validators + +import ( + "thesis/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.Validators { + return predicate.Validators(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Validators { + return predicate.Validators(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Validators { + return predicate.Validators(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Validators { + return predicate.Validators(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Validators { + return predicate.Validators(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Validators { + return predicate.Validators(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Validators { + return predicate.Validators(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Validators { + return predicate.Validators(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Validators { + return predicate.Validators(sql.FieldLTE(FieldID, id)) +} + +// Facilitator applies equality check predicate on the "facilitator" field. It's identical to FacilitatorEQ. +func Facilitator(v string) predicate.Validators { + return predicate.Validators(sql.FieldEQ(FieldFacilitator, v)) +} + +// FacilitatorEQ applies the EQ predicate on the "facilitator" field. +func FacilitatorEQ(v string) predicate.Validators { + return predicate.Validators(sql.FieldEQ(FieldFacilitator, v)) +} + +// FacilitatorNEQ applies the NEQ predicate on the "facilitator" field. +func FacilitatorNEQ(v string) predicate.Validators { + return predicate.Validators(sql.FieldNEQ(FieldFacilitator, v)) +} + +// FacilitatorIn applies the In predicate on the "facilitator" field. +func FacilitatorIn(vs ...string) predicate.Validators { + return predicate.Validators(sql.FieldIn(FieldFacilitator, vs...)) +} + +// FacilitatorNotIn applies the NotIn predicate on the "facilitator" field. +func FacilitatorNotIn(vs ...string) predicate.Validators { + return predicate.Validators(sql.FieldNotIn(FieldFacilitator, vs...)) +} + +// FacilitatorGT applies the GT predicate on the "facilitator" field. +func FacilitatorGT(v string) predicate.Validators { + return predicate.Validators(sql.FieldGT(FieldFacilitator, v)) +} + +// FacilitatorGTE applies the GTE predicate on the "facilitator" field. +func FacilitatorGTE(v string) predicate.Validators { + return predicate.Validators(sql.FieldGTE(FieldFacilitator, v)) +} + +// FacilitatorLT applies the LT predicate on the "facilitator" field. +func FacilitatorLT(v string) predicate.Validators { + return predicate.Validators(sql.FieldLT(FieldFacilitator, v)) +} + +// FacilitatorLTE applies the LTE predicate on the "facilitator" field. +func FacilitatorLTE(v string) predicate.Validators { + return predicate.Validators(sql.FieldLTE(FieldFacilitator, v)) +} + +// FacilitatorContains applies the Contains predicate on the "facilitator" field. +func FacilitatorContains(v string) predicate.Validators { + return predicate.Validators(sql.FieldContains(FieldFacilitator, v)) +} + +// FacilitatorHasPrefix applies the HasPrefix predicate on the "facilitator" field. +func FacilitatorHasPrefix(v string) predicate.Validators { + return predicate.Validators(sql.FieldHasPrefix(FieldFacilitator, v)) +} + +// FacilitatorHasSuffix applies the HasSuffix predicate on the "facilitator" field. +func FacilitatorHasSuffix(v string) predicate.Validators { + return predicate.Validators(sql.FieldHasSuffix(FieldFacilitator, v)) +} + +// FacilitatorEqualFold applies the EqualFold predicate on the "facilitator" field. +func FacilitatorEqualFold(v string) predicate.Validators { + return predicate.Validators(sql.FieldEqualFold(FieldFacilitator, v)) +} + +// FacilitatorContainsFold applies the ContainsFold predicate on the "facilitator" field. +func FacilitatorContainsFold(v string) predicate.Validators { + return predicate.Validators(sql.FieldContainsFold(FieldFacilitator, v)) +} + +// HasKey applies the HasEdge predicate on the "key" edge. +func HasKey() predicate.Validators { + return predicate.Validators(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, KeyTable, KeyColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasKeyWith applies the HasEdge predicate on the "key" edge with a given conditions (other predicates). +func HasKeyWith(preds ...predicate.Key) predicate.Validators { + return predicate.Validators(func(s *sql.Selector) { + step := newKeyStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Validators) predicate.Validators { + return predicate.Validators(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Validators) predicate.Validators { + return predicate.Validators(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Validators) predicate.Validators { + return predicate.Validators(sql.NotPredicates(p)) +} diff --git a/z2/backend/ent/validators_create.go b/z2/backend/ent/validators_create.go new file mode 100644 index 0000000..bde6b72 --- /dev/null +++ b/z2/backend/ent/validators_create.go @@ -0,0 +1,220 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "thesis/ent/key" + "thesis/ent/validators" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ValidatorsCreate is the builder for creating a Validators entity. +type ValidatorsCreate struct { + config + mutation *ValidatorsMutation + hooks []Hook +} + +// SetFacilitator sets the "facilitator" field. +func (vc *ValidatorsCreate) SetFacilitator(s string) *ValidatorsCreate { + vc.mutation.SetFacilitator(s) + return vc +} + +// AddKeyIDs adds the "key" edge to the Key entity by IDs. +func (vc *ValidatorsCreate) AddKeyIDs(ids ...int) *ValidatorsCreate { + vc.mutation.AddKeyIDs(ids...) + return vc +} + +// AddKey adds the "key" edges to the Key entity. +func (vc *ValidatorsCreate) AddKey(k ...*Key) *ValidatorsCreate { + ids := make([]int, len(k)) + for i := range k { + ids[i] = k[i].ID + } + return vc.AddKeyIDs(ids...) +} + +// Mutation returns the ValidatorsMutation object of the builder. +func (vc *ValidatorsCreate) Mutation() *ValidatorsMutation { + return vc.mutation +} + +// Save creates the Validators in the database. +func (vc *ValidatorsCreate) Save(ctx context.Context) (*Validators, error) { + return withHooks(ctx, vc.sqlSave, vc.mutation, vc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (vc *ValidatorsCreate) SaveX(ctx context.Context) *Validators { + v, err := vc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (vc *ValidatorsCreate) Exec(ctx context.Context) error { + _, err := vc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (vc *ValidatorsCreate) ExecX(ctx context.Context) { + if err := vc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (vc *ValidatorsCreate) check() error { + if _, ok := vc.mutation.Facilitator(); !ok { + return &ValidationError{Name: "facilitator", err: errors.New(`ent: missing required field "Validators.facilitator"`)} + } + if v, ok := vc.mutation.Facilitator(); ok { + if err := validators.FacilitatorValidator(v); err != nil { + return &ValidationError{Name: "facilitator", err: fmt.Errorf(`ent: validator failed for field "Validators.facilitator": %w`, err)} + } + } + return nil +} + +func (vc *ValidatorsCreate) sqlSave(ctx context.Context) (*Validators, error) { + if err := vc.check(); err != nil { + return nil, err + } + _node, _spec := vc.createSpec() + if err := sqlgraph.CreateNode(ctx, vc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + vc.mutation.id = &_node.ID + vc.mutation.done = true + return _node, nil +} + +func (vc *ValidatorsCreate) createSpec() (*Validators, *sqlgraph.CreateSpec) { + var ( + _node = &Validators{config: vc.config} + _spec = sqlgraph.NewCreateSpec(validators.Table, sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt)) + ) + if value, ok := vc.mutation.Facilitator(); ok { + _spec.SetField(validators.FieldFacilitator, field.TypeString, value) + _node.Facilitator = value + } + if nodes := vc.mutation.KeyIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: validators.KeyTable, + Columns: []string{validators.KeyColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// ValidatorsCreateBulk is the builder for creating many Validators entities in bulk. +type ValidatorsCreateBulk struct { + config + err error + builders []*ValidatorsCreate +} + +// Save creates the Validators entities in the database. +func (vcb *ValidatorsCreateBulk) Save(ctx context.Context) ([]*Validators, error) { + if vcb.err != nil { + return nil, vcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(vcb.builders)) + nodes := make([]*Validators, len(vcb.builders)) + mutators := make([]Mutator, len(vcb.builders)) + for i := range vcb.builders { + func(i int, root context.Context) { + builder := vcb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ValidatorsMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, vcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, vcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, vcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (vcb *ValidatorsCreateBulk) SaveX(ctx context.Context) []*Validators { + v, err := vcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (vcb *ValidatorsCreateBulk) Exec(ctx context.Context) error { + _, err := vcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (vcb *ValidatorsCreateBulk) ExecX(ctx context.Context) { + if err := vcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/z2/backend/ent/validators_delete.go b/z2/backend/ent/validators_delete.go new file mode 100644 index 0000000..8ff89ab --- /dev/null +++ b/z2/backend/ent/validators_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "thesis/ent/predicate" + "thesis/ent/validators" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ValidatorsDelete is the builder for deleting a Validators entity. +type ValidatorsDelete struct { + config + hooks []Hook + mutation *ValidatorsMutation +} + +// Where appends a list predicates to the ValidatorsDelete builder. +func (vd *ValidatorsDelete) Where(ps ...predicate.Validators) *ValidatorsDelete { + vd.mutation.Where(ps...) + return vd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (vd *ValidatorsDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, vd.sqlExec, vd.mutation, vd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (vd *ValidatorsDelete) ExecX(ctx context.Context) int { + n, err := vd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (vd *ValidatorsDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(validators.Table, sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt)) + if ps := vd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, vd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + vd.mutation.done = true + return affected, err +} + +// ValidatorsDeleteOne is the builder for deleting a single Validators entity. +type ValidatorsDeleteOne struct { + vd *ValidatorsDelete +} + +// Where appends a list predicates to the ValidatorsDelete builder. +func (vdo *ValidatorsDeleteOne) Where(ps ...predicate.Validators) *ValidatorsDeleteOne { + vdo.vd.mutation.Where(ps...) + return vdo +} + +// Exec executes the deletion query. +func (vdo *ValidatorsDeleteOne) Exec(ctx context.Context) error { + n, err := vdo.vd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{validators.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (vdo *ValidatorsDeleteOne) ExecX(ctx context.Context) { + if err := vdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/z2/backend/ent/validators_query.go b/z2/backend/ent/validators_query.go new file mode 100644 index 0000000..b2c9663 --- /dev/null +++ b/z2/backend/ent/validators_query.go @@ -0,0 +1,611 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + "thesis/ent/key" + "thesis/ent/predicate" + "thesis/ent/validators" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ValidatorsQuery is the builder for querying Validators entities. +type ValidatorsQuery struct { + config + ctx *QueryContext + order []validators.OrderOption + inters []Interceptor + predicates []predicate.Validators + withKey *KeyQuery + withFKs bool + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ValidatorsQuery builder. +func (vq *ValidatorsQuery) Where(ps ...predicate.Validators) *ValidatorsQuery { + vq.predicates = append(vq.predicates, ps...) + return vq +} + +// Limit the number of records to be returned by this query. +func (vq *ValidatorsQuery) Limit(limit int) *ValidatorsQuery { + vq.ctx.Limit = &limit + return vq +} + +// Offset to start from. +func (vq *ValidatorsQuery) Offset(offset int) *ValidatorsQuery { + vq.ctx.Offset = &offset + return vq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (vq *ValidatorsQuery) Unique(unique bool) *ValidatorsQuery { + vq.ctx.Unique = &unique + return vq +} + +// Order specifies how the records should be ordered. +func (vq *ValidatorsQuery) Order(o ...validators.OrderOption) *ValidatorsQuery { + vq.order = append(vq.order, o...) + return vq +} + +// QueryKey chains the current query on the "key" edge. +func (vq *ValidatorsQuery) QueryKey() *KeyQuery { + query := (&KeyClient{config: vq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := vq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := vq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(validators.Table, validators.FieldID, selector), + sqlgraph.To(key.Table, key.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, validators.KeyTable, validators.KeyColumn), + ) + fromU = sqlgraph.SetNeighbors(vq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Validators entity from the query. +// Returns a *NotFoundError when no Validators was found. +func (vq *ValidatorsQuery) First(ctx context.Context) (*Validators, error) { + nodes, err := vq.Limit(1).All(setContextOp(ctx, vq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{validators.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (vq *ValidatorsQuery) FirstX(ctx context.Context) *Validators { + node, err := vq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Validators ID from the query. +// Returns a *NotFoundError when no Validators ID was found. +func (vq *ValidatorsQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = vq.Limit(1).IDs(setContextOp(ctx, vq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{validators.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (vq *ValidatorsQuery) FirstIDX(ctx context.Context) int { + id, err := vq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Validators entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Validators entity is found. +// Returns a *NotFoundError when no Validators entities are found. +func (vq *ValidatorsQuery) Only(ctx context.Context) (*Validators, error) { + nodes, err := vq.Limit(2).All(setContextOp(ctx, vq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{validators.Label} + default: + return nil, &NotSingularError{validators.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (vq *ValidatorsQuery) OnlyX(ctx context.Context) *Validators { + node, err := vq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Validators ID in the query. +// Returns a *NotSingularError when more than one Validators ID is found. +// Returns a *NotFoundError when no entities are found. +func (vq *ValidatorsQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = vq.Limit(2).IDs(setContextOp(ctx, vq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{validators.Label} + default: + err = &NotSingularError{validators.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (vq *ValidatorsQuery) OnlyIDX(ctx context.Context) int { + id, err := vq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of ValidatorsSlice. +func (vq *ValidatorsQuery) All(ctx context.Context) ([]*Validators, error) { + ctx = setContextOp(ctx, vq.ctx, "All") + if err := vq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Validators, *ValidatorsQuery]() + return withInterceptors[[]*Validators](ctx, vq, qr, vq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (vq *ValidatorsQuery) AllX(ctx context.Context) []*Validators { + nodes, err := vq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Validators IDs. +func (vq *ValidatorsQuery) IDs(ctx context.Context) (ids []int, err error) { + if vq.ctx.Unique == nil && vq.path != nil { + vq.Unique(true) + } + ctx = setContextOp(ctx, vq.ctx, "IDs") + if err = vq.Select(validators.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (vq *ValidatorsQuery) IDsX(ctx context.Context) []int { + ids, err := vq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (vq *ValidatorsQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, vq.ctx, "Count") + if err := vq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, vq, querierCount[*ValidatorsQuery](), vq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (vq *ValidatorsQuery) CountX(ctx context.Context) int { + count, err := vq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (vq *ValidatorsQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, vq.ctx, "Exist") + switch _, err := vq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (vq *ValidatorsQuery) ExistX(ctx context.Context) bool { + exist, err := vq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ValidatorsQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (vq *ValidatorsQuery) Clone() *ValidatorsQuery { + if vq == nil { + return nil + } + return &ValidatorsQuery{ + config: vq.config, + ctx: vq.ctx.Clone(), + order: append([]validators.OrderOption{}, vq.order...), + inters: append([]Interceptor{}, vq.inters...), + predicates: append([]predicate.Validators{}, vq.predicates...), + withKey: vq.withKey.Clone(), + // clone intermediate query. + sql: vq.sql.Clone(), + path: vq.path, + } +} + +// WithKey tells the query-builder to eager-load the nodes that are connected to +// the "key" edge. The optional arguments are used to configure the query builder of the edge. +func (vq *ValidatorsQuery) WithKey(opts ...func(*KeyQuery)) *ValidatorsQuery { + query := (&KeyClient{config: vq.config}).Query() + for _, opt := range opts { + opt(query) + } + vq.withKey = query + return vq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Facilitator string `json:"facilitator,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Validators.Query(). +// GroupBy(validators.FieldFacilitator). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (vq *ValidatorsQuery) GroupBy(field string, fields ...string) *ValidatorsGroupBy { + vq.ctx.Fields = append([]string{field}, fields...) + grbuild := &ValidatorsGroupBy{build: vq} + grbuild.flds = &vq.ctx.Fields + grbuild.label = validators.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Facilitator string `json:"facilitator,omitempty"` +// } +// +// client.Validators.Query(). +// Select(validators.FieldFacilitator). +// Scan(ctx, &v) +func (vq *ValidatorsQuery) Select(fields ...string) *ValidatorsSelect { + vq.ctx.Fields = append(vq.ctx.Fields, fields...) + sbuild := &ValidatorsSelect{ValidatorsQuery: vq} + sbuild.label = validators.Label + sbuild.flds, sbuild.scan = &vq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ValidatorsSelect configured with the given aggregations. +func (vq *ValidatorsQuery) Aggregate(fns ...AggregateFunc) *ValidatorsSelect { + return vq.Select().Aggregate(fns...) +} + +func (vq *ValidatorsQuery) prepareQuery(ctx context.Context) error { + for _, inter := range vq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, vq); err != nil { + return err + } + } + } + for _, f := range vq.ctx.Fields { + if !validators.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if vq.path != nil { + prev, err := vq.path(ctx) + if err != nil { + return err + } + vq.sql = prev + } + return nil +} + +func (vq *ValidatorsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Validators, error) { + var ( + nodes = []*Validators{} + withFKs = vq.withFKs + _spec = vq.querySpec() + loadedTypes = [1]bool{ + vq.withKey != nil, + } + ) + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, validators.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Validators).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Validators{config: vq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, vq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := vq.withKey; query != nil { + if err := vq.loadKey(ctx, query, nodes, + func(n *Validators) { n.Edges.Key = []*Key{} }, + func(n *Validators, e *Key) { n.Edges.Key = append(n.Edges.Key, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (vq *ValidatorsQuery) loadKey(ctx context.Context, query *KeyQuery, nodes []*Validators, init func(*Validators), assign func(*Validators, *Key)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*Validators) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.Key(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(validators.KeyColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.validators_key + if fk == nil { + return fmt.Errorf(`foreign-key "validators_key" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "validators_key" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (vq *ValidatorsQuery) sqlCount(ctx context.Context) (int, error) { + _spec := vq.querySpec() + _spec.Node.Columns = vq.ctx.Fields + if len(vq.ctx.Fields) > 0 { + _spec.Unique = vq.ctx.Unique != nil && *vq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, vq.driver, _spec) +} + +func (vq *ValidatorsQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(validators.Table, validators.Columns, sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt)) + _spec.From = vq.sql + if unique := vq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if vq.path != nil { + _spec.Unique = true + } + if fields := vq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, validators.FieldID) + for i := range fields { + if fields[i] != validators.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := vq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := vq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := vq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := vq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (vq *ValidatorsQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(vq.driver.Dialect()) + t1 := builder.Table(validators.Table) + columns := vq.ctx.Fields + if len(columns) == 0 { + columns = validators.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if vq.sql != nil { + selector = vq.sql + selector.Select(selector.Columns(columns...)...) + } + if vq.ctx.Unique != nil && *vq.ctx.Unique { + selector.Distinct() + } + for _, p := range vq.predicates { + p(selector) + } + for _, p := range vq.order { + p(selector) + } + if offset := vq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := vq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ValidatorsGroupBy is the group-by builder for Validators entities. +type ValidatorsGroupBy struct { + selector + build *ValidatorsQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (vgb *ValidatorsGroupBy) Aggregate(fns ...AggregateFunc) *ValidatorsGroupBy { + vgb.fns = append(vgb.fns, fns...) + return vgb +} + +// Scan applies the selector query and scans the result into the given value. +func (vgb *ValidatorsGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, vgb.build.ctx, "GroupBy") + if err := vgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ValidatorsQuery, *ValidatorsGroupBy](ctx, vgb.build, vgb, vgb.build.inters, v) +} + +func (vgb *ValidatorsGroupBy) sqlScan(ctx context.Context, root *ValidatorsQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(vgb.fns)) + for _, fn := range vgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*vgb.flds)+len(vgb.fns)) + for _, f := range *vgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*vgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := vgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ValidatorsSelect is the builder for selecting fields of Validators entities. +type ValidatorsSelect struct { + *ValidatorsQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (vs *ValidatorsSelect) Aggregate(fns ...AggregateFunc) *ValidatorsSelect { + vs.fns = append(vs.fns, fns...) + return vs +} + +// Scan applies the selector query and scans the result into the given value. +func (vs *ValidatorsSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, vs.ctx, "Select") + if err := vs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ValidatorsQuery, *ValidatorsSelect](ctx, vs.ValidatorsQuery, vs, vs.inters, v) +} + +func (vs *ValidatorsSelect) sqlScan(ctx context.Context, root *ValidatorsQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(vs.fns)) + for _, fn := range vs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*vs.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := vs.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/z2/backend/ent/validators_update.go b/z2/backend/ent/validators_update.go new file mode 100644 index 0000000..fabc25f --- /dev/null +++ b/z2/backend/ent/validators_update.go @@ -0,0 +1,398 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "thesis/ent/key" + "thesis/ent/predicate" + "thesis/ent/validators" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ValidatorsUpdate is the builder for updating Validators entities. +type ValidatorsUpdate struct { + config + hooks []Hook + mutation *ValidatorsMutation +} + +// Where appends a list predicates to the ValidatorsUpdate builder. +func (vu *ValidatorsUpdate) Where(ps ...predicate.Validators) *ValidatorsUpdate { + vu.mutation.Where(ps...) + return vu +} + +// SetFacilitator sets the "facilitator" field. +func (vu *ValidatorsUpdate) SetFacilitator(s string) *ValidatorsUpdate { + vu.mutation.SetFacilitator(s) + return vu +} + +// SetNillableFacilitator sets the "facilitator" field if the given value is not nil. +func (vu *ValidatorsUpdate) SetNillableFacilitator(s *string) *ValidatorsUpdate { + if s != nil { + vu.SetFacilitator(*s) + } + return vu +} + +// AddKeyIDs adds the "key" edge to the Key entity by IDs. +func (vu *ValidatorsUpdate) AddKeyIDs(ids ...int) *ValidatorsUpdate { + vu.mutation.AddKeyIDs(ids...) + return vu +} + +// AddKey adds the "key" edges to the Key entity. +func (vu *ValidatorsUpdate) AddKey(k ...*Key) *ValidatorsUpdate { + ids := make([]int, len(k)) + for i := range k { + ids[i] = k[i].ID + } + return vu.AddKeyIDs(ids...) +} + +// Mutation returns the ValidatorsMutation object of the builder. +func (vu *ValidatorsUpdate) Mutation() *ValidatorsMutation { + return vu.mutation +} + +// ClearKey clears all "key" edges to the Key entity. +func (vu *ValidatorsUpdate) ClearKey() *ValidatorsUpdate { + vu.mutation.ClearKey() + return vu +} + +// RemoveKeyIDs removes the "key" edge to Key entities by IDs. +func (vu *ValidatorsUpdate) RemoveKeyIDs(ids ...int) *ValidatorsUpdate { + vu.mutation.RemoveKeyIDs(ids...) + return vu +} + +// RemoveKey removes "key" edges to Key entities. +func (vu *ValidatorsUpdate) RemoveKey(k ...*Key) *ValidatorsUpdate { + ids := make([]int, len(k)) + for i := range k { + ids[i] = k[i].ID + } + return vu.RemoveKeyIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (vu *ValidatorsUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, vu.sqlSave, vu.mutation, vu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (vu *ValidatorsUpdate) SaveX(ctx context.Context) int { + affected, err := vu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (vu *ValidatorsUpdate) Exec(ctx context.Context) error { + _, err := vu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (vu *ValidatorsUpdate) ExecX(ctx context.Context) { + if err := vu.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (vu *ValidatorsUpdate) check() error { + if v, ok := vu.mutation.Facilitator(); ok { + if err := validators.FacilitatorValidator(v); err != nil { + return &ValidationError{Name: "facilitator", err: fmt.Errorf(`ent: validator failed for field "Validators.facilitator": %w`, err)} + } + } + return nil +} + +func (vu *ValidatorsUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := vu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(validators.Table, validators.Columns, sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt)) + if ps := vu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := vu.mutation.Facilitator(); ok { + _spec.SetField(validators.FieldFacilitator, field.TypeString, value) + } + if vu.mutation.KeyCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: validators.KeyTable, + Columns: []string{validators.KeyColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := vu.mutation.RemovedKeyIDs(); len(nodes) > 0 && !vu.mutation.KeyCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: validators.KeyTable, + Columns: []string{validators.KeyColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := vu.mutation.KeyIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: validators.KeyTable, + Columns: []string{validators.KeyColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, vu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{validators.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + vu.mutation.done = true + return n, nil +} + +// ValidatorsUpdateOne is the builder for updating a single Validators entity. +type ValidatorsUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ValidatorsMutation +} + +// SetFacilitator sets the "facilitator" field. +func (vuo *ValidatorsUpdateOne) SetFacilitator(s string) *ValidatorsUpdateOne { + vuo.mutation.SetFacilitator(s) + return vuo +} + +// SetNillableFacilitator sets the "facilitator" field if the given value is not nil. +func (vuo *ValidatorsUpdateOne) SetNillableFacilitator(s *string) *ValidatorsUpdateOne { + if s != nil { + vuo.SetFacilitator(*s) + } + return vuo +} + +// AddKeyIDs adds the "key" edge to the Key entity by IDs. +func (vuo *ValidatorsUpdateOne) AddKeyIDs(ids ...int) *ValidatorsUpdateOne { + vuo.mutation.AddKeyIDs(ids...) + return vuo +} + +// AddKey adds the "key" edges to the Key entity. +func (vuo *ValidatorsUpdateOne) AddKey(k ...*Key) *ValidatorsUpdateOne { + ids := make([]int, len(k)) + for i := range k { + ids[i] = k[i].ID + } + return vuo.AddKeyIDs(ids...) +} + +// Mutation returns the ValidatorsMutation object of the builder. +func (vuo *ValidatorsUpdateOne) Mutation() *ValidatorsMutation { + return vuo.mutation +} + +// ClearKey clears all "key" edges to the Key entity. +func (vuo *ValidatorsUpdateOne) ClearKey() *ValidatorsUpdateOne { + vuo.mutation.ClearKey() + return vuo +} + +// RemoveKeyIDs removes the "key" edge to Key entities by IDs. +func (vuo *ValidatorsUpdateOne) RemoveKeyIDs(ids ...int) *ValidatorsUpdateOne { + vuo.mutation.RemoveKeyIDs(ids...) + return vuo +} + +// RemoveKey removes "key" edges to Key entities. +func (vuo *ValidatorsUpdateOne) RemoveKey(k ...*Key) *ValidatorsUpdateOne { + ids := make([]int, len(k)) + for i := range k { + ids[i] = k[i].ID + } + return vuo.RemoveKeyIDs(ids...) +} + +// Where appends a list predicates to the ValidatorsUpdate builder. +func (vuo *ValidatorsUpdateOne) Where(ps ...predicate.Validators) *ValidatorsUpdateOne { + vuo.mutation.Where(ps...) + return vuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (vuo *ValidatorsUpdateOne) Select(field string, fields ...string) *ValidatorsUpdateOne { + vuo.fields = append([]string{field}, fields...) + return vuo +} + +// Save executes the query and returns the updated Validators entity. +func (vuo *ValidatorsUpdateOne) Save(ctx context.Context) (*Validators, error) { + return withHooks(ctx, vuo.sqlSave, vuo.mutation, vuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (vuo *ValidatorsUpdateOne) SaveX(ctx context.Context) *Validators { + node, err := vuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (vuo *ValidatorsUpdateOne) Exec(ctx context.Context) error { + _, err := vuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (vuo *ValidatorsUpdateOne) ExecX(ctx context.Context) { + if err := vuo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (vuo *ValidatorsUpdateOne) check() error { + if v, ok := vuo.mutation.Facilitator(); ok { + if err := validators.FacilitatorValidator(v); err != nil { + return &ValidationError{Name: "facilitator", err: fmt.Errorf(`ent: validator failed for field "Validators.facilitator": %w`, err)} + } + } + return nil +} + +func (vuo *ValidatorsUpdateOne) sqlSave(ctx context.Context) (_node *Validators, err error) { + if err := vuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(validators.Table, validators.Columns, sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt)) + id, ok := vuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Validators.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := vuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, validators.FieldID) + for _, f := range fields { + if !validators.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != validators.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := vuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := vuo.mutation.Facilitator(); ok { + _spec.SetField(validators.FieldFacilitator, field.TypeString, value) + } + if vuo.mutation.KeyCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: validators.KeyTable, + Columns: []string{validators.KeyColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := vuo.mutation.RemovedKeyIDs(); len(nodes) > 0 && !vuo.mutation.KeyCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: validators.KeyTable, + Columns: []string{validators.KeyColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := vuo.mutation.KeyIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: validators.KeyTable, + Columns: []string{validators.KeyColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &Validators{config: vuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, vuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{validators.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + vuo.mutation.done = true + return _node, nil +} diff --git a/z2/backend/ent/whitelist.go b/z2/backend/ent/whitelist.go new file mode 100644 index 0000000..c6d71ca --- /dev/null +++ b/z2/backend/ent/whitelist.go @@ -0,0 +1,133 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "thesis/ent/whitelist" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// WhiteList is the model entity for the WhiteList schema. +type WhiteList struct { + config + // ID of the ent. + ID int `json:"id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the WhiteListQuery when eager-loading is set. + Edges WhiteListEdges `json:"edges"` + selectValues sql.SelectValues +} + +// WhiteListEdges holds the relations/edges for other nodes in the graph. +type WhiteListEdges struct { + // Sponsor holds the value of the Sponsor edge. + Sponsor []*Validators `json:"Sponsor,omitempty"` + // Account holds the value of the Account edge. + Account []*Key `json:"Account,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// SponsorOrErr returns the Sponsor value or an error if the edge +// was not loaded in eager-loading. +func (e WhiteListEdges) SponsorOrErr() ([]*Validators, error) { + if e.loadedTypes[0] { + return e.Sponsor, nil + } + return nil, &NotLoadedError{edge: "Sponsor"} +} + +// AccountOrErr returns the Account value or an error if the edge +// was not loaded in eager-loading. +func (e WhiteListEdges) AccountOrErr() ([]*Key, error) { + if e.loadedTypes[1] { + return e.Account, nil + } + return nil, &NotLoadedError{edge: "Account"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*WhiteList) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case whitelist.FieldID: + values[i] = new(sql.NullInt64) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the WhiteList fields. +func (wl *WhiteList) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case whitelist.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + wl.ID = int(value.Int64) + default: + wl.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the WhiteList. +// This includes values selected through modifiers, order, etc. +func (wl *WhiteList) Value(name string) (ent.Value, error) { + return wl.selectValues.Get(name) +} + +// QuerySponsor queries the "Sponsor" edge of the WhiteList entity. +func (wl *WhiteList) QuerySponsor() *ValidatorsQuery { + return NewWhiteListClient(wl.config).QuerySponsor(wl) +} + +// QueryAccount queries the "Account" edge of the WhiteList entity. +func (wl *WhiteList) QueryAccount() *KeyQuery { + return NewWhiteListClient(wl.config).QueryAccount(wl) +} + +// Update returns a builder for updating this WhiteList. +// Note that you need to call WhiteList.Unwrap() before calling this method if this WhiteList +// was returned from a transaction, and the transaction was committed or rolled back. +func (wl *WhiteList) Update() *WhiteListUpdateOne { + return NewWhiteListClient(wl.config).UpdateOne(wl) +} + +// Unwrap unwraps the WhiteList entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (wl *WhiteList) Unwrap() *WhiteList { + _tx, ok := wl.config.driver.(*txDriver) + if !ok { + panic("ent: WhiteList is not a transactional entity") + } + wl.config.driver = _tx.drv + return wl +} + +// String implements the fmt.Stringer. +func (wl *WhiteList) String() string { + var builder strings.Builder + builder.WriteString("WhiteList(") + builder.WriteString(fmt.Sprintf("id=%v", wl.ID)) + builder.WriteByte(')') + return builder.String() +} + +// WhiteLists is a parsable slice of WhiteList. +type WhiteLists []*WhiteList diff --git a/z2/backend/ent/whitelist/where.go b/z2/backend/ent/whitelist/where.go new file mode 100644 index 0000000..432b4b8 --- /dev/null +++ b/z2/backend/ent/whitelist/where.go @@ -0,0 +1,116 @@ +// Code generated by ent, DO NOT EDIT. + +package whitelist + +import ( + "thesis/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.WhiteList { + return predicate.WhiteList(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.WhiteList { + return predicate.WhiteList(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.WhiteList { + return predicate.WhiteList(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.WhiteList { + return predicate.WhiteList(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.WhiteList { + return predicate.WhiteList(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.WhiteList { + return predicate.WhiteList(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.WhiteList { + return predicate.WhiteList(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.WhiteList { + return predicate.WhiteList(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.WhiteList { + return predicate.WhiteList(sql.FieldLTE(FieldID, id)) +} + +// HasSponsor applies the HasEdge predicate on the "Sponsor" edge. +func HasSponsor() predicate.WhiteList { + return predicate.WhiteList(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, SponsorTable, SponsorColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasSponsorWith applies the HasEdge predicate on the "Sponsor" edge with a given conditions (other predicates). +func HasSponsorWith(preds ...predicate.Validators) predicate.WhiteList { + return predicate.WhiteList(func(s *sql.Selector) { + step := newSponsorStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasAccount applies the HasEdge predicate on the "Account" edge. +func HasAccount() predicate.WhiteList { + return predicate.WhiteList(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, AccountTable, AccountColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasAccountWith applies the HasEdge predicate on the "Account" edge with a given conditions (other predicates). +func HasAccountWith(preds ...predicate.Key) predicate.WhiteList { + return predicate.WhiteList(func(s *sql.Selector) { + step := newAccountStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.WhiteList) predicate.WhiteList { + return predicate.WhiteList(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.WhiteList) predicate.WhiteList { + return predicate.WhiteList(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.WhiteList) predicate.WhiteList { + return predicate.WhiteList(sql.NotPredicates(p)) +} diff --git a/z2/backend/ent/whitelist/whitelist.go b/z2/backend/ent/whitelist/whitelist.go new file mode 100644 index 0000000..e1740b8 --- /dev/null +++ b/z2/backend/ent/whitelist/whitelist.go @@ -0,0 +1,100 @@ +// Code generated by ent, DO NOT EDIT. + +package whitelist + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the whitelist type in the database. + Label = "white_list" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // EdgeSponsor holds the string denoting the sponsor edge name in mutations. + EdgeSponsor = "Sponsor" + // EdgeAccount holds the string denoting the account edge name in mutations. + EdgeAccount = "Account" + // Table holds the table name of the whitelist in the database. + Table = "white_lists" + // SponsorTable is the table that holds the Sponsor relation/edge. + SponsorTable = "validators" + // SponsorInverseTable is the table name for the Validators entity. + // It exists in this package in order to avoid circular dependency with the "validators" package. + SponsorInverseTable = "validators" + // SponsorColumn is the table column denoting the Sponsor relation/edge. + SponsorColumn = "white_list_sponsor" + // AccountTable is the table that holds the Account relation/edge. + AccountTable = "keys" + // AccountInverseTable is the table name for the Key entity. + // It exists in this package in order to avoid circular dependency with the "key" package. + AccountInverseTable = "keys" + // AccountColumn is the table column denoting the Account relation/edge. + AccountColumn = "white_list_account" +) + +// Columns holds all SQL columns for whitelist fields. +var Columns = []string{ + FieldID, +} + +// 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 + } + } + return false +} + +// OrderOption defines the ordering options for the WhiteList 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() +} + +// BySponsorCount orders the results by Sponsor count. +func BySponsorCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newSponsorStep(), opts...) + } +} + +// BySponsor orders the results by Sponsor terms. +func BySponsor(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newSponsorStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByAccountCount orders the results by Account count. +func ByAccountCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newAccountStep(), opts...) + } +} + +// ByAccount orders the results by Account terms. +func ByAccount(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newAccountStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newSponsorStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(SponsorInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, SponsorTable, SponsorColumn), + ) +} +func newAccountStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(AccountInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, AccountTable, AccountColumn), + ) +} diff --git a/z2/backend/ent/whitelist_create.go b/z2/backend/ent/whitelist_create.go new file mode 100644 index 0000000..3250cc7 --- /dev/null +++ b/z2/backend/ent/whitelist_create.go @@ -0,0 +1,233 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "thesis/ent/key" + "thesis/ent/validators" + "thesis/ent/whitelist" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WhiteListCreate is the builder for creating a WhiteList entity. +type WhiteListCreate struct { + config + mutation *WhiteListMutation + hooks []Hook +} + +// AddSponsorIDs adds the "Sponsor" edge to the Validators entity by IDs. +func (wlc *WhiteListCreate) AddSponsorIDs(ids ...int) *WhiteListCreate { + wlc.mutation.AddSponsorIDs(ids...) + return wlc +} + +// AddSponsor adds the "Sponsor" edges to the Validators entity. +func (wlc *WhiteListCreate) AddSponsor(v ...*Validators) *WhiteListCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return wlc.AddSponsorIDs(ids...) +} + +// AddAccountIDs adds the "Account" edge to the Key entity by IDs. +func (wlc *WhiteListCreate) AddAccountIDs(ids ...int) *WhiteListCreate { + wlc.mutation.AddAccountIDs(ids...) + return wlc +} + +// AddAccount adds the "Account" edges to the Key entity. +func (wlc *WhiteListCreate) AddAccount(k ...*Key) *WhiteListCreate { + ids := make([]int, len(k)) + for i := range k { + ids[i] = k[i].ID + } + return wlc.AddAccountIDs(ids...) +} + +// Mutation returns the WhiteListMutation object of the builder. +func (wlc *WhiteListCreate) Mutation() *WhiteListMutation { + return wlc.mutation +} + +// Save creates the WhiteList in the database. +func (wlc *WhiteListCreate) Save(ctx context.Context) (*WhiteList, error) { + return withHooks(ctx, wlc.sqlSave, wlc.mutation, wlc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (wlc *WhiteListCreate) SaveX(ctx context.Context) *WhiteList { + v, err := wlc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (wlc *WhiteListCreate) Exec(ctx context.Context) error { + _, err := wlc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wlc *WhiteListCreate) ExecX(ctx context.Context) { + if err := wlc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (wlc *WhiteListCreate) check() error { + return nil +} + +func (wlc *WhiteListCreate) sqlSave(ctx context.Context) (*WhiteList, error) { + if err := wlc.check(); err != nil { + return nil, err + } + _node, _spec := wlc.createSpec() + if err := sqlgraph.CreateNode(ctx, wlc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + wlc.mutation.id = &_node.ID + wlc.mutation.done = true + return _node, nil +} + +func (wlc *WhiteListCreate) createSpec() (*WhiteList, *sqlgraph.CreateSpec) { + var ( + _node = &WhiteList{config: wlc.config} + _spec = sqlgraph.NewCreateSpec(whitelist.Table, sqlgraph.NewFieldSpec(whitelist.FieldID, field.TypeInt)) + ) + if nodes := wlc.mutation.SponsorIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: whitelist.SponsorTable, + Columns: []string{whitelist.SponsorColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := wlc.mutation.AccountIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: whitelist.AccountTable, + Columns: []string{whitelist.AccountColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// WhiteListCreateBulk is the builder for creating many WhiteList entities in bulk. +type WhiteListCreateBulk struct { + config + err error + builders []*WhiteListCreate +} + +// Save creates the WhiteList entities in the database. +func (wlcb *WhiteListCreateBulk) Save(ctx context.Context) ([]*WhiteList, error) { + if wlcb.err != nil { + return nil, wlcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(wlcb.builders)) + nodes := make([]*WhiteList, len(wlcb.builders)) + mutators := make([]Mutator, len(wlcb.builders)) + for i := range wlcb.builders { + func(i int, root context.Context) { + builder := wlcb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*WhiteListMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, wlcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, wlcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, wlcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (wlcb *WhiteListCreateBulk) SaveX(ctx context.Context) []*WhiteList { + v, err := wlcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (wlcb *WhiteListCreateBulk) Exec(ctx context.Context) error { + _, err := wlcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wlcb *WhiteListCreateBulk) ExecX(ctx context.Context) { + if err := wlcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/z2/backend/ent/whitelist_delete.go b/z2/backend/ent/whitelist_delete.go new file mode 100644 index 0000000..711dbc9 --- /dev/null +++ b/z2/backend/ent/whitelist_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "thesis/ent/predicate" + "thesis/ent/whitelist" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WhiteListDelete is the builder for deleting a WhiteList entity. +type WhiteListDelete struct { + config + hooks []Hook + mutation *WhiteListMutation +} + +// Where appends a list predicates to the WhiteListDelete builder. +func (wld *WhiteListDelete) Where(ps ...predicate.WhiteList) *WhiteListDelete { + wld.mutation.Where(ps...) + return wld +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (wld *WhiteListDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, wld.sqlExec, wld.mutation, wld.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (wld *WhiteListDelete) ExecX(ctx context.Context) int { + n, err := wld.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (wld *WhiteListDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(whitelist.Table, sqlgraph.NewFieldSpec(whitelist.FieldID, field.TypeInt)) + if ps := wld.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, wld.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + wld.mutation.done = true + return affected, err +} + +// WhiteListDeleteOne is the builder for deleting a single WhiteList entity. +type WhiteListDeleteOne struct { + wld *WhiteListDelete +} + +// Where appends a list predicates to the WhiteListDelete builder. +func (wldo *WhiteListDeleteOne) Where(ps ...predicate.WhiteList) *WhiteListDeleteOne { + wldo.wld.mutation.Where(ps...) + return wldo +} + +// Exec executes the deletion query. +func (wldo *WhiteListDeleteOne) Exec(ctx context.Context) error { + n, err := wldo.wld.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{whitelist.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (wldo *WhiteListDeleteOne) ExecX(ctx context.Context) { + if err := wldo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/z2/backend/ent/whitelist_query.go b/z2/backend/ent/whitelist_query.go new file mode 100644 index 0000000..6af4374 --- /dev/null +++ b/z2/backend/ent/whitelist_query.go @@ -0,0 +1,659 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + "thesis/ent/key" + "thesis/ent/predicate" + "thesis/ent/validators" + "thesis/ent/whitelist" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WhiteListQuery is the builder for querying WhiteList entities. +type WhiteListQuery struct { + config + ctx *QueryContext + order []whitelist.OrderOption + inters []Interceptor + predicates []predicate.WhiteList + withSponsor *ValidatorsQuery + withAccount *KeyQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the WhiteListQuery builder. +func (wlq *WhiteListQuery) Where(ps ...predicate.WhiteList) *WhiteListQuery { + wlq.predicates = append(wlq.predicates, ps...) + return wlq +} + +// Limit the number of records to be returned by this query. +func (wlq *WhiteListQuery) Limit(limit int) *WhiteListQuery { + wlq.ctx.Limit = &limit + return wlq +} + +// Offset to start from. +func (wlq *WhiteListQuery) Offset(offset int) *WhiteListQuery { + wlq.ctx.Offset = &offset + return wlq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (wlq *WhiteListQuery) Unique(unique bool) *WhiteListQuery { + wlq.ctx.Unique = &unique + return wlq +} + +// Order specifies how the records should be ordered. +func (wlq *WhiteListQuery) Order(o ...whitelist.OrderOption) *WhiteListQuery { + wlq.order = append(wlq.order, o...) + return wlq +} + +// QuerySponsor chains the current query on the "Sponsor" edge. +func (wlq *WhiteListQuery) QuerySponsor() *ValidatorsQuery { + query := (&ValidatorsClient{config: wlq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := wlq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := wlq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(whitelist.Table, whitelist.FieldID, selector), + sqlgraph.To(validators.Table, validators.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, whitelist.SponsorTable, whitelist.SponsorColumn), + ) + fromU = sqlgraph.SetNeighbors(wlq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryAccount chains the current query on the "Account" edge. +func (wlq *WhiteListQuery) QueryAccount() *KeyQuery { + query := (&KeyClient{config: wlq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := wlq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := wlq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(whitelist.Table, whitelist.FieldID, selector), + sqlgraph.To(key.Table, key.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, whitelist.AccountTable, whitelist.AccountColumn), + ) + fromU = sqlgraph.SetNeighbors(wlq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first WhiteList entity from the query. +// Returns a *NotFoundError when no WhiteList was found. +func (wlq *WhiteListQuery) First(ctx context.Context) (*WhiteList, error) { + nodes, err := wlq.Limit(1).All(setContextOp(ctx, wlq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{whitelist.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (wlq *WhiteListQuery) FirstX(ctx context.Context) *WhiteList { + node, err := wlq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first WhiteList ID from the query. +// Returns a *NotFoundError when no WhiteList ID was found. +func (wlq *WhiteListQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = wlq.Limit(1).IDs(setContextOp(ctx, wlq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{whitelist.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (wlq *WhiteListQuery) FirstIDX(ctx context.Context) int { + id, err := wlq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single WhiteList entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one WhiteList entity is found. +// Returns a *NotFoundError when no WhiteList entities are found. +func (wlq *WhiteListQuery) Only(ctx context.Context) (*WhiteList, error) { + nodes, err := wlq.Limit(2).All(setContextOp(ctx, wlq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{whitelist.Label} + default: + return nil, &NotSingularError{whitelist.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (wlq *WhiteListQuery) OnlyX(ctx context.Context) *WhiteList { + node, err := wlq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only WhiteList ID in the query. +// Returns a *NotSingularError when more than one WhiteList ID is found. +// Returns a *NotFoundError when no entities are found. +func (wlq *WhiteListQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = wlq.Limit(2).IDs(setContextOp(ctx, wlq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{whitelist.Label} + default: + err = &NotSingularError{whitelist.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (wlq *WhiteListQuery) OnlyIDX(ctx context.Context) int { + id, err := wlq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of WhiteLists. +func (wlq *WhiteListQuery) All(ctx context.Context) ([]*WhiteList, error) { + ctx = setContextOp(ctx, wlq.ctx, "All") + if err := wlq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*WhiteList, *WhiteListQuery]() + return withInterceptors[[]*WhiteList](ctx, wlq, qr, wlq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (wlq *WhiteListQuery) AllX(ctx context.Context) []*WhiteList { + nodes, err := wlq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of WhiteList IDs. +func (wlq *WhiteListQuery) IDs(ctx context.Context) (ids []int, err error) { + if wlq.ctx.Unique == nil && wlq.path != nil { + wlq.Unique(true) + } + ctx = setContextOp(ctx, wlq.ctx, "IDs") + if err = wlq.Select(whitelist.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (wlq *WhiteListQuery) IDsX(ctx context.Context) []int { + ids, err := wlq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (wlq *WhiteListQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, wlq.ctx, "Count") + if err := wlq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, wlq, querierCount[*WhiteListQuery](), wlq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (wlq *WhiteListQuery) CountX(ctx context.Context) int { + count, err := wlq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (wlq *WhiteListQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, wlq.ctx, "Exist") + switch _, err := wlq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (wlq *WhiteListQuery) ExistX(ctx context.Context) bool { + exist, err := wlq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the WhiteListQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (wlq *WhiteListQuery) Clone() *WhiteListQuery { + if wlq == nil { + return nil + } + return &WhiteListQuery{ + config: wlq.config, + ctx: wlq.ctx.Clone(), + order: append([]whitelist.OrderOption{}, wlq.order...), + inters: append([]Interceptor{}, wlq.inters...), + predicates: append([]predicate.WhiteList{}, wlq.predicates...), + withSponsor: wlq.withSponsor.Clone(), + withAccount: wlq.withAccount.Clone(), + // clone intermediate query. + sql: wlq.sql.Clone(), + path: wlq.path, + } +} + +// WithSponsor tells the query-builder to eager-load the nodes that are connected to +// the "Sponsor" edge. The optional arguments are used to configure the query builder of the edge. +func (wlq *WhiteListQuery) WithSponsor(opts ...func(*ValidatorsQuery)) *WhiteListQuery { + query := (&ValidatorsClient{config: wlq.config}).Query() + for _, opt := range opts { + opt(query) + } + wlq.withSponsor = query + return wlq +} + +// WithAccount tells the query-builder to eager-load the nodes that are connected to +// the "Account" edge. The optional arguments are used to configure the query builder of the edge. +func (wlq *WhiteListQuery) WithAccount(opts ...func(*KeyQuery)) *WhiteListQuery { + query := (&KeyClient{config: wlq.config}).Query() + for _, opt := range opts { + opt(query) + } + wlq.withAccount = query + return wlq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +func (wlq *WhiteListQuery) GroupBy(field string, fields ...string) *WhiteListGroupBy { + wlq.ctx.Fields = append([]string{field}, fields...) + grbuild := &WhiteListGroupBy{build: wlq} + grbuild.flds = &wlq.ctx.Fields + grbuild.label = whitelist.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +func (wlq *WhiteListQuery) Select(fields ...string) *WhiteListSelect { + wlq.ctx.Fields = append(wlq.ctx.Fields, fields...) + sbuild := &WhiteListSelect{WhiteListQuery: wlq} + sbuild.label = whitelist.Label + sbuild.flds, sbuild.scan = &wlq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a WhiteListSelect configured with the given aggregations. +func (wlq *WhiteListQuery) Aggregate(fns ...AggregateFunc) *WhiteListSelect { + return wlq.Select().Aggregate(fns...) +} + +func (wlq *WhiteListQuery) prepareQuery(ctx context.Context) error { + for _, inter := range wlq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, wlq); err != nil { + return err + } + } + } + for _, f := range wlq.ctx.Fields { + if !whitelist.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if wlq.path != nil { + prev, err := wlq.path(ctx) + if err != nil { + return err + } + wlq.sql = prev + } + return nil +} + +func (wlq *WhiteListQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*WhiteList, error) { + var ( + nodes = []*WhiteList{} + _spec = wlq.querySpec() + loadedTypes = [2]bool{ + wlq.withSponsor != nil, + wlq.withAccount != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*WhiteList).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &WhiteList{config: wlq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, wlq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := wlq.withSponsor; query != nil { + if err := wlq.loadSponsor(ctx, query, nodes, + func(n *WhiteList) { n.Edges.Sponsor = []*Validators{} }, + func(n *WhiteList, e *Validators) { n.Edges.Sponsor = append(n.Edges.Sponsor, e) }); err != nil { + return nil, err + } + } + if query := wlq.withAccount; query != nil { + if err := wlq.loadAccount(ctx, query, nodes, + func(n *WhiteList) { n.Edges.Account = []*Key{} }, + func(n *WhiteList, e *Key) { n.Edges.Account = append(n.Edges.Account, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (wlq *WhiteListQuery) loadSponsor(ctx context.Context, query *ValidatorsQuery, nodes []*WhiteList, init func(*WhiteList), assign func(*WhiteList, *Validators)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*WhiteList) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.Validators(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(whitelist.SponsorColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.white_list_sponsor + if fk == nil { + return fmt.Errorf(`foreign-key "white_list_sponsor" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "white_list_sponsor" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} +func (wlq *WhiteListQuery) loadAccount(ctx context.Context, query *KeyQuery, nodes []*WhiteList, init func(*WhiteList), assign func(*WhiteList, *Key)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*WhiteList) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.Key(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(whitelist.AccountColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.white_list_account + if fk == nil { + return fmt.Errorf(`foreign-key "white_list_account" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "white_list_account" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (wlq *WhiteListQuery) sqlCount(ctx context.Context) (int, error) { + _spec := wlq.querySpec() + _spec.Node.Columns = wlq.ctx.Fields + if len(wlq.ctx.Fields) > 0 { + _spec.Unique = wlq.ctx.Unique != nil && *wlq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, wlq.driver, _spec) +} + +func (wlq *WhiteListQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(whitelist.Table, whitelist.Columns, sqlgraph.NewFieldSpec(whitelist.FieldID, field.TypeInt)) + _spec.From = wlq.sql + if unique := wlq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if wlq.path != nil { + _spec.Unique = true + } + if fields := wlq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, whitelist.FieldID) + for i := range fields { + if fields[i] != whitelist.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := wlq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := wlq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := wlq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := wlq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (wlq *WhiteListQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(wlq.driver.Dialect()) + t1 := builder.Table(whitelist.Table) + columns := wlq.ctx.Fields + if len(columns) == 0 { + columns = whitelist.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if wlq.sql != nil { + selector = wlq.sql + selector.Select(selector.Columns(columns...)...) + } + if wlq.ctx.Unique != nil && *wlq.ctx.Unique { + selector.Distinct() + } + for _, p := range wlq.predicates { + p(selector) + } + for _, p := range wlq.order { + p(selector) + } + if offset := wlq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := wlq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// WhiteListGroupBy is the group-by builder for WhiteList entities. +type WhiteListGroupBy struct { + selector + build *WhiteListQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (wlgb *WhiteListGroupBy) Aggregate(fns ...AggregateFunc) *WhiteListGroupBy { + wlgb.fns = append(wlgb.fns, fns...) + return wlgb +} + +// Scan applies the selector query and scans the result into the given value. +func (wlgb *WhiteListGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, wlgb.build.ctx, "GroupBy") + if err := wlgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*WhiteListQuery, *WhiteListGroupBy](ctx, wlgb.build, wlgb, wlgb.build.inters, v) +} + +func (wlgb *WhiteListGroupBy) sqlScan(ctx context.Context, root *WhiteListQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(wlgb.fns)) + for _, fn := range wlgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*wlgb.flds)+len(wlgb.fns)) + for _, f := range *wlgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*wlgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := wlgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// WhiteListSelect is the builder for selecting fields of WhiteList entities. +type WhiteListSelect struct { + *WhiteListQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (wls *WhiteListSelect) Aggregate(fns ...AggregateFunc) *WhiteListSelect { + wls.fns = append(wls.fns, fns...) + return wls +} + +// Scan applies the selector query and scans the result into the given value. +func (wls *WhiteListSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, wls.ctx, "Select") + if err := wls.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*WhiteListQuery, *WhiteListSelect](ctx, wls.WhiteListQuery, wls, wls.inters, v) +} + +func (wls *WhiteListSelect) sqlScan(ctx context.Context, root *WhiteListQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(wls.fns)) + for _, fn := range wls.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*wls.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := wls.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/z2/backend/ent/whitelist_update.go b/z2/backend/ent/whitelist_update.go new file mode 100644 index 0000000..d53f91d --- /dev/null +++ b/z2/backend/ent/whitelist_update.go @@ -0,0 +1,501 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "thesis/ent/key" + "thesis/ent/predicate" + "thesis/ent/validators" + "thesis/ent/whitelist" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WhiteListUpdate is the builder for updating WhiteList entities. +type WhiteListUpdate struct { + config + hooks []Hook + mutation *WhiteListMutation +} + +// Where appends a list predicates to the WhiteListUpdate builder. +func (wlu *WhiteListUpdate) Where(ps ...predicate.WhiteList) *WhiteListUpdate { + wlu.mutation.Where(ps...) + return wlu +} + +// AddSponsorIDs adds the "Sponsor" edge to the Validators entity by IDs. +func (wlu *WhiteListUpdate) AddSponsorIDs(ids ...int) *WhiteListUpdate { + wlu.mutation.AddSponsorIDs(ids...) + return wlu +} + +// AddSponsor adds the "Sponsor" edges to the Validators entity. +func (wlu *WhiteListUpdate) AddSponsor(v ...*Validators) *WhiteListUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return wlu.AddSponsorIDs(ids...) +} + +// AddAccountIDs adds the "Account" edge to the Key entity by IDs. +func (wlu *WhiteListUpdate) AddAccountIDs(ids ...int) *WhiteListUpdate { + wlu.mutation.AddAccountIDs(ids...) + return wlu +} + +// AddAccount adds the "Account" edges to the Key entity. +func (wlu *WhiteListUpdate) AddAccount(k ...*Key) *WhiteListUpdate { + ids := make([]int, len(k)) + for i := range k { + ids[i] = k[i].ID + } + return wlu.AddAccountIDs(ids...) +} + +// Mutation returns the WhiteListMutation object of the builder. +func (wlu *WhiteListUpdate) Mutation() *WhiteListMutation { + return wlu.mutation +} + +// ClearSponsor clears all "Sponsor" edges to the Validators entity. +func (wlu *WhiteListUpdate) ClearSponsor() *WhiteListUpdate { + wlu.mutation.ClearSponsor() + return wlu +} + +// RemoveSponsorIDs removes the "Sponsor" edge to Validators entities by IDs. +func (wlu *WhiteListUpdate) RemoveSponsorIDs(ids ...int) *WhiteListUpdate { + wlu.mutation.RemoveSponsorIDs(ids...) + return wlu +} + +// RemoveSponsor removes "Sponsor" edges to Validators entities. +func (wlu *WhiteListUpdate) RemoveSponsor(v ...*Validators) *WhiteListUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return wlu.RemoveSponsorIDs(ids...) +} + +// ClearAccount clears all "Account" edges to the Key entity. +func (wlu *WhiteListUpdate) ClearAccount() *WhiteListUpdate { + wlu.mutation.ClearAccount() + return wlu +} + +// RemoveAccountIDs removes the "Account" edge to Key entities by IDs. +func (wlu *WhiteListUpdate) RemoveAccountIDs(ids ...int) *WhiteListUpdate { + wlu.mutation.RemoveAccountIDs(ids...) + return wlu +} + +// RemoveAccount removes "Account" edges to Key entities. +func (wlu *WhiteListUpdate) RemoveAccount(k ...*Key) *WhiteListUpdate { + ids := make([]int, len(k)) + for i := range k { + ids[i] = k[i].ID + } + return wlu.RemoveAccountIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (wlu *WhiteListUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, wlu.sqlSave, wlu.mutation, wlu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (wlu *WhiteListUpdate) SaveX(ctx context.Context) int { + affected, err := wlu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (wlu *WhiteListUpdate) Exec(ctx context.Context) error { + _, err := wlu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wlu *WhiteListUpdate) ExecX(ctx context.Context) { + if err := wlu.Exec(ctx); err != nil { + panic(err) + } +} + +func (wlu *WhiteListUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := sqlgraph.NewUpdateSpec(whitelist.Table, whitelist.Columns, sqlgraph.NewFieldSpec(whitelist.FieldID, field.TypeInt)) + if ps := wlu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if wlu.mutation.SponsorCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: whitelist.SponsorTable, + Columns: []string{whitelist.SponsorColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := wlu.mutation.RemovedSponsorIDs(); len(nodes) > 0 && !wlu.mutation.SponsorCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: whitelist.SponsorTable, + Columns: []string{whitelist.SponsorColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := wlu.mutation.SponsorIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: whitelist.SponsorTable, + Columns: []string{whitelist.SponsorColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if wlu.mutation.AccountCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: whitelist.AccountTable, + Columns: []string{whitelist.AccountColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := wlu.mutation.RemovedAccountIDs(); len(nodes) > 0 && !wlu.mutation.AccountCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: whitelist.AccountTable, + Columns: []string{whitelist.AccountColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := wlu.mutation.AccountIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: whitelist.AccountTable, + Columns: []string{whitelist.AccountColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, wlu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{whitelist.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + wlu.mutation.done = true + return n, nil +} + +// WhiteListUpdateOne is the builder for updating a single WhiteList entity. +type WhiteListUpdateOne struct { + config + fields []string + hooks []Hook + mutation *WhiteListMutation +} + +// AddSponsorIDs adds the "Sponsor" edge to the Validators entity by IDs. +func (wluo *WhiteListUpdateOne) AddSponsorIDs(ids ...int) *WhiteListUpdateOne { + wluo.mutation.AddSponsorIDs(ids...) + return wluo +} + +// AddSponsor adds the "Sponsor" edges to the Validators entity. +func (wluo *WhiteListUpdateOne) AddSponsor(v ...*Validators) *WhiteListUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return wluo.AddSponsorIDs(ids...) +} + +// AddAccountIDs adds the "Account" edge to the Key entity by IDs. +func (wluo *WhiteListUpdateOne) AddAccountIDs(ids ...int) *WhiteListUpdateOne { + wluo.mutation.AddAccountIDs(ids...) + return wluo +} + +// AddAccount adds the "Account" edges to the Key entity. +func (wluo *WhiteListUpdateOne) AddAccount(k ...*Key) *WhiteListUpdateOne { + ids := make([]int, len(k)) + for i := range k { + ids[i] = k[i].ID + } + return wluo.AddAccountIDs(ids...) +} + +// Mutation returns the WhiteListMutation object of the builder. +func (wluo *WhiteListUpdateOne) Mutation() *WhiteListMutation { + return wluo.mutation +} + +// ClearSponsor clears all "Sponsor" edges to the Validators entity. +func (wluo *WhiteListUpdateOne) ClearSponsor() *WhiteListUpdateOne { + wluo.mutation.ClearSponsor() + return wluo +} + +// RemoveSponsorIDs removes the "Sponsor" edge to Validators entities by IDs. +func (wluo *WhiteListUpdateOne) RemoveSponsorIDs(ids ...int) *WhiteListUpdateOne { + wluo.mutation.RemoveSponsorIDs(ids...) + return wluo +} + +// RemoveSponsor removes "Sponsor" edges to Validators entities. +func (wluo *WhiteListUpdateOne) RemoveSponsor(v ...*Validators) *WhiteListUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return wluo.RemoveSponsorIDs(ids...) +} + +// ClearAccount clears all "Account" edges to the Key entity. +func (wluo *WhiteListUpdateOne) ClearAccount() *WhiteListUpdateOne { + wluo.mutation.ClearAccount() + return wluo +} + +// RemoveAccountIDs removes the "Account" edge to Key entities by IDs. +func (wluo *WhiteListUpdateOne) RemoveAccountIDs(ids ...int) *WhiteListUpdateOne { + wluo.mutation.RemoveAccountIDs(ids...) + return wluo +} + +// RemoveAccount removes "Account" edges to Key entities. +func (wluo *WhiteListUpdateOne) RemoveAccount(k ...*Key) *WhiteListUpdateOne { + ids := make([]int, len(k)) + for i := range k { + ids[i] = k[i].ID + } + return wluo.RemoveAccountIDs(ids...) +} + +// Where appends a list predicates to the WhiteListUpdate builder. +func (wluo *WhiteListUpdateOne) Where(ps ...predicate.WhiteList) *WhiteListUpdateOne { + wluo.mutation.Where(ps...) + return wluo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (wluo *WhiteListUpdateOne) Select(field string, fields ...string) *WhiteListUpdateOne { + wluo.fields = append([]string{field}, fields...) + return wluo +} + +// Save executes the query and returns the updated WhiteList entity. +func (wluo *WhiteListUpdateOne) Save(ctx context.Context) (*WhiteList, error) { + return withHooks(ctx, wluo.sqlSave, wluo.mutation, wluo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (wluo *WhiteListUpdateOne) SaveX(ctx context.Context) *WhiteList { + node, err := wluo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (wluo *WhiteListUpdateOne) Exec(ctx context.Context) error { + _, err := wluo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wluo *WhiteListUpdateOne) ExecX(ctx context.Context) { + if err := wluo.Exec(ctx); err != nil { + panic(err) + } +} + +func (wluo *WhiteListUpdateOne) sqlSave(ctx context.Context) (_node *WhiteList, err error) { + _spec := sqlgraph.NewUpdateSpec(whitelist.Table, whitelist.Columns, sqlgraph.NewFieldSpec(whitelist.FieldID, field.TypeInt)) + id, ok := wluo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "WhiteList.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := wluo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, whitelist.FieldID) + for _, f := range fields { + if !whitelist.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != whitelist.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := wluo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if wluo.mutation.SponsorCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: whitelist.SponsorTable, + Columns: []string{whitelist.SponsorColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := wluo.mutation.RemovedSponsorIDs(); len(nodes) > 0 && !wluo.mutation.SponsorCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: whitelist.SponsorTable, + Columns: []string{whitelist.SponsorColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := wluo.mutation.SponsorIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: whitelist.SponsorTable, + Columns: []string{whitelist.SponsorColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if wluo.mutation.AccountCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: whitelist.AccountTable, + Columns: []string{whitelist.AccountColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := wluo.mutation.RemovedAccountIDs(); len(nodes) > 0 && !wluo.mutation.AccountCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: whitelist.AccountTable, + Columns: []string{whitelist.AccountColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := wluo.mutation.AccountIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: whitelist.AccountTable, + Columns: []string{whitelist.AccountColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(key.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &WhiteList{config: wluo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, wluo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{whitelist.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + wluo.mutation.done = true + return _node, nil +} diff --git a/z2/backend/go.mod b/z2/backend/go.mod new file mode 100644 index 0000000..346a566 --- /dev/null +++ b/z2/backend/go.mod @@ -0,0 +1,163 @@ +module thesis + +go 1.21 + +toolchain go1.22.0 + +require ( + entgo.io/ent v0.13.1 + github.com/consensys/gnark v0.9.1 + github.com/consensys/gnark-crypto v0.12.2-0.20231013160410-1f65e75b6dfb + github.com/libp2p/go-libp2p v0.33.2 + github.com/libp2p/go-libp2p-kad-dht v0.25.2 + github.com/mattn/go-sqlite3 v1.14.22 + github.com/multiformats/go-multiaddr v0.12.3 + github.com/supranational/blst v0.3.11 + github.com/txaty/go-merkletree v0.2.2 +) + +require ( + ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 // indirect + github.com/agext/levenshtein v1.2.1 // indirect + github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/benbjohnson/clock v1.3.5 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/bits-and-blooms/bitset v1.8.0 // indirect + github.com/blang/semver/v4 v4.0.0 // indirect + github.com/bytedance/sonic v1.11.5 // indirect + github.com/bytedance/sonic/loader v0.1.1 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect + github.com/cloudwego/base64x v0.1.3 // indirect + github.com/cloudwego/iasm v0.2.0 // indirect + github.com/consensys/bavard v0.1.13 // indirect + github.com/containerd/cgroups v1.1.0 // indirect + github.com/coreos/go-systemd/v22 v22.5.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect + github.com/docker/go-units v0.5.0 // indirect + github.com/elastic/gosigar v0.14.2 // indirect + github.com/flynn/noise v1.1.0 // indirect + github.com/francoispqt/gojay v1.2.13 // indirect + github.com/fxamacker/cbor/v2 v2.5.0 // indirect + github.com/gabriel-vasile/mimetype v1.4.3 // indirect + github.com/gin-contrib/cors v1.7.1 + github.com/gin-contrib/sse v0.1.0 // indirect + github.com/gin-gonic/gin v1.9.1 // indirect + github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-openapi/inflect v0.19.0 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.19.0 // indirect + github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect + github.com/goccy/go-json v0.10.2 // indirect + github.com/godbus/dbus/v5 v5.1.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/google/gopacket v1.1.19 // indirect + github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/gorilla/websocket v1.5.1 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/hashicorp/golang-lru v1.0.2 // indirect + github.com/hashicorp/hcl/v2 v2.13.0 // indirect + github.com/huin/goupnp v1.3.0 // indirect + github.com/ipfs/boxo v0.19.0 // indirect + github.com/ipfs/go-cid v0.4.1 // indirect + github.com/ipfs/go-datastore v0.6.0 // indirect + github.com/ipfs/go-log v1.0.5 // indirect + github.com/ipfs/go-log/v2 v2.5.1 // indirect + github.com/ipld/go-ipld-prime v0.21.0 // indirect + github.com/jackpal/go-nat-pmp v1.0.2 // indirect + github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect + github.com/jbenet/goprocess v0.1.4 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/compress v1.17.6 // indirect + github.com/klauspost/cpuid/v2 v2.2.7 // indirect + github.com/koron/go-ssdp v0.0.4 // indirect + github.com/leodido/go-urn v1.4.0 // indirect + github.com/libp2p/go-buffer-pool v0.1.0 // indirect + github.com/libp2p/go-cidranger v1.1.0 // indirect + github.com/libp2p/go-flow-metrics v0.1.0 // indirect + github.com/libp2p/go-libp2p-asn-util v0.4.1 // indirect + github.com/libp2p/go-libp2p-kbucket v0.6.3 // indirect + github.com/libp2p/go-libp2p-record v0.2.0 // indirect + github.com/libp2p/go-libp2p-routing-helpers v0.7.3 // indirect + github.com/libp2p/go-msgio v0.3.0 // indirect + github.com/libp2p/go-nat v0.2.0 // indirect + github.com/libp2p/go-netroute v0.2.1 // indirect + github.com/libp2p/go-reuseport v0.4.0 // indirect + github.com/libp2p/go-yamux/v4 v4.0.1 // indirect + github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/miekg/dns v1.1.58 // indirect + github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect + github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect + github.com/minio/sha256-simd v1.0.1 // indirect + github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect + github.com/mmcloughlin/addchain v0.4.0 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/mr-tron/base58 v1.2.0 // indirect + github.com/multiformats/go-base32 v0.1.0 // indirect + github.com/multiformats/go-base36 v0.2.0 // indirect + github.com/multiformats/go-multiaddr-dns v0.3.1 // indirect + github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect + github.com/multiformats/go-multibase v0.2.0 // indirect + github.com/multiformats/go-multicodec v0.9.0 // indirect + github.com/multiformats/go-multihash v0.2.3 // indirect + github.com/multiformats/go-multistream v0.5.0 // indirect + github.com/multiformats/go-varint v0.0.7 // indirect + github.com/onsi/ginkgo/v2 v2.15.0 // indirect + github.com/opencontainers/runtime-spec v1.2.0 // indirect + github.com/opentracing/opentracing-go v1.2.0 // indirect + github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect + github.com/pelletier/go-toml/v2 v2.2.1 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/polydawn/refmt v0.89.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.53.0 // indirect + github.com/prometheus/procfs v0.14.0 // indirect + github.com/quic-go/qpack v0.4.0 // indirect + github.com/quic-go/quic-go v0.42.0 // indirect + github.com/quic-go/webtransport-go v0.6.0 // indirect + github.com/raulk/go-watchdog v1.3.0 // indirect + github.com/rs/zerolog v1.30.0 // indirect + github.com/spaolacci/murmur3 v1.1.0 // indirect + github.com/stretchr/testify v1.9.0 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/ugorji/go/codec v1.2.12 // indirect + github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect + github.com/x448/float16 v0.8.4 // indirect + github.com/zclconf/go-cty v1.8.0 // indirect + go.opencensus.io v0.24.0 // indirect + go.opentelemetry.io/otel v1.25.0 // indirect + go.opentelemetry.io/otel/metric v1.25.0 // indirect + go.opentelemetry.io/otel/trace v1.25.0 // indirect + go.uber.org/dig v1.17.1 // indirect + go.uber.org/fx v1.20.1 // indirect + go.uber.org/mock v0.4.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.27.0 // indirect + golang.org/x/arch v0.7.0 // indirect + golang.org/x/crypto v0.22.0 // indirect + golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/net v0.24.0 // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/sys v0.19.0 // indirect + golang.org/x/text v0.14.0 // indirect + golang.org/x/tools v0.20.0 // indirect + gonum.org/v1/gonum v0.15.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + lukechampine.com/blake3 v1.2.2 // indirect + rsc.io/tmplfunc v0.0.3 // indirect +) diff --git a/z2/backend/main.go b/z2/backend/main.go new file mode 100644 index 0000000..648e9eb --- /dev/null +++ b/z2/backend/main.go @@ -0,0 +1,217 @@ +package main + +import ( + "context" + "crypto/sha256" + "encoding/json" + "fmt" + "log" + "sync" + + // "crypto/rand" + + "thesis/core" + "thesis/crypto" + "thesis/db" + "thesis/ent" + "thesis/rpc" + "time" + + _ "github.com/mattn/go-sqlite3" + blst "github.com/supranational/blst/bindings/go" + mt "github.com/txaty/go-merkletree" +) + +type Transaction = core.Transaction + +// func generateRandBlocks(size int) (blocks []mt.DataBlock) { +// for i := 0; i < size; i++ { +// block := &Transaction{ +// data: make([]byte, 100), +// } +// _, err := rand.Read(block.data) +// handleError(err) +// blocks = append(blocks, block) +// } +// return +// } + +// func merklePOC() { +// blocks := generateRandBlocks(5) +// tree, err := mt.New(nil, blocks) +// handleError(err) +// proofs := tree.Proofs +// for i := 0; i < len(proofs); i++ { +// ok, err := tree.Verify(blocks[i], proofs[i]) +// handleError(err) +// fmt.Println(ok) +// } + +// rootHash := tree.Root +// for i := 0; i < len(blocks); i++ { +// ok, err := mt.Verify(blocks[i], proofs[i], rootHash, nil) +// handleError(err) +// fmt.Println(ok) +// } +// } + +func generateRandData(client *ent.Client, sk *blst.SecretKey, pk string, n int) { + + signerKey, err := client.Key.Create().SetPublicKey(pk).SetOwner("gensis miner").Save(context.Background()) + handleError(err) + var blocks []mt.DataBlock + for i := 0; i < n; i++ { + + txContent := &core.TransactionContent{ + Signer: "0x0deadbeef", + Commitment: "0x0000", + } + contentBytes, err := json.Marshal(txContent) + handleError(err) + var tx *core.Transaction + if i == 0 { + tx = &core.Transaction{ + Type: i, + Timestamp: time.Now().Unix(), + Comment: "The gensis block", + Content: contentBytes, + } + } else { + tx = &core.Transaction{ + Type: 2, + Timestamp: time.Now().Unix(), + Comment: "dummy block", + Content: contentBytes, + } + } + + txBytes, err := json.Marshal(tx) + handleError(err) + hash := sha256.New() + hash.Write(txBytes) + tx.Hash = fmt.Sprintf("0x%x", string(hash.Sum(nil))) + + tx.Signature = crypto.SignMessage(tx.Hash, sk) + // fmt.Println("The signature is", tx.Signature) + // fmt.Println(string(tx.Signature)) + txDB := db.AddTx(client, tx, signerKey) + + txBytes, err = json.Marshal(tx) + handleError(err) + hash = sha256.New() + hash.Write(txBytes) + var block core.Block + + if i == 0 { + block = core.Block{ + Hash: fmt.Sprintf("0x%x", string(hash.Sum(nil))), + Nonce: i, + Length: 1, + PreviousHash: "0x000", + } + } else { + // lastBlock, err := client.Blocks.Query().Order(ent.Desc()).All(context.Background()) //Only(context.Background()) + // handleError(err) + lastHash, err := blocks[len(blocks)-1].Serialize() + handleError(err) + + block = core.Block{ + Hash: fmt.Sprintf("0x%x", string(hash.Sum(nil))), + Nonce: i, + Length: 1, + PreviousHash: string(lastHash), //lastBlock[0].Hash, + } + } + + // fmt.Printf("0x%x", string(tx.Signature)) + blockDB := db.AddBlock(client, &block) + txDB.Update().AddBlock(blockDB).Save(context.Background()) + blocks = append(blocks, block) + } + tree, err := mt.New(nil, blocks) + handleError(err) + proofs := tree.Proofs + for i := 0; i < len(proofs); i++ { + ok, err := tree.Verify(blocks[i], proofs[i]) + handleError(err) + fmt.Println(ok) + } + + rootHash := tree.Root + for i := 0; i < len(blocks); i++ { + ok, err := mt.Verify(blocks[i], proofs[i], rootHash, nil) + handleError(err) + fmt.Println(ok) + } + + fmt.Printf("Root Hash: 0x%x", rootHash) +} + +func main() { + + client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") + // client, err := ent.Open("sqlite3", "file:chaindb?cache=shared&_fk=1") + handleError(err) + defer client.Close() + + // // keys.GenerateKeys() + // sk, _ := crypto.ImportKeyFromHex("0x2ed682681702cddf5b9cd4f26a95c78953bfa1058a76aae69cc1aa0bb9bb3c5b") + // pk := new(crypto.PublicKey).From(sk) + // // Run the auto migration tool. + if err := client.Schema.Create(context.Background()); err != nil { + log.Fatalf("failed creating schema resources: %v", err) + } + // core.ValidateContent(client, pk) + // server := true + // generateRandData(client, sk, string(pk.Compress()), 30) + // testSk, _ := crypto.ImportKeyFromHex("0x328c8bdb0a70df287e8241b93f75bba446d1b7a3cbc8b1b0eebbb9e856e83cff") + // pk := new(crypto.PublicKey).From(testSk) + // encodePk := hex.EncodeToString(pk.Compress()) + // fmt.Println(encodePk) + // testPub := "b82ab3d1841afc7d9b65ee31cb38f82d5d177231f05edc93e01a74f1d3151503ee37eda7d2093122b725d37ffbda2098" + // testSig := "99a734d2bf5c509f9651992725a2c3ea43bd33621bb177317664bc4c3aebbfef58f401605134a6c9349bf7fb918177b706ed1a97e4fc92ab0a0813e7bd96e5fadbf10446f32cbf314337a59c1372f6b944e12eb1c0f3b2dae5dd9393a6c75d71" + + // testPubBytes, err := hex.DecodeString(testPub) + // handleError(err) + // testPk := new(crypto.PublicKey).Uncompress(testPubBytes) + // fmt.Println(hex.EncodeToString(testPk.Compress())) + // hash, err := hex.DecodeString("a47cb1f3c9f8066549b30ef863f4ce919d089c7d3d1c779ea28cdb8fdf7bb1c5") + // handleError(err) + // err = crypto.ValidateSignature(testSig, testPk, hash) + // if err == nil { + // fmt.Println("woop we got it man") + // } else { + // fmt.Println("invalid") + // } + // client.Transactions.Create().SetType() + + // blocks := []mt.DataBlock{block} + + // ctx, cancel := context.WithCancel(context.Background()) + // defer cancel() + + // node := p2p.StartNode(0) + // if server { + // p2p.StartListener(ctx, node) + // <-ctx.Done() + // } else { + // txContent := &core.TransactionContent{ + // Signer: "0x0deadbeef", + // Commitment: "0x0000", + // } + // contentBytes, err := json.Marshal(txContent) + // contentBytes = append(contentBytes, []byte("\n")...) + // handleError(err) + // p2p.RunSender(ctx, node, "/ip4/127.0.0.1/tcp/40125/p2p/12D3KooWFKjCej7sXzgV2hcYvDtPBsB66mg6WwjacGUMpF6spe8X", contentBytes) + // } + var wg sync.WaitGroup + wg.Add(1) + go rpc.Serve(&wg, client) + wg.Wait() +} + +func handleError(err error) { + if err != nil { + panic(err) + } +} diff --git a/z2/backend/p2p/p2p.go b/z2/backend/p2p/p2p.go new file mode 100644 index 0000000..20169f6 --- /dev/null +++ b/z2/backend/p2p/p2p.go @@ -0,0 +1,288 @@ +package p2p + +import ( + "bufio" + "context" + "encoding/json" + "fmt" + + // "log" + "os" + "os/signal" + "syscall" + "thesis/core" + "time" + + drouting "github.com/libp2p/go-libp2p/p2p/discovery/routing" + dutil "github.com/libp2p/go-libp2p/p2p/discovery/util" + + "github.com/ipfs/go-log/v2" + "github.com/libp2p/go-libp2p" + dht "github.com/libp2p/go-libp2p-kad-dht" + "github.com/libp2p/go-libp2p/core/host" + "github.com/libp2p/go-libp2p/core/network" + "github.com/libp2p/go-libp2p/core/peer" + "github.com/libp2p/go-libp2p/core/peerstore" + multiaddr "github.com/multiformats/go-multiaddr" +) + +var logger = log.Logger("rendezvous") + +type addrList []multiaddr.Multiaddr + +type Config struct { + RendezvousString string + BootstrapPeers addrList + ListenAddresses addrList + ProtocolID string +} + +func StartNode(port int) host.Host { + log.SetAllLoggers(log.LevelWarn) + node, err := libp2p.New( + libp2p.ListenAddrStrings(fmt.Sprintf("/ip4/127.0.0.1/tcp/%d", port)), + ) + if err != nil { + panic(err) + } + + peerInfo := peer.AddrInfo{ + ID: node.ID(), + Addrs: node.Addrs(), + } + + addrs, _ := peer.AddrInfoToP2pAddrs(&peerInfo) + fmt.Println("libp2p node address:", addrs[0]) + return node +} + +func ConnectToTargetNode(sourceNode host.Host, targetNode host.Host) { + + targetAddr := host.InfoFromHost(targetNode) + err := sourceNode.Connect(context.Background(), *targetAddr) + if err != nil { + panic(err) + } +} + +func CountSourceNodePeers(sourceNode host.Host) int { + return len(sourceNode.Network().Peers()) +} + +func getHostAddress(ha host.Host) string { + // Build host multiaddress + hostAddr, _ := multiaddr.NewMultiaddr(fmt.Sprintf("/p2p/%s", ha.ID())) + + // Now we can build a full multiaddress to reach this host + // by encapsulating both addresses: + addr := ha.Addrs()[0] + return addr.Encapsulate(hostAddr).String() +} + +func StartListener(ctx context.Context, ha host.Host) { + fullAddr := getHostAddress(ha) + logger.Warn("I am %s\n", fullAddr) + + ha.SetStreamHandler("/echo/1.0.0", handleStream) + logger.Warn("listening for connections...") + bootstrapPeers := make([]peer.AddrInfo, len(dht.DefaultBootstrapPeers)) + for i, addr := range dht.DefaultBootstrapPeers { + peerinfo, _ := peer.AddrInfoFromP2pAddr(addr) + bootstrapPeers[i] = *peerinfo + } + kademliaDHT, err := dht.New(ctx, ha, dht.BootstrapPeers(bootstrapPeers...)) + if err != nil { + panic(err) + } + logger.Warn("Bootstrapping the DHT") + if err = kademliaDHT.Bootstrap(ctx); err != nil { + panic(err) + } + rendezvousString := "meet me here" + + // Wait a bit to let bootstrapping finish (really bootstrap should block until it's ready, but that isn't the case yet.) + time.Sleep(1 * time.Second) + + // We use a rendezvous point "meet me here" to announce our location. + // This is like telling your friends to meet you at the Eiffel Tower. + logger.Warn("Announcing ourselves...") + routingDiscovery := drouting.NewRoutingDiscovery(kademliaDHT) + dutil.Advertise(ctx, routingDiscovery, rendezvousString) + logger.Warn("Successfully announced!") + + // Now, look for others who have announced + // This is like your friend telling you the location to meet you. + myctx := context.Background() + logger.Warn("Searching for other peers...") + peerChan, err := routingDiscovery.FindPeers(myctx, rendezvousString) + if err != nil { + panic(err) + } + + for peer := range peerChan { + if peer.ID == ha.ID() { + logger.Warn("wew") + continue + } + + logger.Warn("Found peer:", peer) + + logger.Warn("Connecting to:", peer) + stream, err := ha.NewStream(myctx, peer.ID, "/echo/1.0.0") + + if err != nil { + logger.Warn("Connection failed:", err) + continue + } else { + rw := bufio.NewReadWriter(bufio.NewReader(stream), bufio.NewWriter(stream)) + + go writeData(rw) + go readData(rw) + } + + logger.Warn("Connected to:", peer) + } + + select {} + +} + +func handleStream(s network.Stream) { + logger.Warn("Got a new stream!") + + // Create a buffer stream for non-blocking read and write. + rw := bufio.NewReadWriter(bufio.NewReader(s), bufio.NewWriter(s)) + + go readData(rw) + go writeData(rw) + + // stream 's' will stay open until you close it (or the other side closes it). +} + +func readData(rw *bufio.ReadWriter) { + for { + str, _ := rw.ReadString('\n') + + if str == "" { + return + } + if str != "\n" { + + fmt.Println(str) + } + + } +} + +func writeData(rw *bufio.ReadWriter) { + rw.WriteString("{\"Status\": \"ok\"}\n") + rw.Flush() +} + +// doEcho reads a line of data a stream and writes it back +func doEcho(s network.Stream) error { + + buf := make([]byte, 1024) + n, err := s.Read(buf) + if err != nil { + logger.Fatal(err) + } + + var msg core.TransactionContent + err = json.Unmarshal(buf[:n], &msg) + if err != nil { + logger.Fatal(err) + } + + fmt.Println("Received message:", msg) + return err +} + +func CloseNode(sourceNode host.Host) { + if err := sourceNode.Close(); err != nil { + panic(err) + } +} + +func RunSender(ctx context.Context, ha host.Host, targetPeer string, content []byte) { + fullAddr := getHostAddress(ha) + logger.Warn("I am %s\n", fullAddr) + maddr, err := multiaddr.NewMultiaddr(targetPeer) + handleError(err) + info, err := peer.AddrInfoFromP2pAddr(maddr) + handleError(err) + ha.Peerstore().AddAddr(info.ID, info.Addrs[0], peerstore.PermanentAddrTTL) + logger.Warn("Sender stream opened") + + s, err := ha.NewStream(context.Background(), info.ID, "/echo/1.0.0") + handleError(err) + logger.Warn("Sending...") + _, err = s.Write(content) + if err != nil { + logger.Warn(err) + return + } + // s.Close() + + buf := make([]byte, 1024) + _, err = s.Read(buf) + if err != nil { + logger.Fatal(err) + } + + // var msg core.TransactionContent + // err = json.Unmarshal(buf[:n], &msg) + // if err != nil { + // log.Fatal(err) + // } + + logger.Warn("Read reply: ", string(buf)) + s.Close() +} + +func handleError(err error) { + if err != nil { + panic(err) + } +} + +func POC() { + node, err := libp2p.New( + libp2p.ListenAddrStrings("/ip4/127.0.0.1/tcp/0"), + ) + if err != nil { + panic(err) + } + + peerInfo := peer.AddrInfo{ + ID: node.ID(), + Addrs: node.Addrs(), + } + + addrs, _ := peer.AddrInfoToP2pAddrs(&peerInfo) + fmt.Println("libp2p node address:", addrs[0]) + + if len(os.Args) > 1 { + addr, err := multiaddr.NewMultiaddr(os.Args[1]) + if err != nil { + panic(err) + } + peer, err := peer.AddrInfoFromP2pAddr(addr) + if err != nil { + panic(err) + } + if err := node.Connect(context.Background(), *peer); err != nil { + panic(err) + } + } else { + ch := make(chan os.Signal, 1) + signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM) + <-ch + fmt.Println("Received signal, shutting down...") + } + + if err := node.Close(); err != nil { + panic(err) + } + +} diff --git a/z2/backend/rpc/server.go b/z2/backend/rpc/server.go new file mode 100644 index 0000000..f8394d7 --- /dev/null +++ b/z2/backend/rpc/server.go @@ -0,0 +1,120 @@ +package rpc + +import ( + "fmt" + "net/http" + "sync" + + "thesis/core" + "thesis/db" + "thesis/ent" + + "github.com/gin-contrib/cors" + "github.com/gin-gonic/gin" +) + +type RegistrationInfo struct { + PublicKey string `json:"pk" binding:"required"` + Owner string `json:"owner" binding:"required"` +} + +type TransactionSubmission struct { + Signer string `json:"signer" binding:"required"` + Comment string `json:"comment" binding:"required"` + Commitment string `json:"commit" binding:"required"` + Signature string `json:"sig" binding:"required"` +} + +func Serve(wg *sync.WaitGroup, client *ent.Client) { + + r := gin.Default() + + // r.Use(cors.New(cors.Config{ + // AllowOrigins: []string{"http://localhost:5173/"}, + // AllowMethods: []string{"POST", "GET", "OPTIONS"}, + // AllowHeaders: []string{"Origin", "Access-Control-Allow-Origin", "Content-Type"}, + // ExposeHeaders: []string{"Content-Length"}, + // })) + + r.Use(cors.Default()) + + r.GET("/ping", func(c *gin.Context) { + c.JSON(200, gin.H{ + "message": "pong", + }) + }) + r.GET("/stats", func(c *gin.Context) { + + txCount := db.GetTxCount(client) + lastBlock := db.GetLatestBlock(client) + if lastBlock != nil { + c.JSON(200, gin.H{ + "status": "ok", + "data": gin.H{ + "txCount": txCount, + "latestBlock": lastBlock.Hash, + "peers": 2, + }, + }) + return + } + c.JSON(200, gin.H{ + "status": "ok", + "data": gin.H{ + "txCount": 0, + "latestBlock": 0x000, + "peers": 2, + }, + }) + + }) + + r.POST("/submitTx", func(c *gin.Context) { + var data TransactionSubmission + if err := c.BindJSON(&data); err != nil { + c.JSON(http.StatusBadRequest, gin.H{ + "status": "bad", + "details": "malformed data provided", + }) + return + } + fmt.Println(data) + + key := db.GetKeyFromHex(client, data.Signer) + err := core.AddNewTx(client, []byte(data.Comment), data.Commitment, data.Signature, key) + if err != nil { + c.JSON(http.StatusBadRequest, gin.H{ + "status": "bad", + "details": "can't process tx", + }) + return + } + c.JSON(http.StatusOK, gin.H{ + "status": "ok", + }) + }) + + r.POST("/register", func(c *gin.Context) { + var data RegistrationInfo + if err := c.BindJSON(&data); err != nil { + c.JSON(http.StatusBadRequest, gin.H{ + "status": "bad", + "details": "invalid data provided", + }) + return + } + err := db.AddKey(client, data.PublicKey, data.Owner) + if err != nil { + c.JSON(http.StatusBadRequest, gin.H{ + "status": "bad", + "details": "key already registered", + }) + return + } + c.JSON(http.StatusOK, gin.H{ + "status": "ok", + }) + }) + r.Run() + wg.Done() +} diff --git a/z2/backend/zk/zk.go b/z2/backend/zk/zk.go new file mode 100644 index 0000000..ebced1f --- /dev/null +++ b/z2/backend/zk/zk.go @@ -0,0 +1,44 @@ +package zk + +import ( + "encoding/hex" + + "github.com/consensys/gnark-crypto/ecc" + "github.com/consensys/gnark/backend/groth16" + "github.com/consensys/gnark/frontend" + "github.com/consensys/gnark/frontend/cs/r1cs" + "github.com/consensys/gnark/std/hash/mimc" +) + +type Circuit struct { + Secret frontend.Variable + Hash frontend.Variable +} + +func (circuit *Circuit) Define(api frontend.API) error { + mimc, _ := mimc.NewMiMC(api) + mimc.Write(circuit.Secret) + + api.AssertIsEqual(circuit.Hash, mimc.Sum()) + + return nil +} + +func POC() { + var circuit Circuit + + r1cs, err := frontend.Compile(ecc.BW6_633.ScalarField(), r1cs.NewBuilder, &circuit) + if err != nil { + panic(err) + } + + var assignment Circuit + assignment.Secret = "0x" + hex.EncodeToString([]byte("Hello, World!")) + assignment.Hash = "27353532363483121849779111558069699868988271024434984431742151050156752877051628698253914937683" + + witness, _ := frontend.NewWitness(&assignment, ecc.BW6_633.ScalarField()) + pk, vk, _ := groth16.Setup(r1cs) + proof, _ := groth16.Prove(r1cs, pk, witness) + publicWitness, _ := witness.Public() + _ = groth16.Verify(proof, vk, publicWitness) +} diff --git a/z2/deployment.yml b/z2/deployment.yml new file mode 100644 index 0000000..040a120 --- /dev/null +++ b/z2/deployment.yml @@ -0,0 +1,59 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: p2p-node + namespace: veritas +spec: + replicas: 1 + selector: + matchLabels: + name: p2p-node + template: + metadata: + labels: + name: p2p-node + spec: + containers: + - env: + - name: PORT + value: "6000" + name: p2pnode + image: localhost:5000/veritasnode + imagePullPolicy: IfNotPresent + imagePullPolicy: IfNotPresent + ports: + - containerPort: 6000 + hostPort: 6000 + protocol: TCP + volumeMounts: + - mountPath: /app + name: node-data + volumes: + - name: node-data + persistentVolumeClaim: + claimName: node-data +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: veritasfe + namespace: veritas +spec: + replicas: 1 + selector: + matchLabels: + app: veritasfe + template: + metadata: + labels: + app: veritasfe + spec: + containers: + - image: localhost:5000/veritasfe + name: frontend + ports: + - containerPort: 3000 + hostPort: 3000 + protocol: TCP + restartPolicy: Always diff --git a/z2/docker-compose.yml b/z2/docker-compose.yml new file mode 100644 index 0000000..df819e7 --- /dev/null +++ b/z2/docker-compose.yml @@ -0,0 +1,31 @@ +services: + + p2p-node: + build: ./backend + restart: "always" + container_name: p2pnode + environment: + - PORT=6000 + ports: + - 6000:6000 + networks: + - internalnet + volumes: + - node_data:/app + + + frontend: + build: ./veritasfe + restart: "always" + container_name: frontend + ports: + - 3000:3000 + networks: + - internalnet + +networks: + internalnet: + driver: bridge + +volumes: + node_data: \ No newline at end of file diff --git a/z2/service.yml b/z2/service.yml new file mode 100644 index 0000000..c502977 --- /dev/null +++ b/z2/service.yml @@ -0,0 +1,27 @@ +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: p2p-node + name: p2p-node + namespace: veritas +spec: + ports: + - name: "6000" + port: 6000 + targetPort: 6000 + +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: frontend + name: frontend + namespace: veritas +spec: + ports: + - name: "3000" + port: 3000 + targetPort: 3000 diff --git a/z2/start-app.sh b/z2/start-app.sh new file mode 100755 index 0000000..ce2a50c --- /dev/null +++ b/z2/start-app.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +kubectl create namespace veritas +kubectl apply -f deployment.yml +kubectl apply -f service.yml +kubectl apply -f statefulset.yaml diff --git a/z2/statefulset.yaml b/z2/statefulset.yaml new file mode 100644 index 0000000..f945f08 --- /dev/null +++ b/z2/statefulset.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: node-data + namespace: veritas +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 300Mi diff --git a/z2/stop-app.sh b/z2/stop-app.sh new file mode 100755 index 0000000..b75d35d --- /dev/null +++ b/z2/stop-app.sh @@ -0,0 +1,4 @@ +#!/bin/bash +kubectl delete -f deployment.yml +kubectl delete -f service.yml +kubectl delete -f statefulset.yaml diff --git a/z2/veritasfe/.gitignore b/z2/veritasfe/.gitignore new file mode 100644 index 0000000..6635cf5 --- /dev/null +++ b/z2/veritasfe/.gitignore @@ -0,0 +1,10 @@ +.DS_Store +node_modules +/build +/.svelte-kit +/package +.env +.env.* +!.env.example +vite.config.js.timestamp-* +vite.config.ts.timestamp-* diff --git a/z2/veritasfe/.npmrc b/z2/veritasfe/.npmrc new file mode 100644 index 0000000..b6f27f1 --- /dev/null +++ b/z2/veritasfe/.npmrc @@ -0,0 +1 @@ +engine-strict=true diff --git a/z2/veritasfe/Dockerfile b/z2/veritasfe/Dockerfile new file mode 100644 index 0000000..a719a1e --- /dev/null +++ b/z2/veritasfe/Dockerfile @@ -0,0 +1,16 @@ +FROM node:18-alpine AS builder +WORKDIR /app +COPY package*.json . +RUN npm ci +COPY . . +RUN npm run build +RUN npm prune --production + +FROM node:18-alpine +WORKDIR /app +COPY --from=builder /app/build build/ +COPY --from=builder /app/node_modules node_modules/ +COPY package.json . +EXPOSE 3000 +ENV NODE_ENV=production +CMD [ "node", "build" ] \ No newline at end of file diff --git a/z2/veritasfe/README.md b/z2/veritasfe/README.md new file mode 100644 index 0000000..5ce6766 --- /dev/null +++ b/z2/veritasfe/README.md @@ -0,0 +1,38 @@ +# create-svelte + +Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte). + +## Creating a project + +If you're seeing this, you've probably already done this step. Congrats! + +```bash +# create a new project in the current directory +npm create svelte@latest + +# create a new project in my-app +npm create svelte@latest my-app +``` + +## Developing + +Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: + +```bash +npm run dev + +# or start the server and open the app in a new browser tab +npm run dev -- --open +``` + +## Building + +To create a production version of your app: + +```bash +npm run build +``` + +You can preview the production build with `npm run preview`. + +> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment. diff --git a/z2/veritasfe/package-lock.json b/z2/veritasfe/package-lock.json new file mode 100644 index 0000000..8a8c453 --- /dev/null +++ b/z2/veritasfe/package-lock.json @@ -0,0 +1,5012 @@ +{ + "name": "veritasfe", + "version": "0.0.1", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "veritasfe", + "version": "0.0.1", + "dependencies": { + "@chainsafe/bls": "^8.1.0", + "@chainsafe/blst": "^1.0.0", + "@chainsafe/libp2p-noise": "^15.0.0", + "@chainsafe/libp2p-yamux": "^6.0.2", + "@libp2p/bootstrap": "^10.0.20", + "@libp2p/websockets": "^8.0.20", + "@sveltejs/adapter-node": "^5.0.1", + "buffer": "^6.0.3", + "libp2p": "^1.4.2" + }, + "devDependencies": { + "@sveltejs/adapter-auto": "^3.0.0", + "@sveltejs/kit": "^2.0.0", + "@sveltejs/vite-plugin-svelte": "^3.0.0", + "@zerodevx/svelte-toast": "^0.9.5", + "autoprefixer": "^10.4.19", + "daisyui": "^4.10.2", + "postcss": "^8.4.38", + "svelte": "^4.2.7", + "svelte-check": "^3.6.0", + "tailwindcss": "^3.4.3", + "tslib": "^2.4.1", + "typescript": "^5.0.0", + "vite": "^5.0.3" + } + }, + "node_modules/@alloc/quick-lru": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz", + "integrity": "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@ampproject/remapping": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", + "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@chainsafe/as-chacha20poly1305": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@chainsafe/as-chacha20poly1305/-/as-chacha20poly1305-0.1.0.tgz", + "integrity": "sha512-BpNcL8/lji/GM3+vZ/bgRWqJ1q5kwvTFmGPk7pxm/QQZDbaMI98waOHjEymTjq2JmdD/INdNBFOVSyJofXg7ew==" + }, + "node_modules/@chainsafe/as-sha256": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@chainsafe/as-sha256/-/as-sha256-0.4.1.tgz", + "integrity": "sha512-IqeeGwQihK6Y2EYLFofqs2eY2ep1I2MvQXHzOAI+5iQN51OZlUkrLgyAugu2x86xZewDk5xas7lNczkzFzF62w==" + }, + "node_modules/@chainsafe/bls": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@chainsafe/bls/-/bls-8.1.0.tgz", + "integrity": "sha512-C4a1gUpFHYzJG7aaik4w+7QTeJ4pGCDTZ28YUwAWOFaWgAJSK+769ib6CNBu5Txb3PpvcC5GuhICQaDopIgEHg==", + "dependencies": { + "@chainsafe/bls-keygen": "^0.4.0", + "bls-eth-wasm": "^1.1.1" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@chainsafe/blst": "^1.0.0" + }, + "peerDependenciesMeta": { + "@chainsafe/blst": { + "optional": true + } + } + }, + "node_modules/@chainsafe/bls-hd-key": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@chainsafe/bls-hd-key/-/bls-hd-key-0.3.0.tgz", + "integrity": "sha512-LsYYnfBEEmqGFPDm8hQN3Kc+v9wPFnhn+CToD403KEynUiUSHKLAf5B6UCY5eooShDOcaGCUgAUhIw1CmpEf3Q==", + "dependencies": { + "@noble/hashes": "^1.0.0" + } + }, + "node_modules/@chainsafe/bls-keygen": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@chainsafe/bls-keygen/-/bls-keygen-0.4.0.tgz", + "integrity": "sha512-wqtuj4G/sWpIugJW1mb/nSTwcTuZKqB3DS3ANUIOn7pva8EB6LfxgIL34o4qk3lti/8Mdxqtqc2n4xRszrNdzA==", + "dependencies": { + "@chainsafe/bls-hd-key": "^0.3.0", + "@noble/hashes": "^1.0.0", + "@scure/bip39": "^1.0.0" + } + }, + "node_modules/@chainsafe/blst": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@chainsafe/blst/-/blst-1.0.0.tgz", + "integrity": "sha512-WQDxFvcG+glmusXnWQ3W4g2tvHuTQEK0/cIZz37TskZJqOqAtOogZsK3cD3j+OoxbdCRT6l08QUCOtPMOLe/zA==", + "hasInstallScript": true, + "dependencies": { + "node-addon-api": "^6.1.0", + "node-gyp": "^10.0.1", + "ts-node": "^10.9.2" + } + }, + "node_modules/@chainsafe/is-ip": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@chainsafe/is-ip/-/is-ip-2.0.2.tgz", + "integrity": "sha512-ndGqEMG1W5WkGagaqOZHpPU172AGdxr+LD15sv3WIUvT5oCFUrG1Y0CW/v2Egwj4JXEvSibaIIIqImsm98y1nA==" + }, + "node_modules/@chainsafe/libp2p-noise": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/@chainsafe/libp2p-noise/-/libp2p-noise-15.0.0.tgz", + "integrity": "sha512-O8Y/WVU4J/qrnG72jwVhbmdXiBzv1dT9B3PMClCRmZ9z/5vVPEGRVXE/SVYeGF3bNuBTLoh+F+GaKG/9UHlMhg==", + "dependencies": { + "@chainsafe/as-chacha20poly1305": "^0.1.0", + "@chainsafe/as-sha256": "^0.4.1", + "@libp2p/crypto": "^4.0.0", + "@libp2p/interface": "^1.0.0", + "@libp2p/peer-id": "^4.0.0", + "@noble/ciphers": "^0.4.0", + "@noble/curves": "^1.1.0", + "@noble/hashes": "^1.3.1", + "it-length-prefixed": "^9.0.1", + "it-length-prefixed-stream": "^1.0.0", + "it-pair": "^2.0.6", + "it-pipe": "^3.0.1", + "it-stream-types": "^2.0.1", + "protons-runtime": "^5.0.0", + "uint8arraylist": "^2.4.3", + "uint8arrays": "^5.0.0", + "wherearewe": "^2.0.1" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/@chainsafe/libp2p-yamux": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@chainsafe/libp2p-yamux/-/libp2p-yamux-6.0.2.tgz", + "integrity": "sha512-S5OkLHqYhEVMQQ4BTgnRANEIbGTQhaC23glCgBwGdeoTRtMpIozwDiPfljFLCm0RYWdCRJw9oFztO95KUHjptA==", + "dependencies": { + "@libp2p/interface": "^1.1.3", + "@libp2p/utils": "^5.2.5", + "get-iterator": "^2.0.1", + "it-foreach": "^2.0.6", + "it-pipe": "^3.0.1", + "it-pushable": "^3.2.3", + "uint8arraylist": "^2.4.8" + } + }, + "node_modules/@chainsafe/netmask": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@chainsafe/netmask/-/netmask-2.0.0.tgz", + "integrity": "sha512-I3Z+6SWUoaljh3TBzCnCxjlUyN8tA+NAk5L6m9IxvCf1BENQTePzPMis97CoN/iMW1St3WN+AWCCRp+TTBRiDg==", + "dependencies": { + "@chainsafe/is-ip": "^2.0.1" + } + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.20.2.tgz", + "integrity": "sha512-D+EBOJHXdNZcLJRBkhENNG8Wji2kgc9AZ9KiPr1JuZjsNtyHzrsfLRrY0tk2H2aoFu6RANO1y1iPPUCDYWkb5g==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.20.2.tgz", + "integrity": "sha512-t98Ra6pw2VaDhqNWO2Oph2LXbz/EJcnLmKLGBJwEwXX/JAN83Fym1rU8l0JUWK6HkIbWONCSSatf4sf2NBRx/w==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.20.2.tgz", + "integrity": "sha512-mRzjLacRtl/tWU0SvD8lUEwb61yP9cqQo6noDZP/O8VkwafSYwZ4yWy24kan8jE/IMERpYncRt2dw438LP3Xmg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.20.2.tgz", + "integrity": "sha512-btzExgV+/lMGDDa194CcUQm53ncxzeBrWJcncOBxuC6ndBkKxnHdFJn86mCIgTELsooUmwUm9FkhSp5HYu00Rg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.20.2.tgz", + "integrity": "sha512-4J6IRT+10J3aJH3l1yzEg9y3wkTDgDk7TSDFX+wKFiWjqWp/iCfLIYzGyasx9l0SAFPT1HwSCR+0w/h1ES/MjA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.20.2.tgz", + "integrity": "sha512-tBcXp9KNphnNH0dfhv8KYkZhjc+H3XBkF5DKtswJblV7KlT9EI2+jeA8DgBjp908WEuYll6pF+UStUCfEpdysA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.20.2.tgz", + "integrity": "sha512-d3qI41G4SuLiCGCFGUrKsSeTXyWG6yem1KcGZVS+3FYlYhtNoNgYrWcvkOoaqMhwXSMrZRl69ArHsGJ9mYdbbw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.20.2.tgz", + "integrity": "sha512-d+DipyvHRuqEeM5zDivKV1KuXn9WeRX6vqSqIDgwIfPQtwMP4jaDsQsDncjTDDsExT4lR/91OLjRo8bmC1e+Cw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.20.2.tgz", + "integrity": "sha512-VhLPeR8HTMPccbuWWcEUD1Az68TqaTYyj6nfE4QByZIQEQVWBB8vup8PpR7y1QHL3CpcF6xd5WVBU/+SBEvGTg==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.20.2.tgz", + "integrity": "sha512-9pb6rBjGvTFNira2FLIWqDk/uaf42sSyLE8j1rnUpuzsODBq7FvpwHYZxQ/It/8b+QOS1RYfqgGFNLRI+qlq2A==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.20.2.tgz", + "integrity": "sha512-o10utieEkNPFDZFQm9CoP7Tvb33UutoJqg3qKf1PWVeeJhJw0Q347PxMvBgVVFgouYLGIhFYG0UGdBumROyiig==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.20.2.tgz", + "integrity": "sha512-PR7sp6R/UC4CFVomVINKJ80pMFlfDfMQMYynX7t1tNTeivQ6XdX5r2XovMmha/VjR1YN/HgHWsVcTRIMkymrgQ==", + "cpu": [ + "loong64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.20.2.tgz", + "integrity": "sha512-4BlTqeutE/KnOiTG5Y6Sb/Hw6hsBOZapOVF6njAESHInhlQAghVVZL1ZpIctBOoTFbQyGW+LsVYZ8lSSB3wkjA==", + "cpu": [ + "mips64el" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.20.2.tgz", + "integrity": "sha512-rD3KsaDprDcfajSKdn25ooz5J5/fWBylaaXkuotBDGnMnDP1Uv5DLAN/45qfnf3JDYyJv/ytGHQaziHUdyzaAg==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.20.2.tgz", + "integrity": "sha512-snwmBKacKmwTMmhLlz/3aH1Q9T8v45bKYGE3j26TsaOVtjIag4wLfWSiZykXzXuE1kbCE+zJRmwp+ZbIHinnVg==", + "cpu": [ + "riscv64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.20.2.tgz", + "integrity": "sha512-wcWISOobRWNm3cezm5HOZcYz1sKoHLd8VL1dl309DiixxVFoFe/o8HnwuIwn6sXre88Nwj+VwZUvJf4AFxkyrQ==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.20.2.tgz", + "integrity": "sha512-1MdwI6OOTsfQfek8sLwgyjOXAu+wKhLEoaOLTjbijk6E2WONYpH9ZU2mNtR+lZ2B4uwr+usqGuVfFT9tMtGvGw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.20.2.tgz", + "integrity": "sha512-K8/DhBxcVQkzYc43yJXDSyjlFeHQJBiowJ0uVL6Tor3jGQfSGHNNJcWxNbOI8v5k82prYqzPuwkzHt3J1T1iZQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.20.2.tgz", + "integrity": "sha512-eMpKlV0SThJmmJgiVyN9jTPJ2VBPquf6Kt/nAoo6DgHAoN57K15ZghiHaMvqjCye/uU4X5u3YSMgVBI1h3vKrQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.20.2.tgz", + "integrity": "sha512-2UyFtRC6cXLyejf/YEld4Hajo7UHILetzE1vsRcGL3earZEW77JxrFjH4Ez2qaTiEfMgAXxfAZCm1fvM/G/o8w==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.20.2.tgz", + "integrity": "sha512-GRibxoawM9ZCnDxnP3usoUDO9vUkpAxIIZ6GQI+IlVmr5kP3zUq+l17xELTHMWTWzjxa2guPNyrpq1GWmPvcGQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.20.2.tgz", + "integrity": "sha512-HfLOfn9YWmkSKRQqovpnITazdtquEW8/SoHW7pWpuEeguaZI4QnCRW6b+oZTztdBnZOS2hqJ6im/D5cPzBTTlQ==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.20.2.tgz", + "integrity": "sha512-N49X4lJX27+l9jbLKSqZ6bKNjzQvHaT8IIFUy+YIqmXQdjYCToGWwOItDrfby14c78aDd5NHQl29xingXfCdLQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", + "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", + "dependencies": { + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@leichtgewicht/ip-codec": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@leichtgewicht/ip-codec/-/ip-codec-2.0.5.tgz", + "integrity": "sha512-Vo+PSpZG2/fmgmiNzYK9qWRh8h/CHrwD0mo1h1DzL4yzHNSfWYujGTYsWGreD000gcgmZ7K4Ys6Tx9TxtsKdDw==" + }, + "node_modules/@libp2p/bootstrap": { + "version": "10.0.20", + "resolved": "https://registry.npmjs.org/@libp2p/bootstrap/-/bootstrap-10.0.20.tgz", + "integrity": "sha512-xy0bYs7JYPvVKRpGX3va8QOwPnGhmjAytEzQBKProDzpO8ASGwyFedzxn43ce+OI7Uzdo6tCeP5vXkEX19wPnQ==", + "dependencies": { + "@libp2p/interface": "^1.2.0", + "@libp2p/peer-id": "^4.0.10", + "@multiformats/mafmt": "^12.1.6", + "@multiformats/multiaddr": "^12.2.1" + } + }, + "node_modules/@libp2p/crypto": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@libp2p/crypto/-/crypto-4.0.6.tgz", + "integrity": "sha512-AJ4i3DHOTlY961O26M3k1IjmU4rUd5WgeK4t9IRzFfLIbD6uwA+cevJMG2qr0UHJfbYdGKKQ2Po1wqZONoIA9Q==", + "dependencies": { + "@libp2p/interface": "^1.2.0", + "@noble/curves": "^1.4.0", + "@noble/hashes": "^1.4.0", + "asn1js": "^3.0.5", + "multiformats": "^13.1.0", + "protons-runtime": "^5.4.0", + "uint8arraylist": "^2.4.8", + "uint8arrays": "^5.0.3" + } + }, + "node_modules/@libp2p/interface": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@libp2p/interface/-/interface-1.2.0.tgz", + "integrity": "sha512-ImnGNl3El/AukgaojACT8i9SNW1FOsrThcQU/qA3w5tEBR5p84Uwgzl/nxa4X5vGinItUJ9jLEJmtkQJENoiGQ==", + "dependencies": { + "@multiformats/multiaddr": "^12.2.1", + "it-pushable": "^3.2.3", + "it-stream-types": "^2.0.1", + "multiformats": "^13.1.0", + "progress-events": "^1.0.0", + "uint8arraylist": "^2.4.8" + } + }, + "node_modules/@libp2p/interface-internal": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@libp2p/interface-internal/-/interface-internal-1.1.0.tgz", + "integrity": "sha512-B6Cu3Mhp5kY2Z1cU0soCR4ZtjZtE4FuWE0qdJNauOpcQe9HOjPF8SanFmeEIZ0FKSOo0onQdQi2YdNUTtOVyvQ==", + "dependencies": { + "@libp2p/interface": "^1.2.0", + "@libp2p/peer-collections": "^5.1.10", + "@multiformats/multiaddr": "^12.2.1", + "uint8arraylist": "^2.4.8" + } + }, + "node_modules/@libp2p/logger": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/@libp2p/logger/-/logger-4.0.10.tgz", + "integrity": "sha512-JiRfJHO/D9Jlh2rJ6STnONoeQevBAdAZaGUxrtvBf4RFfucldSFEMOtdkFO8xFGuiA90Q2kj4BE2douG6fB3Lw==", + "dependencies": { + "@libp2p/interface": "^1.2.0", + "@multiformats/multiaddr": "^12.2.1", + "debug": "^4.3.4", + "interface-datastore": "^8.2.11", + "multiformats": "^13.1.0" + } + }, + "node_modules/@libp2p/multistream-select": { + "version": "5.1.7", + "resolved": "https://registry.npmjs.org/@libp2p/multistream-select/-/multistream-select-5.1.7.tgz", + "integrity": "sha512-R+Crhd5EDZZpGA3F02F4vwVxIJ2NkIqwWOfPB0RRGAhQLZu2dJGa0yXclYvdCR89p1hDJMIENekz4ncAVhTE7Q==", + "dependencies": { + "@libp2p/interface": "^1.2.0", + "it-length-prefixed": "^9.0.4", + "it-length-prefixed-stream": "^1.1.6", + "it-stream-types": "^2.0.1", + "p-defer": "^4.0.1", + "race-signal": "^1.0.2", + "uint8-varint": "^2.0.4", + "uint8arraylist": "^2.4.8", + "uint8arrays": "^5.0.3" + } + }, + "node_modules/@libp2p/peer-collections": { + "version": "5.1.10", + "resolved": "https://registry.npmjs.org/@libp2p/peer-collections/-/peer-collections-5.1.10.tgz", + "integrity": "sha512-Edr4FBzCgE7FRgc0wfYfcmihQ4GDHwkQP7xMG4oOVoIxHEzuk9Nb2opK9cLbK+nU4oAROgFLzJEJuiG7BGV2hg==", + "dependencies": { + "@libp2p/interface": "^1.2.0", + "@libp2p/peer-id": "^4.0.10" + } + }, + "node_modules/@libp2p/peer-id": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/@libp2p/peer-id/-/peer-id-4.0.10.tgz", + "integrity": "sha512-cR5dQ5fPcxP4LLSXDgo+TSOhtElZSwRXVSSgT/GM/Vvbua5M91NzsksYfd/lg8XwTCSvTER0qmE6ZIR05vjQrA==", + "dependencies": { + "@libp2p/interface": "^1.2.0", + "multiformats": "^13.1.0", + "uint8arrays": "^5.0.3" + } + }, + "node_modules/@libp2p/peer-id-factory": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/@libp2p/peer-id-factory/-/peer-id-factory-4.0.10.tgz", + "integrity": "sha512-iCGKY4gjv00omV2S8hkqmz+DY4hM1GBdN858utLbnCwPXvgkdoS9UqD8tIHw56IZ5/VcxYVmgRxSbD/ECDXVsA==", + "dependencies": { + "@libp2p/crypto": "^4.0.6", + "@libp2p/interface": "^1.2.0", + "@libp2p/peer-id": "^4.0.10", + "protons-runtime": "^5.4.0", + "uint8arraylist": "^2.4.8", + "uint8arrays": "^5.0.3" + } + }, + "node_modules/@libp2p/peer-record": { + "version": "7.0.14", + "resolved": "https://registry.npmjs.org/@libp2p/peer-record/-/peer-record-7.0.14.tgz", + "integrity": "sha512-vaL3irs6OBkINFqj/ZeZ4+kXGVhKmR3LF+g5ELk1CqHoWWNNRXMiecm+gX2ttzHBA/moa7M3AF4pH/iF2H3dHQ==", + "dependencies": { + "@libp2p/crypto": "^4.0.6", + "@libp2p/interface": "^1.2.0", + "@libp2p/peer-id": "^4.0.10", + "@libp2p/utils": "^5.3.1", + "@multiformats/multiaddr": "^12.2.1", + "protons-runtime": "^5.4.0", + "uint8-varint": "^2.0.4", + "uint8arraylist": "^2.4.8", + "uint8arrays": "^5.0.3" + } + }, + "node_modules/@libp2p/peer-store": { + "version": "10.0.15", + "resolved": "https://registry.npmjs.org/@libp2p/peer-store/-/peer-store-10.0.15.tgz", + "integrity": "sha512-DDhn/JbwpDM3oWQhSMTiNnFD4v2Xbs0Wsr6f35Gvx/8PR45n5qg3CHB2RBRNZORXDXyxF8FEPygXqPKQ0elO0Q==", + "dependencies": { + "@libp2p/interface": "^1.2.0", + "@libp2p/peer-collections": "^5.1.10", + "@libp2p/peer-id": "^4.0.10", + "@libp2p/peer-record": "^7.0.14", + "@multiformats/multiaddr": "^12.2.1", + "interface-datastore": "^8.2.11", + "it-all": "^3.0.4", + "mortice": "^3.0.4", + "multiformats": "^13.1.0", + "protons-runtime": "^5.4.0", + "uint8arraylist": "^2.4.8", + "uint8arrays": "^5.0.3" + } + }, + "node_modules/@libp2p/utils": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/@libp2p/utils/-/utils-5.3.1.tgz", + "integrity": "sha512-FdGzRU50PJLYSEOmVXqqtq27yjUVXkU4QNRZzMVuXF9L/sKgSC2oXwj0Satc9fHx5tG3MCX1ZOSAmYEIl2fu+w==", + "dependencies": { + "@chainsafe/is-ip": "^2.0.2", + "@libp2p/interface": "^1.2.0", + "@libp2p/logger": "^4.0.10", + "@multiformats/multiaddr": "^12.2.1", + "@multiformats/multiaddr-matcher": "^1.2.0", + "delay": "^6.0.0", + "get-iterator": "^2.0.1", + "is-loopback-addr": "^2.0.2", + "it-pushable": "^3.2.3", + "it-stream-types": "^2.0.1", + "netmask": "^2.0.2", + "p-defer": "^4.0.1", + "race-event": "^1.2.0", + "race-signal": "^1.0.2", + "uint8arraylist": "^2.4.8" + } + }, + "node_modules/@libp2p/websockets": { + "version": "8.0.20", + "resolved": "https://registry.npmjs.org/@libp2p/websockets/-/websockets-8.0.20.tgz", + "integrity": "sha512-9GeNALY82CavRAFSa4GO0DGSON7nDpWaRNdqJ7quxPDrbbne7j6VuzbcQ0IWWMFWDVtAkkfjx3c9uWmud6T+TQ==", + "dependencies": { + "@libp2p/interface": "^1.2.0", + "@libp2p/utils": "^5.3.1", + "@multiformats/mafmt": "^12.1.6", + "@multiformats/multiaddr": "^12.2.1", + "@multiformats/multiaddr-to-uri": "^10.0.1", + "@types/ws": "^8.5.10", + "it-ws": "^6.1.1", + "p-defer": "^4.0.1", + "wherearewe": "^2.0.1", + "ws": "^8.16.0" + } + }, + "node_modules/@multiformats/dns": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@multiformats/dns/-/dns-1.0.6.tgz", + "integrity": "sha512-nt/5UqjMPtyvkG9BQYdJ4GfLK3nMqGpFZOzf4hAmIa0sJh2LlS9YKXZ4FgwBDsaHvzZqR/rUFIywIc7pkHNNuw==", + "dependencies": { + "@types/dns-packet": "^5.6.5", + "buffer": "^6.0.3", + "dns-packet": "^5.6.1", + "hashlru": "^2.3.0", + "p-queue": "^8.0.1", + "progress-events": "^1.0.0", + "uint8arrays": "^5.0.2" + } + }, + "node_modules/@multiformats/mafmt": { + "version": "12.1.6", + "resolved": "https://registry.npmjs.org/@multiformats/mafmt/-/mafmt-12.1.6.tgz", + "integrity": "sha512-tlJRfL21X+AKn9b5i5VnaTD6bNttpSpcqwKVmDmSHLwxoz97fAHaepqFOk/l1fIu94nImIXneNbhsJx/RQNIww==", + "dependencies": { + "@multiformats/multiaddr": "^12.0.0" + } + }, + "node_modules/@multiformats/multiaddr": { + "version": "12.2.1", + "resolved": "https://registry.npmjs.org/@multiformats/multiaddr/-/multiaddr-12.2.1.tgz", + "integrity": "sha512-UwjoArBbv64FlaetV4DDwh+PUMfzXUBltxQwdh+uTYnGFzVa8ZfJsn1vt1RJlJ6+Xtrm3RMekF/B+K338i2L5Q==", + "dependencies": { + "@chainsafe/is-ip": "^2.0.1", + "@chainsafe/netmask": "^2.0.0", + "@libp2p/interface": "^1.0.0", + "@multiformats/dns": "^1.0.3", + "multiformats": "^13.0.0", + "uint8-varint": "^2.0.1", + "uint8arrays": "^5.0.0" + } + }, + "node_modules/@multiformats/multiaddr-matcher": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@multiformats/multiaddr-matcher/-/multiaddr-matcher-1.2.0.tgz", + "integrity": "sha512-LH6yR7h3HSNKcxuvvi2UpLuowuVkYC6H9Y3jqmKuTai8XtKnXtW6NcDZFD/ooTBY+H4yX/scoJpjOalHrk5qdQ==", + "dependencies": { + "@chainsafe/is-ip": "^2.0.1", + "@multiformats/multiaddr": "^12.0.0", + "multiformats": "^13.0.0" + } + }, + "node_modules/@multiformats/multiaddr-to-uri": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/@multiformats/multiaddr-to-uri/-/multiaddr-to-uri-10.0.1.tgz", + "integrity": "sha512-RtOBRJucMCzINPytvt1y7tJ2jr4aSKJmv3DF7/C515RJO9+nu9sZHdsk9vn251OtN8k21rAGlIHESt/BSJWAnQ==", + "dependencies": { + "@multiformats/multiaddr": "^12.0.0" + } + }, + "node_modules/@noble/ciphers": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-0.4.1.tgz", + "integrity": "sha512-QCOA9cgf3Rc33owG0AYBB9wszz+Ul2kramWN8tXG44Gyciud/tbkEqvxRF/IpqQaBpRBNi9f4jdNxqB2CQCIXg==", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/curves": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.4.0.tgz", + "integrity": "sha512-p+4cb332SFCrReJkCYe8Xzm0OWi4Jji5jVdIZRL/PmacmDkFNw6MrrV+gGpiPxLHbV+zKFRywUWbaseT+tZRXg==", + "dependencies": { + "@noble/hashes": "1.4.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/hashes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@npmcli/agent": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@npmcli/agent/-/agent-2.2.2.tgz", + "integrity": "sha512-OrcNPXdpSl9UX7qPVRWbmWMCSXrcDa2M9DvrbOTj7ao1S4PlqVFYv9/yLKMkrJKZ/V5A/kDBC690or307i26Og==", + "dependencies": { + "agent-base": "^7.1.0", + "http-proxy-agent": "^7.0.0", + "https-proxy-agent": "^7.0.1", + "lru-cache": "^10.0.1", + "socks-proxy-agent": "^8.0.3" + }, + "engines": { + "node": "^16.14.0 || >=18.0.0" + } + }, + "node_modules/@npmcli/fs": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@npmcli/fs/-/fs-3.1.0.tgz", + "integrity": "sha512-7kZUAaLscfgbwBQRbvdMYaZOWyMEcPTH/tJjnyAWJ/dvvs9Ef+CERx/qJb9GExJpl1qipaDGn7KqHnFGGixd0w==", + "dependencies": { + "semver": "^7.3.5" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "optional": true, + "engines": { + "node": ">=14" + } + }, + "node_modules/@polka/url": { + "version": "1.0.0-next.25", + "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.25.tgz", + "integrity": "sha512-j7P6Rgr3mmtdkeDGTe0E/aYyWEWVtc5yFXtHCRHs28/jptDEWfaVOc5T7cblqy1XKPPfCxJc/8DwQ5YgLOZOVQ==" + }, + "node_modules/@rollup/plugin-commonjs": { + "version": "25.0.7", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-25.0.7.tgz", + "integrity": "sha512-nEvcR+LRjEjsaSsc4x3XZfCCvZIaSMenZu/OiwOKGN2UhQpAYI7ru7czFvyWbErlpoGjnSX3D5Ch5FcMA3kRWQ==", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "commondir": "^1.0.1", + "estree-walker": "^2.0.2", + "glob": "^8.0.3", + "is-reference": "1.2.1", + "magic-string": "^0.30.3" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.68.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==" + }, + "node_modules/@rollup/plugin-commonjs/node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dependencies": { + "@types/estree": "*" + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@rollup/plugin-json": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-6.1.0.tgz", + "integrity": "sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA==", + "dependencies": { + "@rollup/pluginutils": "^5.1.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-node-resolve": { + "version": "15.2.3", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.2.3.tgz", + "integrity": "sha512-j/lym8nf5E21LwBT4Df1VD6hRO2L2iwUeUmP7litikRsVp1H6NWx20NEp0Y7su+7XGc476GnXXc4kFeZNGmaSQ==", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-builtin-module": "^3.2.1", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.78.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", + "integrity": "sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==", + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils/node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==" + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.16.4.tgz", + "integrity": "sha512-GkhjAaQ8oUTOKE4g4gsZ0u8K/IHU1+2WQSgS1TwTcYvL+sjbaQjNHFXbOJ6kgqGHIO1DfUhI/Sphi9GkRT9K+Q==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.16.4.tgz", + "integrity": "sha512-Bvm6D+NPbGMQOcxvS1zUl8H7DWlywSXsphAeOnVeiZLQ+0J6Is8T7SrjGTH29KtYkiY9vld8ZnpV3G2EPbom+w==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.16.4.tgz", + "integrity": "sha512-i5d64MlnYBO9EkCOGe5vPR/EeDwjnKOGGdd7zKFhU5y8haKhQZTN2DgVtpODDMxUr4t2K90wTUJg7ilgND6bXw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.16.4.tgz", + "integrity": "sha512-WZupV1+CdUYehaZqjaFTClJI72fjJEgTXdf4NbW69I9XyvdmztUExBtcI2yIIU6hJtYvtwS6pkTkHJz+k08mAQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.16.4.tgz", + "integrity": "sha512-ADm/xt86JUnmAfA9mBqFcRp//RVRt1ohGOYF6yL+IFCYqOBNwy5lbEK05xTsEoJq+/tJzg8ICUtS82WinJRuIw==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.16.4.tgz", + "integrity": "sha512-tJfJaXPiFAG+Jn3cutp7mCs1ePltuAgRqdDZrzb1aeE3TktWWJ+g7xK9SNlaSUFw6IU4QgOxAY4rA+wZUT5Wfg==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.16.4.tgz", + "integrity": "sha512-7dy1BzQkgYlUTapDTvK997cgi0Orh5Iu7JlZVBy1MBURk7/HSbHkzRnXZa19ozy+wwD8/SlpJnOOckuNZtJR9w==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.16.4.tgz", + "integrity": "sha512-zsFwdUw5XLD1gQe0aoU2HVceI6NEW7q7m05wA46eUAyrkeNYExObfRFQcvA6zw8lfRc5BHtan3tBpo+kqEOxmg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.16.4.tgz", + "integrity": "sha512-p8C3NnxXooRdNrdv6dBmRTddEapfESEUflpICDNKXpHvTjRRq1J82CbU5G3XfebIZyI3B0s074JHMWD36qOW6w==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.16.4.tgz", + "integrity": "sha512-Lh/8ckoar4s4Id2foY7jNgitTOUQczwMWNYi+Mjt0eQ9LKhr6sK477REqQkmy8YHY3Ca3A2JJVdXnfb3Rrwkng==", + "cpu": [ + "riscv64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.16.4.tgz", + "integrity": "sha512-1xwwn9ZCQYuqGmulGsTZoKrrn0z2fAur2ujE60QgyDpHmBbXbxLaQiEvzJWDrscRq43c8DnuHx3QorhMTZgisQ==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.16.4.tgz", + "integrity": "sha512-LuOGGKAJ7dfRtxVnO1i3qWc6N9sh0Em/8aZ3CezixSTM+E9Oq3OvTsvC4sm6wWjzpsIlOCnZjdluINKESflJLA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.16.4.tgz", + "integrity": "sha512-ch86i7KkJKkLybDP2AtySFTRi5fM3KXp0PnHocHuJMdZwu7BuyIKi35BE9guMlmTpwwBTB3ljHj9IQXnTCD0vA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.16.4.tgz", + "integrity": "sha512-Ma4PwyLfOWZWayfEsNQzTDBVW8PZ6TUUN1uFTBQbF2Chv/+sjenE86lpiEwj2FiviSmSZ4Ap4MaAfl1ciF4aSA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.16.4.tgz", + "integrity": "sha512-9m/ZDrQsdo/c06uOlP3W9G2ENRVzgzbSXmXHT4hwVaDQhYcRpi9bgBT0FTG9OhESxwK0WjQxYOSfv40cU+T69w==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.16.4.tgz", + "integrity": "sha512-YunpoOAyGLDseanENHmbFvQSfVL5BxW3k7hhy0eN4rb3gS/ct75dVD0EXOWIqFT/nE8XYW6LP6vz6ctKRi0k9A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@scure/base": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.6.tgz", + "integrity": "sha512-ok9AWwhcgYuGG3Zfhyqg+zwl+Wn5uE+dwC0NV/2qQkx4dABbb/bx96vWu8NSj+BNjjSjno+JRYRjle1jV08k3g==", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip39": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.3.0.tgz", + "integrity": "sha512-disdg7gHuTDZtY+ZdkmLpPCk7fxZSu3gBiEGuoC1XYxv9cGx3Z6cpTggCgW6odSOOIXCiDjuGejW+aJKCY/pIQ==", + "dependencies": { + "@noble/hashes": "~1.4.0", + "@scure/base": "~1.1.6" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@sveltejs/adapter-auto": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@sveltejs/adapter-auto/-/adapter-auto-3.2.0.tgz", + "integrity": "sha512-She5nKT47kwHE18v9NMe6pbJcvULr82u0V3yZ0ej3n1laWKGgkgdEABE9/ak5iDPs93LqsBkuIo51kkwCLBjJA==", + "dev": true, + "dependencies": { + "import-meta-resolve": "^4.0.0" + }, + "peerDependencies": { + "@sveltejs/kit": "^2.0.0" + } + }, + "node_modules/@sveltejs/adapter-node": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@sveltejs/adapter-node/-/adapter-node-5.0.1.tgz", + "integrity": "sha512-eYdmxdUWMW+dad1JfMsWBPY2vjXz9eE+52A2AQnXPScPJlIxIVk5mmbaEEzrZivLfO2wEcLTZ5vdC03W69x+iA==", + "dependencies": { + "@rollup/plugin-commonjs": "^25.0.7", + "@rollup/plugin-json": "^6.1.0", + "@rollup/plugin-node-resolve": "^15.2.3", + "rollup": "^4.9.5" + }, + "peerDependencies": { + "@sveltejs/kit": "^2.4.0" + } + }, + "node_modules/@sveltejs/kit": { + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-2.5.7.tgz", + "integrity": "sha512-6uedTzrb7nQrw6HALxnPrPaXdIN2jJJTzTIl96Z3P5NiG+OAfpdPbrWrvkJ3GN4CfWqrmU4dJqwMMRMTD/C7ow==", + "hasInstallScript": true, + "dependencies": { + "@types/cookie": "^0.6.0", + "cookie": "^0.6.0", + "devalue": "^5.0.0", + "esm-env": "^1.0.0", + "import-meta-resolve": "^4.0.0", + "kleur": "^4.1.5", + "magic-string": "^0.30.5", + "mrmime": "^2.0.0", + "sade": "^1.8.1", + "set-cookie-parser": "^2.6.0", + "sirv": "^2.0.4", + "tiny-glob": "^0.2.9" + }, + "bin": { + "svelte-kit": "svelte-kit.js" + }, + "engines": { + "node": ">=18.13" + }, + "peerDependencies": { + "@sveltejs/vite-plugin-svelte": "^3.0.0", + "svelte": "^4.0.0 || ^5.0.0-next.0", + "vite": "^5.0.3" + } + }, + "node_modules/@sveltejs/vite-plugin-svelte": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-3.1.0.tgz", + "integrity": "sha512-sY6ncCvg+O3njnzbZexcVtUqOBE3iYmQPJ9y+yXSkOwG576QI/xJrBnQSRXFLGwJNBa0T78JEKg5cIR0WOAuUw==", + "dependencies": { + "@sveltejs/vite-plugin-svelte-inspector": "^2.0.0", + "debug": "^4.3.4", + "deepmerge": "^4.3.1", + "kleur": "^4.1.5", + "magic-string": "^0.30.9", + "svelte-hmr": "^0.16.0", + "vitefu": "^0.2.5" + }, + "engines": { + "node": "^18.0.0 || >=20" + }, + "peerDependencies": { + "svelte": "^4.0.0 || ^5.0.0-next.0", + "vite": "^5.0.0" + } + }, + "node_modules/@sveltejs/vite-plugin-svelte-inspector": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte-inspector/-/vite-plugin-svelte-inspector-2.1.0.tgz", + "integrity": "sha512-9QX28IymvBlSCqsCll5t0kQVxipsfhFFL+L2t3nTWfXnddYwxBuAEtTtlaVQpRz9c37BhJjltSeY4AJSC03SSg==", + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": "^18.0.0 || >=20" + }, + "peerDependencies": { + "@sveltejs/vite-plugin-svelte": "^3.0.0", + "svelte": "^4.0.0 || ^5.0.0-next.0", + "vite": "^5.0.0" + } + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==" + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==" + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==" + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==" + }, + "node_modules/@types/cookie": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==" + }, + "node_modules/@types/dns-packet": { + "version": "5.6.5", + "resolved": "https://registry.npmjs.org/@types/dns-packet/-/dns-packet-5.6.5.tgz", + "integrity": "sha512-qXOC7XLOEe43ehtWJCMnQXvgcIpv6rPmQ1jXT98Ad8A3TB1Ue50jsCbSSSyuazScEuZ/Q026vHbrOTVkmwA+7Q==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==" + }, + "node_modules/@types/node": { + "version": "20.12.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.7.tgz", + "integrity": "sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/pug": { + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/@types/pug/-/pug-2.0.10.tgz", + "integrity": "sha512-Sk/uYFOBAB7mb74XcpizmH0KOR2Pv3D2Hmrh1Dmy5BmK3MpdSa5kqZcg6EKBdklU0bFXX9gCfzvpnyUehrPIuA==", + "dev": true + }, + "node_modules/@types/resolve": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==" + }, + "node_modules/@types/ws": { + "version": "8.5.10", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.10.tgz", + "integrity": "sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@zerodevx/svelte-toast": { + "version": "0.9.5", + "resolved": "https://registry.npmjs.org/@zerodevx/svelte-toast/-/svelte-toast-0.9.5.tgz", + "integrity": "sha512-JLeB/oRdJfT+dz9A5bgd3Z7TuQnBQbeUtXrGIrNWMGqWbabpepBF2KxtWVhL2qtxpRqhae2f6NAOzH7xs4jUSw==", + "dev": true, + "peerDependencies": { + "svelte": "^3.57.0 || ^4.0.0" + } + }, + "node_modules/abbrev": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-2.0.0.tgz", + "integrity": "sha512-6/mh1E2u2YgEsCHdY0Yx5oW+61gZU+1vXaoiHHrpKeuRNNgFvS+/jrwHiQhB5apAf5oB7UB7E19ol2R2LKH8hQ==", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/acorn": { + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", + "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/agent-base": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", + "integrity": "sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==", + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/aggregate-error": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", + "integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==", + "dependencies": { + "clean-stack": "^2.0.0", + "indent-string": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", + "dev": true + }, + "node_modules/any-signal": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/any-signal/-/any-signal-4.1.1.tgz", + "integrity": "sha512-iADenERppdC+A2YKbOXXB2WUeABLaM6qnpZ70kZbPZ1cZMMJ7eF+3CaYm+/PhBizgkzlvssC7QuHS30oOiQYWA==", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/arg": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", + "integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==", + "dev": true + }, + "node_modules/aria-query": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", + "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", + "dependencies": { + "dequal": "^2.0.3" + } + }, + "node_modules/asn1js": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.5.tgz", + "integrity": "sha512-FVnvrKJwpt9LP2lAMl8qZswRNm3T4q9CON+bxldk2iwk3FFpuwhx2FfinyitizWHsVYyaY+y5JzDR0rCMV5yTQ==", + "dependencies": { + "pvtsutils": "^1.3.2", + "pvutils": "^1.1.3", + "tslib": "^2.4.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/autoprefixer": { + "version": "10.4.19", + "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.19.tgz", + "integrity": "sha512-BaENR2+zBZ8xXhM4pUaKUxlVdxZ0EZhjvbopwnXmxRUfqDmwSpC2lAi/QXvx7NRdPCo1WKEcEF6mV64si1z4Ew==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/autoprefixer" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "browserslist": "^4.23.0", + "caniuse-lite": "^1.0.30001599", + "fraction.js": "^4.3.7", + "normalize-range": "^0.1.2", + "picocolors": "^1.0.0", + "postcss-value-parser": "^4.2.0" + }, + "bin": { + "autoprefixer": "bin/autoprefixer" + }, + "engines": { + "node": "^10 || ^12 || >=14" + }, + "peerDependencies": { + "postcss": "^8.1.0" + } + }, + "node_modules/axobject-query": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.0.0.tgz", + "integrity": "sha512-+60uv1hiVFhHZeO+Lz0RYzsVHy5Wr1ayX0mwda9KPDVLNJgZ1T9Ny7VmFbLDzxsH0D87I86vgj3gFrjTJUYznw==", + "dependencies": { + "dequal": "^2.0.3" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/bls-eth-wasm": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/bls-eth-wasm/-/bls-eth-wasm-1.2.1.tgz", + "integrity": "sha512-hl4oBzZQmPGNb9Wt5GI+oEuHM6twGc5HzXCzNZMVLMMg+dltsOuvuioRyLolpDFbncC0BJbGPzP1ZTysUGkksw==" + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.23.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.0.tgz", + "integrity": "sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "caniuse-lite": "^1.0.30001587", + "electron-to-chromium": "^1.4.668", + "node-releases": "^2.0.14", + "update-browserslist-db": "^1.0.13" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/builtin-modules": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/cacache": { + "version": "18.0.2", + "resolved": "https://registry.npmjs.org/cacache/-/cacache-18.0.2.tgz", + "integrity": "sha512-r3NU8h/P+4lVUHfeRw1dtgQYar3DZMm4/cm2bZgOvrFC/su7budSOeqh52VJIC4U4iG1WWwV6vRW0znqBvxNuw==", + "dependencies": { + "@npmcli/fs": "^3.1.0", + "fs-minipass": "^3.0.0", + "glob": "^10.2.2", + "lru-cache": "^10.0.1", + "minipass": "^7.0.3", + "minipass-collect": "^2.0.1", + "minipass-flush": "^1.0.5", + "minipass-pipeline": "^1.2.4", + "p-map": "^4.0.0", + "ssri": "^10.0.0", + "tar": "^6.1.11", + "unique-filename": "^3.0.0" + }, + "engines": { + "node": "^16.14.0 || >=18.0.0" + } + }, + "node_modules/cacache/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/cacache/node_modules/glob": { + "version": "10.3.12", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz", + "integrity": "sha512-TCNv8vJ+xz4QiqTpfOJA7HvYv+tNIRHKfUWw/q+v2jdgN4ebz+KY9tGx5J4rHP0o84mNP+ApH66HRX8us3Khqg==", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^2.3.6", + "minimatch": "^9.0.1", + "minipass": "^7.0.4", + "path-scurry": "^1.10.2" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/cacache/node_modules/minimatch": { + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", + "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/camelcase-css": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/camelcase-css/-/camelcase-css-2.0.1.tgz", + "integrity": "sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001612", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001612.tgz", + "integrity": "sha512-lFgnZ07UhaCcsSZgWW0K5j4e69dK1u/ltrL9lTUiFOwNHs12S3UMIEYgBV0Z6C6hRDev7iRnMzzYmKabYdXF9g==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ] + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "engines": { + "node": ">=10" + } + }, + "node_modules/clean-stack": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", + "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", + "engines": { + "node": ">=6" + } + }, + "node_modules/code-red": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/code-red/-/code-red-1.0.4.tgz", + "integrity": "sha512-7qJWqItLA8/VPVlKJlFXU+NBlo/qyfs39aJcuMT/2ere32ZqvF5OSxgdM5xOfJJ7O429gg2HM47y8v9P+9wrNw==", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.15", + "@types/estree": "^1.0.1", + "acorn": "^8.10.0", + "estree-walker": "^3.0.3", + "periscopic": "^3.1.0" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, + "node_modules/commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==" + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/cookie": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/css-selector-tokenizer": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/css-selector-tokenizer/-/css-selector-tokenizer-0.8.0.tgz", + "integrity": "sha512-Jd6Ig3/pe62/qe5SBPTN8h8LeUg/pT4lLgtavPf7updwwHpvFzxvOQBHYj2LZDMjUnBzgvIUSjRcf6oT5HzHFg==", + "dev": true, + "dependencies": { + "cssesc": "^3.0.0", + "fastparse": "^1.1.2" + } + }, + "node_modules/css-tree": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz", + "integrity": "sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==", + "dependencies": { + "mdn-data": "2.0.30", + "source-map-js": "^1.0.1" + }, + "engines": { + "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" + } + }, + "node_modules/cssesc": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", + "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", + "dev": true, + "bin": { + "cssesc": "bin/cssesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/culori": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/culori/-/culori-3.3.0.tgz", + "integrity": "sha512-pHJg+jbuFsCjz9iclQBqyL3B2HLCBF71BwVNujUYEvCeQMvV97R59MNK3R2+jgJ3a1fcZgI9B3vYgz8lzr/BFQ==", + "dev": true, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + } + }, + "node_modules/daisyui": { + "version": "4.10.2", + "resolved": "https://registry.npmjs.org/daisyui/-/daisyui-4.10.2.tgz", + "integrity": "sha512-eCWS1W/JPyxW9IvlgW5m0R6rp9ZhRsBTW37rvEUthckkjsV04u8XipV519OoccSA46ixhSJa3q7XLI1WUFtRCA==", + "dev": true, + "dependencies": { + "css-selector-tokenizer": "^0.8", + "culori": "^3", + "picocolors": "^1", + "postcss-js": "^4" + }, + "engines": { + "node": ">=16.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/daisyui" + } + }, + "node_modules/datastore-core": { + "version": "9.2.9", + "resolved": "https://registry.npmjs.org/datastore-core/-/datastore-core-9.2.9.tgz", + "integrity": "sha512-wraWTPsbtdE7FFaVo3pwPuTB/zXsgwGGAm8BgBYwYAuzZCTS0MfXmd/HH1vR9s0/NFFjOVmBkGiWCvKxZ+QjVw==", + "dependencies": { + "@libp2p/logger": "^4.0.6", + "err-code": "^3.0.1", + "interface-datastore": "^8.0.0", + "interface-store": "^5.0.0", + "it-drain": "^3.0.5", + "it-filter": "^3.0.4", + "it-map": "^3.0.5", + "it-merge": "^3.0.3", + "it-pipe": "^3.0.1", + "it-pushable": "^3.2.3", + "it-sort": "^3.0.4", + "it-take": "^3.0.4" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/delay": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/delay/-/delay-6.0.0.tgz", + "integrity": "sha512-2NJozoOHQ4NuZuVIr5CWd0iiLVIRSDepakaovIN+9eIDHEhdCAEvSy2cuf1DCrPPQLvHmbqTHODlhHg8UCy4zw==", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "engines": { + "node": ">=6" + } + }, + "node_modules/detect-indent": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.1.0.tgz", + "integrity": "sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/devalue": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.0.0.tgz", + "integrity": "sha512-gO+/OMXF7488D+u3ue+G7Y4AA3ZmUnB3eHJXmBTgNHvr4ZNzl36A0ZtG+XCRNYCkYx/bFmw4qtkoFLa+wSrwAA==" + }, + "node_modules/didyoumean": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", + "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==", + "dev": true + }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/dlv": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.3.tgz", + "integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==", + "dev": true + }, + "node_modules/dns-packet": { + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-5.6.1.tgz", + "integrity": "sha512-l4gcSouhcgIKRvyy99RNVOgxXiicE+2jZoNmaNmZ6JXiGajBOJAesk1OBlJuM5k2c+eudGdLxDqXuPCKIj6kpw==", + "dependencies": { + "@leichtgewicht/ip-codec": "^2.0.1" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==" + }, + "node_modules/electron-to-chromium": { + "version": "1.4.747", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.747.tgz", + "integrity": "sha512-+FnSWZIAvFHbsNVmUxhEqWiaOiPMcfum1GQzlWCg/wLigVtshOsjXHyEFfmt6cFK6+HkS3QOJBv6/3OPumbBfw==", + "dev": true + }, + "node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==" + }, + "node_modules/encoding": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", + "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", + "optional": true, + "dependencies": { + "iconv-lite": "^0.6.2" + } + }, + "node_modules/env-paths": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", + "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", + "engines": { + "node": ">=6" + } + }, + "node_modules/err-code": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-3.0.1.tgz", + "integrity": "sha512-GiaH0KJUewYok+eeY05IIgjtAe4Yltygk9Wqp1V5yVWLdhf0hYZchRjNIT9bb0mSwRcIusT3cx7PJUf3zEIfUA==" + }, + "node_modules/es6-promise": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz", + "integrity": "sha512-SOp9Phqvqn7jtEUxPWdWfWoLmyt2VaJ6MpvP9Comy1MceMXqE6bxvaTu4iaxpYYPzhny28Lc+M87/c2cPK6lDg==", + "dev": true + }, + "node_modules/esbuild": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.20.2.tgz", + "integrity": "sha512-WdOOppmUNU+IbZ0PaDiTst80zjnrOkyJNHoKupIcVyU8Lvla3Ugx94VzkQ32Ijqd7UhHJy75gNWDMUekcrSJ6g==", + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.20.2", + "@esbuild/android-arm": "0.20.2", + "@esbuild/android-arm64": "0.20.2", + "@esbuild/android-x64": "0.20.2", + "@esbuild/darwin-arm64": "0.20.2", + "@esbuild/darwin-x64": "0.20.2", + "@esbuild/freebsd-arm64": "0.20.2", + "@esbuild/freebsd-x64": "0.20.2", + "@esbuild/linux-arm": "0.20.2", + "@esbuild/linux-arm64": "0.20.2", + "@esbuild/linux-ia32": "0.20.2", + "@esbuild/linux-loong64": "0.20.2", + "@esbuild/linux-mips64el": "0.20.2", + "@esbuild/linux-ppc64": "0.20.2", + "@esbuild/linux-riscv64": "0.20.2", + "@esbuild/linux-s390x": "0.20.2", + "@esbuild/linux-x64": "0.20.2", + "@esbuild/netbsd-x64": "0.20.2", + "@esbuild/openbsd-x64": "0.20.2", + "@esbuild/sunos-x64": "0.20.2", + "@esbuild/win32-arm64": "0.20.2", + "@esbuild/win32-ia32": "0.20.2", + "@esbuild/win32-x64": "0.20.2" + } + }, + "node_modules/escalade": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", + "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/esm-env": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/esm-env/-/esm-env-1.0.0.tgz", + "integrity": "sha512-Cf6VksWPsTuW01vU9Mk/3vRue91Zevka5SjyNf3nEpokFRuqt/KjUQoGAwq9qMmhpLTHmXzSIrFRw8zxWzmFBA==" + }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/event-iterator": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/event-iterator/-/event-iterator-2.0.0.tgz", + "integrity": "sha512-KGft0ldl31BZVV//jj+IAIGCxkvvUkkON+ScH6zfoX+l+omX6001ggyRSpI0Io2Hlro0ThXotswCtfzS8UkIiQ==" + }, + "node_modules/eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==" + }, + "node_modules/exponential-backoff": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/exponential-backoff/-/exponential-backoff-3.1.1.tgz", + "integrity": "sha512-dX7e/LHVJ6W3DE1MHWi9S1EYzDESENfLrYohG2G++ovZrYOkm4Knwa0mc1cn84xJOR4KEU0WSchhLbd0UklbHw==" + }, + "node_modules/fast-glob": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fastparse": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/fastparse/-/fastparse-1.1.2.tgz", + "integrity": "sha512-483XLLxTVIwWK3QTrMGRqUfUpoOs/0hbQrl2oz4J0pAcm3A3bu84wxTFqGqkJzewCLdME38xJLJAxBABfQT8sQ==", + "dev": true + }, + "node_modules/fastq": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", + "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", + "dev": true, + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/foreground-child": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", + "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/fraction.js": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz", + "integrity": "sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==", + "dev": true, + "engines": { + "node": "*" + }, + "funding": { + "type": "patreon", + "url": "https://github.com/sponsors/rawify" + } + }, + "node_modules/fs-minipass": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-3.0.3.tgz", + "integrity": "sha512-XUBA9XClHbnJWSfBzjkm6RvPsyg3sryZt06BEQoXcF7EK/xpGaQYJgQKDJSUH5SGZ76Y7pFx1QBnXz09rU5Fbw==", + "dependencies": { + "minipass": "^7.0.3" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-iterator": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/get-iterator/-/get-iterator-2.0.1.tgz", + "integrity": "sha512-7HuY/hebu4gryTDT7O/XY/fvY9wRByEGdK6QOa4of8npTcv0+NS6frFKABcf6S9EBAsveTuKTsZQQBFMMNILIg==" + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/globalyzer": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.0.tgz", + "integrity": "sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==" + }, + "node_modules/globrex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz", + "integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==" + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" + }, + "node_modules/hashlru": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/hashlru/-/hashlru-2.3.0.tgz", + "integrity": "sha512-0cMsjjIC8I+D3M44pOQdsy0OHXGLVz6Z0beRuufhKa0KfaD2wGwAev6jILzXsd3/vpnNQJmWyZtIILqM1N+n5A==" + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-cache-semantics": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz", + "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==" + }, + "node_modules/http-proxy-agent": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", + "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", + "dependencies": { + "agent-base": "^7.1.0", + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/https-proxy-agent": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.4.tgz", + "integrity": "sha512-wlwpilI7YdjSkWaQ/7omYBMTliDcmCN8OLihO6I9B86g06lMyAoqgoDpV0XqoaPOKj+0DIdAvnsWfyAAhmimcg==", + "dependencies": { + "agent-base": "^7.0.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "optional": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/import-meta-resolve": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-4.0.0.tgz", + "integrity": "sha512-okYUR7ZQPH+efeuMJGlq4f8ubUgO50kByRPyt/Cy1Io4PSRsPjxME+YlVaCOx+NIToW7hCsZNFJyTPFFKepRSA==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/interface-datastore": { + "version": "8.2.11", + "resolved": "https://registry.npmjs.org/interface-datastore/-/interface-datastore-8.2.11.tgz", + "integrity": "sha512-9E0iXehfp/j0UbZ2mvlYB4K9pP7uQBCppfuy8WHs1EHF6wLQrM9+zwyX+8Qt6HnH4GKZRyXX/CNXm6oD4+QYgA==", + "dependencies": { + "interface-store": "^5.0.0", + "uint8arrays": "^5.0.2" + } + }, + "node_modules/interface-store": { + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/interface-store/-/interface-store-5.1.8.tgz", + "integrity": "sha512-7na81Uxkl0vqk0CBPO5PvyTkdaJBaezwUJGsMOz7riPOq0rJt+7W31iaopaMICWea/iykUsvNlPx/Tc+MxC3/w==" + }, + "node_modules/ip-address": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-9.0.5.tgz", + "integrity": "sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==", + "dependencies": { + "jsbn": "1.1.0", + "sprintf-js": "^1.1.3" + }, + "engines": { + "node": ">= 12" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-builtin-module": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz", + "integrity": "sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==", + "dependencies": { + "builtin-modules": "^3.3.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-core-module": { + "version": "2.13.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz", + "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", + "dependencies": { + "hasown": "^2.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-electron": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/is-electron/-/is-electron-2.2.2.tgz", + "integrity": "sha512-FO/Rhvz5tuw4MCWkpMzHFKWD2LsfHzIb7i6MdPYZ/KW7AlxawyLkqdy+jPZP1WubqEADE3O4FUENlJHDfQASRg==" + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-lambda": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-lambda/-/is-lambda-1.0.1.tgz", + "integrity": "sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ==" + }, + "node_modules/is-loopback-addr": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/is-loopback-addr/-/is-loopback-addr-2.0.2.tgz", + "integrity": "sha512-26POf2KRCno/KTNL5Q0b/9TYnL00xEsSaLfiFRmjM7m7Lw7ZMmFybzzuX4CcsLAluZGd+niLUiMRxEooVE3aqg==" + }, + "node_modules/is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==" + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-reference": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.2.tgz", + "integrity": "sha512-v3rht/LgVcsdZa3O2Nqs+NMowLOxeOm7Ay9+/ARQ2F+qEoANRcqrjAZKGN0v8ymUetZGgkp26LTnGT7H0Qo9Pg==", + "dependencies": { + "@types/estree": "*" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + }, + "node_modules/it-all": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/it-all/-/it-all-3.0.4.tgz", + "integrity": "sha512-UMiy0i9DqCHBdWvMbzdYvVGa5/w4t1cc4nchpbnjdLhklglv8mQeEYnii0gvKESJuL1zV32Cqdb33R6/GPfxpQ==" + }, + "node_modules/it-byte-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/it-byte-stream/-/it-byte-stream-1.0.8.tgz", + "integrity": "sha512-H32LbN6kdX8HXqH68z5uivfkVYJEi5tIPRwIQNR5Qsx3uoDRhYdBRHzf3NOVAf6vqulFUSQLuU+Y0rs/QeWn3A==", + "dependencies": { + "it-stream-types": "^2.0.1", + "p-defer": "^4.0.0", + "race-signal": "^1.0.1", + "uint8arraylist": "^2.4.1" + } + }, + "node_modules/it-drain": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/it-drain/-/it-drain-3.0.5.tgz", + "integrity": "sha512-qYFe4SWdvs9oJGUY5bSjvmiLUMLzFEODNOQUdYdCIkuIgQF+AUB2INhM4yQ09buJ2rhHKDFxvTD/+yUq6qg0XA==" + }, + "node_modules/it-filter": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/it-filter/-/it-filter-3.0.4.tgz", + "integrity": "sha512-e0sz+st4sudK/zH6GZ/gRTRP8A/ADuJFCYDmRgMbZvR79y5+v4ZXav850bBZk5wL9zXaYZFxS1v/6Qi+Vjwh5g==", + "dependencies": { + "it-peekable": "^3.0.0" + } + }, + "node_modules/it-foreach": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/it-foreach/-/it-foreach-2.0.6.tgz", + "integrity": "sha512-OVosBHJsdXpAyeFlCbe3IGZia+65UykyAznakNsKXK+b99dbhuu/mOnXxTadDEo1GWhKx+WA8RNanKkMf07zQw==", + "dependencies": { + "it-peekable": "^3.0.0" + } + }, + "node_modules/it-length-prefixed": { + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/it-length-prefixed/-/it-length-prefixed-9.0.4.tgz", + "integrity": "sha512-lz28fykbG0jq7s5XtvlzGxO5BeSOw6ikymkRllxjL21V5VKLcvB4pHr9wPvEnsAJ2et1xpOk3BRTMq9XrhgKsg==", + "dependencies": { + "err-code": "^3.0.1", + "it-reader": "^6.0.1", + "it-stream-types": "^2.0.1", + "uint8-varint": "^2.0.1", + "uint8arraylist": "^2.0.0", + "uint8arrays": "^5.0.1" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/it-length-prefixed-stream": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/it-length-prefixed-stream/-/it-length-prefixed-stream-1.1.6.tgz", + "integrity": "sha512-MEby4r8n3XIYXjaWT3DweCuhBPQmFVT8RdI1BNjYQ5gelbFD3NLdjYpTI3TVmSEs/aJfgpfVFZzy6iP7OCxIgw==", + "dependencies": { + "it-byte-stream": "^1.0.0", + "it-stream-types": "^2.0.1", + "uint8-varint": "^2.0.1", + "uint8arraylist": "^2.4.1" + } + }, + "node_modules/it-map": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/it-map/-/it-map-3.0.5.tgz", + "integrity": "sha512-hB0TDXo/h4KSJJDSRLgAPmDroiXP6Fx1ck4Bzl3US9hHfZweTKsuiP0y4gXuTMcJlS6vj0bb+f70rhkD47ZA3w==", + "dependencies": { + "it-peekable": "^3.0.0" + } + }, + "node_modules/it-merge": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/it-merge/-/it-merge-3.0.3.tgz", + "integrity": "sha512-FYVU15KC5pb/GQX1Ims+lee8d4pdqGVCpWr0lkNj8o4xuNo7jY71k6GuEiWdP+T7W1bJqewSxX5yoTy5yZpRVA==", + "dependencies": { + "it-pushable": "^3.2.0" + } + }, + "node_modules/it-pair": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/it-pair/-/it-pair-2.0.6.tgz", + "integrity": "sha512-5M0t5RAcYEQYNG5BV7d7cqbdwbCAp5yLdzvkxsZmkuZsLbTdZzah6MQySYfaAQjNDCq6PUnDt0hqBZ4NwMfW6g==", + "dependencies": { + "it-stream-types": "^2.0.1", + "p-defer": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/it-parallel": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/it-parallel/-/it-parallel-3.0.6.tgz", + "integrity": "sha512-i7UM7I9LTkDJw3YIqXHFAPZX6CWYzGc+X3irdNrVExI4vPazrJdI7t5OqrSVN8CONXLAunCiqaSV/zZRbQR56A==", + "dependencies": { + "p-defer": "^4.0.0" + } + }, + "node_modules/it-peekable": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/it-peekable/-/it-peekable-3.0.3.tgz", + "integrity": "sha512-Wx21JX/rMzTEl9flx3DGHuPV1KQFGOl8uoKfQtmZHgPQtGb89eQ6RyVd82h3HuP9Ghpt0WgBDlmmdWeHXqyx7w==" + }, + "node_modules/it-pipe": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/it-pipe/-/it-pipe-3.0.1.tgz", + "integrity": "sha512-sIoNrQl1qSRg2seYSBH/3QxWhJFn9PKYvOf/bHdtCBF0bnghey44VyASsWzn5dAx0DCDDABq1hZIuzKmtBZmKA==", + "dependencies": { + "it-merge": "^3.0.0", + "it-pushable": "^3.1.2", + "it-stream-types": "^2.0.1" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/it-pushable": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/it-pushable/-/it-pushable-3.2.3.tgz", + "integrity": "sha512-gzYnXYK8Y5t5b/BnJUr7glfQLO4U5vyb05gPx/TyTw+4Bv1zM9gFk4YsOrnulWefMewlphCjKkakFvj1y99Tcg==", + "dependencies": { + "p-defer": "^4.0.0" + } + }, + "node_modules/it-reader": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/it-reader/-/it-reader-6.0.4.tgz", + "integrity": "sha512-XCWifEcNFFjjBHtor4Sfaj8rcpt+FkY0L6WdhD578SCDhV4VUm7fCkF3dv5a+fTcfQqvN9BsxBTvWbYO6iCjTg==", + "dependencies": { + "it-stream-types": "^2.0.1", + "uint8arraylist": "^2.0.0" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/it-sort": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/it-sort/-/it-sort-3.0.4.tgz", + "integrity": "sha512-tvnC93JZZWjX4UxALy0asow0dzXabkoaRbrPJKClTKhNCqw4gzHr+H5axf1gohcthedRRkqd/ae+wl7WqoxFhw==", + "dependencies": { + "it-all": "^3.0.0" + } + }, + "node_modules/it-stream-types": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/it-stream-types/-/it-stream-types-2.0.1.tgz", + "integrity": "sha512-6DmOs5r7ERDbvS4q8yLKENcj6Yecr7QQTqWApbZdfAUTEC947d+PEha7PCqhm//9oxaLYL7TWRekwhoXl2s6fg==", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/it-take": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/it-take/-/it-take-3.0.4.tgz", + "integrity": "sha512-RG8HDjAZlvkzz5Nav4xq6gK5zNT+Ff1UTIf+CrSJW8nIl6N1FpBH5e7clUshiCn+MmmMoSdIEpw4UaTolszxhA==" + }, + "node_modules/it-ws": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/it-ws/-/it-ws-6.1.1.tgz", + "integrity": "sha512-oyk4eCeZto2lzWDnJOa3j1S2M+VOGKUh8isEf94ySoaL6IFlyie0T4P9E0ZUaIvX8LyJxYFHFKCt8Zk7Sm/XPQ==", + "dependencies": { + "@types/ws": "^8.2.2", + "event-iterator": "^2.0.0", + "it-stream-types": "^2.0.1", + "uint8arrays": "^5.0.0", + "ws": "^8.4.0" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/jackspeak": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", + "integrity": "sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, + "node_modules/jiti": { + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.0.tgz", + "integrity": "sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q==", + "dev": true, + "bin": { + "jiti": "bin/jiti.js" + } + }, + "node_modules/jsbn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", + "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==" + }, + "node_modules/kleur": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", + "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==", + "engines": { + "node": ">=6" + } + }, + "node_modules/libp2p": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/libp2p/-/libp2p-1.4.2.tgz", + "integrity": "sha512-Ek4NJ4Fb09I3/RwGYB5ytVi7rpdja6PCdA00Lh+meN6Dj1KKaqbMGHvCEuciErtv9ujkmT3JWB0j/kl/exHRbA==", + "dependencies": { + "@libp2p/crypto": "^4.0.6", + "@libp2p/interface": "^1.2.0", + "@libp2p/interface-internal": "^1.1.0", + "@libp2p/logger": "^4.0.10", + "@libp2p/multistream-select": "^5.1.7", + "@libp2p/peer-collections": "^5.1.10", + "@libp2p/peer-id": "^4.0.10", + "@libp2p/peer-id-factory": "^4.0.10", + "@libp2p/peer-store": "^10.0.15", + "@libp2p/utils": "^5.3.1", + "@multiformats/dns": "^1.0.5", + "@multiformats/multiaddr": "^12.2.1", + "@multiformats/multiaddr-matcher": "^1.2.0", + "any-signal": "^4.1.1", + "datastore-core": "^9.2.9", + "interface-datastore": "^8.2.11", + "it-merge": "^3.0.3", + "it-parallel": "^3.0.6", + "merge-options": "^3.0.4", + "multiformats": "^13.1.0", + "uint8arrays": "^5.0.3" + } + }, + "node_modules/lilconfig": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz", + "integrity": "sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true + }, + "node_modules/locate-character": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz", + "integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==" + }, + "node_modules/lru-cache": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.0.tgz", + "integrity": "sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==", + "engines": { + "node": "14 || >=16.14" + } + }, + "node_modules/magic-string": { + "version": "0.30.10", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.10.tgz", + "integrity": "sha512-iIRwTIf0QKV3UAnYK4PU8uiEc4SRh5jX0mwpIwETPpHdhVM4f53RSwS/vXvN1JhGX+Cs7B8qIq3d6AH49O5fAQ==", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.15" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" + }, + "node_modules/make-fetch-happen": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-13.0.0.tgz", + "integrity": "sha512-7ThobcL8brtGo9CavByQrQi+23aIfgYU++wg4B87AIS8Rb2ZBt/MEaDqzA00Xwv/jUjAjYkLHjVolYuTLKda2A==", + "dependencies": { + "@npmcli/agent": "^2.0.0", + "cacache": "^18.0.0", + "http-cache-semantics": "^4.1.1", + "is-lambda": "^1.0.1", + "minipass": "^7.0.2", + "minipass-fetch": "^3.0.0", + "minipass-flush": "^1.0.5", + "minipass-pipeline": "^1.2.4", + "negotiator": "^0.6.3", + "promise-retry": "^2.0.1", + "ssri": "^10.0.0" + }, + "engines": { + "node": "^16.14.0 || >=18.0.0" + } + }, + "node_modules/mdn-data": { + "version": "2.0.30", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.30.tgz", + "integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==" + }, + "node_modules/merge-options": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/merge-options/-/merge-options-3.0.4.tgz", + "integrity": "sha512-2Sug1+knBjkaMsMgf1ctR1Ujx+Ayku4EdJN4Z+C2+JzoeF7A3OZ9KM2GY0CpQS51NR61LTurMJrRKPhSs3ZRTQ==", + "dependencies": { + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/min-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", + "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/minipass": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", + "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/minipass-collect": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/minipass-collect/-/minipass-collect-2.0.1.tgz", + "integrity": "sha512-D7V8PO9oaz7PWGLbCACuI1qEOsq7UKfLotx/C0Aet43fCUB/wfQ7DYeq2oR/svFJGYDHPr38SHATeaj/ZoKHKw==", + "dependencies": { + "minipass": "^7.0.3" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/minipass-fetch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minipass-fetch/-/minipass-fetch-3.0.4.tgz", + "integrity": "sha512-jHAqnA728uUpIaFm7NWsCnqKT6UqZz7GcI/bDpPATuwYyKwJwW0remxSCxUlKiEty+eopHGa3oc8WxgQ1FFJqg==", + "dependencies": { + "minipass": "^7.0.3", + "minipass-sized": "^1.0.3", + "minizlib": "^2.1.2" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + }, + "optionalDependencies": { + "encoding": "^0.1.13" + } + }, + "node_modules/minipass-flush": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/minipass-flush/-/minipass-flush-1.0.5.tgz", + "integrity": "sha512-JmQSYYpPUqX5Jyn1mXaRwOda1uQ8HP5KAT/oDSLCzt1BYRhQU0/hDtsB1ufZfEEzMZ9aAVmsBw8+FWsIXlClWw==", + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/minipass-flush/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minipass-pipeline": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/minipass-pipeline/-/minipass-pipeline-1.2.4.tgz", + "integrity": "sha512-xuIq7cIOt09RPRJ19gdi4b+RiNvDFYe5JH+ggNvBqGqpQXcru3PcRmOZuHBKWK1Txf9+cQ+HMVN4d6z46LZP7A==", + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minipass-pipeline/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minipass-sized": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/minipass-sized/-/minipass-sized-1.0.3.tgz", + "integrity": "sha512-MbkQQ2CTiBMlA2Dm/5cY+9SWFEN8pzzOXi6rlM5Xxq0Yqbda5ZQy9sU75a673FE9ZK0Zsbr6Y5iP6u9nktfg2g==", + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minipass-sized/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "dependencies": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/minizlib/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/mortice": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/mortice/-/mortice-3.0.4.tgz", + "integrity": "sha512-MUHRCAztSl4v/dAmK8vbYi5u1n9NZtQu4H3FsqS7qgMFQIAFw9lTpHiErd9kJpapqmvEdD1L3dUmiikifAvLsQ==", + "dependencies": { + "observable-webworkers": "^2.0.1", + "p-queue": "^8.0.1", + "p-timeout": "^6.0.0" + } + }, + "node_modules/mri": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz", + "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==", + "engines": { + "node": ">=4" + } + }, + "node_modules/mrmime": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.0.tgz", + "integrity": "sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw==", + "engines": { + "node": ">=10" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/multiformats": { + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-13.1.0.tgz", + "integrity": "sha512-HzdtdBwxsIkzpeXzhQ5mAhhuxcHbjEHH+JQoxt7hG/2HGFjjwyolLo7hbaexcnhoEuV4e0TNJ8kkpMjiEYY4VQ==" + }, + "node_modules/mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dev": true, + "dependencies": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, + "node_modules/nanoid": { + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/netmask": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/netmask/-/netmask-2.0.2.tgz", + "integrity": "sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/node-addon-api": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-6.1.0.tgz", + "integrity": "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==" + }, + "node_modules/node-gyp": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-10.1.0.tgz", + "integrity": "sha512-B4J5M1cABxPc5PwfjhbV5hoy2DP9p8lFXASnEN6hugXOa61416tnTZ29x9sSwAd0o99XNIcpvDDy1swAExsVKA==", + "dependencies": { + "env-paths": "^2.2.0", + "exponential-backoff": "^3.1.1", + "glob": "^10.3.10", + "graceful-fs": "^4.2.6", + "make-fetch-happen": "^13.0.0", + "nopt": "^7.0.0", + "proc-log": "^3.0.0", + "semver": "^7.3.5", + "tar": "^6.1.2", + "which": "^4.0.0" + }, + "bin": { + "node-gyp": "bin/node-gyp.js" + }, + "engines": { + "node": "^16.14.0 || >=18.0.0" + } + }, + "node_modules/node-gyp/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/node-gyp/node_modules/glob": { + "version": "10.3.12", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz", + "integrity": "sha512-TCNv8vJ+xz4QiqTpfOJA7HvYv+tNIRHKfUWw/q+v2jdgN4ebz+KY9tGx5J4rHP0o84mNP+ApH66HRX8us3Khqg==", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^2.3.6", + "minimatch": "^9.0.1", + "minipass": "^7.0.4", + "path-scurry": "^1.10.2" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/node-gyp/node_modules/isexe": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.1.tgz", + "integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==", + "engines": { + "node": ">=16" + } + }, + "node_modules/node-gyp/node_modules/minimatch": { + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", + "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/node-gyp/node_modules/which": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/which/-/which-4.0.0.tgz", + "integrity": "sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==", + "dependencies": { + "isexe": "^3.1.1" + }, + "bin": { + "node-which": "bin/which.js" + }, + "engines": { + "node": "^16.13.0 || >=18.0.0" + } + }, + "node_modules/node-releases": { + "version": "2.0.14", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", + "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==", + "dev": true + }, + "node_modules/nopt": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-7.2.0.tgz", + "integrity": "sha512-CVDtwCdhYIvnAzFoJ6NJ6dX3oga9/HyciQDnG1vQDjSLMeKLJ4A93ZqYKDrgYSr1FBY5/hMYC+2VCi24pgpkGA==", + "dependencies": { + "abbrev": "^2.0.0" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/normalize-range": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz", + "integrity": "sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-hash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz", + "integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, + "node_modules/observable-webworkers": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/observable-webworkers/-/observable-webworkers-2.0.1.tgz", + "integrity": "sha512-JI1vB0u3pZjoQKOK1ROWzp0ygxSi7Yb0iR+7UNsw4/Zn4cQ0P3R7XL38zac/Dy2tEA7Lg88/wIJTjF8vYXZ0uw==", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/p-defer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-4.0.1.tgz", + "integrity": "sha512-Mr5KC5efvAK5VUptYEIopP1bakB85k2IWXaRC0rsh1uwn1L6M0LVml8OIQ4Gudg4oyZakf7FmeRLkMMtZW1i5A==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-map": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz", + "integrity": "sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==", + "dependencies": { + "aggregate-error": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-queue": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/p-queue/-/p-queue-8.0.1.tgz", + "integrity": "sha512-NXzu9aQJTAzbBqOt2hwsR63ea7yvxJc0PwN/zobNAudYfb1B7R08SzB4TsLeSbUCuG467NhnoT0oO6w1qRO+BA==", + "dependencies": { + "eventemitter3": "^5.0.1", + "p-timeout": "^6.1.2" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-timeout": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-6.1.2.tgz", + "integrity": "sha512-UbD77BuZ9Bc9aABo74gfXhNvzC9Tx7SxtHSh1fxvx3jTLLYvmVhiQZZrJzqqU0jKbN32kb5VOKiLEQI/3bIjgQ==", + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" + }, + "node_modules/path-scurry": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.2.tgz", + "integrity": "sha512-7xTavNy5RQXnsjANvVvMkEjvloOinkAjv/Z6Ildz9v2RinZ4SBKTWFOVRbaF8p0vpHnyjV/UwNDdKuUv6M5qcA==", + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/periscopic": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/periscopic/-/periscopic-3.1.0.tgz", + "integrity": "sha512-vKiQ8RRtkl9P+r/+oefh25C3fhybptkHKCZSPlcXiJux2tJF55GnEj3BVn4A5gKfq9NWWXXrxkHBwVPUfH0opw==", + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^3.0.0", + "is-reference": "^3.0.0" + } + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pirates": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", + "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, + "node_modules/postcss": { + "version": "8.4.38", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz", + "integrity": "sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "nanoid": "^3.3.7", + "picocolors": "^1.0.0", + "source-map-js": "^1.2.0" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/postcss-import": { + "version": "15.1.0", + "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-15.1.0.tgz", + "integrity": "sha512-hpr+J05B2FVYUAXHeK1YyI267J/dDDhMU6B6civm8hSY1jYJnBXxzKDKDswzJmtLHryrjhnDjqqp/49t8FALew==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.0.0", + "read-cache": "^1.0.0", + "resolve": "^1.1.7" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "postcss": "^8.0.0" + } + }, + "node_modules/postcss-js": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/postcss-js/-/postcss-js-4.0.1.tgz", + "integrity": "sha512-dDLF8pEO191hJMtlHFPRa8xsizHaM82MLfNkUHdUtVEV3tgTp5oj+8qbEqYM57SLfc74KSbw//4SeJma2LRVIw==", + "dev": true, + "dependencies": { + "camelcase-css": "^2.0.1" + }, + "engines": { + "node": "^12 || ^14 || >= 16" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + "peerDependencies": { + "postcss": "^8.4.21" + } + }, + "node_modules/postcss-load-config": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-4.0.2.tgz", + "integrity": "sha512-bSVhyJGL00wMVoPUzAVAnbEoWyqRxkjv64tUl427SKnPrENtq6hJwUojroMz2VB+Q1edmi4IfrAPpami5VVgMQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "lilconfig": "^3.0.0", + "yaml": "^2.3.4" + }, + "engines": { + "node": ">= 14" + }, + "peerDependencies": { + "postcss": ">=8.0.9", + "ts-node": ">=9.0.0" + }, + "peerDependenciesMeta": { + "postcss": { + "optional": true + }, + "ts-node": { + "optional": true + } + } + }, + "node_modules/postcss-load-config/node_modules/lilconfig": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.1.tgz", + "integrity": "sha512-O18pf7nyvHTckunPWCV1XUNXU1piu01y2b7ATJ0ppkUkk8ocqVWBrYjJBCwHDjD/ZWcfyrA0P4gKhzWGi5EINQ==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antonk52" + } + }, + "node_modules/postcss-nested": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/postcss-nested/-/postcss-nested-6.0.1.tgz", + "integrity": "sha512-mEp4xPMi5bSWiMbsgoPfcP74lsWLHkQbZc3sY+jWYd65CUwXrUaTp0fmNpa01ZcETKlIgUdFN/MpS2xZtqL9dQ==", + "dev": true, + "dependencies": { + "postcss-selector-parser": "^6.0.11" + }, + "engines": { + "node": ">=12.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + "peerDependencies": { + "postcss": "^8.2.14" + } + }, + "node_modules/postcss-selector-parser": { + "version": "6.0.16", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.16.tgz", + "integrity": "sha512-A0RVJrX+IUkVZbW3ClroRWurercFhieevHB38sr2+l9eUClMqome3LmEmnhlNy+5Mr2EYN6B2Kaw9wYdd+VHiw==", + "dev": true, + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-value-parser": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", + "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", + "dev": true + }, + "node_modules/proc-log": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-3.0.0.tgz", + "integrity": "sha512-++Vn7NS4Xf9NacaU9Xq3URUuqZETPsf8L4j5/ckhaRYsfPeRyzGw+iDjFhV/Jr3uNmTvvddEJFWh5R1gRgUH8A==", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/progress-events": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/progress-events/-/progress-events-1.0.0.tgz", + "integrity": "sha512-zIB6QDrSbPfRg+33FZalluFIowkbV5Xh1xSuetjG+rlC5he6u2dc6VQJ0TbMdlN3R1RHdpOqxEFMKTnQ+itUwA==", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/promise-retry": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/promise-retry/-/promise-retry-2.0.1.tgz", + "integrity": "sha512-y+WKFlBR8BGXnsNlIHFGPZmyDf3DFMoLhaflAnyZgV6rG6xu+JwesTo2Q9R6XwYmtmwAFCkAk3e35jEdoeh/3g==", + "dependencies": { + "err-code": "^2.0.2", + "retry": "^0.12.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/promise-retry/node_modules/err-code": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz", + "integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==" + }, + "node_modules/protons-runtime": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/protons-runtime/-/protons-runtime-5.4.0.tgz", + "integrity": "sha512-XfA++W/WlQOSyjUyuF5lgYBfXZUEMP01Oh1C2dSwZAlF2e/ZrMRPfWonXj6BGM+o8Xciv7w0tsRMKYwYEuQvaw==", + "dependencies": { + "uint8-varint": "^2.0.2", + "uint8arraylist": "^2.4.3", + "uint8arrays": "^5.0.1" + } + }, + "node_modules/pvtsutils": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.5.tgz", + "integrity": "sha512-ARvb14YB9Nm2Xi6nBq1ZX6dAM0FsJnuk+31aUp4TrcZEdKUlSqOqsxJHUPJDNE3qiIp+iUPEIeR6Je/tgV7zsA==", + "dependencies": { + "tslib": "^2.6.1" + } + }, + "node_modules/pvutils": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/pvutils/-/pvutils-1.1.3.tgz", + "integrity": "sha512-pMpnA0qRdFp32b1sJl1wOJNxZLQ2cbQx+k6tjNtZ8CpvVhNqEPRgivZ2WOUev2YMajecdH7ctUPDvEe87nariQ==", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/race-event": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/race-event/-/race-event-1.2.0.tgz", + "integrity": "sha512-7EvAjTu9uuKa03Jky8yfSy6/SnnMTh6nouNmdeWv9b0dT8eDZC5ylx30cOR9YO9otQorVjjkIuSHQ5Ml/bKwMw==" + }, + "node_modules/race-signal": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/race-signal/-/race-signal-1.0.2.tgz", + "integrity": "sha512-o3xNv0iTcIDQCXFlF6fPAMEBRjFxssgGoRqLbg06m+AdzEXXLUmoNOoUHTVz2NoBI8hHwKFKoC6IqyNtWr2bww==" + }, + "node_modules/read-cache": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", + "integrity": "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==", + "dev": true, + "dependencies": { + "pify": "^2.3.0" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/resolve": { + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", + "dependencies": { + "is-core-module": "^2.13.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==", + "engines": { + "node": ">= 4" + } + }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + } + }, + "node_modules/rollup": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.16.4.tgz", + "integrity": "sha512-kuaTJSUbz+Wsb2ATGvEknkI12XV40vIiHmLuFlejoo7HtDok/O5eDDD0UpCVY5bBX5U5RYo8wWP83H7ZsqVEnA==", + "dependencies": { + "@types/estree": "1.0.5" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.16.4", + "@rollup/rollup-android-arm64": "4.16.4", + "@rollup/rollup-darwin-arm64": "4.16.4", + "@rollup/rollup-darwin-x64": "4.16.4", + "@rollup/rollup-linux-arm-gnueabihf": "4.16.4", + "@rollup/rollup-linux-arm-musleabihf": "4.16.4", + "@rollup/rollup-linux-arm64-gnu": "4.16.4", + "@rollup/rollup-linux-arm64-musl": "4.16.4", + "@rollup/rollup-linux-powerpc64le-gnu": "4.16.4", + "@rollup/rollup-linux-riscv64-gnu": "4.16.4", + "@rollup/rollup-linux-s390x-gnu": "4.16.4", + "@rollup/rollup-linux-x64-gnu": "4.16.4", + "@rollup/rollup-linux-x64-musl": "4.16.4", + "@rollup/rollup-win32-arm64-msvc": "4.16.4", + "@rollup/rollup-win32-ia32-msvc": "4.16.4", + "@rollup/rollup-win32-x64-msvc": "4.16.4", + "fsevents": "~2.3.2" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/sade": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz", + "integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==", + "dependencies": { + "mri": "^1.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "optional": true + }, + "node_modules/sander": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/sander/-/sander-0.5.1.tgz", + "integrity": "sha512-3lVqBir7WuKDHGrKRDn/1Ye3kwpXaDOMsiRP1wd6wpZW56gJhsbp5RqQpA6JG/P+pkXizygnr1dKR8vzWaVsfA==", + "dev": true, + "dependencies": { + "es6-promise": "^3.1.2", + "graceful-fs": "^4.1.3", + "mkdirp": "^0.5.1", + "rimraf": "^2.5.2" + } + }, + "node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/semver/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/set-cookie-parser": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.6.0.tgz", + "integrity": "sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==" + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/sirv": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/sirv/-/sirv-2.0.4.tgz", + "integrity": "sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ==", + "dependencies": { + "@polka/url": "^1.0.0-next.24", + "mrmime": "^2.0.0", + "totalist": "^3.0.0" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/smart-buffer": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", + "engines": { + "node": ">= 6.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/socks": { + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.3.tgz", + "integrity": "sha512-l5x7VUUWbjVFbafGLxPWkYsHIhEvmF85tbIeFZWc8ZPtoMyybuEhL7Jye/ooC4/d48FgOjSJXgsF/AJPYCW8Zw==", + "dependencies": { + "ip-address": "^9.0.5", + "smart-buffer": "^4.2.0" + }, + "engines": { + "node": ">= 10.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/socks-proxy-agent": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.3.tgz", + "integrity": "sha512-VNegTZKhuGq5vSD6XNKlbqWhyt/40CgoEw8XxD6dhnm8Jq9IEa3nIa4HwnM8XOqU0CdB0BwWVXusqiFXfHB3+A==", + "dependencies": { + "agent-base": "^7.1.1", + "debug": "^4.3.4", + "socks": "^2.7.1" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/sorcery": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/sorcery/-/sorcery-0.11.0.tgz", + "integrity": "sha512-J69LQ22xrQB1cIFJhPfgtLuI6BpWRiWu1Y3vSsIwK/eAScqJxd/+CJlUuHQRdX2C9NGFamq+KqNywGgaThwfHw==", + "dev": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.14", + "buffer-crc32": "^0.2.5", + "minimist": "^1.2.0", + "sander": "^0.5.0" + }, + "bin": { + "sorcery": "bin/sorcery" + } + }, + "node_modules/source-map-js": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", + "integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/sprintf-js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", + "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==" + }, + "node_modules/ssri": { + "version": "10.0.5", + "resolved": "https://registry.npmjs.org/ssri/-/ssri-10.0.5.tgz", + "integrity": "sha512-bSf16tAFkGeRlUNDjXu8FzaMQt6g2HZJrun7mtMbIPOddxt3GLMSz5VWUWcqTJUPfLEaDIepGxv+bYQW49596A==", + "dependencies": { + "minipass": "^7.0.3" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/string-width-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-indent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", + "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", + "dev": true, + "dependencies": { + "min-indent": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/sucrase": { + "version": "3.35.0", + "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.35.0.tgz", + "integrity": "sha512-8EbVDiu9iN/nESwxeSxDKe0dunta1GOlHufmSSXxMD2z2/tMZpDMpvXQGsc+ajGo8y2uYUmixaSRUc/QPoQ0GA==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.2", + "commander": "^4.0.0", + "glob": "^10.3.10", + "lines-and-columns": "^1.1.6", + "mz": "^2.7.0", + "pirates": "^4.0.1", + "ts-interface-checker": "^0.1.9" + }, + "bin": { + "sucrase": "bin/sucrase", + "sucrase-node": "bin/sucrase-node" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/sucrase/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/sucrase/node_modules/glob": { + "version": "10.3.12", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz", + "integrity": "sha512-TCNv8vJ+xz4QiqTpfOJA7HvYv+tNIRHKfUWw/q+v2jdgN4ebz+KY9tGx5J4rHP0o84mNP+ApH66HRX8us3Khqg==", + "dev": true, + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^2.3.6", + "minimatch": "^9.0.1", + "minipass": "^7.0.4", + "path-scurry": "^1.10.2" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/sucrase/node_modules/minimatch": { + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", + "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/svelte": { + "version": "4.2.15", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-4.2.15.tgz", + "integrity": "sha512-j9KJSccHgLeRERPlhMKrCXpk2TqL2m5Z+k+OBTQhZOhIdCCd3WfqV+ylPWeipEwq17P/ekiSFWwrVQv93i3bsg==", + "dependencies": { + "@ampproject/remapping": "^2.2.1", + "@jridgewell/sourcemap-codec": "^1.4.15", + "@jridgewell/trace-mapping": "^0.3.18", + "@types/estree": "^1.0.1", + "acorn": "^8.9.0", + "aria-query": "^5.3.0", + "axobject-query": "^4.0.0", + "code-red": "^1.0.3", + "css-tree": "^2.3.1", + "estree-walker": "^3.0.3", + "is-reference": "^3.0.1", + "locate-character": "^3.0.0", + "magic-string": "^0.30.4", + "periscopic": "^3.1.0" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/svelte-check": { + "version": "3.6.9", + "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-3.6.9.tgz", + "integrity": "sha512-hDQrk3L0osX07djQyMiXocKysTLfusqi8AriNcCiQxhQR49/LonYolcUGMtZ0fbUR8HTR198Prrgf52WWU9wEg==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.17", + "chokidar": "^3.4.1", + "fast-glob": "^3.2.7", + "import-fresh": "^3.2.1", + "picocolors": "^1.0.0", + "sade": "^1.7.4", + "svelte-preprocess": "^5.1.3", + "typescript": "^5.0.3" + }, + "bin": { + "svelte-check": "bin/svelte-check" + }, + "peerDependencies": { + "svelte": "^3.55.0 || ^4.0.0-next.0 || ^4.0.0 || ^5.0.0-next.0" + } + }, + "node_modules/svelte-hmr": { + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/svelte-hmr/-/svelte-hmr-0.16.0.tgz", + "integrity": "sha512-Gyc7cOS3VJzLlfj7wKS0ZnzDVdv3Pn2IuVeJPk9m2skfhcu5bq3wtIZyQGggr7/Iim5rH5cncyQft/kRLupcnA==", + "engines": { + "node": "^12.20 || ^14.13.1 || >= 16" + }, + "peerDependencies": { + "svelte": "^3.19.0 || ^4.0.0" + } + }, + "node_modules/svelte-preprocess": { + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/svelte-preprocess/-/svelte-preprocess-5.1.4.tgz", + "integrity": "sha512-IvnbQ6D6Ao3Gg6ftiM5tdbR6aAETwjhHV+UKGf5bHGYR69RQvF1ho0JKPcbUON4vy4R7zom13jPjgdOWCQ5hDA==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@types/pug": "^2.0.6", + "detect-indent": "^6.1.0", + "magic-string": "^0.30.5", + "sorcery": "^0.11.0", + "strip-indent": "^3.0.0" + }, + "engines": { + "node": ">= 16.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.10.2", + "coffeescript": "^2.5.1", + "less": "^3.11.3 || ^4.0.0", + "postcss": "^7 || ^8", + "postcss-load-config": "^2.1.0 || ^3.0.0 || ^4.0.0 || ^5.0.0", + "pug": "^3.0.0", + "sass": "^1.26.8", + "stylus": "^0.55.0", + "sugarss": "^2.0.0 || ^3.0.0 || ^4.0.0", + "svelte": "^3.23.0 || ^4.0.0-next.0 || ^4.0.0 || ^5.0.0-next.0", + "typescript": ">=3.9.5 || ^4.0.0 || ^5.0.0" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "coffeescript": { + "optional": true + }, + "less": { + "optional": true + }, + "postcss": { + "optional": true + }, + "postcss-load-config": { + "optional": true + }, + "pug": { + "optional": true + }, + "sass": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "typescript": { + "optional": true + } + } + }, + "node_modules/tailwindcss": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.3.tgz", + "integrity": "sha512-U7sxQk/n397Bmx4JHbJx/iSOOv5G+II3f1kpLpY2QeUv5DcPdcTsYLlusZfq1NthHS1c1cZoyFmmkex1rzke0A==", + "dev": true, + "dependencies": { + "@alloc/quick-lru": "^5.2.0", + "arg": "^5.0.2", + "chokidar": "^3.5.3", + "didyoumean": "^1.2.2", + "dlv": "^1.1.3", + "fast-glob": "^3.3.0", + "glob-parent": "^6.0.2", + "is-glob": "^4.0.3", + "jiti": "^1.21.0", + "lilconfig": "^2.1.0", + "micromatch": "^4.0.5", + "normalize-path": "^3.0.0", + "object-hash": "^3.0.0", + "picocolors": "^1.0.0", + "postcss": "^8.4.23", + "postcss-import": "^15.1.0", + "postcss-js": "^4.0.1", + "postcss-load-config": "^4.0.1", + "postcss-nested": "^6.0.1", + "postcss-selector-parser": "^6.0.11", + "resolve": "^1.22.2", + "sucrase": "^3.32.0" + }, + "bin": { + "tailwind": "lib/cli.js", + "tailwindcss": "lib/cli.js" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tailwindcss/node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/tar": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", + "dependencies": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^5.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/tar/node_modules/fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/tar/node_modules/fs-minipass/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tar/node_modules/minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/tar/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dev": true, + "dependencies": { + "any-promise": "^1.0.0" + } + }, + "node_modules/thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", + "dev": true, + "dependencies": { + "thenify": ">= 3.1.0 < 4" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/tiny-glob": { + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz", + "integrity": "sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==", + "dependencies": { + "globalyzer": "0.1.0", + "globrex": "^0.1.2" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/totalist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", + "engines": { + "node": ">=6" + } + }, + "node_modules/ts-interface-checker": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", + "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", + "dev": true + }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/ts-node/node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" + }, + "node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + }, + "node_modules/typescript": { + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/uint8-varint": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/uint8-varint/-/uint8-varint-2.0.4.tgz", + "integrity": "sha512-FwpTa7ZGA/f/EssWAb5/YV6pHgVF1fViKdW8cWaEarjB8t7NyofSWBdOTyFPaGuUG4gx3v1O3PQ8etsiOs3lcw==", + "dependencies": { + "uint8arraylist": "^2.0.0", + "uint8arrays": "^5.0.0" + } + }, + "node_modules/uint8arraylist": { + "version": "2.4.8", + "resolved": "https://registry.npmjs.org/uint8arraylist/-/uint8arraylist-2.4.8.tgz", + "integrity": "sha512-vc1PlGOzglLF0eae1M8mLRTBivsvrGsdmJ5RbK3e+QRvRLOZfZhQROTwH/OfyF3+ZVUg9/8hE8bmKP2CvP9quQ==", + "dependencies": { + "uint8arrays": "^5.0.1" + } + }, + "node_modules/uint8arrays": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-5.0.3.tgz", + "integrity": "sha512-6LBuKji28kHjgPJMkQ6GDaBb1lRwIhyOYq6pDGwYMoDPfImE9SkuYENVmR0yu9yGgs2clHUSY9fKDukR+AXfqQ==", + "dependencies": { + "multiformats": "^13.0.0" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + }, + "node_modules/unique-filename": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-3.0.0.tgz", + "integrity": "sha512-afXhuC55wkAmZ0P18QsVE6kp8JaxrEokN2HGIoIVv2ijHQd419H0+6EigAFcIzXeMIkcIkNBpB3L/DXB3cTS/g==", + "dependencies": { + "unique-slug": "^4.0.0" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/unique-slug": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-4.0.0.tgz", + "integrity": "sha512-WrcA6AyEfqDX5bWige/4NQfPZMtASNVxdmWR76WESYQVAACSgWcR6e9i0mofqqBxYFtL4oAxPIptY73/0YE1DQ==", + "dependencies": { + "imurmurhash": "^0.1.4" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.0.13", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", + "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==" + }, + "node_modules/vite": { + "version": "5.2.10", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.10.tgz", + "integrity": "sha512-PAzgUZbP7msvQvqdSD+ErD5qGnSFiGOoWmV5yAKUEI0kdhjbH6nMWVyZQC/hSc4aXwc0oJ9aEdIiF9Oje0JFCw==", + "dependencies": { + "esbuild": "^0.20.1", + "postcss": "^8.4.38", + "rollup": "^4.13.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || >=20.0.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/vitefu": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-0.2.5.tgz", + "integrity": "sha512-SgHtMLoqaeeGnd2evZ849ZbACbnwQCIwRH57t18FxcXoZop0uQu0uzlIhJBlF/eWVzuce0sHeqPcDo+evVcg8Q==", + "peerDependencies": { + "vite": "^3.0.0 || ^4.0.0 || ^5.0.0" + }, + "peerDependenciesMeta": { + "vite": { + "optional": true + } + } + }, + "node_modules/wherearewe": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/wherearewe/-/wherearewe-2.0.1.tgz", + "integrity": "sha512-XUguZbDxCA2wBn2LoFtcEhXL6AXo+hVjGonwhSTTTU9SzbWG8Xu3onNIpzf9j/mYUcJQ0f+m37SzG77G851uFw==", + "dependencies": { + "is-electron": "^2.2.0" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/wrap-ansi-cjs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "node_modules/ws": { + "version": "8.16.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz", + "integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, + "node_modules/yaml": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.1.tgz", + "integrity": "sha512-pIXzoImaqmfOrL7teGUBt/T7ZDnyeGBWyXQBvOVhLkWLN37GXv8NMLK406UY6dS51JfcQHsmcW5cJ441bHg6Lg==", + "dev": true, + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "engines": { + "node": ">=6" + } + } + } +} diff --git a/z2/veritasfe/package.json b/z2/veritasfe/package.json new file mode 100644 index 0000000..7de700e --- /dev/null +++ b/z2/veritasfe/package.json @@ -0,0 +1,39 @@ +{ + "name": "veritasfe", + "version": "0.0.1", + "private": true, + "scripts": { + "dev": "vite dev", + "build": "vite build", + "preview": "vite preview", + "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", + "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch" + }, + "devDependencies": { + "@sveltejs/adapter-auto": "^3.0.0", + "@sveltejs/kit": "^2.0.0", + "@sveltejs/vite-plugin-svelte": "^3.0.0", + "@zerodevx/svelte-toast": "^0.9.5", + "autoprefixer": "^10.4.19", + "daisyui": "^4.10.2", + "postcss": "^8.4.38", + "svelte": "^4.2.7", + "svelte-check": "^3.6.0", + "tailwindcss": "^3.4.3", + "tslib": "^2.4.1", + "typescript": "^5.0.0", + "vite": "^5.0.3" + }, + "type": "module", + "dependencies": { + "@chainsafe/bls": "^8.1.0", + "@chainsafe/blst": "^1.0.0", + "@chainsafe/libp2p-noise": "^15.0.0", + "@chainsafe/libp2p-yamux": "^6.0.2", + "@libp2p/bootstrap": "^10.0.20", + "@libp2p/websockets": "^8.0.20", + "@sveltejs/adapter-node": "^5.0.1", + "buffer": "^6.0.3", + "libp2p": "^1.4.2" + } +} diff --git a/z2/veritasfe/postcss.config.js b/z2/veritasfe/postcss.config.js new file mode 100644 index 0000000..2e7af2b --- /dev/null +++ b/z2/veritasfe/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/z2/veritasfe/src/app.css b/z2/veritasfe/src/app.css new file mode 100644 index 0000000..bd6213e --- /dev/null +++ b/z2/veritasfe/src/app.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; \ No newline at end of file diff --git a/z2/veritasfe/src/app.d.ts b/z2/veritasfe/src/app.d.ts new file mode 100644 index 0000000..743f07b --- /dev/null +++ b/z2/veritasfe/src/app.d.ts @@ -0,0 +1,13 @@ +// See https://kit.svelte.dev/docs/types#app +// for information about these interfaces +declare global { + namespace App { + // interface Error {} + // interface Locals {} + // interface PageData {} + // interface PageState {} + // interface Platform {} + } +} + +export {}; diff --git a/z2/veritasfe/src/app.html b/z2/veritasfe/src/app.html new file mode 100644 index 0000000..77a5ff5 --- /dev/null +++ b/z2/veritasfe/src/app.html @@ -0,0 +1,12 @@ + + + + + + + %sveltekit.head% + + +
%sveltekit.body%
+ + diff --git a/z2/veritasfe/src/lib/index.ts b/z2/veritasfe/src/lib/index.ts new file mode 100644 index 0000000..856f2b6 --- /dev/null +++ b/z2/veritasfe/src/lib/index.ts @@ -0,0 +1 @@ +// place files you want to import through the `$lib` alias in this folder. diff --git a/z2/veritasfe/src/routes/+layout.svelte b/z2/veritasfe/src/routes/+layout.svelte new file mode 100644 index 0000000..1fe2550 --- /dev/null +++ b/z2/veritasfe/src/routes/+layout.svelte @@ -0,0 +1,5 @@ + + + diff --git a/z2/veritasfe/src/routes/+page.svelte b/z2/veritasfe/src/routes/+page.svelte new file mode 100644 index 0000000..df3bf1a --- /dev/null +++ b/z2/veritasfe/src/routes/+page.svelte @@ -0,0 +1,215 @@ + + + + +
+ {#if status == "commit"} + + + + {:else if status == "register"} + + + {/if} +
+ +
+
+
Peers
+
{stats["peers"]}
+
+ +
+
Transactions mined
+
{stats["txCount"]}
+
+ +
+
Blocks mined
+
{stats["txCount"]}
+
+
+ + diff --git a/z2/veritasfe/src/utils/crypto.ts b/z2/veritasfe/src/utils/crypto.ts new file mode 100644 index 0000000..4279620 --- /dev/null +++ b/z2/veritasfe/src/utils/crypto.ts @@ -0,0 +1,28 @@ +import bls from "@chainsafe/bls/herumi"; +import { Buffer } from "buffer"; + +export const generateKeys = async() => { + const secretKey = bls.SecretKey.fromKeygen(); + const publicKey = secretKey.toPublicKey(); + console.log(publicKey.toHex()); + console.log(secretKey.toHex()); + return [secretKey.toHex(), publicKey.toHex()]; +} + +export const keyFromHex = async(sk:string) => { + const secretKey = bls.SecretKey.fromHex(sk); + const publicKey = secretKey.toPublicKey(); + return [secretKey, publicKey] +} + +export const signMessage = async(sk: string, msg: string) => { + let encoder = new TextEncoder(); + const message = encoder.encode(msg); + const secretKey = bls.SecretKey.fromHex(sk); + const publicKey = secretKey.toPublicKey(); + const signature = secretKey.sign(message); + + console.log("Is valid: ", signature.verify(publicKey, message)); + console.log(signature.toHex()) + return signature.toHex() +} \ No newline at end of file diff --git a/z2/veritasfe/src/utils/p2p.ts b/z2/veritasfe/src/utils/p2p.ts new file mode 100644 index 0000000..e69de29 diff --git a/z2/veritasfe/static/favicon.png b/z2/veritasfe/static/favicon.png new file mode 100644 index 0000000..825b9e6 Binary files /dev/null and b/z2/veritasfe/static/favicon.png differ diff --git a/z2/veritasfe/svelte.config.js b/z2/veritasfe/svelte.config.js new file mode 100644 index 0000000..ead63dd --- /dev/null +++ b/z2/veritasfe/svelte.config.js @@ -0,0 +1,19 @@ +import adapter from '@sveltejs/adapter-node'; +// import adapter from '@sveltejs/adapter-auto'; +import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; + +/** @type {import('@sveltejs/kit').Config} */ +const config = { + // Consult https://kit.svelte.dev/docs/integrations#preprocessors + // for more information about preprocessors + preprocess: vitePreprocess(), + + kit: { + // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. + // If your environment is not supported, or you settled on a specific environment, switch out the adapter. + // See https://kit.svelte.dev/docs/adapters for more information about adapters. + adapter: adapter() + } +}; + +export default config; diff --git a/z2/veritasfe/tailwind.config.js b/z2/veritasfe/tailwind.config.js new file mode 100644 index 0000000..852cf63 --- /dev/null +++ b/z2/veritasfe/tailwind.config.js @@ -0,0 +1,12 @@ +/** @type {import('tailwindcss').Config} */ +export default { + content: ['./src/**/*.{html,js,svelte,ts}'], + theme: { + extend: {}, + }, + daisyui: { + themes: ["dark"], + }, + plugins: [require("daisyui")], +} + diff --git a/z2/veritasfe/tsconfig.json b/z2/veritasfe/tsconfig.json new file mode 100644 index 0000000..fc93cbd --- /dev/null +++ b/z2/veritasfe/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./.svelte-kit/tsconfig.json", + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "sourceMap": true, + "strict": true, + "moduleResolution": "bundler" + } + // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias + // except $lib which is handled by https://kit.svelte.dev/docs/configuration#files + // + // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes + // from the referenced tsconfig.json - TypeScript does not merge them in +} diff --git a/z2/veritasfe/vite.config.ts b/z2/veritasfe/vite.config.ts new file mode 100644 index 0000000..7e40b81 --- /dev/null +++ b/z2/veritasfe/vite.config.ts @@ -0,0 +1,14 @@ +import { sveltekit } from '@sveltejs/kit/vite'; +import { defineConfig } from 'vite'; + +export default defineConfig({ + optimizeDeps: { + esbuildOptions: { + target: 'esnext' + } + }, + build: { + target: 'esnext' //browsers can handle the latest ES features + }, + plugins: [sveltekit()] +});