From a7b9f59651b073313a17d162a9c540738105cd15 Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Sat, 22 Jun 2024 00:25:42 +0330 Subject: [PATCH 01/26] =?UTF-8?q?=E2=9C=A8=20feat(mongo-repo):=20add=20mon?= =?UTF-8?q?godb=20adapter=20to=20store=20data=20>>>=20=E2=8F=B0=203h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 13 +++ go.sum | 44 +++++++ internal/config/model.go | 6 + internal/repository/mongo/assetprice.go | 100 ++++++++++++++++ internal/repository/mongo/assetprice_test.go | 86 ++++++++++++++ internal/repository/mongo/correctness.go | 103 +++++++++++++++++ internal/repository/mongo/correctness_test.go | 81 +++++++++++++ internal/repository/mongo/eventlog.go | 109 ++++++++++++++++++ internal/repository/mongo/eventlog_test.go | 83 +++++++++++++ internal/repository/mongo/signer.go | 92 +++++++++++++++ internal/repository/mongo/signer_test.go | 61 ++++++++++ internal/service/evmlog/evmlog.go | 1 - internal/transport/database/database.go | 6 + internal/transport/database/mongo/mongo.go | 50 ++++++++ 14 files changed, 834 insertions(+), 1 deletion(-) create mode 100644 internal/repository/mongo/assetprice.go create mode 100644 internal/repository/mongo/assetprice_test.go create mode 100644 internal/repository/mongo/correctness.go create mode 100644 internal/repository/mongo/correctness_test.go create mode 100644 internal/repository/mongo/eventlog.go create mode 100644 internal/repository/mongo/eventlog_test.go create mode 100644 internal/repository/mongo/signer.go create mode 100644 internal/repository/mongo/signer_test.go create mode 100644 internal/transport/database/mongo/mongo.go diff --git a/go.mod b/go.mod index a5b70934..dbec6f69 100644 --- a/go.mod +++ b/go.mod @@ -19,12 +19,15 @@ require ( github.com/lib/pq v1.10.9 github.com/lmittmann/tint v1.0.4 github.com/mattn/go-colorable v0.1.13 + github.com/newrelic/go-agent/v3/integrations/nrmongo v1.1.3 github.com/peterldowns/pgtestdb v0.0.14 github.com/pouya-eghbali/go-sia/v2 v2.1.0 github.com/puzpuzpuz/xsync/v3 v3.1.0 github.com/spf13/cobra v1.8.0 github.com/stretchr/testify v1.9.0 + github.com/tryvium-travels/memongo v0.12.0 github.com/vektah/gqlparser/v2 v2.5.11 + go.mongodb.org/mongo-driver v1.15.1 golang.org/x/crypto v0.21.0 golang.org/x/sync v0.6.0 golang.org/x/text v0.14.0 @@ -37,6 +40,7 @@ require ( github.com/DataDog/zstd v1.4.5 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/VictoriaMetrics/fastcache v1.12.1 // indirect + github.com/acobaugh/osrelease v0.0.0-20181218015638-a93a0a55a249 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/agnivade/levenshtein v1.1.1 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect @@ -101,6 +105,8 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/pointerstructure v1.2.0 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect + github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect + github.com/newrelic/go-agent/v3 v3.29.1 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect @@ -115,6 +121,7 @@ require ( github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/sosodev/duration v1.2.0 // indirect + github.com/spf13/afero v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/status-im/keycard-go v0.2.0 // indirect github.com/stretchr/objx v0.5.2 // indirect @@ -126,7 +133,11 @@ require ( github.com/urfave/cli/v2 v2.27.1 // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect + github.com/xdg-go/pbkdf2 v1.0.0 // indirect + github.com/xdg-go/scram v1.1.2 // indirect + github.com/xdg-go/stringprep v1.0.4 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect + github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect github.com/zclconf/go-cty v1.14.4 // indirect go.opencensus.io v0.24.0 // indirect @@ -136,6 +147,8 @@ require ( golang.org/x/sys v0.18.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.19.0 // indirect + google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect + google.golang.org/grpc v1.56.3 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect olympos.io/encoding/edn v0.0.0-20201019073823-d3554ca0b0a3 // indirect diff --git a/go.sum b/go.sum index 2ea0c99e..41323dce 100644 --- a/go.sum +++ b/go.sum @@ -60,6 +60,8 @@ github.com/PuerkitoBio/goquery v1.9.1/go.mod h1:cW1n6TmIMDoORQU5IU/P1T3tGFunOeXE github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40= github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= +github.com/acobaugh/osrelease v0.0.0-20181218015638-a93a0a55a249 h1:fMi9ZZ/it4orHj3xWrM6cLkVFcCbkXQALFUiNtHtCPs= +github.com/acobaugh/osrelease v0.0.0-20181218015638-a93a0a55a249/go.mod h1:iU1PxQMQwoHZZWmMKrMkrNlY+3+p9vxIjpZOVyxWa0g= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= @@ -249,6 +251,8 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -392,6 +396,7 @@ github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ib github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -449,12 +454,18 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= +github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nats-io/nats.go v1.8.1/go.mod h1:BrFz9vVn0fU3AcH9Vn4Kd7W0NpJ651tD5omQ3M8LwxM= github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/newrelic/go-agent/v3 v3.29.1 h1:OINNRev5ImiyRq0IUYwhfTmtqQgQFYyDNQEtbRFAi+k= +github.com/newrelic/go-agent/v3 v3.29.1/go.mod h1:9utrgxlSryNqRrTvII2XBL+0lpofXbqXApvVWPpbzUg= +github.com/newrelic/go-agent/v3/integrations/nrmongo v1.1.3 h1:Z85RJZKk+hghOQYJzsKUo3s4vP9W7/HUlB+CuLelqnc= +github.com/newrelic/go-agent/v3/integrations/nrmongo v1.1.3/go.mod h1:BzSK3ljUwW9PaTPdKstpKwQszKPnrU3xUaqidleearI= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= @@ -481,6 +492,7 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -539,6 +551,8 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9 github.com/sosodev/duration v1.2.0 h1:pqK/FLSjsAADWY74SyWDCjOcd5l7H8GSnnOGEB9A1Us= github.com/sosodev/duration v1.2.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= +github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= @@ -573,6 +587,8 @@ github.com/tklauser/go-sysconf v0.3.13 h1:GBUpcahXSpR2xN01jhkNAbTLRk2Yzgggk8IM08 github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0= github.com/tklauser/numcpus v0.7.0 h1:yjuerZP127QG9m5Zh/mSO4wqurYil27tHrqwRoRjpr4= github.com/tklauser/numcpus v0.7.0/go.mod h1:bb6dMVcj8A42tSE7i32fsIUCbQNllK5iDguyOZRUzAY= +github.com/tryvium-travels/memongo v0.12.0 h1:B56+Do7Z3vcR93oqkyUubvdFPJEqpHn1ZBSQRYe4Nnk= +github.com/tryvium-travels/memongo v0.12.0/go.mod h1:riRUHKRQ5JbeX2ryzFfmr7P2EYXIkNwgloSQJPpBikA= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= @@ -590,6 +606,12 @@ github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IU github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= +github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= +github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= +github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= +github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= +github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= +github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= @@ -597,6 +619,8 @@ github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1: github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= +github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= +github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= @@ -604,10 +628,13 @@ github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +go.mongodb.org/mongo-driver v1.15.1 h1:l+RvoUOoMXFmADTLfYDm7On9dRm7p4T80/lEQM+r7HU= +go.mongodb.org/mongo-driver v1.15.1/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -624,9 +651,11 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -661,6 +690,7 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -699,7 +729,9 @@ golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -719,6 +751,7 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -768,7 +801,10 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -777,12 +813,15 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -836,6 +875,7 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -895,6 +935,8 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -909,6 +951,8 @@ google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3Iji google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= +google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= diff --git a/internal/config/model.go b/internal/config/model.go index 2c2efba9..757e439f 100644 --- a/internal/config/model.go +++ b/internal/config/model.go @@ -74,6 +74,11 @@ type Network struct { BrokerTimeout time.Duration `env:"BROKER_TIMEOUT" env-default:"3s" yaml:"brokerTimeout"` } +type Mongo struct { + URL string `env:"Mongo_URL" yaml:"url"` + Database string `env:"Mongo_Database" yaml:"database"` +} + type Postgres struct { URL string `env:"DATABASE_URL" yaml:"url"` } @@ -92,6 +97,7 @@ type Config struct { System System `yaml:"system"` Network Network `yaml:"network"` RPC []RPC `yaml:"rpc"` + Mongo Mongo `yaml:"mongo"` Postgres Postgres `yaml:"postgres"` ProofOfStake ProofOfStake `yaml:"pos"` Plugins Plugins `yaml:"plugins"` diff --git a/internal/repository/mongo/assetprice.go b/internal/repository/mongo/assetprice.go new file mode 100644 index 00000000..4c8043dd --- /dev/null +++ b/internal/repository/mongo/assetprice.go @@ -0,0 +1,100 @@ +package mongo + +import ( + "context" + "github.com/TimeleapLabs/unchained/internal/config" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo/options" + "log" + + "github.com/TimeleapLabs/unchained/internal/consts" + "github.com/TimeleapLabs/unchained/internal/ent" + "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/repository" + "github.com/TimeleapLabs/unchained/internal/transport/database" + "github.com/TimeleapLabs/unchained/internal/utils" +) + +type AssetPriceRepo struct { + client database.MongoDatabase +} + +func (a AssetPriceRepo) Upsert(ctx context.Context, data model.AssetPrice) error { + opt := options.Update().SetUpsert(true) + + _, err := a.client. + GetConnection(). + Database(config.App.Mongo.Database). + Collection("assetprice"). + UpdateOne(ctx, bson.M{ + "block": data.Block, + "chain": data.Chain, + "asset": data.Name, + "pair": data.Pair, + }, bson.M{ + "$set": bson.M{ + "name": data.Name, + "price": data.Price, + "signers_count": data.SignersCount, + "signature": data.Signature, + "consensus": data.Consensus, + "voted": data.Voted, + "signer_ids": data.SignerIDs, + }, + "$setOnInsert": bson.M{ + "pair": data.Pair, + "chain": data.Chain, + "block": data.Block, + "asset": data.Name, + }, + }, opt) + + if err != nil { + utils.Logger.With("err", err).Error("Cant upsert asset price record in database") + return consts.ErrInternalError + } + + return nil +} + +func (a AssetPriceRepo) Find(ctx context.Context, block uint64, chain string, name string, pair string) ([]*ent.AssetPrice, error) { + currentRecords := []*ent.AssetPrice{} + cursor, err := a.client. + GetConnection(). + Database(config.App.Mongo.Database). + Collection("assetprice"). + Find(ctx, map[string]interface{}{ + "block": block, + "chain": chain, + "asset": name, + "pair": pair, + }) + + if err != nil { + utils.Logger.With("err", err).Error("Cant fetch asset price records from database") + return nil, consts.ErrInternalError + } + + defer cursor.Close(ctx) + for cursor.Next(ctx) { + var result ent.AssetPrice + err := cursor.Decode(&result) + if err != nil { + log.Fatal(err) + } + + currentRecords = append(currentRecords, &result) + } + if err := cursor.Err(); err != nil { + utils.Logger.With("err", err).Error("Cant fetch asset price records from database") + return nil, consts.ErrInternalError + } + + return currentRecords, nil +} + +func NewAssetPrice(client database.MongoDatabase) repository.AssetPrice { + return &AssetPriceRepo{ + client: client, + } +} diff --git a/internal/repository/mongo/assetprice_test.go b/internal/repository/mongo/assetprice_test.go new file mode 100644 index 00000000..7b2bc579 --- /dev/null +++ b/internal/repository/mongo/assetprice_test.go @@ -0,0 +1,86 @@ +package mongo + +import ( + "context" + "github.com/TimeleapLabs/unchained/internal/config" + "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/repository" + "github.com/TimeleapLabs/unchained/internal/transport/database/mongo" + "github.com/TimeleapLabs/unchained/internal/utils" + "github.com/stretchr/testify/suite" + "github.com/tryvium-travels/memongo" + "log" + "math/big" + "runtime" + "testing" +) + +var SampleAssetPrice = model.AssetPrice{ + Pair: "USDT/ETH", + Name: "USDT", + Chain: "ETH", + Block: 999, + Price: *big.NewInt(1000), + SignersCount: 10, + Signature: nil, + Consensus: false, + Voted: *big.NewInt(1000), + SignerIDs: nil, +} + +type AssetPriceRepositoryTestSuite struct { + suite.Suite + dbServer *memongo.Server + repo repository.AssetPrice +} + +func (s *AssetPriceRepositoryTestSuite) SetupTest() { + utils.SetupLogger(config.App.System.Log) + + var err error + opts := &memongo.Options{ + MongoVersion: "5.0.0", + } + if runtime.GOARCH == "arm64" { + if runtime.GOOS == "darwin" { + opts.DownloadURL = "https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-5.0.0.tgz" + } + } + + s.dbServer, err = memongo.StartWithOptions(opts) + if err != nil { + log.Fatal(err) + } + + config.App.Mongo.URL = s.dbServer.URI() + config.App.Mongo.Database = memongo.RandomDatabase() + db := mongo.New() + s.repo = NewAssetPrice(db) +} + +func (s *AssetPriceRepositoryTestSuite) TestUpsert() { + s.Run("Upsert asset price", func() { + err := s.repo.Upsert(context.TODO(), SampleAssetPrice) + s.NoError(err) + }) +} + +func (s *AssetPriceRepositoryTestSuite) TestFind() { + s.Run("Find asset price", func() { + err := s.repo.Upsert(context.TODO(), SampleAssetPrice) + s.NoError(err) + + assetPrices, err := s.repo.Find(context.TODO(), SampleAssetPrice.Block, SampleAssetPrice.Chain, SampleAssetPrice.Name, SampleAssetPrice.Pair) + s.NoError(err) + s.Len(assetPrices, 1) + }) +} + +func (s *AssetPriceRepositoryTestSuite) TearDownSuite() { + s.T().Log("Stopping the mongo server") + s.dbServer.Stop() +} + +func TestAssetPriceRepositoryTestSuite(t *testing.T) { + suite.Run(t, new(AssetPriceRepositoryTestSuite)) +} diff --git a/internal/repository/mongo/correctness.go b/internal/repository/mongo/correctness.go new file mode 100644 index 00000000..d801b799 --- /dev/null +++ b/internal/repository/mongo/correctness.go @@ -0,0 +1,103 @@ +package mongo + +import ( + "context" + "github.com/TimeleapLabs/unchained/internal/config" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo/options" + "log" + + "github.com/TimeleapLabs/unchained/internal/consts" + "github.com/TimeleapLabs/unchained/internal/ent" + "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/repository" + "github.com/TimeleapLabs/unchained/internal/transport/database" + "github.com/TimeleapLabs/unchained/internal/utils" +) + +type CorrectnessRepo struct { + client database.MongoDatabase +} + +func (c CorrectnessRepo) Find(ctx context.Context, hash []byte, topic []byte, timestamp uint64) ([]*ent.CorrectnessReport, error) { + currentRecords := []*ent.CorrectnessReport{} + + cursor, err := c.client. + GetConnection(). + Database(config.App.Mongo.Database). + Collection("correctnessreport"). + Find(ctx, bson.M{ + "hash": hash, + "topic": topic, + "timestamp": timestamp, + }) + + if err != nil { + utils.Logger.With("err", err).Error("Cant fetch correctness reports from database") + return nil, consts.ErrInternalError + } + + defer cursor.Close(ctx) + for cursor.Next(ctx) { + var result ent.CorrectnessReport + err := cursor.Decode(&result) + if err != nil { + log.Fatal(err) + } + + currentRecords = append(currentRecords, &result) + } + if err := cursor.Err(); err != nil { + utils.Logger.With("err", err).Error("Cant fetch asset price records from database") + return nil, consts.ErrInternalError + } + + return currentRecords, nil +} + +func (c CorrectnessRepo) Upsert(ctx context.Context, data model.Correctness) error { + opt := options.Update().SetUpsert(true) + + _, err := c.client. + GetConnection(). + Database(config.App.Mongo.Database). + Collection("correctnessreport"). + UpdateOne(ctx, bson.M{ + "hash": data.Hash, + "topic": data.Topic[:], + }, bson.M{ + "$set": bson.M{ + "correct": data.Correct, + "signers_count": data.SignersCount, + "signature": data.Signature, + "timestamp": data.Timestamp, + "consensus": data.Consensus, + "voted": data.Voted, + "signer_ids": data.SignerIDs, + }, + "$setOnInsert": bson.M{ + "correct": data.Correct, + "signers_count": data.SignersCount, + "signature": data.Signature, + "hash": data.Hash, + "timestamp": data.Timestamp, + "topic": data.Topic[:], + "consensus": data.Consensus, + "voted": data.Voted, + "signer_ids": data.SignerIDs, + }, + }, opt) + + if err != nil { + utils.Logger.With("err", err).Error("Cant upsert correctness report in database") + return consts.ErrInternalError + } + + return nil +} + +func NewCorrectness(client database.MongoDatabase) repository.CorrectnessReport { + return &CorrectnessRepo{ + client: client, + } +} diff --git a/internal/repository/mongo/correctness_test.go b/internal/repository/mongo/correctness_test.go new file mode 100644 index 00000000..75caef14 --- /dev/null +++ b/internal/repository/mongo/correctness_test.go @@ -0,0 +1,81 @@ +package mongo + +import ( + "github.com/TimeleapLabs/unchained/internal/config" + "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/repository" + "github.com/TimeleapLabs/unchained/internal/transport/database/mongo" + "github.com/TimeleapLabs/unchained/internal/utils" + "github.com/stretchr/testify/suite" + "github.com/tryvium-travels/memongo" + "log" + "math/big" + "runtime" + "testing" +) + +var sampleCorrectness = model.Correctness{ + SignersCount: 100, + Signature: nil, + Consensus: false, + Voted: *big.NewInt(1000), + SignerIDs: nil, + Timestamp: 999, + Hash: nil, + Topic: [64]byte{}, + Correct: false, +} + +type CorrectnessRepositoryTestSuite struct { + suite.Suite + dbServer *memongo.Server + repo repository.CorrectnessReport +} + +func (s *CorrectnessRepositoryTestSuite) SetupTest() { + utils.SetupLogger(config.App.System.Log) + + var err error + opts := &memongo.Options{ + MongoVersion: "5.0.0", + } + if runtime.GOARCH == "arm64" { + if runtime.GOOS == "darwin" { + opts.DownloadURL = "https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-5.0.0.tgz" + } + } + + s.dbServer, err = memongo.StartWithOptions(opts) + if err != nil { + log.Fatal(err) + } + + config.App.Mongo.URL = s.dbServer.URI() + config.App.Mongo.Database = memongo.RandomDatabase() + db := mongo.New() + s.repo = NewCorrectness(db) +} + +func (s *CorrectnessRepositoryTestSuite) TestUpsert() { + err := s.repo.Upsert(nil, sampleCorrectness) + s.NoError(err) +} + +func (s *CorrectnessRepositoryTestSuite) TestFind() { + err := s.repo.Upsert(nil, sampleCorrectness) + s.NoError(err) + + result, err := s.repo.Find(nil, sampleCorrectness.Hash, sampleCorrectness.Topic[:], sampleCorrectness.Timestamp) + s.NoError(err) + s.Len(result, 1) +} + +func (s *CorrectnessRepositoryTestSuite) TearDownTest() { + if s.dbServer != nil { + s.dbServer.Stop() + } +} + +func TestCorrectnessRepositoryTestSuite(t *testing.T) { + suite.Run(t, new(CorrectnessRepositoryTestSuite)) +} diff --git a/internal/repository/mongo/eventlog.go b/internal/repository/mongo/eventlog.go new file mode 100644 index 00000000..939e6155 --- /dev/null +++ b/internal/repository/mongo/eventlog.go @@ -0,0 +1,109 @@ +package mongo + +import ( + "context" + "github.com/TimeleapLabs/unchained/internal/config" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo/options" + "log" + + "github.com/TimeleapLabs/unchained/internal/consts" + "github.com/TimeleapLabs/unchained/internal/ent" + "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/repository" + "github.com/TimeleapLabs/unchained/internal/transport/database" + "github.com/TimeleapLabs/unchained/internal/utils" +) + +type EventLogRepo struct { + client database.MongoDatabase +} + +func (r EventLogRepo) Find(ctx context.Context, block uint64, hash []byte, index uint64) ([]*ent.EventLog, error) { + currentRecords := []*ent.EventLog{} + + cursor, err := r.client. + GetConnection(). + Database(config.App.Mongo.Database). + Collection("eventlog"). + Find(ctx, bson.M{ + "block": block, + "transaction": hash, + "index": index, + }) + + if err != nil { + utils.Logger.With("err", err).Error("Cant fetch event log records from database") + return nil, consts.ErrInternalError + } + + defer cursor.Close(ctx) + for cursor.Next(ctx) { + var result ent.EventLog + err := cursor.Decode(&result) + if err != nil { + log.Fatal(err) + } + + currentRecords = append(currentRecords, &result) + } + if err := cursor.Err(); err != nil { + utils.Logger.With("err", err).Error("Cant fetch event log records from database") + return nil, consts.ErrInternalError + } + + return currentRecords, nil +} + +func (r EventLogRepo) Upsert(ctx context.Context, data model.EventLog) error { + opt := options.Update().SetUpsert(true) + + _, err := r.client. + GetConnection(). + Database(config.App.Mongo.Database). + Collection("eventlog"). + UpdateOne(ctx, bson.M{ + "block": data.Block, + "transaction": data.TxHash[:], + "index": data.LogIndex, + }, bson.M{ + "$set": bson.M{ + "chain": data.Chain, + "address": data.Address, + "event": data.Event, + "signers_count": data.SignersCount, + "signature": data.Signature, + "args": data.Args, + "consensus": data.Consensus, + "voted": data.Voted, + "signer_ids": data.SignerIDs, + }, + "$setOnInsert": bson.M{ + "block": data.Block, + "chain": data.Chain, + "address": data.Address, + "event": data.Event, + "index": data.LogIndex, + "transaction": data.TxHash[:], + "signers_count": data.SignersCount, + "signature": data.Signature, + "args": data.Args, + "consensus": data.Consensus, + "voted": data.Voted, + "signer_ids": data.SignerIDs, + }, + }, opt) + + if err != nil { + utils.Logger.With("err", err).Error("Cant upsert event log record to database") + return consts.ErrInternalError + } + + return nil +} + +func NewEventLog(client database.MongoDatabase) repository.EventLog { + return &EventLogRepo{ + client: client, + } +} diff --git a/internal/repository/mongo/eventlog_test.go b/internal/repository/mongo/eventlog_test.go new file mode 100644 index 00000000..213c9bcf --- /dev/null +++ b/internal/repository/mongo/eventlog_test.go @@ -0,0 +1,83 @@ +package mongo + +import ( + "github.com/TimeleapLabs/unchained/internal/config" + "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/repository" + "github.com/TimeleapLabs/unchained/internal/transport/database/mongo" + "github.com/TimeleapLabs/unchained/internal/utils" + "github.com/stretchr/testify/suite" + "github.com/tryvium-travels/memongo" + "log" + "runtime" + "testing" +) + +var sampleEventLog = model.EventLog{ + LogIndex: 999, + Block: 999, + Address: "123", + Event: "321", + Chain: "ETH", + TxHash: [32]byte{}, + Args: nil, + Consensus: false, + SignersCount: 100, + SignerIDs: nil, + Signature: nil, + Voted: nil, +} + +type EventLogRepositoryTestSuite struct { + suite.Suite + dbServer *memongo.Server + repo repository.EventLog +} + +func (s *EventLogRepositoryTestSuite) SetupTest() { + utils.SetupLogger(config.App.System.Log) + + var err error + opts := &memongo.Options{ + MongoVersion: "5.0.0", + } + if runtime.GOARCH == "arm64" { + if runtime.GOOS == "darwin" { + opts.DownloadURL = "https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-5.0.0.tgz" + } + } + + s.dbServer, err = memongo.StartWithOptions(opts) + if err != nil { + log.Fatal(err) + } + + config.App.Mongo.URL = s.dbServer.URI() + config.App.Mongo.Database = memongo.RandomDatabase() + db := mongo.New() + s.repo = NewEventLog(db) +} + +func (s *EventLogRepositoryTestSuite) TestUpsert() { + err := s.repo.Upsert(nil, sampleEventLog) + s.NoError(err) +} + +func (s *EventLogRepositoryTestSuite) TestFind() { + err := s.repo.Upsert(nil, sampleEventLog) + s.NoError(err) + + result, err := s.repo.Find(nil, sampleEventLog.Block, sampleEventLog.TxHash[:], sampleEventLog.LogIndex) + s.NoError(err) + s.Len(result, 1) +} + +func (s *EventLogRepositoryTestSuite) TearDownTest() { + if s.dbServer != nil { + s.dbServer.Stop() + } +} + +func TestEventLogRepositoryTestSuite(t *testing.T) { + suite.Run(t, new(EventLogRepositoryTestSuite)) +} diff --git a/internal/repository/mongo/signer.go b/internal/repository/mongo/signer.go new file mode 100644 index 00000000..9c090389 --- /dev/null +++ b/internal/repository/mongo/signer.go @@ -0,0 +1,92 @@ +package mongo + +import ( + "context" + "github.com/TimeleapLabs/unchained/internal/config" + "github.com/TimeleapLabs/unchained/internal/consts" + "github.com/TimeleapLabs/unchained/internal/ent" + "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/repository" + "github.com/TimeleapLabs/unchained/internal/transport/database" + "github.com/TimeleapLabs/unchained/internal/utils" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo/options" + "log" +) + +type signerRepo struct { + client database.MongoDatabase +} + +func (s signerRepo) CreateSigners(ctx context.Context, signers []model.Signer) error { + + for _, singer := range signers { + opt := options.Update().SetUpsert(true) + + _, err := s.client. + GetConnection(). + Database(config.App.Mongo.Database). + Collection("signer"). + UpdateOne(ctx, + bson.M{ + "shortkey": singer.ShortPublicKey[:], + }, bson.M{ + "$set": bson.M{ + "name": singer.Name, + "evm": singer.EvmAddress, + "key": singer.PublicKey[:], + "points": bson.M{"$inc": 1}, + }, "$setOnInsert": bson.M{ + "shortkey": singer.ShortPublicKey[:], + }, + }, + opt, + ) + if err != nil { + utils.Logger.With("err", err).Error("Cant create signers in database") + return consts.ErrInternalError + } + } + + return nil +} + +func (s signerRepo) GetSingerIDsByKeys(ctx context.Context, keys [][]byte) ([]int, error) { + opt := options.Find().SetProjection(bson.M{"_id": 1}) + cursor, err := s.client. + GetConnection(). + Database(config.App.Mongo.Database). + Collection("signer"). + Find(ctx, bson.M{ + "key": bson.M{"$in": keys}, + }, opt) + + if err != nil { + utils.Logger.With("err", err).Error("Cant fetch signer IDs from database") + return []int{}, consts.ErrInternalError + } + + ids := []int{} + defer cursor.Close(ctx) + for cursor.Next(ctx) { + var result ent.Signer + err := cursor.Decode(&result) + if err != nil { + log.Fatal(err) + } + + ids = append(ids, result.ID) + } + if err := cursor.Err(); err != nil { + utils.Logger.With("err", err).Error("Cant fetch asset price records from database") + return nil, consts.ErrInternalError + } + + return ids, nil +} + +func NewSigner(client database.MongoDatabase) repository.Signer { + return &signerRepo{ + client: client, + } +} diff --git a/internal/repository/mongo/signer_test.go b/internal/repository/mongo/signer_test.go new file mode 100644 index 00000000..5fea7a3a --- /dev/null +++ b/internal/repository/mongo/signer_test.go @@ -0,0 +1,61 @@ +package mongo + +import ( + "github.com/TimeleapLabs/unchained/internal/config" + "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/repository" + "github.com/TimeleapLabs/unchained/internal/transport/database/mongo" + "github.com/TimeleapLabs/unchained/internal/utils" + "github.com/stretchr/testify/suite" + "github.com/tryvium-travels/memongo" + "log" + "runtime" + "testing" +) + +var sampleSigner = model.Signer{} + +type SignerRepositoryTestSuite struct { + suite.Suite + dbServer *memongo.Server + repo repository.Signer +} + +func (s *SignerRepositoryTestSuite) SetupTest() { + utils.SetupLogger(config.App.System.Log) + + var err error + opts := &memongo.Options{ + MongoVersion: "5.0.0", + } + if runtime.GOARCH == "arm64" { + if runtime.GOOS == "darwin" { + opts.DownloadURL = "https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-5.0.0.tgz" + } + } + + s.dbServer, err = memongo.StartWithOptions(opts) + if err != nil { + log.Fatal(err) + } + + config.App.Mongo.URL = s.dbServer.URI() + config.App.Mongo.Database = memongo.RandomDatabase() + db := mongo.New() + s.repo = NewSigner(db) +} + +func (s *SignerRepositoryTestSuite) TestUpsert() { + err := s.repo.CreateSigners(nil, []model.Signer{sampleSigner}) + s.Require().NoError(err) +} + +func (s *SignerRepositoryTestSuite) TearDownTest() { + if s.dbServer != nil { + s.dbServer.Stop() + } +} + +func TestSignerRepositoryTestSuite(t *testing.T) { + suite.Run(t, new(SignerRepositoryTestSuite)) +} diff --git a/internal/service/evmlog/evmlog.go b/internal/service/evmlog/evmlog.go index b96d1bfb..f6539027 100644 --- a/internal/service/evmlog/evmlog.go +++ b/internal/service/evmlog/evmlog.go @@ -110,7 +110,6 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er } signerIDs, err := s.signerRepo.GetSingerIDsByKeys(ctx, keys) - if err != nil { return err } diff --git a/internal/transport/database/database.go b/internal/transport/database/database.go index 39ded2c0..56d7eff3 100644 --- a/internal/transport/database/database.go +++ b/internal/transport/database/database.go @@ -2,6 +2,7 @@ package database import ( "context" + "go.mongodb.org/mongo-driver/mongo" "github.com/TimeleapLabs/unchained/internal/ent" ) @@ -10,3 +11,8 @@ type Database interface { GetConnection() *ent.Client HealthCheck(ctx context.Context) bool } + +type MongoDatabase interface { + GetConnection() *mongo.Client + HealthCheck(ctx context.Context) bool +} diff --git a/internal/transport/database/mongo/mongo.go b/internal/transport/database/mongo/mongo.go new file mode 100644 index 00000000..21351660 --- /dev/null +++ b/internal/transport/database/mongo/mongo.go @@ -0,0 +1,50 @@ +package mongo + +import ( + "context" + "github.com/TimeleapLabs/unchained/internal/config" + "github.com/TimeleapLabs/unchained/internal/transport/database" + "github.com/TimeleapLabs/unchained/internal/utils" + "github.com/newrelic/go-agent/v3/integrations/nrmongo" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" +) + +type connection struct { + db *mongo.Client +} + +func (c *connection) HealthCheck(ctx context.Context) bool { + if c.db == nil { + return false + } + + err := c.db.Ping(ctx, nil) + if err != nil { + utils.Logger.With("Error", err).Error("HealthCheck") + return false + } + + return true +} + +func (c *connection) GetConnection() *mongo.Client { + if c.db != nil { + return c.db + } + + utils.Logger.Info("Connecting to MongoDB") + + var err error + nrMon := nrmongo.NewCommandMonitor(nil) + c.db, err = mongo.Connect(context.Background(), options.Client().SetMonitor(nrMon).ApplyURI(config.App.Mongo.URL)) + if err != nil { + panic(err) + } + + return c.db +} + +func New() database.MongoDatabase { + return &connection{} +} From 3ef6cf0c7385e430798b557ad27f2b63fdd03558 Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Sat, 22 Jun 2024 00:58:06 +0330 Subject: [PATCH 02/26] =?UTF-8?q?=F0=9F=90=9B=20fix(fixes):=20some=20fixes?= =?UTF-8?q?=20and=20lint=20problem=20>>>=20=E2=8F=B0=2030m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/app/consumer.go | 2 +- internal/config/model.go | 2 +- internal/repository/mongo/assetprice.go | 5 ++-- internal/repository/mongo/assetprice_test.go | 9 +++--- internal/repository/mongo/correctness.go | 19 +++--------- internal/repository/mongo/correctness_test.go | 16 +++++----- internal/repository/mongo/eventlog.go | 17 ++--------- internal/repository/mongo/eventlog_test.go | 15 ++++++---- internal/repository/mongo/signer.go | 6 ++-- internal/repository/mongo/signer_test.go | 10 ++++--- internal/repository/mongo/utils.go | 30 +++++++++++++++++++ internal/transport/database/database.go | 1 + internal/transport/database/mongo/mongo.go | 1 + 13 files changed, 76 insertions(+), 57 deletions(-) create mode 100644 internal/repository/mongo/utils.go diff --git a/internal/app/consumer.go b/internal/app/consumer.go index 726a798d..0af2e6a8 100644 --- a/internal/app/consumer.go +++ b/internal/app/consumer.go @@ -33,8 +33,8 @@ func Consumer() { ethRPC := ethereum.New() pos := pos.New(ethRPC) - db := postgres.New() + db := postgres.New() eventLogRepo := postgresRepo.NewEventLog(db) signerRepo := postgresRepo.NewSigner(db) assetPrice := postgresRepo.NewAssetPrice(db) diff --git a/internal/config/model.go b/internal/config/model.go index 757e439f..8cdb79b6 100644 --- a/internal/config/model.go +++ b/internal/config/model.go @@ -75,7 +75,7 @@ type Network struct { } type Mongo struct { - URL string `env:"Mongo_URL" yaml:"url"` + URL string `env:"Mongo_URL" yaml:"url"` Database string `env:"Mongo_Database" yaml:"database"` } diff --git a/internal/repository/mongo/assetprice.go b/internal/repository/mongo/assetprice.go index 4c8043dd..65f01146 100644 --- a/internal/repository/mongo/assetprice.go +++ b/internal/repository/mongo/assetprice.go @@ -2,10 +2,10 @@ package mongo import ( "context" + "github.com/TimeleapLabs/unchained/internal/config" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo/options" - "log" "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/ent" @@ -80,7 +80,8 @@ func (a AssetPriceRepo) Find(ctx context.Context, block uint64, chain string, na var result ent.AssetPrice err := cursor.Decode(&result) if err != nil { - log.Fatal(err) + utils.Logger.With("err", err).Error("Cant decode signer record") + return nil, err } currentRecords = append(currentRecords, &result) diff --git a/internal/repository/mongo/assetprice_test.go b/internal/repository/mongo/assetprice_test.go index 7b2bc579..850331d3 100644 --- a/internal/repository/mongo/assetprice_test.go +++ b/internal/repository/mongo/assetprice_test.go @@ -2,6 +2,11 @@ package mongo import ( "context" + "log" + "math/big" + "runtime" + "testing" + "github.com/TimeleapLabs/unchained/internal/config" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" @@ -9,10 +14,6 @@ import ( "github.com/TimeleapLabs/unchained/internal/utils" "github.com/stretchr/testify/suite" "github.com/tryvium-travels/memongo" - "log" - "math/big" - "runtime" - "testing" ) var SampleAssetPrice = model.AssetPrice{ diff --git a/internal/repository/mongo/correctness.go b/internal/repository/mongo/correctness.go index d801b799..2819380e 100644 --- a/internal/repository/mongo/correctness.go +++ b/internal/repository/mongo/correctness.go @@ -2,10 +2,10 @@ package mongo import ( "context" + "github.com/TimeleapLabs/unchained/internal/config" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo/options" - "log" "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/ent" @@ -20,8 +20,6 @@ type CorrectnessRepo struct { } func (c CorrectnessRepo) Find(ctx context.Context, hash []byte, topic []byte, timestamp uint64) ([]*ent.CorrectnessReport, error) { - currentRecords := []*ent.CorrectnessReport{} - cursor, err := c.client. GetConnection(). Database(config.App.Mongo.Database). @@ -37,18 +35,9 @@ func (c CorrectnessRepo) Find(ctx context.Context, hash []byte, topic []byte, ti return nil, consts.ErrInternalError } - defer cursor.Close(ctx) - for cursor.Next(ctx) { - var result ent.CorrectnessReport - err := cursor.Decode(&result) - if err != nil { - log.Fatal(err) - } - - currentRecords = append(currentRecords, &result) - } - if err := cursor.Err(); err != nil { - utils.Logger.With("err", err).Error("Cant fetch asset price records from database") + currentRecords, err := CursorToList[*ent.CorrectnessReport](ctx, cursor) + if err != nil { + utils.Logger.With("err", err).Error("Cant fetch correctness reports from database") return nil, consts.ErrInternalError } diff --git a/internal/repository/mongo/correctness_test.go b/internal/repository/mongo/correctness_test.go index 75caef14..fb3e1a6c 100644 --- a/internal/repository/mongo/correctness_test.go +++ b/internal/repository/mongo/correctness_test.go @@ -1,6 +1,12 @@ package mongo import ( + "context" + "log" + "math/big" + "runtime" + "testing" + "github.com/TimeleapLabs/unchained/internal/config" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" @@ -8,10 +14,6 @@ import ( "github.com/TimeleapLabs/unchained/internal/utils" "github.com/stretchr/testify/suite" "github.com/tryvium-travels/memongo" - "log" - "math/big" - "runtime" - "testing" ) var sampleCorrectness = model.Correctness{ @@ -57,15 +59,15 @@ func (s *CorrectnessRepositoryTestSuite) SetupTest() { } func (s *CorrectnessRepositoryTestSuite) TestUpsert() { - err := s.repo.Upsert(nil, sampleCorrectness) + err := s.repo.Upsert(context.TODO(), sampleCorrectness) s.NoError(err) } func (s *CorrectnessRepositoryTestSuite) TestFind() { - err := s.repo.Upsert(nil, sampleCorrectness) + err := s.repo.Upsert(context.TODO(), sampleCorrectness) s.NoError(err) - result, err := s.repo.Find(nil, sampleCorrectness.Hash, sampleCorrectness.Topic[:], sampleCorrectness.Timestamp) + result, err := s.repo.Find(context.TODO(), sampleCorrectness.Hash, sampleCorrectness.Topic[:], sampleCorrectness.Timestamp) s.NoError(err) s.Len(result, 1) } diff --git a/internal/repository/mongo/eventlog.go b/internal/repository/mongo/eventlog.go index 939e6155..9c4e7663 100644 --- a/internal/repository/mongo/eventlog.go +++ b/internal/repository/mongo/eventlog.go @@ -2,10 +2,10 @@ package mongo import ( "context" + "github.com/TimeleapLabs/unchained/internal/config" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo/options" - "log" "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/ent" @@ -20,8 +20,6 @@ type EventLogRepo struct { } func (r EventLogRepo) Find(ctx context.Context, block uint64, hash []byte, index uint64) ([]*ent.EventLog, error) { - currentRecords := []*ent.EventLog{} - cursor, err := r.client. GetConnection(). Database(config.App.Mongo.Database). @@ -37,17 +35,8 @@ func (r EventLogRepo) Find(ctx context.Context, block uint64, hash []byte, index return nil, consts.ErrInternalError } - defer cursor.Close(ctx) - for cursor.Next(ctx) { - var result ent.EventLog - err := cursor.Decode(&result) - if err != nil { - log.Fatal(err) - } - - currentRecords = append(currentRecords, &result) - } - if err := cursor.Err(); err != nil { + currentRecords, err := CursorToList[*ent.EventLog](ctx, cursor) + if err != nil { utils.Logger.With("err", err).Error("Cant fetch event log records from database") return nil, consts.ErrInternalError } diff --git a/internal/repository/mongo/eventlog_test.go b/internal/repository/mongo/eventlog_test.go index 213c9bcf..1756b000 100644 --- a/internal/repository/mongo/eventlog_test.go +++ b/internal/repository/mongo/eventlog_test.go @@ -1,6 +1,12 @@ package mongo import ( + "log" + "runtime" + "testing" + + "golang.org/x/net/context" + "github.com/TimeleapLabs/unchained/internal/config" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" @@ -8,9 +14,6 @@ import ( "github.com/TimeleapLabs/unchained/internal/utils" "github.com/stretchr/testify/suite" "github.com/tryvium-travels/memongo" - "log" - "runtime" - "testing" ) var sampleEventLog = model.EventLog{ @@ -59,15 +62,15 @@ func (s *EventLogRepositoryTestSuite) SetupTest() { } func (s *EventLogRepositoryTestSuite) TestUpsert() { - err := s.repo.Upsert(nil, sampleEventLog) + err := s.repo.Upsert(context.TODO(), sampleEventLog) s.NoError(err) } func (s *EventLogRepositoryTestSuite) TestFind() { - err := s.repo.Upsert(nil, sampleEventLog) + err := s.repo.Upsert(context.TODO(), sampleEventLog) s.NoError(err) - result, err := s.repo.Find(nil, sampleEventLog.Block, sampleEventLog.TxHash[:], sampleEventLog.LogIndex) + result, err := s.repo.Find(context.TODO(), sampleEventLog.Block, sampleEventLog.TxHash[:], sampleEventLog.LogIndex) s.NoError(err) s.Len(result, 1) } diff --git a/internal/repository/mongo/signer.go b/internal/repository/mongo/signer.go index 9c090389..c3db604b 100644 --- a/internal/repository/mongo/signer.go +++ b/internal/repository/mongo/signer.go @@ -2,6 +2,7 @@ package mongo import ( "context" + "github.com/TimeleapLabs/unchained/internal/config" "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/ent" @@ -11,7 +12,6 @@ import ( "github.com/TimeleapLabs/unchained/internal/utils" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo/options" - "log" ) type signerRepo struct { @@ -19,7 +19,6 @@ type signerRepo struct { } func (s signerRepo) CreateSigners(ctx context.Context, signers []model.Signer) error { - for _, singer := range signers { opt := options.Update().SetUpsert(true) @@ -72,7 +71,8 @@ func (s signerRepo) GetSingerIDsByKeys(ctx context.Context, keys [][]byte) ([]in var result ent.Signer err := cursor.Decode(&result) if err != nil { - log.Fatal(err) + utils.Logger.With("err", err).Error("Cant decode signer record") + return nil, err } ids = append(ids, result.ID) diff --git a/internal/repository/mongo/signer_test.go b/internal/repository/mongo/signer_test.go index 5fea7a3a..c596ebac 100644 --- a/internal/repository/mongo/signer_test.go +++ b/internal/repository/mongo/signer_test.go @@ -1,6 +1,11 @@ package mongo import ( + "context" + "log" + "runtime" + "testing" + "github.com/TimeleapLabs/unchained/internal/config" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" @@ -8,9 +13,6 @@ import ( "github.com/TimeleapLabs/unchained/internal/utils" "github.com/stretchr/testify/suite" "github.com/tryvium-travels/memongo" - "log" - "runtime" - "testing" ) var sampleSigner = model.Signer{} @@ -46,7 +48,7 @@ func (s *SignerRepositoryTestSuite) SetupTest() { } func (s *SignerRepositoryTestSuite) TestUpsert() { - err := s.repo.CreateSigners(nil, []model.Signer{sampleSigner}) + err := s.repo.CreateSigners(context.TODO(), []model.Signer{sampleSigner}) s.Require().NoError(err) } diff --git a/internal/repository/mongo/utils.go b/internal/repository/mongo/utils.go new file mode 100644 index 00000000..eadba8c3 --- /dev/null +++ b/internal/repository/mongo/utils.go @@ -0,0 +1,30 @@ +package mongo + +import ( + "context" + + "github.com/TimeleapLabs/unchained/internal/consts" + "github.com/TimeleapLabs/unchained/internal/utils" + "go.mongodb.org/mongo-driver/mongo" +) + +func CursorToList[T any](ctx context.Context, cursor *mongo.Cursor) ([]T, error) { + defer cursor.Close(ctx) + + result := []T{} + for cursor.Next(ctx) { + var item T + err := cursor.Decode(&item) + if err != nil { + return nil, err + } + result = append(result, item) + } + + if err := cursor.Err(); err != nil { + utils.Logger.With("err", err).Error("Cant fetch asset price records from database") + return nil, consts.ErrInternalError + } + + return result, nil +} diff --git a/internal/transport/database/database.go b/internal/transport/database/database.go index 56d7eff3..5bc118fb 100644 --- a/internal/transport/database/database.go +++ b/internal/transport/database/database.go @@ -2,6 +2,7 @@ package database import ( "context" + "go.mongodb.org/mongo-driver/mongo" "github.com/TimeleapLabs/unchained/internal/ent" diff --git a/internal/transport/database/mongo/mongo.go b/internal/transport/database/mongo/mongo.go index 21351660..ee97d7d1 100644 --- a/internal/transport/database/mongo/mongo.go +++ b/internal/transport/database/mongo/mongo.go @@ -2,6 +2,7 @@ package mongo import ( "context" + "github.com/TimeleapLabs/unchained/internal/config" "github.com/TimeleapLabs/unchained/internal/transport/database" "github.com/TimeleapLabs/unchained/internal/utils" From 0a9d1b30ec75ce988774f02be50ae3c248205484 Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Sat, 22 Jun 2024 01:05:19 +0330 Subject: [PATCH 03/26] =?UTF-8?q?=F0=9F=90=9B=20fix(errors):=20fix=20error?= =?UTF-8?q?=20check=20of=20linters=20>>>=20=E2=8F=B0=205m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/repository/mongo/assetprice.go | 8 +++++++- internal/repository/mongo/signer.go | 8 +++++++- internal/repository/mongo/utils.go | 7 ++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/internal/repository/mongo/assetprice.go b/internal/repository/mongo/assetprice.go index 65f01146..da6a4d77 100644 --- a/internal/repository/mongo/assetprice.go +++ b/internal/repository/mongo/assetprice.go @@ -2,6 +2,7 @@ package mongo import ( "context" + "go.mongodb.org/mongo-driver/mongo" "github.com/TimeleapLabs/unchained/internal/config" "go.mongodb.org/mongo-driver/bson" @@ -75,7 +76,12 @@ func (a AssetPriceRepo) Find(ctx context.Context, block uint64, chain string, na return nil, consts.ErrInternalError } - defer cursor.Close(ctx) + defer func(cursor *mongo.Cursor, ctx context.Context) { + err := cursor.Close(ctx) + if err != nil { + utils.Logger.With("err", err).Error("Cant close cursor") + } + }(cursor, ctx) for cursor.Next(ctx) { var result ent.AssetPrice err := cursor.Decode(&result) diff --git a/internal/repository/mongo/signer.go b/internal/repository/mongo/signer.go index c3db604b..4bd3145f 100644 --- a/internal/repository/mongo/signer.go +++ b/internal/repository/mongo/signer.go @@ -2,6 +2,7 @@ package mongo import ( "context" + "go.mongodb.org/mongo-driver/mongo" "github.com/TimeleapLabs/unchained/internal/config" "github.com/TimeleapLabs/unchained/internal/consts" @@ -66,7 +67,12 @@ func (s signerRepo) GetSingerIDsByKeys(ctx context.Context, keys [][]byte) ([]in } ids := []int{} - defer cursor.Close(ctx) + defer func(cursor *mongo.Cursor, ctx context.Context) { + err := cursor.Close(ctx) + if err != nil { + utils.Logger.With("err", err).Error("Cant close cursor") + } + }(cursor, ctx) for cursor.Next(ctx) { var result ent.Signer err := cursor.Decode(&result) diff --git a/internal/repository/mongo/utils.go b/internal/repository/mongo/utils.go index eadba8c3..160e9a93 100644 --- a/internal/repository/mongo/utils.go +++ b/internal/repository/mongo/utils.go @@ -9,7 +9,12 @@ import ( ) func CursorToList[T any](ctx context.Context, cursor *mongo.Cursor) ([]T, error) { - defer cursor.Close(ctx) + defer func(cursor *mongo.Cursor, ctx context.Context) { + err := cursor.Close(ctx) + if err != nil { + utils.Logger.With("err", err).Error("Cant close cursor") + } + }(cursor, ctx) result := []T{} for cursor.Next(ctx) { From 573ef5d89fe25c7da7df5a589b7ff333276c3184 Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Sat, 22 Jun 2024 01:28:20 +0330 Subject: [PATCH 04/26] =?UTF-8?q?=F0=9F=90=9B=20fix(lint):=20lint=20>>>=20?= =?UTF-8?q?=E2=8F=B0=202m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/repository/mongo/assetprice.go | 1 + internal/repository/mongo/signer.go | 1 + 2 files changed, 2 insertions(+) diff --git a/internal/repository/mongo/assetprice.go b/internal/repository/mongo/assetprice.go index da6a4d77..0aea88d2 100644 --- a/internal/repository/mongo/assetprice.go +++ b/internal/repository/mongo/assetprice.go @@ -2,6 +2,7 @@ package mongo import ( "context" + "go.mongodb.org/mongo-driver/mongo" "github.com/TimeleapLabs/unchained/internal/config" diff --git a/internal/repository/mongo/signer.go b/internal/repository/mongo/signer.go index 4bd3145f..9ffcd9de 100644 --- a/internal/repository/mongo/signer.go +++ b/internal/repository/mongo/signer.go @@ -2,6 +2,7 @@ package mongo import ( "context" + "go.mongodb.org/mongo-driver/mongo" "github.com/TimeleapLabs/unchained/internal/config" From dcb856c8837bfaf9bd2b5ba65bf6800a3c5ec61c Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Mon, 24 Jun 2024 01:48:49 +0330 Subject: [PATCH 05/26] =?UTF-8?q?=E2=9C=A8=20feat(postgres):=20rewrite=20r?= =?UTF-8?q?epositories=20with=20gorm=20-=20remove=20gql=20-=20seprate=20pa?= =?UTF-8?q?ckets=20from=20models=20>>>=20=E2=8F=B0=205h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .golangci.yml | 3 + go.mod | 9 +- go.sum | 8 + internal/app/consumer.go | 6 +- internal/ent/assetprice.go | 255 - internal/ent/assetprice/assetprice.go | 148 - internal/ent/assetprice/where.go | 583 -- internal/ent/assetprice_create.go | 1077 -- internal/ent/assetprice_delete.go | 88 - internal/ent/assetprice_query.go | 671 -- internal/ent/assetprice_update.go | 735 -- internal/ent/client.go | 868 -- internal/ent/correctnessreport.go | 239 - .../correctnessreport/correctnessreport.go | 134 - internal/ent/correctnessreport/where.go | 393 - internal/ent/correctnessreport_create.go | 934 -- internal/ent/correctnessreport_delete.go | 88 - internal/ent/correctnessreport_query.go | 671 -- internal/ent/correctnessreport_update.go | 633 -- internal/ent/ent.go | 614 -- internal/ent/entc.go | 32 - internal/ent/enttest/enttest.go | 84 - internal/ent/eventlog.go | 278 - internal/ent/eventlog/eventlog.go | 156 - internal/ent/eventlog/where.go | 588 -- internal/ent/eventlog_create.go | 1109 --- internal/ent/eventlog_delete.go | 88 - internal/ent/eventlog_query.go | 671 -- internal/ent/eventlog_update.go | 769 -- internal/ent/gql_collection.go | 678 -- internal/ent/gql_edge.go | 81 - internal/ent/gql_node.go | 348 - internal/ent/gql_pagination.go | 1282 --- internal/ent/gql_transaction.go | 30 - internal/ent/gql_where_input.go | 1563 --- internal/ent/helpers/bigint.go | 34 - internal/ent/hook/hook.go | 235 - internal/ent/migrate/migrate.go | 64 - internal/ent/migrate/schema.go | 226 - internal/ent/mutation.go | 3837 -------- internal/ent/predicate/predicate.go | 19 - internal/ent/runtime.go | 101 - internal/ent/runtime/runtime.go | 10 - internal/ent/schema/assetprice.go | 77 - internal/ent/schema/correctness.go | 75 - internal/ent/schema/eventlog.go | 80 - internal/ent/schema/signer.go | 68 - internal/ent/signer.go | 288 - internal/ent/signer/signer.go | 175 - internal/ent/signer/where.go | 423 - internal/ent/signer_create.go | 822 -- internal/ent/signer_delete.go | 88 - internal/ent/signer_query.go | 927 -- internal/ent/signer_update.go | 886 -- internal/ent/tx.go | 219 - internal/generate.go | 1 - internal/model/assetprice.go | 16 +- internal/model/correctness.go | 53 +- internal/model/dataframe.go | 9 + internal/model/logs.go | 47 +- internal/model/price.go | 28 - internal/model/proof.go | 11 + internal/model/{bls.go => signer.go} | 29 - internal/model/uniswap.go | 115 - internal/repository/postgres/assetprice.go | 55 +- internal/repository/postgres/correctness.go | 52 +- internal/repository/postgres/eventlog.go | 54 +- internal/repository/postgres/signer.go | 50 +- internal/repository/repository.go | 7 +- internal/service/correctness/correctness.go | 22 +- .../service/correctness/correctness_test.go | 43 +- internal/service/correctness/types.go | 34 + internal/service/evmlog/evmlog.go | 15 +- internal/service/evmlog/helper.go | 8 +- internal/service/evmlog/record.go | 4 +- internal/service/uniswap/helper.go | 8 +- internal/service/uniswap/process.go | 5 +- internal/service/uniswap/record.go | 4 +- internal/service/uniswap/types/assetkey.go | 21 + internal/service/uniswap/types/priceinfo.go | 43 + .../{model => service/uniswap/types}/token.go | 2 +- internal/service/uniswap/types/tokenkey.go | 33 + internal/service/uniswap/uniswap.go | 67 +- .../transport/client/handler/challenge.go | 6 +- .../transport/client/handler/correctness.go | 10 +- internal/transport/client/handler/event.go | 5 +- internal/transport/client/handler/price.go | 5 +- internal/transport/database/database.go | 4 +- .../transport/database/mock/postgres_mock.go | 17 +- .../transport/database/postgres/postgres.go | 51 +- internal/transport/server/gql/args.graphql | 7 - .../transport/server/gql/args.resolvers.go | 39 - .../transport/server/gql/extensions.graphql | 8 - .../server/gql/extensions.resolvers.go | 65 - .../server/gql/generated/args.generated.go | 279 - .../server/gql/generated/prelude.generated.go | 2969 ------ .../server/gql/generated/root_.generated.go | 1712 ---- .../gql/generated/unchained.generated.go | 8709 ----------------- internal/transport/server/gql/resolver.go | 18 - internal/transport/server/gql/server.go | 21 - internal/transport/server/gql/types/bytes.go | 34 - .../transport/server/gql/unchained.graphql | 847 -- .../server/gql/unchained.resolvers.go | 342 - .../server/packet/challenge.go} | 2 +- .../transport/server/packet/correctness.go | 49 + internal/transport/server/packet/eventlog.go | 48 + internal/transport/server/packet/price.go | 52 + .../server/websocket/handler/correctness.go | 12 +- .../server/websocket/handler/event.go | 6 +- .../server/websocket/handler/hello.go | 3 +- .../server/websocket/handler/kosk.go | 4 +- .../server/websocket/handler/price.go | 6 +- .../transport/server/websocket/store/store.go | 3 +- 113 files changed, 620 insertions(+), 40117 deletions(-) delete mode 100644 internal/ent/assetprice.go delete mode 100644 internal/ent/assetprice/assetprice.go delete mode 100644 internal/ent/assetprice/where.go delete mode 100644 internal/ent/assetprice_create.go delete mode 100644 internal/ent/assetprice_delete.go delete mode 100644 internal/ent/assetprice_query.go delete mode 100644 internal/ent/assetprice_update.go delete mode 100644 internal/ent/client.go delete mode 100644 internal/ent/correctnessreport.go delete mode 100644 internal/ent/correctnessreport/correctnessreport.go delete mode 100644 internal/ent/correctnessreport/where.go delete mode 100644 internal/ent/correctnessreport_create.go delete mode 100644 internal/ent/correctnessreport_delete.go delete mode 100644 internal/ent/correctnessreport_query.go delete mode 100644 internal/ent/correctnessreport_update.go delete mode 100644 internal/ent/ent.go delete mode 100644 internal/ent/entc.go delete mode 100644 internal/ent/enttest/enttest.go delete mode 100644 internal/ent/eventlog.go delete mode 100644 internal/ent/eventlog/eventlog.go delete mode 100644 internal/ent/eventlog/where.go delete mode 100644 internal/ent/eventlog_create.go delete mode 100644 internal/ent/eventlog_delete.go delete mode 100644 internal/ent/eventlog_query.go delete mode 100644 internal/ent/eventlog_update.go delete mode 100644 internal/ent/gql_collection.go delete mode 100644 internal/ent/gql_edge.go delete mode 100644 internal/ent/gql_node.go delete mode 100644 internal/ent/gql_pagination.go delete mode 100644 internal/ent/gql_transaction.go delete mode 100644 internal/ent/gql_where_input.go delete mode 100644 internal/ent/helpers/bigint.go delete mode 100644 internal/ent/hook/hook.go delete mode 100644 internal/ent/migrate/migrate.go delete mode 100644 internal/ent/migrate/schema.go delete mode 100644 internal/ent/mutation.go delete mode 100644 internal/ent/predicate/predicate.go delete mode 100644 internal/ent/runtime.go delete mode 100644 internal/ent/runtime/runtime.go delete mode 100644 internal/ent/schema/assetprice.go delete mode 100644 internal/ent/schema/correctness.go delete mode 100644 internal/ent/schema/eventlog.go delete mode 100644 internal/ent/schema/signer.go delete mode 100644 internal/ent/signer.go delete mode 100644 internal/ent/signer/signer.go delete mode 100644 internal/ent/signer/where.go delete mode 100644 internal/ent/signer_create.go delete mode 100644 internal/ent/signer_delete.go delete mode 100644 internal/ent/signer_query.go delete mode 100644 internal/ent/signer_update.go delete mode 100644 internal/ent/tx.go create mode 100644 internal/model/dataframe.go delete mode 100644 internal/model/price.go create mode 100644 internal/model/proof.go rename internal/model/{bls.go => signer.go} (54%) delete mode 100644 internal/model/uniswap.go create mode 100644 internal/service/uniswap/types/assetkey.go create mode 100644 internal/service/uniswap/types/priceinfo.go rename internal/{model => service/uniswap/types}/token.go (98%) create mode 100644 internal/service/uniswap/types/tokenkey.go delete mode 100644 internal/transport/server/gql/args.graphql delete mode 100644 internal/transport/server/gql/args.resolvers.go delete mode 100644 internal/transport/server/gql/extensions.graphql delete mode 100644 internal/transport/server/gql/extensions.resolvers.go delete mode 100644 internal/transport/server/gql/generated/args.generated.go delete mode 100644 internal/transport/server/gql/generated/prelude.generated.go delete mode 100644 internal/transport/server/gql/generated/root_.generated.go delete mode 100644 internal/transport/server/gql/generated/unchained.generated.go delete mode 100644 internal/transport/server/gql/resolver.go delete mode 100644 internal/transport/server/gql/server.go delete mode 100644 internal/transport/server/gql/types/bytes.go delete mode 100644 internal/transport/server/gql/unchained.graphql delete mode 100644 internal/transport/server/gql/unchained.resolvers.go rename internal/{model/kosk.go => transport/server/packet/challenge.go} (97%) create mode 100644 internal/transport/server/packet/correctness.go create mode 100644 internal/transport/server/packet/eventlog.go create mode 100644 internal/transport/server/packet/price.go diff --git a/.golangci.yml b/.golangci.yml index 3da1aa7a..49ba88dd 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -199,6 +199,9 @@ issues: linters: [ godot ] - source: "//noinspection" linters: [ gocritic ] + - path: "internal/transport/server/packet/*" + linters: + - dupl - path: "cmd" linters: - funlen diff --git a/go.mod b/go.mod index a5b70934..69719814 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/TimeleapLabs/unchained go 1.22.1 require ( + ariga.io/atlas v0.20.0 entgo.io/contrib v0.4.6-0.20240215171353-eff33e4dca0b entgo.io/ent v0.13.1 github.com/99designs/gqlgen v0.17.45 @@ -15,8 +16,6 @@ require ( github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/golang-lru/v2 v2.0.7 github.com/ilyakaznacheev/cleanenv v1.5.0 - github.com/jackc/pgx/v5 v5.5.5 - github.com/lib/pq v1.10.9 github.com/lmittmann/tint v1.0.4 github.com/mattn/go-colorable v0.1.13 github.com/peterldowns/pgtestdb v0.0.14 @@ -29,10 +28,11 @@ require ( golang.org/x/sync v0.6.0 golang.org/x/text v0.14.0 gopkg.in/yaml.v3 v3.0.1 + gorm.io/driver/postgres v1.5.9 + gorm.io/gorm v1.25.10 ) require ( - ariga.io/atlas v0.20.0 // indirect github.com/BurntSushi/toml v1.3.2 // indirect github.com/DataDog/zstd v1.4.5 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect @@ -87,8 +87,11 @@ require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect + github.com/jackc/pgx/v5 v5.5.5 // indirect github.com/jackc/puddle/v2 v2.2.1 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // indirect github.com/joho/godotenv v1.5.1 // indirect github.com/jonboulle/clockwork v0.4.0 // indirect github.com/klauspost/compress v1.17.7 // indirect diff --git a/go.sum b/go.sum index 2ea0c99e..0a91c1d8 100644 --- a/go.sum +++ b/go.sum @@ -358,6 +358,10 @@ github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFr github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4= @@ -948,6 +952,10 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/driver/postgres v1.5.9 h1:DkegyItji119OlcaLjqN11kHoUgZ/j13E0jkJZgD6A8= +gorm.io/driver/postgres v1.5.9/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI= +gorm.io/gorm v1.25.10 h1:dQpO+33KalOA+aFYGlK+EfxcI5MbO7EP2yYygwh9h+s= +gorm.io/gorm v1.25.10/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/internal/app/consumer.go b/internal/app/consumer.go index 726a798d..37a226bc 100644 --- a/internal/app/consumer.go +++ b/internal/app/consumer.go @@ -13,8 +13,6 @@ import ( "github.com/TimeleapLabs/unchained/internal/transport/client/conn" "github.com/TimeleapLabs/unchained/internal/transport/client/handler" "github.com/TimeleapLabs/unchained/internal/transport/database/postgres" - "github.com/TimeleapLabs/unchained/internal/transport/server" - "github.com/TimeleapLabs/unchained/internal/transport/server/gql" "github.com/TimeleapLabs/unchained/internal/utils" ) @@ -49,7 +47,5 @@ func Consumer() { handler := handler.NewConsumerHandler(correctnessService, uniswapService, evmLogService) client.NewRPC(handler) - server.New( - gql.WithGraphQL(db), - ) + select {} } diff --git a/internal/ent/assetprice.go b/internal/ent/assetprice.go deleted file mode 100644 index fa9814ef..00000000 --- a/internal/ent/assetprice.go +++ /dev/null @@ -1,255 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "fmt" - "strings" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" -) - -// AssetPrice is the model entity for the AssetPrice schema. -type AssetPrice struct { - config `json:"-"` - // ID of the ent. - ID int `json:"id,omitempty"` - // Block holds the value of the "block" field. - Block uint64 `json:"block,omitempty"` - // SignersCount holds the value of the "signersCount" field. - SignersCount *uint64 `json:"signersCount,omitempty"` - // Price holds the value of the "price" field. - Price *helpers.BigInt `json:"price,omitempty"` - // Signature holds the value of the "signature" field. - Signature []byte `json:"signature,omitempty"` - // Asset holds the value of the "asset" field. - Asset string `json:"asset,omitempty"` - // Chain holds the value of the "chain" field. - Chain string `json:"chain,omitempty"` - // Pair holds the value of the "pair" field. - Pair string `json:"pair,omitempty"` - // Consensus holds the value of the "consensus" field. - Consensus bool `json:"consensus,omitempty"` - // Voted holds the value of the "voted" field. - Voted *helpers.BigInt `json:"voted,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the AssetPriceQuery when eager-loading is set. - Edges AssetPriceEdges `json:"edges"` - selectValues sql.SelectValues -} - -// AssetPriceEdges holds the relations/edges for other nodes in the graph. -type AssetPriceEdges struct { - // Signers holds the value of the signers edge. - Signers []*Signer `json:"signers,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [1]bool - // totalCount holds the count of the edges above. - totalCount [1]map[string]int - - namedSigners map[string][]*Signer -} - -// SignersOrErr returns the Signers value or an error if the edge -// was not loaded in eager-loading. -func (e AssetPriceEdges) SignersOrErr() ([]*Signer, error) { - if e.loadedTypes[0] { - return e.Signers, nil - } - return nil, &NotLoadedError{edge: "signers"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*AssetPrice) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case assetprice.FieldSignature: - values[i] = new([]byte) - case assetprice.FieldPrice, assetprice.FieldVoted: - values[i] = new(helpers.BigInt) - case assetprice.FieldConsensus: - values[i] = new(sql.NullBool) - case assetprice.FieldID, assetprice.FieldBlock, assetprice.FieldSignersCount: - values[i] = new(sql.NullInt64) - case assetprice.FieldAsset, assetprice.FieldChain, assetprice.FieldPair: - 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 AssetPrice fields. -func (ap *AssetPrice) 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 assetprice.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) - } - ap.ID = int(value.Int64) - case assetprice.FieldBlock: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field block", values[i]) - } else if value.Valid { - ap.Block = uint64(value.Int64) - } - case assetprice.FieldSignersCount: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field signersCount", values[i]) - } else if value.Valid { - ap.SignersCount = new(uint64) - *ap.SignersCount = uint64(value.Int64) - } - case assetprice.FieldPrice: - if value, ok := values[i].(*helpers.BigInt); !ok { - return fmt.Errorf("unexpected type %T for field price", values[i]) - } else if value != nil { - ap.Price = value - } - case assetprice.FieldSignature: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field signature", values[i]) - } else if value != nil { - ap.Signature = *value - } - case assetprice.FieldAsset: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field asset", values[i]) - } else if value.Valid { - ap.Asset = value.String - } - case assetprice.FieldChain: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field chain", values[i]) - } else if value.Valid { - ap.Chain = value.String - } - case assetprice.FieldPair: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field pair", values[i]) - } else if value.Valid { - ap.Pair = value.String - } - case assetprice.FieldConsensus: - if value, ok := values[i].(*sql.NullBool); !ok { - return fmt.Errorf("unexpected type %T for field consensus", values[i]) - } else if value.Valid { - ap.Consensus = value.Bool - } - case assetprice.FieldVoted: - if value, ok := values[i].(*helpers.BigInt); !ok { - return fmt.Errorf("unexpected type %T for field voted", values[i]) - } else if value != nil { - ap.Voted = value - } - default: - ap.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the AssetPrice. -// This includes values selected through modifiers, order, etc. -func (ap *AssetPrice) Value(name string) (ent.Value, error) { - return ap.selectValues.Get(name) -} - -// QuerySigners queries the "signers" edge of the AssetPrice entity. -func (ap *AssetPrice) QuerySigners() *SignerQuery { - return NewAssetPriceClient(ap.config).QuerySigners(ap) -} - -// Update returns a builder for updating this AssetPrice. -// Note that you need to call AssetPrice.Unwrap() before calling this method if this AssetPrice -// was returned from a transaction, and the transaction was committed or rolled back. -func (ap *AssetPrice) Update() *AssetPriceUpdateOne { - return NewAssetPriceClient(ap.config).UpdateOne(ap) -} - -// Unwrap unwraps the AssetPrice 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 (ap *AssetPrice) Unwrap() *AssetPrice { - _tx, ok := ap.config.driver.(*txDriver) - if !ok { - panic("ent: AssetPrice is not a transactional entity") - } - ap.config.driver = _tx.drv - return ap -} - -// String implements the fmt.Stringer. -func (ap *AssetPrice) String() string { - var builder strings.Builder - builder.WriteString("AssetPrice(") - builder.WriteString(fmt.Sprintf("id=%v, ", ap.ID)) - builder.WriteString("block=") - builder.WriteString(fmt.Sprintf("%v", ap.Block)) - builder.WriteString(", ") - if v := ap.SignersCount; v != nil { - builder.WriteString("signersCount=") - builder.WriteString(fmt.Sprintf("%v", *v)) - } - builder.WriteString(", ") - builder.WriteString("price=") - builder.WriteString(fmt.Sprintf("%v", ap.Price)) - builder.WriteString(", ") - builder.WriteString("signature=") - builder.WriteString(fmt.Sprintf("%v", ap.Signature)) - builder.WriteString(", ") - builder.WriteString("asset=") - builder.WriteString(ap.Asset) - builder.WriteString(", ") - builder.WriteString("chain=") - builder.WriteString(ap.Chain) - builder.WriteString(", ") - builder.WriteString("pair=") - builder.WriteString(ap.Pair) - builder.WriteString(", ") - builder.WriteString("consensus=") - builder.WriteString(fmt.Sprintf("%v", ap.Consensus)) - builder.WriteString(", ") - builder.WriteString("voted=") - builder.WriteString(fmt.Sprintf("%v", ap.Voted)) - builder.WriteByte(')') - return builder.String() -} - -// NamedSigners returns the Signers named value or an error if the edge was not -// loaded in eager-loading with this name. -func (ap *AssetPrice) NamedSigners(name string) ([]*Signer, error) { - if ap.Edges.namedSigners == nil { - return nil, &NotLoadedError{edge: name} - } - nodes, ok := ap.Edges.namedSigners[name] - if !ok { - return nil, &NotLoadedError{edge: name} - } - return nodes, nil -} - -func (ap *AssetPrice) appendNamedSigners(name string, edges ...*Signer) { - if ap.Edges.namedSigners == nil { - ap.Edges.namedSigners = make(map[string][]*Signer) - } - if len(edges) == 0 { - ap.Edges.namedSigners[name] = []*Signer{} - } else { - ap.Edges.namedSigners[name] = append(ap.Edges.namedSigners[name], edges...) - } -} - -// AssetPrices is a parsable slice of AssetPrice. -type AssetPrices []*AssetPrice diff --git a/internal/ent/assetprice/assetprice.go b/internal/ent/assetprice/assetprice.go deleted file mode 100644 index e233d7d7..00000000 --- a/internal/ent/assetprice/assetprice.go +++ /dev/null @@ -1,148 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package assetprice - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the assetprice type in the database. - Label = "asset_price" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldBlock holds the string denoting the block field in the database. - FieldBlock = "block" - // FieldSignersCount holds the string denoting the signerscount field in the database. - FieldSignersCount = "signers_count" - // FieldPrice holds the string denoting the price field in the database. - FieldPrice = "price" - // FieldSignature holds the string denoting the signature field in the database. - FieldSignature = "signature" - // FieldAsset holds the string denoting the asset field in the database. - FieldAsset = "asset" - // FieldChain holds the string denoting the chain field in the database. - FieldChain = "chain" - // FieldPair holds the string denoting the pair field in the database. - FieldPair = "pair" - // FieldConsensus holds the string denoting the consensus field in the database. - FieldConsensus = "consensus" - // FieldVoted holds the string denoting the voted field in the database. - FieldVoted = "voted" - // EdgeSigners holds the string denoting the signers edge name in mutations. - EdgeSigners = "signers" - // Table holds the table name of the assetprice in the database. - Table = "asset_prices" - // SignersTable is the table that holds the signers relation/edge. The primary key declared below. - SignersTable = "asset_price_signers" - // SignersInverseTable is the table name for the Signer entity. - // It exists in this package in order to avoid circular dependency with the "signer" package. - SignersInverseTable = "signers" -) - -// Columns holds all SQL columns for assetprice fields. -var Columns = []string{ - FieldID, - FieldBlock, - FieldSignersCount, - FieldPrice, - FieldSignature, - FieldAsset, - FieldChain, - FieldPair, - FieldConsensus, - FieldVoted, -} - -var ( - // SignersPrimaryKey and SignersColumn2 are the table columns denoting the - // primary key for the signers relation (M2M). - SignersPrimaryKey = []string{"asset_price_id", "signer_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 -} - -var ( - // SignatureValidator is a validator for the "signature" field. It is called by the builders before save. - SignatureValidator func([]byte) error - // DefaultConsensus holds the default value on creation for the "consensus" field. - DefaultConsensus bool -) - -// OrderOption defines the ordering options for the AssetPrice 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() -} - -// ByBlock orders the results by the block field. -func ByBlock(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldBlock, opts...).ToFunc() -} - -// BySignersCountField orders the results by the signersCount field. -func BySignersCountField(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSignersCount, opts...).ToFunc() -} - -// ByPrice orders the results by the price field. -func ByPrice(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPrice, opts...).ToFunc() -} - -// ByAsset orders the results by the asset field. -func ByAsset(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldAsset, opts...).ToFunc() -} - -// ByChain orders the results by the chain field. -func ByChain(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldChain, opts...).ToFunc() -} - -// ByPair orders the results by the pair field. -func ByPair(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPair, opts...).ToFunc() -} - -// ByConsensus orders the results by the consensus field. -func ByConsensus(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldConsensus, opts...).ToFunc() -} - -// ByVoted orders the results by the voted field. -func ByVoted(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldVoted, opts...).ToFunc() -} - -// BySignersCount orders the results by signers count. -func BySignersCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newSignersStep(), opts...) - } -} - -// BySigners orders the results by signers terms. -func BySigners(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newSignersStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newSignersStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(SignersInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, SignersTable, SignersPrimaryKey...), - ) -} diff --git a/internal/ent/assetprice/where.go b/internal/ent/assetprice/where.go deleted file mode 100644 index d8fa4389..00000000 --- a/internal/ent/assetprice/where.go +++ /dev/null @@ -1,583 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package assetprice - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLTE(FieldID, id)) -} - -// Block applies equality check predicate on the "block" field. It's identical to BlockEQ. -func Block(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldBlock, v)) -} - -// SignersCount applies equality check predicate on the "signersCount" field. It's identical to SignersCountEQ. -func SignersCount(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldSignersCount, v)) -} - -// Price applies equality check predicate on the "price" field. It's identical to PriceEQ. -func Price(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldPrice, v)) -} - -// Signature applies equality check predicate on the "signature" field. It's identical to SignatureEQ. -func Signature(v []byte) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldSignature, v)) -} - -// Asset applies equality check predicate on the "asset" field. It's identical to AssetEQ. -func Asset(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldAsset, v)) -} - -// Chain applies equality check predicate on the "chain" field. It's identical to ChainEQ. -func Chain(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldChain, v)) -} - -// Pair applies equality check predicate on the "pair" field. It's identical to PairEQ. -func Pair(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldPair, v)) -} - -// Consensus applies equality check predicate on the "consensus" field. It's identical to ConsensusEQ. -func Consensus(v bool) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldConsensus, v)) -} - -// Voted applies equality check predicate on the "voted" field. It's identical to VotedEQ. -func Voted(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldVoted, v)) -} - -// BlockEQ applies the EQ predicate on the "block" field. -func BlockEQ(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldBlock, v)) -} - -// BlockNEQ applies the NEQ predicate on the "block" field. -func BlockNEQ(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldBlock, v)) -} - -// BlockIn applies the In predicate on the "block" field. -func BlockIn(vs ...uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIn(FieldBlock, vs...)) -} - -// BlockNotIn applies the NotIn predicate on the "block" field. -func BlockNotIn(vs ...uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotIn(FieldBlock, vs...)) -} - -// BlockGT applies the GT predicate on the "block" field. -func BlockGT(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGT(FieldBlock, v)) -} - -// BlockGTE applies the GTE predicate on the "block" field. -func BlockGTE(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGTE(FieldBlock, v)) -} - -// BlockLT applies the LT predicate on the "block" field. -func BlockLT(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLT(FieldBlock, v)) -} - -// BlockLTE applies the LTE predicate on the "block" field. -func BlockLTE(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLTE(FieldBlock, v)) -} - -// SignersCountEQ applies the EQ predicate on the "signersCount" field. -func SignersCountEQ(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldSignersCount, v)) -} - -// SignersCountNEQ applies the NEQ predicate on the "signersCount" field. -func SignersCountNEQ(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldSignersCount, v)) -} - -// SignersCountIn applies the In predicate on the "signersCount" field. -func SignersCountIn(vs ...uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIn(FieldSignersCount, vs...)) -} - -// SignersCountNotIn applies the NotIn predicate on the "signersCount" field. -func SignersCountNotIn(vs ...uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotIn(FieldSignersCount, vs...)) -} - -// SignersCountGT applies the GT predicate on the "signersCount" field. -func SignersCountGT(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGT(FieldSignersCount, v)) -} - -// SignersCountGTE applies the GTE predicate on the "signersCount" field. -func SignersCountGTE(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGTE(FieldSignersCount, v)) -} - -// SignersCountLT applies the LT predicate on the "signersCount" field. -func SignersCountLT(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLT(FieldSignersCount, v)) -} - -// SignersCountLTE applies the LTE predicate on the "signersCount" field. -func SignersCountLTE(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLTE(FieldSignersCount, v)) -} - -// SignersCountIsNil applies the IsNil predicate on the "signersCount" field. -func SignersCountIsNil() predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIsNull(FieldSignersCount)) -} - -// SignersCountNotNil applies the NotNil predicate on the "signersCount" field. -func SignersCountNotNil() predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotNull(FieldSignersCount)) -} - -// PriceEQ applies the EQ predicate on the "price" field. -func PriceEQ(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldPrice, v)) -} - -// PriceNEQ applies the NEQ predicate on the "price" field. -func PriceNEQ(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldPrice, v)) -} - -// PriceIn applies the In predicate on the "price" field. -func PriceIn(vs ...*helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIn(FieldPrice, vs...)) -} - -// PriceNotIn applies the NotIn predicate on the "price" field. -func PriceNotIn(vs ...*helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotIn(FieldPrice, vs...)) -} - -// PriceGT applies the GT predicate on the "price" field. -func PriceGT(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGT(FieldPrice, v)) -} - -// PriceGTE applies the GTE predicate on the "price" field. -func PriceGTE(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGTE(FieldPrice, v)) -} - -// PriceLT applies the LT predicate on the "price" field. -func PriceLT(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLT(FieldPrice, v)) -} - -// PriceLTE applies the LTE predicate on the "price" field. -func PriceLTE(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLTE(FieldPrice, v)) -} - -// SignatureEQ applies the EQ predicate on the "signature" field. -func SignatureEQ(v []byte) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldSignature, v)) -} - -// SignatureNEQ applies the NEQ predicate on the "signature" field. -func SignatureNEQ(v []byte) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldSignature, v)) -} - -// SignatureIn applies the In predicate on the "signature" field. -func SignatureIn(vs ...[]byte) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIn(FieldSignature, vs...)) -} - -// SignatureNotIn applies the NotIn predicate on the "signature" field. -func SignatureNotIn(vs ...[]byte) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotIn(FieldSignature, vs...)) -} - -// SignatureGT applies the GT predicate on the "signature" field. -func SignatureGT(v []byte) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGT(FieldSignature, v)) -} - -// SignatureGTE applies the GTE predicate on the "signature" field. -func SignatureGTE(v []byte) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGTE(FieldSignature, v)) -} - -// SignatureLT applies the LT predicate on the "signature" field. -func SignatureLT(v []byte) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLT(FieldSignature, v)) -} - -// SignatureLTE applies the LTE predicate on the "signature" field. -func SignatureLTE(v []byte) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLTE(FieldSignature, v)) -} - -// AssetEQ applies the EQ predicate on the "asset" field. -func AssetEQ(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldAsset, v)) -} - -// AssetNEQ applies the NEQ predicate on the "asset" field. -func AssetNEQ(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldAsset, v)) -} - -// AssetIn applies the In predicate on the "asset" field. -func AssetIn(vs ...string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIn(FieldAsset, vs...)) -} - -// AssetNotIn applies the NotIn predicate on the "asset" field. -func AssetNotIn(vs ...string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotIn(FieldAsset, vs...)) -} - -// AssetGT applies the GT predicate on the "asset" field. -func AssetGT(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGT(FieldAsset, v)) -} - -// AssetGTE applies the GTE predicate on the "asset" field. -func AssetGTE(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGTE(FieldAsset, v)) -} - -// AssetLT applies the LT predicate on the "asset" field. -func AssetLT(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLT(FieldAsset, v)) -} - -// AssetLTE applies the LTE predicate on the "asset" field. -func AssetLTE(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLTE(FieldAsset, v)) -} - -// AssetContains applies the Contains predicate on the "asset" field. -func AssetContains(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldContains(FieldAsset, v)) -} - -// AssetHasPrefix applies the HasPrefix predicate on the "asset" field. -func AssetHasPrefix(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldHasPrefix(FieldAsset, v)) -} - -// AssetHasSuffix applies the HasSuffix predicate on the "asset" field. -func AssetHasSuffix(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldHasSuffix(FieldAsset, v)) -} - -// AssetIsNil applies the IsNil predicate on the "asset" field. -func AssetIsNil() predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIsNull(FieldAsset)) -} - -// AssetNotNil applies the NotNil predicate on the "asset" field. -func AssetNotNil() predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotNull(FieldAsset)) -} - -// AssetEqualFold applies the EqualFold predicate on the "asset" field. -func AssetEqualFold(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEqualFold(FieldAsset, v)) -} - -// AssetContainsFold applies the ContainsFold predicate on the "asset" field. -func AssetContainsFold(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldContainsFold(FieldAsset, v)) -} - -// ChainEQ applies the EQ predicate on the "chain" field. -func ChainEQ(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldChain, v)) -} - -// ChainNEQ applies the NEQ predicate on the "chain" field. -func ChainNEQ(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldChain, v)) -} - -// ChainIn applies the In predicate on the "chain" field. -func ChainIn(vs ...string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIn(FieldChain, vs...)) -} - -// ChainNotIn applies the NotIn predicate on the "chain" field. -func ChainNotIn(vs ...string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotIn(FieldChain, vs...)) -} - -// ChainGT applies the GT predicate on the "chain" field. -func ChainGT(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGT(FieldChain, v)) -} - -// ChainGTE applies the GTE predicate on the "chain" field. -func ChainGTE(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGTE(FieldChain, v)) -} - -// ChainLT applies the LT predicate on the "chain" field. -func ChainLT(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLT(FieldChain, v)) -} - -// ChainLTE applies the LTE predicate on the "chain" field. -func ChainLTE(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLTE(FieldChain, v)) -} - -// ChainContains applies the Contains predicate on the "chain" field. -func ChainContains(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldContains(FieldChain, v)) -} - -// ChainHasPrefix applies the HasPrefix predicate on the "chain" field. -func ChainHasPrefix(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldHasPrefix(FieldChain, v)) -} - -// ChainHasSuffix applies the HasSuffix predicate on the "chain" field. -func ChainHasSuffix(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldHasSuffix(FieldChain, v)) -} - -// ChainIsNil applies the IsNil predicate on the "chain" field. -func ChainIsNil() predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIsNull(FieldChain)) -} - -// ChainNotNil applies the NotNil predicate on the "chain" field. -func ChainNotNil() predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotNull(FieldChain)) -} - -// ChainEqualFold applies the EqualFold predicate on the "chain" field. -func ChainEqualFold(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEqualFold(FieldChain, v)) -} - -// ChainContainsFold applies the ContainsFold predicate on the "chain" field. -func ChainContainsFold(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldContainsFold(FieldChain, v)) -} - -// PairEQ applies the EQ predicate on the "pair" field. -func PairEQ(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldPair, v)) -} - -// PairNEQ applies the NEQ predicate on the "pair" field. -func PairNEQ(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldPair, v)) -} - -// PairIn applies the In predicate on the "pair" field. -func PairIn(vs ...string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIn(FieldPair, vs...)) -} - -// PairNotIn applies the NotIn predicate on the "pair" field. -func PairNotIn(vs ...string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotIn(FieldPair, vs...)) -} - -// PairGT applies the GT predicate on the "pair" field. -func PairGT(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGT(FieldPair, v)) -} - -// PairGTE applies the GTE predicate on the "pair" field. -func PairGTE(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGTE(FieldPair, v)) -} - -// PairLT applies the LT predicate on the "pair" field. -func PairLT(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLT(FieldPair, v)) -} - -// PairLTE applies the LTE predicate on the "pair" field. -func PairLTE(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLTE(FieldPair, v)) -} - -// PairContains applies the Contains predicate on the "pair" field. -func PairContains(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldContains(FieldPair, v)) -} - -// PairHasPrefix applies the HasPrefix predicate on the "pair" field. -func PairHasPrefix(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldHasPrefix(FieldPair, v)) -} - -// PairHasSuffix applies the HasSuffix predicate on the "pair" field. -func PairHasSuffix(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldHasSuffix(FieldPair, v)) -} - -// PairIsNil applies the IsNil predicate on the "pair" field. -func PairIsNil() predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIsNull(FieldPair)) -} - -// PairNotNil applies the NotNil predicate on the "pair" field. -func PairNotNil() predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotNull(FieldPair)) -} - -// PairEqualFold applies the EqualFold predicate on the "pair" field. -func PairEqualFold(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEqualFold(FieldPair, v)) -} - -// PairContainsFold applies the ContainsFold predicate on the "pair" field. -func PairContainsFold(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldContainsFold(FieldPair, v)) -} - -// ConsensusEQ applies the EQ predicate on the "consensus" field. -func ConsensusEQ(v bool) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldConsensus, v)) -} - -// ConsensusNEQ applies the NEQ predicate on the "consensus" field. -func ConsensusNEQ(v bool) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldConsensus, v)) -} - -// VotedEQ applies the EQ predicate on the "voted" field. -func VotedEQ(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldVoted, v)) -} - -// VotedNEQ applies the NEQ predicate on the "voted" field. -func VotedNEQ(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldVoted, v)) -} - -// VotedIn applies the In predicate on the "voted" field. -func VotedIn(vs ...*helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIn(FieldVoted, vs...)) -} - -// VotedNotIn applies the NotIn predicate on the "voted" field. -func VotedNotIn(vs ...*helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotIn(FieldVoted, vs...)) -} - -// VotedGT applies the GT predicate on the "voted" field. -func VotedGT(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGT(FieldVoted, v)) -} - -// VotedGTE applies the GTE predicate on the "voted" field. -func VotedGTE(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGTE(FieldVoted, v)) -} - -// VotedLT applies the LT predicate on the "voted" field. -func VotedLT(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLT(FieldVoted, v)) -} - -// VotedLTE applies the LTE predicate on the "voted" field. -func VotedLTE(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLTE(FieldVoted, v)) -} - -// HasSigners applies the HasEdge predicate on the "signers" edge. -func HasSigners() predicate.AssetPrice { - return predicate.AssetPrice(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, SignersTable, SignersPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasSignersWith applies the HasEdge predicate on the "signers" edge with a given conditions (other predicates). -func HasSignersWith(preds ...predicate.Signer) predicate.AssetPrice { - return predicate.AssetPrice(func(s *sql.Selector) { - step := newSignersStep() - 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.AssetPrice) predicate.AssetPrice { - return predicate.AssetPrice(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.AssetPrice) predicate.AssetPrice { - return predicate.AssetPrice(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.AssetPrice) predicate.AssetPrice { - return predicate.AssetPrice(sql.NotPredicates(p)) -} diff --git a/internal/ent/assetprice_create.go b/internal/ent/assetprice_create.go deleted file mode 100644 index d81c50b3..00000000 --- a/internal/ent/assetprice_create.go +++ /dev/null @@ -1,1077 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// AssetPriceCreate is the builder for creating a AssetPrice entity. -type AssetPriceCreate struct { - config - mutation *AssetPriceMutation - hooks []Hook - conflict []sql.ConflictOption -} - -// SetBlock sets the "block" field. -func (apc *AssetPriceCreate) SetBlock(u uint64) *AssetPriceCreate { - apc.mutation.SetBlock(u) - return apc -} - -// SetSignersCount sets the "signersCount" field. -func (apc *AssetPriceCreate) SetSignersCount(u uint64) *AssetPriceCreate { - apc.mutation.SetSignersCount(u) - return apc -} - -// SetNillableSignersCount sets the "signersCount" field if the given value is not nil. -func (apc *AssetPriceCreate) SetNillableSignersCount(u *uint64) *AssetPriceCreate { - if u != nil { - apc.SetSignersCount(*u) - } - return apc -} - -// SetPrice sets the "price" field. -func (apc *AssetPriceCreate) SetPrice(hi *helpers.BigInt) *AssetPriceCreate { - apc.mutation.SetPrice(hi) - return apc -} - -// SetSignature sets the "signature" field. -func (apc *AssetPriceCreate) SetSignature(b []byte) *AssetPriceCreate { - apc.mutation.SetSignature(b) - return apc -} - -// SetAsset sets the "asset" field. -func (apc *AssetPriceCreate) SetAsset(s string) *AssetPriceCreate { - apc.mutation.SetAsset(s) - return apc -} - -// SetNillableAsset sets the "asset" field if the given value is not nil. -func (apc *AssetPriceCreate) SetNillableAsset(s *string) *AssetPriceCreate { - if s != nil { - apc.SetAsset(*s) - } - return apc -} - -// SetChain sets the "chain" field. -func (apc *AssetPriceCreate) SetChain(s string) *AssetPriceCreate { - apc.mutation.SetChain(s) - return apc -} - -// SetNillableChain sets the "chain" field if the given value is not nil. -func (apc *AssetPriceCreate) SetNillableChain(s *string) *AssetPriceCreate { - if s != nil { - apc.SetChain(*s) - } - return apc -} - -// SetPair sets the "pair" field. -func (apc *AssetPriceCreate) SetPair(s string) *AssetPriceCreate { - apc.mutation.SetPair(s) - return apc -} - -// SetNillablePair sets the "pair" field if the given value is not nil. -func (apc *AssetPriceCreate) SetNillablePair(s *string) *AssetPriceCreate { - if s != nil { - apc.SetPair(*s) - } - return apc -} - -// SetConsensus sets the "consensus" field. -func (apc *AssetPriceCreate) SetConsensus(b bool) *AssetPriceCreate { - apc.mutation.SetConsensus(b) - return apc -} - -// SetNillableConsensus sets the "consensus" field if the given value is not nil. -func (apc *AssetPriceCreate) SetNillableConsensus(b *bool) *AssetPriceCreate { - if b != nil { - apc.SetConsensus(*b) - } - return apc -} - -// SetVoted sets the "voted" field. -func (apc *AssetPriceCreate) SetVoted(hi *helpers.BigInt) *AssetPriceCreate { - apc.mutation.SetVoted(hi) - return apc -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by IDs. -func (apc *AssetPriceCreate) AddSignerIDs(ids ...int) *AssetPriceCreate { - apc.mutation.AddSignerIDs(ids...) - return apc -} - -// AddSigners adds the "signers" edges to the Signer entity. -func (apc *AssetPriceCreate) AddSigners(s ...*Signer) *AssetPriceCreate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return apc.AddSignerIDs(ids...) -} - -// Mutation returns the AssetPriceMutation object of the builder. -func (apc *AssetPriceCreate) Mutation() *AssetPriceMutation { - return apc.mutation -} - -// Save creates the AssetPrice in the database. -func (apc *AssetPriceCreate) Save(ctx context.Context) (*AssetPrice, error) { - apc.defaults() - return withHooks(ctx, apc.sqlSave, apc.mutation, apc.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (apc *AssetPriceCreate) SaveX(ctx context.Context) *AssetPrice { - v, err := apc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (apc *AssetPriceCreate) Exec(ctx context.Context) error { - _, err := apc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (apc *AssetPriceCreate) ExecX(ctx context.Context) { - if err := apc.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (apc *AssetPriceCreate) defaults() { - if _, ok := apc.mutation.Consensus(); !ok { - v := assetprice.DefaultConsensus - apc.mutation.SetConsensus(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (apc *AssetPriceCreate) check() error { - if _, ok := apc.mutation.Block(); !ok { - return &ValidationError{Name: "block", err: errors.New(`ent: missing required field "AssetPrice.block"`)} - } - if _, ok := apc.mutation.Price(); !ok { - return &ValidationError{Name: "price", err: errors.New(`ent: missing required field "AssetPrice.price"`)} - } - if _, ok := apc.mutation.Signature(); !ok { - return &ValidationError{Name: "signature", err: errors.New(`ent: missing required field "AssetPrice.signature"`)} - } - if v, ok := apc.mutation.Signature(); ok { - if err := assetprice.SignatureValidator(v); err != nil { - return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "AssetPrice.signature": %w`, err)} - } - } - if _, ok := apc.mutation.Consensus(); !ok { - return &ValidationError{Name: "consensus", err: errors.New(`ent: missing required field "AssetPrice.consensus"`)} - } - if _, ok := apc.mutation.Voted(); !ok { - return &ValidationError{Name: "voted", err: errors.New(`ent: missing required field "AssetPrice.voted"`)} - } - if len(apc.mutation.SignersIDs()) == 0 { - return &ValidationError{Name: "signers", err: errors.New(`ent: missing required edge "AssetPrice.signers"`)} - } - return nil -} - -func (apc *AssetPriceCreate) sqlSave(ctx context.Context) (*AssetPrice, error) { - if err := apc.check(); err != nil { - return nil, err - } - _node, _spec := apc.createSpec() - if err := sqlgraph.CreateNode(ctx, apc.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) - apc.mutation.id = &_node.ID - apc.mutation.done = true - return _node, nil -} - -func (apc *AssetPriceCreate) createSpec() (*AssetPrice, *sqlgraph.CreateSpec) { - var ( - _node = &AssetPrice{config: apc.config} - _spec = sqlgraph.NewCreateSpec(assetprice.Table, sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt)) - ) - _spec.OnConflict = apc.conflict - if value, ok := apc.mutation.Block(); ok { - _spec.SetField(assetprice.FieldBlock, field.TypeUint64, value) - _node.Block = value - } - if value, ok := apc.mutation.SignersCount(); ok { - _spec.SetField(assetprice.FieldSignersCount, field.TypeUint64, value) - _node.SignersCount = &value - } - if value, ok := apc.mutation.Price(); ok { - _spec.SetField(assetprice.FieldPrice, field.TypeUint, value) - _node.Price = value - } - if value, ok := apc.mutation.Signature(); ok { - _spec.SetField(assetprice.FieldSignature, field.TypeBytes, value) - _node.Signature = value - } - if value, ok := apc.mutation.Asset(); ok { - _spec.SetField(assetprice.FieldAsset, field.TypeString, value) - _node.Asset = value - } - if value, ok := apc.mutation.Chain(); ok { - _spec.SetField(assetprice.FieldChain, field.TypeString, value) - _node.Chain = value - } - if value, ok := apc.mutation.Pair(); ok { - _spec.SetField(assetprice.FieldPair, field.TypeString, value) - _node.Pair = value - } - if value, ok := apc.mutation.Consensus(); ok { - _spec.SetField(assetprice.FieldConsensus, field.TypeBool, value) - _node.Consensus = value - } - if value, ok := apc.mutation.Voted(); ok { - _spec.SetField(assetprice.FieldVoted, field.TypeUint, value) - _node.Voted = value - } - if nodes := apc.mutation.SignersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: assetprice.SignersTable, - Columns: assetprice.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.AssetPrice.Create(). -// SetBlock(v). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.AssetPriceUpsert) { -// SetBlock(v+v). -// }). -// Exec(ctx) -func (apc *AssetPriceCreate) OnConflict(opts ...sql.ConflictOption) *AssetPriceUpsertOne { - apc.conflict = opts - return &AssetPriceUpsertOne{ - create: apc, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.AssetPrice.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (apc *AssetPriceCreate) OnConflictColumns(columns ...string) *AssetPriceUpsertOne { - apc.conflict = append(apc.conflict, sql.ConflictColumns(columns...)) - return &AssetPriceUpsertOne{ - create: apc, - } -} - -type ( - // AssetPriceUpsertOne is the builder for "upsert"-ing - // one AssetPrice node. - AssetPriceUpsertOne struct { - create *AssetPriceCreate - } - - // AssetPriceUpsert is the "OnConflict" setter. - AssetPriceUpsert struct { - *sql.UpdateSet - } -) - -// SetBlock sets the "block" field. -func (u *AssetPriceUpsert) SetBlock(v uint64) *AssetPriceUpsert { - u.Set(assetprice.FieldBlock, v) - return u -} - -// UpdateBlock sets the "block" field to the value that was provided on create. -func (u *AssetPriceUpsert) UpdateBlock() *AssetPriceUpsert { - u.SetExcluded(assetprice.FieldBlock) - return u -} - -// AddBlock adds v to the "block" field. -func (u *AssetPriceUpsert) AddBlock(v uint64) *AssetPriceUpsert { - u.Add(assetprice.FieldBlock, v) - return u -} - -// SetSignersCount sets the "signersCount" field. -func (u *AssetPriceUpsert) SetSignersCount(v uint64) *AssetPriceUpsert { - u.Set(assetprice.FieldSignersCount, v) - return u -} - -// UpdateSignersCount sets the "signersCount" field to the value that was provided on create. -func (u *AssetPriceUpsert) UpdateSignersCount() *AssetPriceUpsert { - u.SetExcluded(assetprice.FieldSignersCount) - return u -} - -// AddSignersCount adds v to the "signersCount" field. -func (u *AssetPriceUpsert) AddSignersCount(v uint64) *AssetPriceUpsert { - u.Add(assetprice.FieldSignersCount, v) - return u -} - -// ClearSignersCount clears the value of the "signersCount" field. -func (u *AssetPriceUpsert) ClearSignersCount() *AssetPriceUpsert { - u.SetNull(assetprice.FieldSignersCount) - return u -} - -// SetPrice sets the "price" field. -func (u *AssetPriceUpsert) SetPrice(v *helpers.BigInt) *AssetPriceUpsert { - u.Set(assetprice.FieldPrice, v) - return u -} - -// UpdatePrice sets the "price" field to the value that was provided on create. -func (u *AssetPriceUpsert) UpdatePrice() *AssetPriceUpsert { - u.SetExcluded(assetprice.FieldPrice) - return u -} - -// SetSignature sets the "signature" field. -func (u *AssetPriceUpsert) SetSignature(v []byte) *AssetPriceUpsert { - u.Set(assetprice.FieldSignature, v) - return u -} - -// UpdateSignature sets the "signature" field to the value that was provided on create. -func (u *AssetPriceUpsert) UpdateSignature() *AssetPriceUpsert { - u.SetExcluded(assetprice.FieldSignature) - return u -} - -// SetAsset sets the "asset" field. -func (u *AssetPriceUpsert) SetAsset(v string) *AssetPriceUpsert { - u.Set(assetprice.FieldAsset, v) - return u -} - -// UpdateAsset sets the "asset" field to the value that was provided on create. -func (u *AssetPriceUpsert) UpdateAsset() *AssetPriceUpsert { - u.SetExcluded(assetprice.FieldAsset) - return u -} - -// ClearAsset clears the value of the "asset" field. -func (u *AssetPriceUpsert) ClearAsset() *AssetPriceUpsert { - u.SetNull(assetprice.FieldAsset) - return u -} - -// SetChain sets the "chain" field. -func (u *AssetPriceUpsert) SetChain(v string) *AssetPriceUpsert { - u.Set(assetprice.FieldChain, v) - return u -} - -// UpdateChain sets the "chain" field to the value that was provided on create. -func (u *AssetPriceUpsert) UpdateChain() *AssetPriceUpsert { - u.SetExcluded(assetprice.FieldChain) - return u -} - -// ClearChain clears the value of the "chain" field. -func (u *AssetPriceUpsert) ClearChain() *AssetPriceUpsert { - u.SetNull(assetprice.FieldChain) - return u -} - -// SetPair sets the "pair" field. -func (u *AssetPriceUpsert) SetPair(v string) *AssetPriceUpsert { - u.Set(assetprice.FieldPair, v) - return u -} - -// UpdatePair sets the "pair" field to the value that was provided on create. -func (u *AssetPriceUpsert) UpdatePair() *AssetPriceUpsert { - u.SetExcluded(assetprice.FieldPair) - return u -} - -// ClearPair clears the value of the "pair" field. -func (u *AssetPriceUpsert) ClearPair() *AssetPriceUpsert { - u.SetNull(assetprice.FieldPair) - return u -} - -// SetConsensus sets the "consensus" field. -func (u *AssetPriceUpsert) SetConsensus(v bool) *AssetPriceUpsert { - u.Set(assetprice.FieldConsensus, v) - return u -} - -// UpdateConsensus sets the "consensus" field to the value that was provided on create. -func (u *AssetPriceUpsert) UpdateConsensus() *AssetPriceUpsert { - u.SetExcluded(assetprice.FieldConsensus) - return u -} - -// SetVoted sets the "voted" field. -func (u *AssetPriceUpsert) SetVoted(v *helpers.BigInt) *AssetPriceUpsert { - u.Set(assetprice.FieldVoted, v) - return u -} - -// UpdateVoted sets the "voted" field to the value that was provided on create. -func (u *AssetPriceUpsert) UpdateVoted() *AssetPriceUpsert { - u.SetExcluded(assetprice.FieldVoted) - return u -} - -// UpdateNewValues updates the mutable fields using the new values that were set on create. -// Using this option is equivalent to using: -// -// client.AssetPrice.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *AssetPriceUpsertOne) UpdateNewValues() *AssetPriceUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.AssetPrice.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *AssetPriceUpsertOne) Ignore() *AssetPriceUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *AssetPriceUpsertOne) DoNothing() *AssetPriceUpsertOne { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the AssetPriceCreate.OnConflict -// documentation for more info. -func (u *AssetPriceUpsertOne) Update(set func(*AssetPriceUpsert)) *AssetPriceUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&AssetPriceUpsert{UpdateSet: update}) - })) - return u -} - -// SetBlock sets the "block" field. -func (u *AssetPriceUpsertOne) SetBlock(v uint64) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.SetBlock(v) - }) -} - -// AddBlock adds v to the "block" field. -func (u *AssetPriceUpsertOne) AddBlock(v uint64) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.AddBlock(v) - }) -} - -// UpdateBlock sets the "block" field to the value that was provided on create. -func (u *AssetPriceUpsertOne) UpdateBlock() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateBlock() - }) -} - -// SetSignersCount sets the "signersCount" field. -func (u *AssetPriceUpsertOne) SetSignersCount(v uint64) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.SetSignersCount(v) - }) -} - -// AddSignersCount adds v to the "signersCount" field. -func (u *AssetPriceUpsertOne) AddSignersCount(v uint64) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.AddSignersCount(v) - }) -} - -// UpdateSignersCount sets the "signersCount" field to the value that was provided on create. -func (u *AssetPriceUpsertOne) UpdateSignersCount() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateSignersCount() - }) -} - -// ClearSignersCount clears the value of the "signersCount" field. -func (u *AssetPriceUpsertOne) ClearSignersCount() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.ClearSignersCount() - }) -} - -// SetPrice sets the "price" field. -func (u *AssetPriceUpsertOne) SetPrice(v *helpers.BigInt) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.SetPrice(v) - }) -} - -// UpdatePrice sets the "price" field to the value that was provided on create. -func (u *AssetPriceUpsertOne) UpdatePrice() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdatePrice() - }) -} - -// SetSignature sets the "signature" field. -func (u *AssetPriceUpsertOne) SetSignature(v []byte) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.SetSignature(v) - }) -} - -// UpdateSignature sets the "signature" field to the value that was provided on create. -func (u *AssetPriceUpsertOne) UpdateSignature() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateSignature() - }) -} - -// SetAsset sets the "asset" field. -func (u *AssetPriceUpsertOne) SetAsset(v string) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.SetAsset(v) - }) -} - -// UpdateAsset sets the "asset" field to the value that was provided on create. -func (u *AssetPriceUpsertOne) UpdateAsset() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateAsset() - }) -} - -// ClearAsset clears the value of the "asset" field. -func (u *AssetPriceUpsertOne) ClearAsset() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.ClearAsset() - }) -} - -// SetChain sets the "chain" field. -func (u *AssetPriceUpsertOne) SetChain(v string) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.SetChain(v) - }) -} - -// UpdateChain sets the "chain" field to the value that was provided on create. -func (u *AssetPriceUpsertOne) UpdateChain() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateChain() - }) -} - -// ClearChain clears the value of the "chain" field. -func (u *AssetPriceUpsertOne) ClearChain() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.ClearChain() - }) -} - -// SetPair sets the "pair" field. -func (u *AssetPriceUpsertOne) SetPair(v string) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.SetPair(v) - }) -} - -// UpdatePair sets the "pair" field to the value that was provided on create. -func (u *AssetPriceUpsertOne) UpdatePair() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdatePair() - }) -} - -// ClearPair clears the value of the "pair" field. -func (u *AssetPriceUpsertOne) ClearPair() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.ClearPair() - }) -} - -// SetConsensus sets the "consensus" field. -func (u *AssetPriceUpsertOne) SetConsensus(v bool) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.SetConsensus(v) - }) -} - -// UpdateConsensus sets the "consensus" field to the value that was provided on create. -func (u *AssetPriceUpsertOne) UpdateConsensus() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateConsensus() - }) -} - -// SetVoted sets the "voted" field. -func (u *AssetPriceUpsertOne) SetVoted(v *helpers.BigInt) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.SetVoted(v) - }) -} - -// UpdateVoted sets the "voted" field to the value that was provided on create. -func (u *AssetPriceUpsertOne) UpdateVoted() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateVoted() - }) -} - -// Exec executes the query. -func (u *AssetPriceUpsertOne) Exec(ctx context.Context) error { - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for AssetPriceCreate.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *AssetPriceUpsertOne) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} - -// Exec executes the UPSERT query and returns the inserted/updated ID. -func (u *AssetPriceUpsertOne) ID(ctx context.Context) (id int, err error) { - node, err := u.create.Save(ctx) - if err != nil { - return id, err - } - return node.ID, nil -} - -// IDX is like ID, but panics if an error occurs. -func (u *AssetPriceUpsertOne) IDX(ctx context.Context) int { - id, err := u.ID(ctx) - if err != nil { - panic(err) - } - return id -} - -// AssetPriceCreateBulk is the builder for creating many AssetPrice entities in bulk. -type AssetPriceCreateBulk struct { - config - err error - builders []*AssetPriceCreate - conflict []sql.ConflictOption -} - -// Save creates the AssetPrice entities in the database. -func (apcb *AssetPriceCreateBulk) Save(ctx context.Context) ([]*AssetPrice, error) { - if apcb.err != nil { - return nil, apcb.err - } - specs := make([]*sqlgraph.CreateSpec, len(apcb.builders)) - nodes := make([]*AssetPrice, len(apcb.builders)) - mutators := make([]Mutator, len(apcb.builders)) - for i := range apcb.builders { - func(i int, root context.Context) { - builder := apcb.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*AssetPriceMutation) - 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, apcb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - spec.OnConflict = apcb.conflict - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, apcb.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, apcb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (apcb *AssetPriceCreateBulk) SaveX(ctx context.Context) []*AssetPrice { - v, err := apcb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (apcb *AssetPriceCreateBulk) Exec(ctx context.Context) error { - _, err := apcb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (apcb *AssetPriceCreateBulk) ExecX(ctx context.Context) { - if err := apcb.Exec(ctx); err != nil { - panic(err) - } -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.AssetPrice.CreateBulk(builders...). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.AssetPriceUpsert) { -// SetBlock(v+v). -// }). -// Exec(ctx) -func (apcb *AssetPriceCreateBulk) OnConflict(opts ...sql.ConflictOption) *AssetPriceUpsertBulk { - apcb.conflict = opts - return &AssetPriceUpsertBulk{ - create: apcb, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.AssetPrice.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (apcb *AssetPriceCreateBulk) OnConflictColumns(columns ...string) *AssetPriceUpsertBulk { - apcb.conflict = append(apcb.conflict, sql.ConflictColumns(columns...)) - return &AssetPriceUpsertBulk{ - create: apcb, - } -} - -// AssetPriceUpsertBulk is the builder for "upsert"-ing -// a bulk of AssetPrice nodes. -type AssetPriceUpsertBulk struct { - create *AssetPriceCreateBulk -} - -// UpdateNewValues updates the mutable fields using the new values that -// were set on create. Using this option is equivalent to using: -// -// client.AssetPrice.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *AssetPriceUpsertBulk) UpdateNewValues() *AssetPriceUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.AssetPrice.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *AssetPriceUpsertBulk) Ignore() *AssetPriceUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *AssetPriceUpsertBulk) DoNothing() *AssetPriceUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the AssetPriceCreateBulk.OnConflict -// documentation for more info. -func (u *AssetPriceUpsertBulk) Update(set func(*AssetPriceUpsert)) *AssetPriceUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&AssetPriceUpsert{UpdateSet: update}) - })) - return u -} - -// SetBlock sets the "block" field. -func (u *AssetPriceUpsertBulk) SetBlock(v uint64) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.SetBlock(v) - }) -} - -// AddBlock adds v to the "block" field. -func (u *AssetPriceUpsertBulk) AddBlock(v uint64) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.AddBlock(v) - }) -} - -// UpdateBlock sets the "block" field to the value that was provided on create. -func (u *AssetPriceUpsertBulk) UpdateBlock() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateBlock() - }) -} - -// SetSignersCount sets the "signersCount" field. -func (u *AssetPriceUpsertBulk) SetSignersCount(v uint64) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.SetSignersCount(v) - }) -} - -// AddSignersCount adds v to the "signersCount" field. -func (u *AssetPriceUpsertBulk) AddSignersCount(v uint64) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.AddSignersCount(v) - }) -} - -// UpdateSignersCount sets the "signersCount" field to the value that was provided on create. -func (u *AssetPriceUpsertBulk) UpdateSignersCount() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateSignersCount() - }) -} - -// ClearSignersCount clears the value of the "signersCount" field. -func (u *AssetPriceUpsertBulk) ClearSignersCount() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.ClearSignersCount() - }) -} - -// SetPrice sets the "price" field. -func (u *AssetPriceUpsertBulk) SetPrice(v *helpers.BigInt) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.SetPrice(v) - }) -} - -// UpdatePrice sets the "price" field to the value that was provided on create. -func (u *AssetPriceUpsertBulk) UpdatePrice() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdatePrice() - }) -} - -// SetSignature sets the "signature" field. -func (u *AssetPriceUpsertBulk) SetSignature(v []byte) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.SetSignature(v) - }) -} - -// UpdateSignature sets the "signature" field to the value that was provided on create. -func (u *AssetPriceUpsertBulk) UpdateSignature() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateSignature() - }) -} - -// SetAsset sets the "asset" field. -func (u *AssetPriceUpsertBulk) SetAsset(v string) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.SetAsset(v) - }) -} - -// UpdateAsset sets the "asset" field to the value that was provided on create. -func (u *AssetPriceUpsertBulk) UpdateAsset() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateAsset() - }) -} - -// ClearAsset clears the value of the "asset" field. -func (u *AssetPriceUpsertBulk) ClearAsset() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.ClearAsset() - }) -} - -// SetChain sets the "chain" field. -func (u *AssetPriceUpsertBulk) SetChain(v string) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.SetChain(v) - }) -} - -// UpdateChain sets the "chain" field to the value that was provided on create. -func (u *AssetPriceUpsertBulk) UpdateChain() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateChain() - }) -} - -// ClearChain clears the value of the "chain" field. -func (u *AssetPriceUpsertBulk) ClearChain() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.ClearChain() - }) -} - -// SetPair sets the "pair" field. -func (u *AssetPriceUpsertBulk) SetPair(v string) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.SetPair(v) - }) -} - -// UpdatePair sets the "pair" field to the value that was provided on create. -func (u *AssetPriceUpsertBulk) UpdatePair() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdatePair() - }) -} - -// ClearPair clears the value of the "pair" field. -func (u *AssetPriceUpsertBulk) ClearPair() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.ClearPair() - }) -} - -// SetConsensus sets the "consensus" field. -func (u *AssetPriceUpsertBulk) SetConsensus(v bool) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.SetConsensus(v) - }) -} - -// UpdateConsensus sets the "consensus" field to the value that was provided on create. -func (u *AssetPriceUpsertBulk) UpdateConsensus() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateConsensus() - }) -} - -// SetVoted sets the "voted" field. -func (u *AssetPriceUpsertBulk) SetVoted(v *helpers.BigInt) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.SetVoted(v) - }) -} - -// UpdateVoted sets the "voted" field to the value that was provided on create. -func (u *AssetPriceUpsertBulk) UpdateVoted() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateVoted() - }) -} - -// Exec executes the query. -func (u *AssetPriceUpsertBulk) Exec(ctx context.Context) error { - if u.create.err != nil { - return u.create.err - } - for i, b := range u.create.builders { - if len(b.conflict) != 0 { - return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the AssetPriceCreateBulk instead", i) - } - } - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for AssetPriceCreateBulk.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *AssetPriceUpsertBulk) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/ent/assetprice_delete.go b/internal/ent/assetprice_delete.go deleted file mode 100644 index 3e83a733..00000000 --- a/internal/ent/assetprice_delete.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" -) - -// AssetPriceDelete is the builder for deleting a AssetPrice entity. -type AssetPriceDelete struct { - config - hooks []Hook - mutation *AssetPriceMutation -} - -// Where appends a list predicates to the AssetPriceDelete builder. -func (apd *AssetPriceDelete) Where(ps ...predicate.AssetPrice) *AssetPriceDelete { - apd.mutation.Where(ps...) - return apd -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (apd *AssetPriceDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, apd.sqlExec, apd.mutation, apd.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (apd *AssetPriceDelete) ExecX(ctx context.Context) int { - n, err := apd.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (apd *AssetPriceDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(assetprice.Table, sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt)) - if ps := apd.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, apd.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - apd.mutation.done = true - return affected, err -} - -// AssetPriceDeleteOne is the builder for deleting a single AssetPrice entity. -type AssetPriceDeleteOne struct { - apd *AssetPriceDelete -} - -// Where appends a list predicates to the AssetPriceDelete builder. -func (apdo *AssetPriceDeleteOne) Where(ps ...predicate.AssetPrice) *AssetPriceDeleteOne { - apdo.apd.mutation.Where(ps...) - return apdo -} - -// Exec executes the deletion query. -func (apdo *AssetPriceDeleteOne) Exec(ctx context.Context) error { - n, err := apdo.apd.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{assetprice.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (apdo *AssetPriceDeleteOne) ExecX(ctx context.Context) { - if err := apdo.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/ent/assetprice_query.go b/internal/ent/assetprice_query.go deleted file mode 100644 index 12624a34..00000000 --- a/internal/ent/assetprice_query.go +++ /dev/null @@ -1,671 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "database/sql/driver" - "fmt" - "math" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// AssetPriceQuery is the builder for querying AssetPrice entities. -type AssetPriceQuery struct { - config - ctx *QueryContext - order []assetprice.OrderOption - inters []Interceptor - predicates []predicate.AssetPrice - withSigners *SignerQuery - modifiers []func(*sql.Selector) - loadTotal []func(context.Context, []*AssetPrice) error - withNamedSigners map[string]*SignerQuery - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the AssetPriceQuery builder. -func (apq *AssetPriceQuery) Where(ps ...predicate.AssetPrice) *AssetPriceQuery { - apq.predicates = append(apq.predicates, ps...) - return apq -} - -// Limit the number of records to be returned by this query. -func (apq *AssetPriceQuery) Limit(limit int) *AssetPriceQuery { - apq.ctx.Limit = &limit - return apq -} - -// Offset to start from. -func (apq *AssetPriceQuery) Offset(offset int) *AssetPriceQuery { - apq.ctx.Offset = &offset - return apq -} - -// 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 (apq *AssetPriceQuery) Unique(unique bool) *AssetPriceQuery { - apq.ctx.Unique = &unique - return apq -} - -// Order specifies how the records should be ordered. -func (apq *AssetPriceQuery) Order(o ...assetprice.OrderOption) *AssetPriceQuery { - apq.order = append(apq.order, o...) - return apq -} - -// QuerySigners chains the current query on the "signers" edge. -func (apq *AssetPriceQuery) QuerySigners() *SignerQuery { - query := (&SignerClient{config: apq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := apq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := apq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(assetprice.Table, assetprice.FieldID, selector), - sqlgraph.To(signer.Table, signer.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, assetprice.SignersTable, assetprice.SignersPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(apq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first AssetPrice entity from the query. -// Returns a *NotFoundError when no AssetPrice was found. -func (apq *AssetPriceQuery) First(ctx context.Context) (*AssetPrice, error) { - nodes, err := apq.Limit(1).All(setContextOp(ctx, apq.ctx, "First")) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{assetprice.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (apq *AssetPriceQuery) FirstX(ctx context.Context) *AssetPrice { - node, err := apq.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first AssetPrice ID from the query. -// Returns a *NotFoundError when no AssetPrice ID was found. -func (apq *AssetPriceQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = apq.Limit(1).IDs(setContextOp(ctx, apq.ctx, "FirstID")); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{assetprice.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (apq *AssetPriceQuery) FirstIDX(ctx context.Context) int { - id, err := apq.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single AssetPrice entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one AssetPrice entity is found. -// Returns a *NotFoundError when no AssetPrice entities are found. -func (apq *AssetPriceQuery) Only(ctx context.Context) (*AssetPrice, error) { - nodes, err := apq.Limit(2).All(setContextOp(ctx, apq.ctx, "Only")) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{assetprice.Label} - default: - return nil, &NotSingularError{assetprice.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (apq *AssetPriceQuery) OnlyX(ctx context.Context) *AssetPrice { - node, err := apq.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only AssetPrice ID in the query. -// Returns a *NotSingularError when more than one AssetPrice ID is found. -// Returns a *NotFoundError when no entities are found. -func (apq *AssetPriceQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = apq.Limit(2).IDs(setContextOp(ctx, apq.ctx, "OnlyID")); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{assetprice.Label} - default: - err = &NotSingularError{assetprice.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (apq *AssetPriceQuery) OnlyIDX(ctx context.Context) int { - id, err := apq.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of AssetPrices. -func (apq *AssetPriceQuery) All(ctx context.Context) ([]*AssetPrice, error) { - ctx = setContextOp(ctx, apq.ctx, "All") - if err := apq.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*AssetPrice, *AssetPriceQuery]() - return withInterceptors[[]*AssetPrice](ctx, apq, qr, apq.inters) -} - -// AllX is like All, but panics if an error occurs. -func (apq *AssetPriceQuery) AllX(ctx context.Context) []*AssetPrice { - nodes, err := apq.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of AssetPrice IDs. -func (apq *AssetPriceQuery) IDs(ctx context.Context) (ids []int, err error) { - if apq.ctx.Unique == nil && apq.path != nil { - apq.Unique(true) - } - ctx = setContextOp(ctx, apq.ctx, "IDs") - if err = apq.Select(assetprice.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (apq *AssetPriceQuery) IDsX(ctx context.Context) []int { - ids, err := apq.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (apq *AssetPriceQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, apq.ctx, "Count") - if err := apq.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, apq, querierCount[*AssetPriceQuery](), apq.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (apq *AssetPriceQuery) CountX(ctx context.Context) int { - count, err := apq.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (apq *AssetPriceQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, apq.ctx, "Exist") - switch _, err := apq.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 (apq *AssetPriceQuery) ExistX(ctx context.Context) bool { - exist, err := apq.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the AssetPriceQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (apq *AssetPriceQuery) Clone() *AssetPriceQuery { - if apq == nil { - return nil - } - return &AssetPriceQuery{ - config: apq.config, - ctx: apq.ctx.Clone(), - order: append([]assetprice.OrderOption{}, apq.order...), - inters: append([]Interceptor{}, apq.inters...), - predicates: append([]predicate.AssetPrice{}, apq.predicates...), - withSigners: apq.withSigners.Clone(), - // clone intermediate query. - sql: apq.sql.Clone(), - path: apq.path, - } -} - -// WithSigners tells the query-builder to eager-load the nodes that are connected to -// the "signers" edge. The optional arguments are used to configure the query builder of the edge. -func (apq *AssetPriceQuery) WithSigners(opts ...func(*SignerQuery)) *AssetPriceQuery { - query := (&SignerClient{config: apq.config}).Query() - for _, opt := range opts { - opt(query) - } - apq.withSigners = query - return apq -} - -// 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 { -// Block uint64 `json:"block,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.AssetPrice.Query(). -// GroupBy(assetprice.FieldBlock). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (apq *AssetPriceQuery) GroupBy(field string, fields ...string) *AssetPriceGroupBy { - apq.ctx.Fields = append([]string{field}, fields...) - grbuild := &AssetPriceGroupBy{build: apq} - grbuild.flds = &apq.ctx.Fields - grbuild.label = assetprice.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 { -// Block uint64 `json:"block,omitempty"` -// } -// -// client.AssetPrice.Query(). -// Select(assetprice.FieldBlock). -// Scan(ctx, &v) -func (apq *AssetPriceQuery) Select(fields ...string) *AssetPriceSelect { - apq.ctx.Fields = append(apq.ctx.Fields, fields...) - sbuild := &AssetPriceSelect{AssetPriceQuery: apq} - sbuild.label = assetprice.Label - sbuild.flds, sbuild.scan = &apq.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a AssetPriceSelect configured with the given aggregations. -func (apq *AssetPriceQuery) Aggregate(fns ...AggregateFunc) *AssetPriceSelect { - return apq.Select().Aggregate(fns...) -} - -func (apq *AssetPriceQuery) prepareQuery(ctx context.Context) error { - for _, inter := range apq.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, apq); err != nil { - return err - } - } - } - for _, f := range apq.ctx.Fields { - if !assetprice.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if apq.path != nil { - prev, err := apq.path(ctx) - if err != nil { - return err - } - apq.sql = prev - } - return nil -} - -func (apq *AssetPriceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AssetPrice, error) { - var ( - nodes = []*AssetPrice{} - _spec = apq.querySpec() - loadedTypes = [1]bool{ - apq.withSigners != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*AssetPrice).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &AssetPrice{config: apq.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(apq.modifiers) > 0 { - _spec.Modifiers = apq.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, apq.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := apq.withSigners; query != nil { - if err := apq.loadSigners(ctx, query, nodes, - func(n *AssetPrice) { n.Edges.Signers = []*Signer{} }, - func(n *AssetPrice, e *Signer) { n.Edges.Signers = append(n.Edges.Signers, e) }); err != nil { - return nil, err - } - } - for name, query := range apq.withNamedSigners { - if err := apq.loadSigners(ctx, query, nodes, - func(n *AssetPrice) { n.appendNamedSigners(name) }, - func(n *AssetPrice, e *Signer) { n.appendNamedSigners(name, e) }); err != nil { - return nil, err - } - } - for i := range apq.loadTotal { - if err := apq.loadTotal[i](ctx, nodes); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (apq *AssetPriceQuery) loadSigners(ctx context.Context, query *SignerQuery, nodes []*AssetPrice, init func(*AssetPrice), assign func(*AssetPrice, *Signer)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int]*AssetPrice) - nids := make(map[int]map[*AssetPrice]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(assetprice.SignersTable) - s.Join(joinT).On(s.C(signer.FieldID), joinT.C(assetprice.SignersPrimaryKey[1])) - s.Where(sql.InValues(joinT.C(assetprice.SignersPrimaryKey[0]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(assetprice.SignersPrimaryKey[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[*AssetPrice]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*Signer](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 "signers" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} - -func (apq *AssetPriceQuery) sqlCount(ctx context.Context) (int, error) { - _spec := apq.querySpec() - if len(apq.modifiers) > 0 { - _spec.Modifiers = apq.modifiers - } - _spec.Node.Columns = apq.ctx.Fields - if len(apq.ctx.Fields) > 0 { - _spec.Unique = apq.ctx.Unique != nil && *apq.ctx.Unique - } - return sqlgraph.CountNodes(ctx, apq.driver, _spec) -} - -func (apq *AssetPriceQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(assetprice.Table, assetprice.Columns, sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt)) - _spec.From = apq.sql - if unique := apq.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if apq.path != nil { - _spec.Unique = true - } - if fields := apq.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, assetprice.FieldID) - for i := range fields { - if fields[i] != assetprice.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := apq.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := apq.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := apq.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := apq.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (apq *AssetPriceQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(apq.driver.Dialect()) - t1 := builder.Table(assetprice.Table) - columns := apq.ctx.Fields - if len(columns) == 0 { - columns = assetprice.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if apq.sql != nil { - selector = apq.sql - selector.Select(selector.Columns(columns...)...) - } - if apq.ctx.Unique != nil && *apq.ctx.Unique { - selector.Distinct() - } - for _, p := range apq.predicates { - p(selector) - } - for _, p := range apq.order { - p(selector) - } - if offset := apq.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 := apq.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// WithNamedSigners tells the query-builder to eager-load the nodes that are connected to the "signers" -// edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (apq *AssetPriceQuery) WithNamedSigners(name string, opts ...func(*SignerQuery)) *AssetPriceQuery { - query := (&SignerClient{config: apq.config}).Query() - for _, opt := range opts { - opt(query) - } - if apq.withNamedSigners == nil { - apq.withNamedSigners = make(map[string]*SignerQuery) - } - apq.withNamedSigners[name] = query - return apq -} - -// AssetPriceGroupBy is the group-by builder for AssetPrice entities. -type AssetPriceGroupBy struct { - selector - build *AssetPriceQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (apgb *AssetPriceGroupBy) Aggregate(fns ...AggregateFunc) *AssetPriceGroupBy { - apgb.fns = append(apgb.fns, fns...) - return apgb -} - -// Scan applies the selector query and scans the result into the given value. -func (apgb *AssetPriceGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, apgb.build.ctx, "GroupBy") - if err := apgb.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*AssetPriceQuery, *AssetPriceGroupBy](ctx, apgb.build, apgb, apgb.build.inters, v) -} - -func (apgb *AssetPriceGroupBy) sqlScan(ctx context.Context, root *AssetPriceQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(apgb.fns)) - for _, fn := range apgb.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*apgb.flds)+len(apgb.fns)) - for _, f := range *apgb.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*apgb.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := apgb.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// AssetPriceSelect is the builder for selecting fields of AssetPrice entities. -type AssetPriceSelect struct { - *AssetPriceQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (aps *AssetPriceSelect) Aggregate(fns ...AggregateFunc) *AssetPriceSelect { - aps.fns = append(aps.fns, fns...) - return aps -} - -// Scan applies the selector query and scans the result into the given value. -func (aps *AssetPriceSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, aps.ctx, "Select") - if err := aps.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*AssetPriceQuery, *AssetPriceSelect](ctx, aps.AssetPriceQuery, aps, aps.inters, v) -} - -func (aps *AssetPriceSelect) sqlScan(ctx context.Context, root *AssetPriceQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(aps.fns)) - for _, fn := range aps.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*aps.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 := aps.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} diff --git a/internal/ent/assetprice_update.go b/internal/ent/assetprice_update.go deleted file mode 100644 index 5d1cb9e5..00000000 --- a/internal/ent/assetprice_update.go +++ /dev/null @@ -1,735 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// AssetPriceUpdate is the builder for updating AssetPrice entities. -type AssetPriceUpdate struct { - config - hooks []Hook - mutation *AssetPriceMutation -} - -// Where appends a list predicates to the AssetPriceUpdate builder. -func (apu *AssetPriceUpdate) Where(ps ...predicate.AssetPrice) *AssetPriceUpdate { - apu.mutation.Where(ps...) - return apu -} - -// SetBlock sets the "block" field. -func (apu *AssetPriceUpdate) SetBlock(u uint64) *AssetPriceUpdate { - apu.mutation.ResetBlock() - apu.mutation.SetBlock(u) - return apu -} - -// SetNillableBlock sets the "block" field if the given value is not nil. -func (apu *AssetPriceUpdate) SetNillableBlock(u *uint64) *AssetPriceUpdate { - if u != nil { - apu.SetBlock(*u) - } - return apu -} - -// AddBlock adds u to the "block" field. -func (apu *AssetPriceUpdate) AddBlock(u int64) *AssetPriceUpdate { - apu.mutation.AddBlock(u) - return apu -} - -// SetSignersCount sets the "signersCount" field. -func (apu *AssetPriceUpdate) SetSignersCount(u uint64) *AssetPriceUpdate { - apu.mutation.ResetSignersCount() - apu.mutation.SetSignersCount(u) - return apu -} - -// SetNillableSignersCount sets the "signersCount" field if the given value is not nil. -func (apu *AssetPriceUpdate) SetNillableSignersCount(u *uint64) *AssetPriceUpdate { - if u != nil { - apu.SetSignersCount(*u) - } - return apu -} - -// AddSignersCount adds u to the "signersCount" field. -func (apu *AssetPriceUpdate) AddSignersCount(u int64) *AssetPriceUpdate { - apu.mutation.AddSignersCount(u) - return apu -} - -// ClearSignersCount clears the value of the "signersCount" field. -func (apu *AssetPriceUpdate) ClearSignersCount() *AssetPriceUpdate { - apu.mutation.ClearSignersCount() - return apu -} - -// SetPrice sets the "price" field. -func (apu *AssetPriceUpdate) SetPrice(hi *helpers.BigInt) *AssetPriceUpdate { - apu.mutation.SetPrice(hi) - return apu -} - -// SetSignature sets the "signature" field. -func (apu *AssetPriceUpdate) SetSignature(b []byte) *AssetPriceUpdate { - apu.mutation.SetSignature(b) - return apu -} - -// SetAsset sets the "asset" field. -func (apu *AssetPriceUpdate) SetAsset(s string) *AssetPriceUpdate { - apu.mutation.SetAsset(s) - return apu -} - -// SetNillableAsset sets the "asset" field if the given value is not nil. -func (apu *AssetPriceUpdate) SetNillableAsset(s *string) *AssetPriceUpdate { - if s != nil { - apu.SetAsset(*s) - } - return apu -} - -// ClearAsset clears the value of the "asset" field. -func (apu *AssetPriceUpdate) ClearAsset() *AssetPriceUpdate { - apu.mutation.ClearAsset() - return apu -} - -// SetChain sets the "chain" field. -func (apu *AssetPriceUpdate) SetChain(s string) *AssetPriceUpdate { - apu.mutation.SetChain(s) - return apu -} - -// SetNillableChain sets the "chain" field if the given value is not nil. -func (apu *AssetPriceUpdate) SetNillableChain(s *string) *AssetPriceUpdate { - if s != nil { - apu.SetChain(*s) - } - return apu -} - -// ClearChain clears the value of the "chain" field. -func (apu *AssetPriceUpdate) ClearChain() *AssetPriceUpdate { - apu.mutation.ClearChain() - return apu -} - -// SetPair sets the "pair" field. -func (apu *AssetPriceUpdate) SetPair(s string) *AssetPriceUpdate { - apu.mutation.SetPair(s) - return apu -} - -// SetNillablePair sets the "pair" field if the given value is not nil. -func (apu *AssetPriceUpdate) SetNillablePair(s *string) *AssetPriceUpdate { - if s != nil { - apu.SetPair(*s) - } - return apu -} - -// ClearPair clears the value of the "pair" field. -func (apu *AssetPriceUpdate) ClearPair() *AssetPriceUpdate { - apu.mutation.ClearPair() - return apu -} - -// SetConsensus sets the "consensus" field. -func (apu *AssetPriceUpdate) SetConsensus(b bool) *AssetPriceUpdate { - apu.mutation.SetConsensus(b) - return apu -} - -// SetNillableConsensus sets the "consensus" field if the given value is not nil. -func (apu *AssetPriceUpdate) SetNillableConsensus(b *bool) *AssetPriceUpdate { - if b != nil { - apu.SetConsensus(*b) - } - return apu -} - -// SetVoted sets the "voted" field. -func (apu *AssetPriceUpdate) SetVoted(hi *helpers.BigInt) *AssetPriceUpdate { - apu.mutation.SetVoted(hi) - return apu -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by IDs. -func (apu *AssetPriceUpdate) AddSignerIDs(ids ...int) *AssetPriceUpdate { - apu.mutation.AddSignerIDs(ids...) - return apu -} - -// AddSigners adds the "signers" edges to the Signer entity. -func (apu *AssetPriceUpdate) AddSigners(s ...*Signer) *AssetPriceUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return apu.AddSignerIDs(ids...) -} - -// Mutation returns the AssetPriceMutation object of the builder. -func (apu *AssetPriceUpdate) Mutation() *AssetPriceMutation { - return apu.mutation -} - -// ClearSigners clears all "signers" edges to the Signer entity. -func (apu *AssetPriceUpdate) ClearSigners() *AssetPriceUpdate { - apu.mutation.ClearSigners() - return apu -} - -// RemoveSignerIDs removes the "signers" edge to Signer entities by IDs. -func (apu *AssetPriceUpdate) RemoveSignerIDs(ids ...int) *AssetPriceUpdate { - apu.mutation.RemoveSignerIDs(ids...) - return apu -} - -// RemoveSigners removes "signers" edges to Signer entities. -func (apu *AssetPriceUpdate) RemoveSigners(s ...*Signer) *AssetPriceUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return apu.RemoveSignerIDs(ids...) -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (apu *AssetPriceUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, apu.sqlSave, apu.mutation, apu.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (apu *AssetPriceUpdate) SaveX(ctx context.Context) int { - affected, err := apu.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (apu *AssetPriceUpdate) Exec(ctx context.Context) error { - _, err := apu.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (apu *AssetPriceUpdate) ExecX(ctx context.Context) { - if err := apu.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (apu *AssetPriceUpdate) check() error { - if v, ok := apu.mutation.Signature(); ok { - if err := assetprice.SignatureValidator(v); err != nil { - return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "AssetPrice.signature": %w`, err)} - } - } - return nil -} - -func (apu *AssetPriceUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := apu.check(); err != nil { - return n, err - } - _spec := sqlgraph.NewUpdateSpec(assetprice.Table, assetprice.Columns, sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt)) - if ps := apu.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := apu.mutation.Block(); ok { - _spec.SetField(assetprice.FieldBlock, field.TypeUint64, value) - } - if value, ok := apu.mutation.AddedBlock(); ok { - _spec.AddField(assetprice.FieldBlock, field.TypeUint64, value) - } - if value, ok := apu.mutation.SignersCount(); ok { - _spec.SetField(assetprice.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := apu.mutation.AddedSignersCount(); ok { - _spec.AddField(assetprice.FieldSignersCount, field.TypeUint64, value) - } - if apu.mutation.SignersCountCleared() { - _spec.ClearField(assetprice.FieldSignersCount, field.TypeUint64) - } - if value, ok := apu.mutation.Price(); ok { - _spec.SetField(assetprice.FieldPrice, field.TypeUint, value) - } - if value, ok := apu.mutation.Signature(); ok { - _spec.SetField(assetprice.FieldSignature, field.TypeBytes, value) - } - if value, ok := apu.mutation.Asset(); ok { - _spec.SetField(assetprice.FieldAsset, field.TypeString, value) - } - if apu.mutation.AssetCleared() { - _spec.ClearField(assetprice.FieldAsset, field.TypeString) - } - if value, ok := apu.mutation.Chain(); ok { - _spec.SetField(assetprice.FieldChain, field.TypeString, value) - } - if apu.mutation.ChainCleared() { - _spec.ClearField(assetprice.FieldChain, field.TypeString) - } - if value, ok := apu.mutation.Pair(); ok { - _spec.SetField(assetprice.FieldPair, field.TypeString, value) - } - if apu.mutation.PairCleared() { - _spec.ClearField(assetprice.FieldPair, field.TypeString) - } - if value, ok := apu.mutation.Consensus(); ok { - _spec.SetField(assetprice.FieldConsensus, field.TypeBool, value) - } - if value, ok := apu.mutation.Voted(); ok { - _spec.SetField(assetprice.FieldVoted, field.TypeUint, value) - } - if apu.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: assetprice.SignersTable, - Columns: assetprice.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := apu.mutation.RemovedSignersIDs(); len(nodes) > 0 && !apu.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: assetprice.SignersTable, - Columns: assetprice.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.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 := apu.mutation.SignersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: assetprice.SignersTable, - Columns: assetprice.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.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, apu.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{assetprice.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - apu.mutation.done = true - return n, nil -} - -// AssetPriceUpdateOne is the builder for updating a single AssetPrice entity. -type AssetPriceUpdateOne struct { - config - fields []string - hooks []Hook - mutation *AssetPriceMutation -} - -// SetBlock sets the "block" field. -func (apuo *AssetPriceUpdateOne) SetBlock(u uint64) *AssetPriceUpdateOne { - apuo.mutation.ResetBlock() - apuo.mutation.SetBlock(u) - return apuo -} - -// SetNillableBlock sets the "block" field if the given value is not nil. -func (apuo *AssetPriceUpdateOne) SetNillableBlock(u *uint64) *AssetPriceUpdateOne { - if u != nil { - apuo.SetBlock(*u) - } - return apuo -} - -// AddBlock adds u to the "block" field. -func (apuo *AssetPriceUpdateOne) AddBlock(u int64) *AssetPriceUpdateOne { - apuo.mutation.AddBlock(u) - return apuo -} - -// SetSignersCount sets the "signersCount" field. -func (apuo *AssetPriceUpdateOne) SetSignersCount(u uint64) *AssetPriceUpdateOne { - apuo.mutation.ResetSignersCount() - apuo.mutation.SetSignersCount(u) - return apuo -} - -// SetNillableSignersCount sets the "signersCount" field if the given value is not nil. -func (apuo *AssetPriceUpdateOne) SetNillableSignersCount(u *uint64) *AssetPriceUpdateOne { - if u != nil { - apuo.SetSignersCount(*u) - } - return apuo -} - -// AddSignersCount adds u to the "signersCount" field. -func (apuo *AssetPriceUpdateOne) AddSignersCount(u int64) *AssetPriceUpdateOne { - apuo.mutation.AddSignersCount(u) - return apuo -} - -// ClearSignersCount clears the value of the "signersCount" field. -func (apuo *AssetPriceUpdateOne) ClearSignersCount() *AssetPriceUpdateOne { - apuo.mutation.ClearSignersCount() - return apuo -} - -// SetPrice sets the "price" field. -func (apuo *AssetPriceUpdateOne) SetPrice(hi *helpers.BigInt) *AssetPriceUpdateOne { - apuo.mutation.SetPrice(hi) - return apuo -} - -// SetSignature sets the "signature" field. -func (apuo *AssetPriceUpdateOne) SetSignature(b []byte) *AssetPriceUpdateOne { - apuo.mutation.SetSignature(b) - return apuo -} - -// SetAsset sets the "asset" field. -func (apuo *AssetPriceUpdateOne) SetAsset(s string) *AssetPriceUpdateOne { - apuo.mutation.SetAsset(s) - return apuo -} - -// SetNillableAsset sets the "asset" field if the given value is not nil. -func (apuo *AssetPriceUpdateOne) SetNillableAsset(s *string) *AssetPriceUpdateOne { - if s != nil { - apuo.SetAsset(*s) - } - return apuo -} - -// ClearAsset clears the value of the "asset" field. -func (apuo *AssetPriceUpdateOne) ClearAsset() *AssetPriceUpdateOne { - apuo.mutation.ClearAsset() - return apuo -} - -// SetChain sets the "chain" field. -func (apuo *AssetPriceUpdateOne) SetChain(s string) *AssetPriceUpdateOne { - apuo.mutation.SetChain(s) - return apuo -} - -// SetNillableChain sets the "chain" field if the given value is not nil. -func (apuo *AssetPriceUpdateOne) SetNillableChain(s *string) *AssetPriceUpdateOne { - if s != nil { - apuo.SetChain(*s) - } - return apuo -} - -// ClearChain clears the value of the "chain" field. -func (apuo *AssetPriceUpdateOne) ClearChain() *AssetPriceUpdateOne { - apuo.mutation.ClearChain() - return apuo -} - -// SetPair sets the "pair" field. -func (apuo *AssetPriceUpdateOne) SetPair(s string) *AssetPriceUpdateOne { - apuo.mutation.SetPair(s) - return apuo -} - -// SetNillablePair sets the "pair" field if the given value is not nil. -func (apuo *AssetPriceUpdateOne) SetNillablePair(s *string) *AssetPriceUpdateOne { - if s != nil { - apuo.SetPair(*s) - } - return apuo -} - -// ClearPair clears the value of the "pair" field. -func (apuo *AssetPriceUpdateOne) ClearPair() *AssetPriceUpdateOne { - apuo.mutation.ClearPair() - return apuo -} - -// SetConsensus sets the "consensus" field. -func (apuo *AssetPriceUpdateOne) SetConsensus(b bool) *AssetPriceUpdateOne { - apuo.mutation.SetConsensus(b) - return apuo -} - -// SetNillableConsensus sets the "consensus" field if the given value is not nil. -func (apuo *AssetPriceUpdateOne) SetNillableConsensus(b *bool) *AssetPriceUpdateOne { - if b != nil { - apuo.SetConsensus(*b) - } - return apuo -} - -// SetVoted sets the "voted" field. -func (apuo *AssetPriceUpdateOne) SetVoted(hi *helpers.BigInt) *AssetPriceUpdateOne { - apuo.mutation.SetVoted(hi) - return apuo -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by IDs. -func (apuo *AssetPriceUpdateOne) AddSignerIDs(ids ...int) *AssetPriceUpdateOne { - apuo.mutation.AddSignerIDs(ids...) - return apuo -} - -// AddSigners adds the "signers" edges to the Signer entity. -func (apuo *AssetPriceUpdateOne) AddSigners(s ...*Signer) *AssetPriceUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return apuo.AddSignerIDs(ids...) -} - -// Mutation returns the AssetPriceMutation object of the builder. -func (apuo *AssetPriceUpdateOne) Mutation() *AssetPriceMutation { - return apuo.mutation -} - -// ClearSigners clears all "signers" edges to the Signer entity. -func (apuo *AssetPriceUpdateOne) ClearSigners() *AssetPriceUpdateOne { - apuo.mutation.ClearSigners() - return apuo -} - -// RemoveSignerIDs removes the "signers" edge to Signer entities by IDs. -func (apuo *AssetPriceUpdateOne) RemoveSignerIDs(ids ...int) *AssetPriceUpdateOne { - apuo.mutation.RemoveSignerIDs(ids...) - return apuo -} - -// RemoveSigners removes "signers" edges to Signer entities. -func (apuo *AssetPriceUpdateOne) RemoveSigners(s ...*Signer) *AssetPriceUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return apuo.RemoveSignerIDs(ids...) -} - -// Where appends a list predicates to the AssetPriceUpdate builder. -func (apuo *AssetPriceUpdateOne) Where(ps ...predicate.AssetPrice) *AssetPriceUpdateOne { - apuo.mutation.Where(ps...) - return apuo -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (apuo *AssetPriceUpdateOne) Select(field string, fields ...string) *AssetPriceUpdateOne { - apuo.fields = append([]string{field}, fields...) - return apuo -} - -// Save executes the query and returns the updated AssetPrice entity. -func (apuo *AssetPriceUpdateOne) Save(ctx context.Context) (*AssetPrice, error) { - return withHooks(ctx, apuo.sqlSave, apuo.mutation, apuo.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (apuo *AssetPriceUpdateOne) SaveX(ctx context.Context) *AssetPrice { - node, err := apuo.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (apuo *AssetPriceUpdateOne) Exec(ctx context.Context) error { - _, err := apuo.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (apuo *AssetPriceUpdateOne) ExecX(ctx context.Context) { - if err := apuo.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (apuo *AssetPriceUpdateOne) check() error { - if v, ok := apuo.mutation.Signature(); ok { - if err := assetprice.SignatureValidator(v); err != nil { - return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "AssetPrice.signature": %w`, err)} - } - } - return nil -} - -func (apuo *AssetPriceUpdateOne) sqlSave(ctx context.Context) (_node *AssetPrice, err error) { - if err := apuo.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(assetprice.Table, assetprice.Columns, sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt)) - id, ok := apuo.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AssetPrice.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := apuo.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, assetprice.FieldID) - for _, f := range fields { - if !assetprice.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != assetprice.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := apuo.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := apuo.mutation.Block(); ok { - _spec.SetField(assetprice.FieldBlock, field.TypeUint64, value) - } - if value, ok := apuo.mutation.AddedBlock(); ok { - _spec.AddField(assetprice.FieldBlock, field.TypeUint64, value) - } - if value, ok := apuo.mutation.SignersCount(); ok { - _spec.SetField(assetprice.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := apuo.mutation.AddedSignersCount(); ok { - _spec.AddField(assetprice.FieldSignersCount, field.TypeUint64, value) - } - if apuo.mutation.SignersCountCleared() { - _spec.ClearField(assetprice.FieldSignersCount, field.TypeUint64) - } - if value, ok := apuo.mutation.Price(); ok { - _spec.SetField(assetprice.FieldPrice, field.TypeUint, value) - } - if value, ok := apuo.mutation.Signature(); ok { - _spec.SetField(assetprice.FieldSignature, field.TypeBytes, value) - } - if value, ok := apuo.mutation.Asset(); ok { - _spec.SetField(assetprice.FieldAsset, field.TypeString, value) - } - if apuo.mutation.AssetCleared() { - _spec.ClearField(assetprice.FieldAsset, field.TypeString) - } - if value, ok := apuo.mutation.Chain(); ok { - _spec.SetField(assetprice.FieldChain, field.TypeString, value) - } - if apuo.mutation.ChainCleared() { - _spec.ClearField(assetprice.FieldChain, field.TypeString) - } - if value, ok := apuo.mutation.Pair(); ok { - _spec.SetField(assetprice.FieldPair, field.TypeString, value) - } - if apuo.mutation.PairCleared() { - _spec.ClearField(assetprice.FieldPair, field.TypeString) - } - if value, ok := apuo.mutation.Consensus(); ok { - _spec.SetField(assetprice.FieldConsensus, field.TypeBool, value) - } - if value, ok := apuo.mutation.Voted(); ok { - _spec.SetField(assetprice.FieldVoted, field.TypeUint, value) - } - if apuo.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: assetprice.SignersTable, - Columns: assetprice.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := apuo.mutation.RemovedSignersIDs(); len(nodes) > 0 && !apuo.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: assetprice.SignersTable, - Columns: assetprice.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.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 := apuo.mutation.SignersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: assetprice.SignersTable, - Columns: assetprice.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _node = &AssetPrice{config: apuo.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, apuo.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{assetprice.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - apuo.mutation.done = true - return _node, nil -} diff --git a/internal/ent/client.go b/internal/ent/client.go deleted file mode 100644 index c21176ce..00000000 --- a/internal/ent/client.go +++ /dev/null @@ -1,868 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "log" - "reflect" - - "github.com/TimeleapLabs/unchained/internal/ent/migrate" - - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// 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 - // AssetPrice is the client for interacting with the AssetPrice builders. - AssetPrice *AssetPriceClient - // CorrectnessReport is the client for interacting with the CorrectnessReport builders. - CorrectnessReport *CorrectnessReportClient - // EventLog is the client for interacting with the EventLog builders. - EventLog *EventLogClient - // Signer is the client for interacting with the Signer builders. - Signer *SignerClient - // additional fields for node api - tables tables -} - -// 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.AssetPrice = NewAssetPriceClient(c.config) - c.CorrectnessReport = NewCorrectnessReportClient(c.config) - c.EventLog = NewEventLogClient(c.config) - c.Signer = NewSignerClient(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, - AssetPrice: NewAssetPriceClient(cfg), - CorrectnessReport: NewCorrectnessReportClient(cfg), - EventLog: NewEventLogClient(cfg), - Signer: NewSignerClient(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, - AssetPrice: NewAssetPriceClient(cfg), - CorrectnessReport: NewCorrectnessReportClient(cfg), - EventLog: NewEventLogClient(cfg), - Signer: NewSignerClient(cfg), - }, nil -} - -// Debug returns a new debug-client. It's used to get verbose logging on specific operations. -// -// client.Debug(). -// AssetPrice. -// 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.AssetPrice.Use(hooks...) - c.CorrectnessReport.Use(hooks...) - c.EventLog.Use(hooks...) - c.Signer.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.AssetPrice.Intercept(interceptors...) - c.CorrectnessReport.Intercept(interceptors...) - c.EventLog.Intercept(interceptors...) - c.Signer.Intercept(interceptors...) -} - -// Mutate implements the ent.Mutator interface. -func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { - switch m := m.(type) { - case *AssetPriceMutation: - return c.AssetPrice.mutate(ctx, m) - case *CorrectnessReportMutation: - return c.CorrectnessReport.mutate(ctx, m) - case *EventLogMutation: - return c.EventLog.mutate(ctx, m) - case *SignerMutation: - return c.Signer.mutate(ctx, m) - default: - return nil, fmt.Errorf("ent: unknown mutation type %T", m) - } -} - -// AssetPriceClient is a client for the AssetPrice schema. -type AssetPriceClient struct { - config -} - -// NewAssetPriceClient returns a client for the AssetPrice from the given config. -func NewAssetPriceClient(c config) *AssetPriceClient { - return &AssetPriceClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `assetprice.Hooks(f(g(h())))`. -func (c *AssetPriceClient) Use(hooks ...Hook) { - c.hooks.AssetPrice = append(c.hooks.AssetPrice, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `assetprice.Intercept(f(g(h())))`. -func (c *AssetPriceClient) Intercept(interceptors ...Interceptor) { - c.inters.AssetPrice = append(c.inters.AssetPrice, interceptors...) -} - -// Create returns a builder for creating a AssetPrice entity. -func (c *AssetPriceClient) Create() *AssetPriceCreate { - mutation := newAssetPriceMutation(c.config, OpCreate) - return &AssetPriceCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of AssetPrice entities. -func (c *AssetPriceClient) CreateBulk(builders ...*AssetPriceCreate) *AssetPriceCreateBulk { - return &AssetPriceCreateBulk{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 *AssetPriceClient) MapCreateBulk(slice any, setFunc func(*AssetPriceCreate, int)) *AssetPriceCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &AssetPriceCreateBulk{err: fmt.Errorf("calling to AssetPriceClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*AssetPriceCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &AssetPriceCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for AssetPrice. -func (c *AssetPriceClient) Update() *AssetPriceUpdate { - mutation := newAssetPriceMutation(c.config, OpUpdate) - return &AssetPriceUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *AssetPriceClient) UpdateOne(ap *AssetPrice) *AssetPriceUpdateOne { - mutation := newAssetPriceMutation(c.config, OpUpdateOne, withAssetPrice(ap)) - return &AssetPriceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *AssetPriceClient) UpdateOneID(id int) *AssetPriceUpdateOne { - mutation := newAssetPriceMutation(c.config, OpUpdateOne, withAssetPriceID(id)) - return &AssetPriceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for AssetPrice. -func (c *AssetPriceClient) Delete() *AssetPriceDelete { - mutation := newAssetPriceMutation(c.config, OpDelete) - return &AssetPriceDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *AssetPriceClient) DeleteOne(ap *AssetPrice) *AssetPriceDeleteOne { - return c.DeleteOneID(ap.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *AssetPriceClient) DeleteOneID(id int) *AssetPriceDeleteOne { - builder := c.Delete().Where(assetprice.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &AssetPriceDeleteOne{builder} -} - -// Query returns a query builder for AssetPrice. -func (c *AssetPriceClient) Query() *AssetPriceQuery { - return &AssetPriceQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeAssetPrice}, - inters: c.Interceptors(), - } -} - -// Get returns a AssetPrice entity by its id. -func (c *AssetPriceClient) Get(ctx context.Context, id int) (*AssetPrice, error) { - return c.Query().Where(assetprice.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *AssetPriceClient) GetX(ctx context.Context, id int) *AssetPrice { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QuerySigners queries the signers edge of a AssetPrice. -func (c *AssetPriceClient) QuerySigners(ap *AssetPrice) *SignerQuery { - query := (&SignerClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := ap.ID - step := sqlgraph.NewStep( - sqlgraph.From(assetprice.Table, assetprice.FieldID, id), - sqlgraph.To(signer.Table, signer.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, assetprice.SignersTable, assetprice.SignersPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(ap.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *AssetPriceClient) Hooks() []Hook { - return c.hooks.AssetPrice -} - -// Interceptors returns the client interceptors. -func (c *AssetPriceClient) Interceptors() []Interceptor { - return c.inters.AssetPrice -} - -func (c *AssetPriceClient) mutate(ctx context.Context, m *AssetPriceMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&AssetPriceCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&AssetPriceUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&AssetPriceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&AssetPriceDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown AssetPrice mutation op: %q", m.Op()) - } -} - -// CorrectnessReportClient is a client for the CorrectnessReport schema. -type CorrectnessReportClient struct { - config -} - -// NewCorrectnessReportClient returns a client for the CorrectnessReport from the given config. -func NewCorrectnessReportClient(c config) *CorrectnessReportClient { - return &CorrectnessReportClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `correctnessreport.Hooks(f(g(h())))`. -func (c *CorrectnessReportClient) Use(hooks ...Hook) { - c.hooks.CorrectnessReport = append(c.hooks.CorrectnessReport, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `correctnessreport.Intercept(f(g(h())))`. -func (c *CorrectnessReportClient) Intercept(interceptors ...Interceptor) { - c.inters.CorrectnessReport = append(c.inters.CorrectnessReport, interceptors...) -} - -// Create returns a builder for creating a CorrectnessReport entity. -func (c *CorrectnessReportClient) Create() *CorrectnessReportCreate { - mutation := newCorrectnessReportMutation(c.config, OpCreate) - return &CorrectnessReportCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of CorrectnessReport entities. -func (c *CorrectnessReportClient) CreateBulk(builders ...*CorrectnessReportCreate) *CorrectnessReportCreateBulk { - return &CorrectnessReportCreateBulk{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 *CorrectnessReportClient) MapCreateBulk(slice any, setFunc func(*CorrectnessReportCreate, int)) *CorrectnessReportCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &CorrectnessReportCreateBulk{err: fmt.Errorf("calling to CorrectnessReportClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*CorrectnessReportCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &CorrectnessReportCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for CorrectnessReport. -func (c *CorrectnessReportClient) Update() *CorrectnessReportUpdate { - mutation := newCorrectnessReportMutation(c.config, OpUpdate) - return &CorrectnessReportUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *CorrectnessReportClient) UpdateOne(cr *CorrectnessReport) *CorrectnessReportUpdateOne { - mutation := newCorrectnessReportMutation(c.config, OpUpdateOne, withCorrectnessReport(cr)) - return &CorrectnessReportUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *CorrectnessReportClient) UpdateOneID(id int) *CorrectnessReportUpdateOne { - mutation := newCorrectnessReportMutation(c.config, OpUpdateOne, withCorrectnessReportID(id)) - return &CorrectnessReportUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for CorrectnessReport. -func (c *CorrectnessReportClient) Delete() *CorrectnessReportDelete { - mutation := newCorrectnessReportMutation(c.config, OpDelete) - return &CorrectnessReportDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *CorrectnessReportClient) DeleteOne(cr *CorrectnessReport) *CorrectnessReportDeleteOne { - return c.DeleteOneID(cr.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *CorrectnessReportClient) DeleteOneID(id int) *CorrectnessReportDeleteOne { - builder := c.Delete().Where(correctnessreport.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &CorrectnessReportDeleteOne{builder} -} - -// Query returns a query builder for CorrectnessReport. -func (c *CorrectnessReportClient) Query() *CorrectnessReportQuery { - return &CorrectnessReportQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeCorrectnessReport}, - inters: c.Interceptors(), - } -} - -// Get returns a CorrectnessReport entity by its id. -func (c *CorrectnessReportClient) Get(ctx context.Context, id int) (*CorrectnessReport, error) { - return c.Query().Where(correctnessreport.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *CorrectnessReportClient) GetX(ctx context.Context, id int) *CorrectnessReport { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QuerySigners queries the signers edge of a CorrectnessReport. -func (c *CorrectnessReportClient) QuerySigners(cr *CorrectnessReport) *SignerQuery { - query := (&SignerClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := cr.ID - step := sqlgraph.NewStep( - sqlgraph.From(correctnessreport.Table, correctnessreport.FieldID, id), - sqlgraph.To(signer.Table, signer.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, correctnessreport.SignersTable, correctnessreport.SignersPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(cr.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *CorrectnessReportClient) Hooks() []Hook { - return c.hooks.CorrectnessReport -} - -// Interceptors returns the client interceptors. -func (c *CorrectnessReportClient) Interceptors() []Interceptor { - return c.inters.CorrectnessReport -} - -func (c *CorrectnessReportClient) mutate(ctx context.Context, m *CorrectnessReportMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&CorrectnessReportCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&CorrectnessReportUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&CorrectnessReportUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&CorrectnessReportDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown CorrectnessReport mutation op: %q", m.Op()) - } -} - -// EventLogClient is a client for the EventLog schema. -type EventLogClient struct { - config -} - -// NewEventLogClient returns a client for the EventLog from the given config. -func NewEventLogClient(c config) *EventLogClient { - return &EventLogClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `eventlog.Hooks(f(g(h())))`. -func (c *EventLogClient) Use(hooks ...Hook) { - c.hooks.EventLog = append(c.hooks.EventLog, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `eventlog.Intercept(f(g(h())))`. -func (c *EventLogClient) Intercept(interceptors ...Interceptor) { - c.inters.EventLog = append(c.inters.EventLog, interceptors...) -} - -// Create returns a builder for creating a EventLog entity. -func (c *EventLogClient) Create() *EventLogCreate { - mutation := newEventLogMutation(c.config, OpCreate) - return &EventLogCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of EventLog entities. -func (c *EventLogClient) CreateBulk(builders ...*EventLogCreate) *EventLogCreateBulk { - return &EventLogCreateBulk{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 *EventLogClient) MapCreateBulk(slice any, setFunc func(*EventLogCreate, int)) *EventLogCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &EventLogCreateBulk{err: fmt.Errorf("calling to EventLogClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*EventLogCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &EventLogCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for EventLog. -func (c *EventLogClient) Update() *EventLogUpdate { - mutation := newEventLogMutation(c.config, OpUpdate) - return &EventLogUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *EventLogClient) UpdateOne(el *EventLog) *EventLogUpdateOne { - mutation := newEventLogMutation(c.config, OpUpdateOne, withEventLog(el)) - return &EventLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *EventLogClient) UpdateOneID(id int) *EventLogUpdateOne { - mutation := newEventLogMutation(c.config, OpUpdateOne, withEventLogID(id)) - return &EventLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for EventLog. -func (c *EventLogClient) Delete() *EventLogDelete { - mutation := newEventLogMutation(c.config, OpDelete) - return &EventLogDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *EventLogClient) DeleteOne(el *EventLog) *EventLogDeleteOne { - return c.DeleteOneID(el.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *EventLogClient) DeleteOneID(id int) *EventLogDeleteOne { - builder := c.Delete().Where(eventlog.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &EventLogDeleteOne{builder} -} - -// Query returns a query builder for EventLog. -func (c *EventLogClient) Query() *EventLogQuery { - return &EventLogQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeEventLog}, - inters: c.Interceptors(), - } -} - -// Get returns a EventLog entity by its id. -func (c *EventLogClient) Get(ctx context.Context, id int) (*EventLog, error) { - return c.Query().Where(eventlog.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *EventLogClient) GetX(ctx context.Context, id int) *EventLog { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QuerySigners queries the signers edge of a EventLog. -func (c *EventLogClient) QuerySigners(el *EventLog) *SignerQuery { - query := (&SignerClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := el.ID - step := sqlgraph.NewStep( - sqlgraph.From(eventlog.Table, eventlog.FieldID, id), - sqlgraph.To(signer.Table, signer.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, eventlog.SignersTable, eventlog.SignersPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(el.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *EventLogClient) Hooks() []Hook { - return c.hooks.EventLog -} - -// Interceptors returns the client interceptors. -func (c *EventLogClient) Interceptors() []Interceptor { - return c.inters.EventLog -} - -func (c *EventLogClient) mutate(ctx context.Context, m *EventLogMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&EventLogCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&EventLogUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&EventLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&EventLogDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown EventLog mutation op: %q", m.Op()) - } -} - -// SignerClient is a client for the Signer schema. -type SignerClient struct { - config -} - -// NewSignerClient returns a client for the Signer from the given config. -func NewSignerClient(c config) *SignerClient { - return &SignerClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `signer.Hooks(f(g(h())))`. -func (c *SignerClient) Use(hooks ...Hook) { - c.hooks.Signer = append(c.hooks.Signer, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `signer.Intercept(f(g(h())))`. -func (c *SignerClient) Intercept(interceptors ...Interceptor) { - c.inters.Signer = append(c.inters.Signer, interceptors...) -} - -// Create returns a builder for creating a Signer entity. -func (c *SignerClient) Create() *SignerCreate { - mutation := newSignerMutation(c.config, OpCreate) - return &SignerCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of Signer entities. -func (c *SignerClient) CreateBulk(builders ...*SignerCreate) *SignerCreateBulk { - return &SignerCreateBulk{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 *SignerClient) MapCreateBulk(slice any, setFunc func(*SignerCreate, int)) *SignerCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &SignerCreateBulk{err: fmt.Errorf("calling to SignerClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*SignerCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &SignerCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for Signer. -func (c *SignerClient) Update() *SignerUpdate { - mutation := newSignerMutation(c.config, OpUpdate) - return &SignerUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *SignerClient) UpdateOne(s *Signer) *SignerUpdateOne { - mutation := newSignerMutation(c.config, OpUpdateOne, withSigner(s)) - return &SignerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *SignerClient) UpdateOneID(id int) *SignerUpdateOne { - mutation := newSignerMutation(c.config, OpUpdateOne, withSignerID(id)) - return &SignerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for Signer. -func (c *SignerClient) Delete() *SignerDelete { - mutation := newSignerMutation(c.config, OpDelete) - return &SignerDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *SignerClient) DeleteOne(s *Signer) *SignerDeleteOne { - return c.DeleteOneID(s.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *SignerClient) DeleteOneID(id int) *SignerDeleteOne { - builder := c.Delete().Where(signer.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &SignerDeleteOne{builder} -} - -// Query returns a query builder for Signer. -func (c *SignerClient) Query() *SignerQuery { - return &SignerQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeSigner}, - inters: c.Interceptors(), - } -} - -// Get returns a Signer entity by its id. -func (c *SignerClient) Get(ctx context.Context, id int) (*Signer, error) { - return c.Query().Where(signer.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *SignerClient) GetX(ctx context.Context, id int) *Signer { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryAssetPrice queries the assetPrice edge of a Signer. -func (c *SignerClient) QueryAssetPrice(s *Signer) *AssetPriceQuery { - query := (&AssetPriceClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := s.ID - step := sqlgraph.NewStep( - sqlgraph.From(signer.Table, signer.FieldID, id), - sqlgraph.To(assetprice.Table, assetprice.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, signer.AssetPriceTable, signer.AssetPricePrimaryKey...), - ) - fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryEventLogs queries the eventLogs edge of a Signer. -func (c *SignerClient) QueryEventLogs(s *Signer) *EventLogQuery { - query := (&EventLogClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := s.ID - step := sqlgraph.NewStep( - sqlgraph.From(signer.Table, signer.FieldID, id), - sqlgraph.To(eventlog.Table, eventlog.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, signer.EventLogsTable, signer.EventLogsPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryCorrectnessReport queries the correctnessReport edge of a Signer. -func (c *SignerClient) QueryCorrectnessReport(s *Signer) *CorrectnessReportQuery { - query := (&CorrectnessReportClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := s.ID - step := sqlgraph.NewStep( - sqlgraph.From(signer.Table, signer.FieldID, id), - sqlgraph.To(correctnessreport.Table, correctnessreport.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, signer.CorrectnessReportTable, signer.CorrectnessReportPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *SignerClient) Hooks() []Hook { - return c.hooks.Signer -} - -// Interceptors returns the client interceptors. -func (c *SignerClient) Interceptors() []Interceptor { - return c.inters.Signer -} - -func (c *SignerClient) mutate(ctx context.Context, m *SignerMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&SignerCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&SignerUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&SignerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&SignerDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown Signer mutation op: %q", m.Op()) - } -} - -// hooks and interceptors per client, for fast access. -type ( - hooks struct { - AssetPrice, CorrectnessReport, EventLog, Signer []ent.Hook - } - inters struct { - AssetPrice, CorrectnessReport, EventLog, Signer []ent.Interceptor - } -) diff --git a/internal/ent/correctnessreport.go b/internal/ent/correctnessreport.go deleted file mode 100644 index 3e518281..00000000 --- a/internal/ent/correctnessreport.go +++ /dev/null @@ -1,239 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "fmt" - "strings" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" -) - -// CorrectnessReport is the model entity for the CorrectnessReport schema. -type CorrectnessReport struct { - config `json:"-"` - // ID of the ent. - ID int `json:"id,omitempty"` - // SignersCount holds the value of the "signersCount" field. - SignersCount uint64 `json:"signersCount,omitempty"` - // Timestamp holds the value of the "timestamp" field. - Timestamp uint64 `json:"timestamp,omitempty"` - // Signature holds the value of the "signature" field. - Signature []byte `json:"signature,omitempty"` - // Hash holds the value of the "hash" field. - Hash []byte `json:"hash,omitempty"` - // Topic holds the value of the "topic" field. - Topic []byte `json:"topic,omitempty"` - // Correct holds the value of the "correct" field. - Correct bool `json:"correct,omitempty"` - // Consensus holds the value of the "consensus" field. - Consensus bool `json:"consensus,omitempty"` - // Voted holds the value of the "voted" field. - Voted *helpers.BigInt `json:"voted,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the CorrectnessReportQuery when eager-loading is set. - Edges CorrectnessReportEdges `json:"edges"` - selectValues sql.SelectValues -} - -// CorrectnessReportEdges holds the relations/edges for other nodes in the graph. -type CorrectnessReportEdges struct { - // Signers holds the value of the signers edge. - Signers []*Signer `json:"signers,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [1]bool - // totalCount holds the count of the edges above. - totalCount [1]map[string]int - - namedSigners map[string][]*Signer -} - -// SignersOrErr returns the Signers value or an error if the edge -// was not loaded in eager-loading. -func (e CorrectnessReportEdges) SignersOrErr() ([]*Signer, error) { - if e.loadedTypes[0] { - return e.Signers, nil - } - return nil, &NotLoadedError{edge: "signers"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*CorrectnessReport) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case correctnessreport.FieldSignature, correctnessreport.FieldHash, correctnessreport.FieldTopic: - values[i] = new([]byte) - case correctnessreport.FieldVoted: - values[i] = new(helpers.BigInt) - case correctnessreport.FieldCorrect, correctnessreport.FieldConsensus: - values[i] = new(sql.NullBool) - case correctnessreport.FieldID, correctnessreport.FieldSignersCount, correctnessreport.FieldTimestamp: - 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 CorrectnessReport fields. -func (cr *CorrectnessReport) 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 correctnessreport.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) - } - cr.ID = int(value.Int64) - case correctnessreport.FieldSignersCount: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field signersCount", values[i]) - } else if value.Valid { - cr.SignersCount = uint64(value.Int64) - } - case correctnessreport.FieldTimestamp: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field timestamp", values[i]) - } else if value.Valid { - cr.Timestamp = uint64(value.Int64) - } - case correctnessreport.FieldSignature: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field signature", values[i]) - } else if value != nil { - cr.Signature = *value - } - case correctnessreport.FieldHash: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field hash", values[i]) - } else if value != nil { - cr.Hash = *value - } - case correctnessreport.FieldTopic: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field topic", values[i]) - } else if value != nil { - cr.Topic = *value - } - case correctnessreport.FieldCorrect: - if value, ok := values[i].(*sql.NullBool); !ok { - return fmt.Errorf("unexpected type %T for field correct", values[i]) - } else if value.Valid { - cr.Correct = value.Bool - } - case correctnessreport.FieldConsensus: - if value, ok := values[i].(*sql.NullBool); !ok { - return fmt.Errorf("unexpected type %T for field consensus", values[i]) - } else if value.Valid { - cr.Consensus = value.Bool - } - case correctnessreport.FieldVoted: - if value, ok := values[i].(*helpers.BigInt); !ok { - return fmt.Errorf("unexpected type %T for field voted", values[i]) - } else if value != nil { - cr.Voted = value - } - default: - cr.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the CorrectnessReport. -// This includes values selected through modifiers, order, etc. -func (cr *CorrectnessReport) Value(name string) (ent.Value, error) { - return cr.selectValues.Get(name) -} - -// QuerySigners queries the "signers" edge of the CorrectnessReport entity. -func (cr *CorrectnessReport) QuerySigners() *SignerQuery { - return NewCorrectnessReportClient(cr.config).QuerySigners(cr) -} - -// Update returns a builder for updating this CorrectnessReport. -// Note that you need to call CorrectnessReport.Unwrap() before calling this method if this CorrectnessReport -// was returned from a transaction, and the transaction was committed or rolled back. -func (cr *CorrectnessReport) Update() *CorrectnessReportUpdateOne { - return NewCorrectnessReportClient(cr.config).UpdateOne(cr) -} - -// Unwrap unwraps the CorrectnessReport 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 (cr *CorrectnessReport) Unwrap() *CorrectnessReport { - _tx, ok := cr.config.driver.(*txDriver) - if !ok { - panic("ent: CorrectnessReport is not a transactional entity") - } - cr.config.driver = _tx.drv - return cr -} - -// String implements the fmt.Stringer. -func (cr *CorrectnessReport) String() string { - var builder strings.Builder - builder.WriteString("CorrectnessReport(") - builder.WriteString(fmt.Sprintf("id=%v, ", cr.ID)) - builder.WriteString("signersCount=") - builder.WriteString(fmt.Sprintf("%v", cr.SignersCount)) - builder.WriteString(", ") - builder.WriteString("timestamp=") - builder.WriteString(fmt.Sprintf("%v", cr.Timestamp)) - builder.WriteString(", ") - builder.WriteString("signature=") - builder.WriteString(fmt.Sprintf("%v", cr.Signature)) - builder.WriteString(", ") - builder.WriteString("hash=") - builder.WriteString(fmt.Sprintf("%v", cr.Hash)) - builder.WriteString(", ") - builder.WriteString("topic=") - builder.WriteString(fmt.Sprintf("%v", cr.Topic)) - builder.WriteString(", ") - builder.WriteString("correct=") - builder.WriteString(fmt.Sprintf("%v", cr.Correct)) - builder.WriteString(", ") - builder.WriteString("consensus=") - builder.WriteString(fmt.Sprintf("%v", cr.Consensus)) - builder.WriteString(", ") - builder.WriteString("voted=") - builder.WriteString(fmt.Sprintf("%v", cr.Voted)) - builder.WriteByte(')') - return builder.String() -} - -// NamedSigners returns the Signers named value or an error if the edge was not -// loaded in eager-loading with this name. -func (cr *CorrectnessReport) NamedSigners(name string) ([]*Signer, error) { - if cr.Edges.namedSigners == nil { - return nil, &NotLoadedError{edge: name} - } - nodes, ok := cr.Edges.namedSigners[name] - if !ok { - return nil, &NotLoadedError{edge: name} - } - return nodes, nil -} - -func (cr *CorrectnessReport) appendNamedSigners(name string, edges ...*Signer) { - if cr.Edges.namedSigners == nil { - cr.Edges.namedSigners = make(map[string][]*Signer) - } - if len(edges) == 0 { - cr.Edges.namedSigners[name] = []*Signer{} - } else { - cr.Edges.namedSigners[name] = append(cr.Edges.namedSigners[name], edges...) - } -} - -// CorrectnessReports is a parsable slice of CorrectnessReport. -type CorrectnessReports []*CorrectnessReport diff --git a/internal/ent/correctnessreport/correctnessreport.go b/internal/ent/correctnessreport/correctnessreport.go deleted file mode 100644 index bc6ba45c..00000000 --- a/internal/ent/correctnessreport/correctnessreport.go +++ /dev/null @@ -1,134 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package correctnessreport - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the correctnessreport type in the database. - Label = "correctness_report" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldSignersCount holds the string denoting the signerscount field in the database. - FieldSignersCount = "signers_count" - // FieldTimestamp holds the string denoting the timestamp field in the database. - FieldTimestamp = "timestamp" - // FieldSignature holds the string denoting the signature field in the database. - FieldSignature = "signature" - // FieldHash holds the string denoting the hash field in the database. - FieldHash = "hash" - // FieldTopic holds the string denoting the topic field in the database. - FieldTopic = "topic" - // FieldCorrect holds the string denoting the correct field in the database. - FieldCorrect = "correct" - // FieldConsensus holds the string denoting the consensus field in the database. - FieldConsensus = "consensus" - // FieldVoted holds the string denoting the voted field in the database. - FieldVoted = "voted" - // EdgeSigners holds the string denoting the signers edge name in mutations. - EdgeSigners = "signers" - // Table holds the table name of the correctnessreport in the database. - Table = "correctness_reports" - // SignersTable is the table that holds the signers relation/edge. The primary key declared below. - SignersTable = "correctness_report_signers" - // SignersInverseTable is the table name for the Signer entity. - // It exists in this package in order to avoid circular dependency with the "signer" package. - SignersInverseTable = "signers" -) - -// Columns holds all SQL columns for correctnessreport fields. -var Columns = []string{ - FieldID, - FieldSignersCount, - FieldTimestamp, - FieldSignature, - FieldHash, - FieldTopic, - FieldCorrect, - FieldConsensus, - FieldVoted, -} - -var ( - // SignersPrimaryKey and SignersColumn2 are the table columns denoting the - // primary key for the signers relation (M2M). - SignersPrimaryKey = []string{"correctness_report_id", "signer_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 -} - -var ( - // SignatureValidator is a validator for the "signature" field. It is called by the builders before save. - SignatureValidator func([]byte) error - // HashValidator is a validator for the "hash" field. It is called by the builders before save. - HashValidator func([]byte) error - // TopicValidator is a validator for the "topic" field. It is called by the builders before save. - TopicValidator func([]byte) error - // DefaultConsensus holds the default value on creation for the "consensus" field. - DefaultConsensus bool -) - -// OrderOption defines the ordering options for the CorrectnessReport 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() -} - -// BySignersCountField orders the results by the signersCount field. -func BySignersCountField(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSignersCount, opts...).ToFunc() -} - -// ByTimestamp orders the results by the timestamp field. -func ByTimestamp(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldTimestamp, opts...).ToFunc() -} - -// ByCorrect orders the results by the correct field. -func ByCorrect(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCorrect, opts...).ToFunc() -} - -// ByConsensus orders the results by the consensus field. -func ByConsensus(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldConsensus, opts...).ToFunc() -} - -// ByVoted orders the results by the voted field. -func ByVoted(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldVoted, opts...).ToFunc() -} - -// BySignersCount orders the results by signers count. -func BySignersCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newSignersStep(), opts...) - } -} - -// BySigners orders the results by signers terms. -func BySigners(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newSignersStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newSignersStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(SignersInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, SignersTable, SignersPrimaryKey...), - ) -} diff --git a/internal/ent/correctnessreport/where.go b/internal/ent/correctnessreport/where.go deleted file mode 100644 index 17bd1bd8..00000000 --- a/internal/ent/correctnessreport/where.go +++ /dev/null @@ -1,393 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package correctnessreport - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLTE(FieldID, id)) -} - -// SignersCount applies equality check predicate on the "signersCount" field. It's identical to SignersCountEQ. -func SignersCount(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldSignersCount, v)) -} - -// Timestamp applies equality check predicate on the "timestamp" field. It's identical to TimestampEQ. -func Timestamp(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldTimestamp, v)) -} - -// Signature applies equality check predicate on the "signature" field. It's identical to SignatureEQ. -func Signature(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldSignature, v)) -} - -// Hash applies equality check predicate on the "hash" field. It's identical to HashEQ. -func Hash(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldHash, v)) -} - -// Topic applies equality check predicate on the "topic" field. It's identical to TopicEQ. -func Topic(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldTopic, v)) -} - -// Correct applies equality check predicate on the "correct" field. It's identical to CorrectEQ. -func Correct(v bool) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldCorrect, v)) -} - -// Consensus applies equality check predicate on the "consensus" field. It's identical to ConsensusEQ. -func Consensus(v bool) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldConsensus, v)) -} - -// Voted applies equality check predicate on the "voted" field. It's identical to VotedEQ. -func Voted(v *helpers.BigInt) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldVoted, v)) -} - -// SignersCountEQ applies the EQ predicate on the "signersCount" field. -func SignersCountEQ(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldSignersCount, v)) -} - -// SignersCountNEQ applies the NEQ predicate on the "signersCount" field. -func SignersCountNEQ(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNEQ(FieldSignersCount, v)) -} - -// SignersCountIn applies the In predicate on the "signersCount" field. -func SignersCountIn(vs ...uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldIn(FieldSignersCount, vs...)) -} - -// SignersCountNotIn applies the NotIn predicate on the "signersCount" field. -func SignersCountNotIn(vs ...uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNotIn(FieldSignersCount, vs...)) -} - -// SignersCountGT applies the GT predicate on the "signersCount" field. -func SignersCountGT(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGT(FieldSignersCount, v)) -} - -// SignersCountGTE applies the GTE predicate on the "signersCount" field. -func SignersCountGTE(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGTE(FieldSignersCount, v)) -} - -// SignersCountLT applies the LT predicate on the "signersCount" field. -func SignersCountLT(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLT(FieldSignersCount, v)) -} - -// SignersCountLTE applies the LTE predicate on the "signersCount" field. -func SignersCountLTE(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLTE(FieldSignersCount, v)) -} - -// TimestampEQ applies the EQ predicate on the "timestamp" field. -func TimestampEQ(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldTimestamp, v)) -} - -// TimestampNEQ applies the NEQ predicate on the "timestamp" field. -func TimestampNEQ(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNEQ(FieldTimestamp, v)) -} - -// TimestampIn applies the In predicate on the "timestamp" field. -func TimestampIn(vs ...uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldIn(FieldTimestamp, vs...)) -} - -// TimestampNotIn applies the NotIn predicate on the "timestamp" field. -func TimestampNotIn(vs ...uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNotIn(FieldTimestamp, vs...)) -} - -// TimestampGT applies the GT predicate on the "timestamp" field. -func TimestampGT(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGT(FieldTimestamp, v)) -} - -// TimestampGTE applies the GTE predicate on the "timestamp" field. -func TimestampGTE(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGTE(FieldTimestamp, v)) -} - -// TimestampLT applies the LT predicate on the "timestamp" field. -func TimestampLT(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLT(FieldTimestamp, v)) -} - -// TimestampLTE applies the LTE predicate on the "timestamp" field. -func TimestampLTE(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLTE(FieldTimestamp, v)) -} - -// SignatureEQ applies the EQ predicate on the "signature" field. -func SignatureEQ(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldSignature, v)) -} - -// SignatureNEQ applies the NEQ predicate on the "signature" field. -func SignatureNEQ(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNEQ(FieldSignature, v)) -} - -// SignatureIn applies the In predicate on the "signature" field. -func SignatureIn(vs ...[]byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldIn(FieldSignature, vs...)) -} - -// SignatureNotIn applies the NotIn predicate on the "signature" field. -func SignatureNotIn(vs ...[]byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNotIn(FieldSignature, vs...)) -} - -// SignatureGT applies the GT predicate on the "signature" field. -func SignatureGT(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGT(FieldSignature, v)) -} - -// SignatureGTE applies the GTE predicate on the "signature" field. -func SignatureGTE(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGTE(FieldSignature, v)) -} - -// SignatureLT applies the LT predicate on the "signature" field. -func SignatureLT(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLT(FieldSignature, v)) -} - -// SignatureLTE applies the LTE predicate on the "signature" field. -func SignatureLTE(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLTE(FieldSignature, v)) -} - -// HashEQ applies the EQ predicate on the "hash" field. -func HashEQ(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldHash, v)) -} - -// HashNEQ applies the NEQ predicate on the "hash" field. -func HashNEQ(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNEQ(FieldHash, v)) -} - -// HashIn applies the In predicate on the "hash" field. -func HashIn(vs ...[]byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldIn(FieldHash, vs...)) -} - -// HashNotIn applies the NotIn predicate on the "hash" field. -func HashNotIn(vs ...[]byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNotIn(FieldHash, vs...)) -} - -// HashGT applies the GT predicate on the "hash" field. -func HashGT(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGT(FieldHash, v)) -} - -// HashGTE applies the GTE predicate on the "hash" field. -func HashGTE(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGTE(FieldHash, v)) -} - -// HashLT applies the LT predicate on the "hash" field. -func HashLT(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLT(FieldHash, v)) -} - -// HashLTE applies the LTE predicate on the "hash" field. -func HashLTE(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLTE(FieldHash, v)) -} - -// TopicEQ applies the EQ predicate on the "topic" field. -func TopicEQ(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldTopic, v)) -} - -// TopicNEQ applies the NEQ predicate on the "topic" field. -func TopicNEQ(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNEQ(FieldTopic, v)) -} - -// TopicIn applies the In predicate on the "topic" field. -func TopicIn(vs ...[]byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldIn(FieldTopic, vs...)) -} - -// TopicNotIn applies the NotIn predicate on the "topic" field. -func TopicNotIn(vs ...[]byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNotIn(FieldTopic, vs...)) -} - -// TopicGT applies the GT predicate on the "topic" field. -func TopicGT(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGT(FieldTopic, v)) -} - -// TopicGTE applies the GTE predicate on the "topic" field. -func TopicGTE(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGTE(FieldTopic, v)) -} - -// TopicLT applies the LT predicate on the "topic" field. -func TopicLT(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLT(FieldTopic, v)) -} - -// TopicLTE applies the LTE predicate on the "topic" field. -func TopicLTE(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLTE(FieldTopic, v)) -} - -// CorrectEQ applies the EQ predicate on the "correct" field. -func CorrectEQ(v bool) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldCorrect, v)) -} - -// CorrectNEQ applies the NEQ predicate on the "correct" field. -func CorrectNEQ(v bool) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNEQ(FieldCorrect, v)) -} - -// ConsensusEQ applies the EQ predicate on the "consensus" field. -func ConsensusEQ(v bool) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldConsensus, v)) -} - -// ConsensusNEQ applies the NEQ predicate on the "consensus" field. -func ConsensusNEQ(v bool) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNEQ(FieldConsensus, v)) -} - -// VotedEQ applies the EQ predicate on the "voted" field. -func VotedEQ(v *helpers.BigInt) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldVoted, v)) -} - -// VotedNEQ applies the NEQ predicate on the "voted" field. -func VotedNEQ(v *helpers.BigInt) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNEQ(FieldVoted, v)) -} - -// VotedIn applies the In predicate on the "voted" field. -func VotedIn(vs ...*helpers.BigInt) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldIn(FieldVoted, vs...)) -} - -// VotedNotIn applies the NotIn predicate on the "voted" field. -func VotedNotIn(vs ...*helpers.BigInt) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNotIn(FieldVoted, vs...)) -} - -// VotedGT applies the GT predicate on the "voted" field. -func VotedGT(v *helpers.BigInt) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGT(FieldVoted, v)) -} - -// VotedGTE applies the GTE predicate on the "voted" field. -func VotedGTE(v *helpers.BigInt) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGTE(FieldVoted, v)) -} - -// VotedLT applies the LT predicate on the "voted" field. -func VotedLT(v *helpers.BigInt) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLT(FieldVoted, v)) -} - -// VotedLTE applies the LTE predicate on the "voted" field. -func VotedLTE(v *helpers.BigInt) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLTE(FieldVoted, v)) -} - -// HasSigners applies the HasEdge predicate on the "signers" edge. -func HasSigners() predicate.CorrectnessReport { - return predicate.CorrectnessReport(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, SignersTable, SignersPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasSignersWith applies the HasEdge predicate on the "signers" edge with a given conditions (other predicates). -func HasSignersWith(preds ...predicate.Signer) predicate.CorrectnessReport { - return predicate.CorrectnessReport(func(s *sql.Selector) { - step := newSignersStep() - 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.CorrectnessReport) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.CorrectnessReport) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.CorrectnessReport) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.NotPredicates(p)) -} diff --git a/internal/ent/correctnessreport_create.go b/internal/ent/correctnessreport_create.go deleted file mode 100644 index 7a8ea285..00000000 --- a/internal/ent/correctnessreport_create.go +++ /dev/null @@ -1,934 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// CorrectnessReportCreate is the builder for creating a CorrectnessReport entity. -type CorrectnessReportCreate struct { - config - mutation *CorrectnessReportMutation - hooks []Hook - conflict []sql.ConflictOption -} - -// SetSignersCount sets the "signersCount" field. -func (crc *CorrectnessReportCreate) SetSignersCount(u uint64) *CorrectnessReportCreate { - crc.mutation.SetSignersCount(u) - return crc -} - -// SetTimestamp sets the "timestamp" field. -func (crc *CorrectnessReportCreate) SetTimestamp(u uint64) *CorrectnessReportCreate { - crc.mutation.SetTimestamp(u) - return crc -} - -// SetSignature sets the "signature" field. -func (crc *CorrectnessReportCreate) SetSignature(b []byte) *CorrectnessReportCreate { - crc.mutation.SetSignature(b) - return crc -} - -// SetHash sets the "hash" field. -func (crc *CorrectnessReportCreate) SetHash(b []byte) *CorrectnessReportCreate { - crc.mutation.SetHash(b) - return crc -} - -// SetTopic sets the "topic" field. -func (crc *CorrectnessReportCreate) SetTopic(b []byte) *CorrectnessReportCreate { - crc.mutation.SetTopic(b) - return crc -} - -// SetCorrect sets the "correct" field. -func (crc *CorrectnessReportCreate) SetCorrect(b bool) *CorrectnessReportCreate { - crc.mutation.SetCorrect(b) - return crc -} - -// SetConsensus sets the "consensus" field. -func (crc *CorrectnessReportCreate) SetConsensus(b bool) *CorrectnessReportCreate { - crc.mutation.SetConsensus(b) - return crc -} - -// SetNillableConsensus sets the "consensus" field if the given value is not nil. -func (crc *CorrectnessReportCreate) SetNillableConsensus(b *bool) *CorrectnessReportCreate { - if b != nil { - crc.SetConsensus(*b) - } - return crc -} - -// SetVoted sets the "voted" field. -func (crc *CorrectnessReportCreate) SetVoted(hi *helpers.BigInt) *CorrectnessReportCreate { - crc.mutation.SetVoted(hi) - return crc -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by IDs. -func (crc *CorrectnessReportCreate) AddSignerIDs(ids ...int) *CorrectnessReportCreate { - crc.mutation.AddSignerIDs(ids...) - return crc -} - -// AddSigners adds the "signers" edges to the Signer entity. -func (crc *CorrectnessReportCreate) AddSigners(s ...*Signer) *CorrectnessReportCreate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return crc.AddSignerIDs(ids...) -} - -// Mutation returns the CorrectnessReportMutation object of the builder. -func (crc *CorrectnessReportCreate) Mutation() *CorrectnessReportMutation { - return crc.mutation -} - -// Save creates the CorrectnessReport in the database. -func (crc *CorrectnessReportCreate) Save(ctx context.Context) (*CorrectnessReport, error) { - crc.defaults() - return withHooks(ctx, crc.sqlSave, crc.mutation, crc.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (crc *CorrectnessReportCreate) SaveX(ctx context.Context) *CorrectnessReport { - v, err := crc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (crc *CorrectnessReportCreate) Exec(ctx context.Context) error { - _, err := crc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (crc *CorrectnessReportCreate) ExecX(ctx context.Context) { - if err := crc.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (crc *CorrectnessReportCreate) defaults() { - if _, ok := crc.mutation.Consensus(); !ok { - v := correctnessreport.DefaultConsensus - crc.mutation.SetConsensus(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (crc *CorrectnessReportCreate) check() error { - if _, ok := crc.mutation.SignersCount(); !ok { - return &ValidationError{Name: "signersCount", err: errors.New(`ent: missing required field "CorrectnessReport.signersCount"`)} - } - if _, ok := crc.mutation.Timestamp(); !ok { - return &ValidationError{Name: "timestamp", err: errors.New(`ent: missing required field "CorrectnessReport.timestamp"`)} - } - if _, ok := crc.mutation.Signature(); !ok { - return &ValidationError{Name: "signature", err: errors.New(`ent: missing required field "CorrectnessReport.signature"`)} - } - if v, ok := crc.mutation.Signature(); ok { - if err := correctnessreport.SignatureValidator(v); err != nil { - return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "CorrectnessReport.signature": %w`, err)} - } - } - if _, ok := crc.mutation.Hash(); !ok { - return &ValidationError{Name: "hash", err: errors.New(`ent: missing required field "CorrectnessReport.hash"`)} - } - if v, ok := crc.mutation.Hash(); ok { - if err := correctnessreport.HashValidator(v); err != nil { - return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "CorrectnessReport.hash": %w`, err)} - } - } - if _, ok := crc.mutation.Topic(); !ok { - return &ValidationError{Name: "topic", err: errors.New(`ent: missing required field "CorrectnessReport.topic"`)} - } - if v, ok := crc.mutation.Topic(); ok { - if err := correctnessreport.TopicValidator(v); err != nil { - return &ValidationError{Name: "topic", err: fmt.Errorf(`ent: validator failed for field "CorrectnessReport.topic": %w`, err)} - } - } - if _, ok := crc.mutation.Correct(); !ok { - return &ValidationError{Name: "correct", err: errors.New(`ent: missing required field "CorrectnessReport.correct"`)} - } - if _, ok := crc.mutation.Consensus(); !ok { - return &ValidationError{Name: "consensus", err: errors.New(`ent: missing required field "CorrectnessReport.consensus"`)} - } - if _, ok := crc.mutation.Voted(); !ok { - return &ValidationError{Name: "voted", err: errors.New(`ent: missing required field "CorrectnessReport.voted"`)} - } - if len(crc.mutation.SignersIDs()) == 0 { - return &ValidationError{Name: "signers", err: errors.New(`ent: missing required edge "CorrectnessReport.signers"`)} - } - return nil -} - -func (crc *CorrectnessReportCreate) sqlSave(ctx context.Context) (*CorrectnessReport, error) { - if err := crc.check(); err != nil { - return nil, err - } - _node, _spec := crc.createSpec() - if err := sqlgraph.CreateNode(ctx, crc.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) - crc.mutation.id = &_node.ID - crc.mutation.done = true - return _node, nil -} - -func (crc *CorrectnessReportCreate) createSpec() (*CorrectnessReport, *sqlgraph.CreateSpec) { - var ( - _node = &CorrectnessReport{config: crc.config} - _spec = sqlgraph.NewCreateSpec(correctnessreport.Table, sqlgraph.NewFieldSpec(correctnessreport.FieldID, field.TypeInt)) - ) - _spec.OnConflict = crc.conflict - if value, ok := crc.mutation.SignersCount(); ok { - _spec.SetField(correctnessreport.FieldSignersCount, field.TypeUint64, value) - _node.SignersCount = value - } - if value, ok := crc.mutation.Timestamp(); ok { - _spec.SetField(correctnessreport.FieldTimestamp, field.TypeUint64, value) - _node.Timestamp = value - } - if value, ok := crc.mutation.Signature(); ok { - _spec.SetField(correctnessreport.FieldSignature, field.TypeBytes, value) - _node.Signature = value - } - if value, ok := crc.mutation.Hash(); ok { - _spec.SetField(correctnessreport.FieldHash, field.TypeBytes, value) - _node.Hash = value - } - if value, ok := crc.mutation.Topic(); ok { - _spec.SetField(correctnessreport.FieldTopic, field.TypeBytes, value) - _node.Topic = value - } - if value, ok := crc.mutation.Correct(); ok { - _spec.SetField(correctnessreport.FieldCorrect, field.TypeBool, value) - _node.Correct = value - } - if value, ok := crc.mutation.Consensus(); ok { - _spec.SetField(correctnessreport.FieldConsensus, field.TypeBool, value) - _node.Consensus = value - } - if value, ok := crc.mutation.Voted(); ok { - _spec.SetField(correctnessreport.FieldVoted, field.TypeUint, value) - _node.Voted = value - } - if nodes := crc.mutation.SignersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: correctnessreport.SignersTable, - Columns: correctnessreport.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.CorrectnessReport.Create(). -// SetSignersCount(v). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.CorrectnessReportUpsert) { -// SetSignersCount(v+v). -// }). -// Exec(ctx) -func (crc *CorrectnessReportCreate) OnConflict(opts ...sql.ConflictOption) *CorrectnessReportUpsertOne { - crc.conflict = opts - return &CorrectnessReportUpsertOne{ - create: crc, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.CorrectnessReport.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (crc *CorrectnessReportCreate) OnConflictColumns(columns ...string) *CorrectnessReportUpsertOne { - crc.conflict = append(crc.conflict, sql.ConflictColumns(columns...)) - return &CorrectnessReportUpsertOne{ - create: crc, - } -} - -type ( - // CorrectnessReportUpsertOne is the builder for "upsert"-ing - // one CorrectnessReport node. - CorrectnessReportUpsertOne struct { - create *CorrectnessReportCreate - } - - // CorrectnessReportUpsert is the "OnConflict" setter. - CorrectnessReportUpsert struct { - *sql.UpdateSet - } -) - -// SetSignersCount sets the "signersCount" field. -func (u *CorrectnessReportUpsert) SetSignersCount(v uint64) *CorrectnessReportUpsert { - u.Set(correctnessreport.FieldSignersCount, v) - return u -} - -// UpdateSignersCount sets the "signersCount" field to the value that was provided on create. -func (u *CorrectnessReportUpsert) UpdateSignersCount() *CorrectnessReportUpsert { - u.SetExcluded(correctnessreport.FieldSignersCount) - return u -} - -// AddSignersCount adds v to the "signersCount" field. -func (u *CorrectnessReportUpsert) AddSignersCount(v uint64) *CorrectnessReportUpsert { - u.Add(correctnessreport.FieldSignersCount, v) - return u -} - -// SetTimestamp sets the "timestamp" field. -func (u *CorrectnessReportUpsert) SetTimestamp(v uint64) *CorrectnessReportUpsert { - u.Set(correctnessreport.FieldTimestamp, v) - return u -} - -// UpdateTimestamp sets the "timestamp" field to the value that was provided on create. -func (u *CorrectnessReportUpsert) UpdateTimestamp() *CorrectnessReportUpsert { - u.SetExcluded(correctnessreport.FieldTimestamp) - return u -} - -// AddTimestamp adds v to the "timestamp" field. -func (u *CorrectnessReportUpsert) AddTimestamp(v uint64) *CorrectnessReportUpsert { - u.Add(correctnessreport.FieldTimestamp, v) - return u -} - -// SetSignature sets the "signature" field. -func (u *CorrectnessReportUpsert) SetSignature(v []byte) *CorrectnessReportUpsert { - u.Set(correctnessreport.FieldSignature, v) - return u -} - -// UpdateSignature sets the "signature" field to the value that was provided on create. -func (u *CorrectnessReportUpsert) UpdateSignature() *CorrectnessReportUpsert { - u.SetExcluded(correctnessreport.FieldSignature) - return u -} - -// SetHash sets the "hash" field. -func (u *CorrectnessReportUpsert) SetHash(v []byte) *CorrectnessReportUpsert { - u.Set(correctnessreport.FieldHash, v) - return u -} - -// UpdateHash sets the "hash" field to the value that was provided on create. -func (u *CorrectnessReportUpsert) UpdateHash() *CorrectnessReportUpsert { - u.SetExcluded(correctnessreport.FieldHash) - return u -} - -// SetTopic sets the "topic" field. -func (u *CorrectnessReportUpsert) SetTopic(v []byte) *CorrectnessReportUpsert { - u.Set(correctnessreport.FieldTopic, v) - return u -} - -// UpdateTopic sets the "topic" field to the value that was provided on create. -func (u *CorrectnessReportUpsert) UpdateTopic() *CorrectnessReportUpsert { - u.SetExcluded(correctnessreport.FieldTopic) - return u -} - -// SetCorrect sets the "correct" field. -func (u *CorrectnessReportUpsert) SetCorrect(v bool) *CorrectnessReportUpsert { - u.Set(correctnessreport.FieldCorrect, v) - return u -} - -// UpdateCorrect sets the "correct" field to the value that was provided on create. -func (u *CorrectnessReportUpsert) UpdateCorrect() *CorrectnessReportUpsert { - u.SetExcluded(correctnessreport.FieldCorrect) - return u -} - -// SetConsensus sets the "consensus" field. -func (u *CorrectnessReportUpsert) SetConsensus(v bool) *CorrectnessReportUpsert { - u.Set(correctnessreport.FieldConsensus, v) - return u -} - -// UpdateConsensus sets the "consensus" field to the value that was provided on create. -func (u *CorrectnessReportUpsert) UpdateConsensus() *CorrectnessReportUpsert { - u.SetExcluded(correctnessreport.FieldConsensus) - return u -} - -// SetVoted sets the "voted" field. -func (u *CorrectnessReportUpsert) SetVoted(v *helpers.BigInt) *CorrectnessReportUpsert { - u.Set(correctnessreport.FieldVoted, v) - return u -} - -// UpdateVoted sets the "voted" field to the value that was provided on create. -func (u *CorrectnessReportUpsert) UpdateVoted() *CorrectnessReportUpsert { - u.SetExcluded(correctnessreport.FieldVoted) - return u -} - -// UpdateNewValues updates the mutable fields using the new values that were set on create. -// Using this option is equivalent to using: -// -// client.CorrectnessReport.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *CorrectnessReportUpsertOne) UpdateNewValues() *CorrectnessReportUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.CorrectnessReport.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *CorrectnessReportUpsertOne) Ignore() *CorrectnessReportUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *CorrectnessReportUpsertOne) DoNothing() *CorrectnessReportUpsertOne { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the CorrectnessReportCreate.OnConflict -// documentation for more info. -func (u *CorrectnessReportUpsertOne) Update(set func(*CorrectnessReportUpsert)) *CorrectnessReportUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&CorrectnessReportUpsert{UpdateSet: update}) - })) - return u -} - -// SetSignersCount sets the "signersCount" field. -func (u *CorrectnessReportUpsertOne) SetSignersCount(v uint64) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetSignersCount(v) - }) -} - -// AddSignersCount adds v to the "signersCount" field. -func (u *CorrectnessReportUpsertOne) AddSignersCount(v uint64) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.AddSignersCount(v) - }) -} - -// UpdateSignersCount sets the "signersCount" field to the value that was provided on create. -func (u *CorrectnessReportUpsertOne) UpdateSignersCount() *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateSignersCount() - }) -} - -// SetTimestamp sets the "timestamp" field. -func (u *CorrectnessReportUpsertOne) SetTimestamp(v uint64) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetTimestamp(v) - }) -} - -// AddTimestamp adds v to the "timestamp" field. -func (u *CorrectnessReportUpsertOne) AddTimestamp(v uint64) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.AddTimestamp(v) - }) -} - -// UpdateTimestamp sets the "timestamp" field to the value that was provided on create. -func (u *CorrectnessReportUpsertOne) UpdateTimestamp() *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateTimestamp() - }) -} - -// SetSignature sets the "signature" field. -func (u *CorrectnessReportUpsertOne) SetSignature(v []byte) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetSignature(v) - }) -} - -// UpdateSignature sets the "signature" field to the value that was provided on create. -func (u *CorrectnessReportUpsertOne) UpdateSignature() *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateSignature() - }) -} - -// SetHash sets the "hash" field. -func (u *CorrectnessReportUpsertOne) SetHash(v []byte) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetHash(v) - }) -} - -// UpdateHash sets the "hash" field to the value that was provided on create. -func (u *CorrectnessReportUpsertOne) UpdateHash() *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateHash() - }) -} - -// SetTopic sets the "topic" field. -func (u *CorrectnessReportUpsertOne) SetTopic(v []byte) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetTopic(v) - }) -} - -// UpdateTopic sets the "topic" field to the value that was provided on create. -func (u *CorrectnessReportUpsertOne) UpdateTopic() *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateTopic() - }) -} - -// SetCorrect sets the "correct" field. -func (u *CorrectnessReportUpsertOne) SetCorrect(v bool) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetCorrect(v) - }) -} - -// UpdateCorrect sets the "correct" field to the value that was provided on create. -func (u *CorrectnessReportUpsertOne) UpdateCorrect() *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateCorrect() - }) -} - -// SetConsensus sets the "consensus" field. -func (u *CorrectnessReportUpsertOne) SetConsensus(v bool) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetConsensus(v) - }) -} - -// UpdateConsensus sets the "consensus" field to the value that was provided on create. -func (u *CorrectnessReportUpsertOne) UpdateConsensus() *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateConsensus() - }) -} - -// SetVoted sets the "voted" field. -func (u *CorrectnessReportUpsertOne) SetVoted(v *helpers.BigInt) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetVoted(v) - }) -} - -// UpdateVoted sets the "voted" field to the value that was provided on create. -func (u *CorrectnessReportUpsertOne) UpdateVoted() *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateVoted() - }) -} - -// Exec executes the query. -func (u *CorrectnessReportUpsertOne) Exec(ctx context.Context) error { - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for CorrectnessReportCreate.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *CorrectnessReportUpsertOne) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} - -// Exec executes the UPSERT query and returns the inserted/updated ID. -func (u *CorrectnessReportUpsertOne) ID(ctx context.Context) (id int, err error) { - node, err := u.create.Save(ctx) - if err != nil { - return id, err - } - return node.ID, nil -} - -// IDX is like ID, but panics if an error occurs. -func (u *CorrectnessReportUpsertOne) IDX(ctx context.Context) int { - id, err := u.ID(ctx) - if err != nil { - panic(err) - } - return id -} - -// CorrectnessReportCreateBulk is the builder for creating many CorrectnessReport entities in bulk. -type CorrectnessReportCreateBulk struct { - config - err error - builders []*CorrectnessReportCreate - conflict []sql.ConflictOption -} - -// Save creates the CorrectnessReport entities in the database. -func (crcb *CorrectnessReportCreateBulk) Save(ctx context.Context) ([]*CorrectnessReport, error) { - if crcb.err != nil { - return nil, crcb.err - } - specs := make([]*sqlgraph.CreateSpec, len(crcb.builders)) - nodes := make([]*CorrectnessReport, len(crcb.builders)) - mutators := make([]Mutator, len(crcb.builders)) - for i := range crcb.builders { - func(i int, root context.Context) { - builder := crcb.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*CorrectnessReportMutation) - 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, crcb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - spec.OnConflict = crcb.conflict - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, crcb.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, crcb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (crcb *CorrectnessReportCreateBulk) SaveX(ctx context.Context) []*CorrectnessReport { - v, err := crcb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (crcb *CorrectnessReportCreateBulk) Exec(ctx context.Context) error { - _, err := crcb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (crcb *CorrectnessReportCreateBulk) ExecX(ctx context.Context) { - if err := crcb.Exec(ctx); err != nil { - panic(err) - } -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.CorrectnessReport.CreateBulk(builders...). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.CorrectnessReportUpsert) { -// SetSignersCount(v+v). -// }). -// Exec(ctx) -func (crcb *CorrectnessReportCreateBulk) OnConflict(opts ...sql.ConflictOption) *CorrectnessReportUpsertBulk { - crcb.conflict = opts - return &CorrectnessReportUpsertBulk{ - create: crcb, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.CorrectnessReport.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (crcb *CorrectnessReportCreateBulk) OnConflictColumns(columns ...string) *CorrectnessReportUpsertBulk { - crcb.conflict = append(crcb.conflict, sql.ConflictColumns(columns...)) - return &CorrectnessReportUpsertBulk{ - create: crcb, - } -} - -// CorrectnessReportUpsertBulk is the builder for "upsert"-ing -// a bulk of CorrectnessReport nodes. -type CorrectnessReportUpsertBulk struct { - create *CorrectnessReportCreateBulk -} - -// UpdateNewValues updates the mutable fields using the new values that -// were set on create. Using this option is equivalent to using: -// -// client.CorrectnessReport.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *CorrectnessReportUpsertBulk) UpdateNewValues() *CorrectnessReportUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.CorrectnessReport.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *CorrectnessReportUpsertBulk) Ignore() *CorrectnessReportUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *CorrectnessReportUpsertBulk) DoNothing() *CorrectnessReportUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the CorrectnessReportCreateBulk.OnConflict -// documentation for more info. -func (u *CorrectnessReportUpsertBulk) Update(set func(*CorrectnessReportUpsert)) *CorrectnessReportUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&CorrectnessReportUpsert{UpdateSet: update}) - })) - return u -} - -// SetSignersCount sets the "signersCount" field. -func (u *CorrectnessReportUpsertBulk) SetSignersCount(v uint64) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetSignersCount(v) - }) -} - -// AddSignersCount adds v to the "signersCount" field. -func (u *CorrectnessReportUpsertBulk) AddSignersCount(v uint64) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.AddSignersCount(v) - }) -} - -// UpdateSignersCount sets the "signersCount" field to the value that was provided on create. -func (u *CorrectnessReportUpsertBulk) UpdateSignersCount() *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateSignersCount() - }) -} - -// SetTimestamp sets the "timestamp" field. -func (u *CorrectnessReportUpsertBulk) SetTimestamp(v uint64) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetTimestamp(v) - }) -} - -// AddTimestamp adds v to the "timestamp" field. -func (u *CorrectnessReportUpsertBulk) AddTimestamp(v uint64) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.AddTimestamp(v) - }) -} - -// UpdateTimestamp sets the "timestamp" field to the value that was provided on create. -func (u *CorrectnessReportUpsertBulk) UpdateTimestamp() *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateTimestamp() - }) -} - -// SetSignature sets the "signature" field. -func (u *CorrectnessReportUpsertBulk) SetSignature(v []byte) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetSignature(v) - }) -} - -// UpdateSignature sets the "signature" field to the value that was provided on create. -func (u *CorrectnessReportUpsertBulk) UpdateSignature() *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateSignature() - }) -} - -// SetHash sets the "hash" field. -func (u *CorrectnessReportUpsertBulk) SetHash(v []byte) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetHash(v) - }) -} - -// UpdateHash sets the "hash" field to the value that was provided on create. -func (u *CorrectnessReportUpsertBulk) UpdateHash() *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateHash() - }) -} - -// SetTopic sets the "topic" field. -func (u *CorrectnessReportUpsertBulk) SetTopic(v []byte) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetTopic(v) - }) -} - -// UpdateTopic sets the "topic" field to the value that was provided on create. -func (u *CorrectnessReportUpsertBulk) UpdateTopic() *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateTopic() - }) -} - -// SetCorrect sets the "correct" field. -func (u *CorrectnessReportUpsertBulk) SetCorrect(v bool) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetCorrect(v) - }) -} - -// UpdateCorrect sets the "correct" field to the value that was provided on create. -func (u *CorrectnessReportUpsertBulk) UpdateCorrect() *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateCorrect() - }) -} - -// SetConsensus sets the "consensus" field. -func (u *CorrectnessReportUpsertBulk) SetConsensus(v bool) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetConsensus(v) - }) -} - -// UpdateConsensus sets the "consensus" field to the value that was provided on create. -func (u *CorrectnessReportUpsertBulk) UpdateConsensus() *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateConsensus() - }) -} - -// SetVoted sets the "voted" field. -func (u *CorrectnessReportUpsertBulk) SetVoted(v *helpers.BigInt) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetVoted(v) - }) -} - -// UpdateVoted sets the "voted" field to the value that was provided on create. -func (u *CorrectnessReportUpsertBulk) UpdateVoted() *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateVoted() - }) -} - -// Exec executes the query. -func (u *CorrectnessReportUpsertBulk) Exec(ctx context.Context) error { - if u.create.err != nil { - return u.create.err - } - for i, b := range u.create.builders { - if len(b.conflict) != 0 { - return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the CorrectnessReportCreateBulk instead", i) - } - } - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for CorrectnessReportCreateBulk.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *CorrectnessReportUpsertBulk) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/ent/correctnessreport_delete.go b/internal/ent/correctnessreport_delete.go deleted file mode 100644 index bff65704..00000000 --- a/internal/ent/correctnessreport_delete.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" -) - -// CorrectnessReportDelete is the builder for deleting a CorrectnessReport entity. -type CorrectnessReportDelete struct { - config - hooks []Hook - mutation *CorrectnessReportMutation -} - -// Where appends a list predicates to the CorrectnessReportDelete builder. -func (crd *CorrectnessReportDelete) Where(ps ...predicate.CorrectnessReport) *CorrectnessReportDelete { - crd.mutation.Where(ps...) - return crd -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (crd *CorrectnessReportDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, crd.sqlExec, crd.mutation, crd.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (crd *CorrectnessReportDelete) ExecX(ctx context.Context) int { - n, err := crd.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (crd *CorrectnessReportDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(correctnessreport.Table, sqlgraph.NewFieldSpec(correctnessreport.FieldID, field.TypeInt)) - if ps := crd.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, crd.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - crd.mutation.done = true - return affected, err -} - -// CorrectnessReportDeleteOne is the builder for deleting a single CorrectnessReport entity. -type CorrectnessReportDeleteOne struct { - crd *CorrectnessReportDelete -} - -// Where appends a list predicates to the CorrectnessReportDelete builder. -func (crdo *CorrectnessReportDeleteOne) Where(ps ...predicate.CorrectnessReport) *CorrectnessReportDeleteOne { - crdo.crd.mutation.Where(ps...) - return crdo -} - -// Exec executes the deletion query. -func (crdo *CorrectnessReportDeleteOne) Exec(ctx context.Context) error { - n, err := crdo.crd.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{correctnessreport.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (crdo *CorrectnessReportDeleteOne) ExecX(ctx context.Context) { - if err := crdo.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/ent/correctnessreport_query.go b/internal/ent/correctnessreport_query.go deleted file mode 100644 index 7c796519..00000000 --- a/internal/ent/correctnessreport_query.go +++ /dev/null @@ -1,671 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "database/sql/driver" - "fmt" - "math" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// CorrectnessReportQuery is the builder for querying CorrectnessReport entities. -type CorrectnessReportQuery struct { - config - ctx *QueryContext - order []correctnessreport.OrderOption - inters []Interceptor - predicates []predicate.CorrectnessReport - withSigners *SignerQuery - modifiers []func(*sql.Selector) - loadTotal []func(context.Context, []*CorrectnessReport) error - withNamedSigners map[string]*SignerQuery - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the CorrectnessReportQuery builder. -func (crq *CorrectnessReportQuery) Where(ps ...predicate.CorrectnessReport) *CorrectnessReportQuery { - crq.predicates = append(crq.predicates, ps...) - return crq -} - -// Limit the number of records to be returned by this query. -func (crq *CorrectnessReportQuery) Limit(limit int) *CorrectnessReportQuery { - crq.ctx.Limit = &limit - return crq -} - -// Offset to start from. -func (crq *CorrectnessReportQuery) Offset(offset int) *CorrectnessReportQuery { - crq.ctx.Offset = &offset - return crq -} - -// 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 (crq *CorrectnessReportQuery) Unique(unique bool) *CorrectnessReportQuery { - crq.ctx.Unique = &unique - return crq -} - -// Order specifies how the records should be ordered. -func (crq *CorrectnessReportQuery) Order(o ...correctnessreport.OrderOption) *CorrectnessReportQuery { - crq.order = append(crq.order, o...) - return crq -} - -// QuerySigners chains the current query on the "signers" edge. -func (crq *CorrectnessReportQuery) QuerySigners() *SignerQuery { - query := (&SignerClient{config: crq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := crq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := crq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(correctnessreport.Table, correctnessreport.FieldID, selector), - sqlgraph.To(signer.Table, signer.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, correctnessreport.SignersTable, correctnessreport.SignersPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(crq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first CorrectnessReport entity from the query. -// Returns a *NotFoundError when no CorrectnessReport was found. -func (crq *CorrectnessReportQuery) First(ctx context.Context) (*CorrectnessReport, error) { - nodes, err := crq.Limit(1).All(setContextOp(ctx, crq.ctx, "First")) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{correctnessreport.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (crq *CorrectnessReportQuery) FirstX(ctx context.Context) *CorrectnessReport { - node, err := crq.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first CorrectnessReport ID from the query. -// Returns a *NotFoundError when no CorrectnessReport ID was found. -func (crq *CorrectnessReportQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = crq.Limit(1).IDs(setContextOp(ctx, crq.ctx, "FirstID")); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{correctnessreport.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (crq *CorrectnessReportQuery) FirstIDX(ctx context.Context) int { - id, err := crq.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single CorrectnessReport entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one CorrectnessReport entity is found. -// Returns a *NotFoundError when no CorrectnessReport entities are found. -func (crq *CorrectnessReportQuery) Only(ctx context.Context) (*CorrectnessReport, error) { - nodes, err := crq.Limit(2).All(setContextOp(ctx, crq.ctx, "Only")) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{correctnessreport.Label} - default: - return nil, &NotSingularError{correctnessreport.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (crq *CorrectnessReportQuery) OnlyX(ctx context.Context) *CorrectnessReport { - node, err := crq.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only CorrectnessReport ID in the query. -// Returns a *NotSingularError when more than one CorrectnessReport ID is found. -// Returns a *NotFoundError when no entities are found. -func (crq *CorrectnessReportQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = crq.Limit(2).IDs(setContextOp(ctx, crq.ctx, "OnlyID")); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{correctnessreport.Label} - default: - err = &NotSingularError{correctnessreport.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (crq *CorrectnessReportQuery) OnlyIDX(ctx context.Context) int { - id, err := crq.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of CorrectnessReports. -func (crq *CorrectnessReportQuery) All(ctx context.Context) ([]*CorrectnessReport, error) { - ctx = setContextOp(ctx, crq.ctx, "All") - if err := crq.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*CorrectnessReport, *CorrectnessReportQuery]() - return withInterceptors[[]*CorrectnessReport](ctx, crq, qr, crq.inters) -} - -// AllX is like All, but panics if an error occurs. -func (crq *CorrectnessReportQuery) AllX(ctx context.Context) []*CorrectnessReport { - nodes, err := crq.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of CorrectnessReport IDs. -func (crq *CorrectnessReportQuery) IDs(ctx context.Context) (ids []int, err error) { - if crq.ctx.Unique == nil && crq.path != nil { - crq.Unique(true) - } - ctx = setContextOp(ctx, crq.ctx, "IDs") - if err = crq.Select(correctnessreport.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (crq *CorrectnessReportQuery) IDsX(ctx context.Context) []int { - ids, err := crq.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (crq *CorrectnessReportQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, crq.ctx, "Count") - if err := crq.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, crq, querierCount[*CorrectnessReportQuery](), crq.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (crq *CorrectnessReportQuery) CountX(ctx context.Context) int { - count, err := crq.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (crq *CorrectnessReportQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, crq.ctx, "Exist") - switch _, err := crq.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 (crq *CorrectnessReportQuery) ExistX(ctx context.Context) bool { - exist, err := crq.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the CorrectnessReportQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (crq *CorrectnessReportQuery) Clone() *CorrectnessReportQuery { - if crq == nil { - return nil - } - return &CorrectnessReportQuery{ - config: crq.config, - ctx: crq.ctx.Clone(), - order: append([]correctnessreport.OrderOption{}, crq.order...), - inters: append([]Interceptor{}, crq.inters...), - predicates: append([]predicate.CorrectnessReport{}, crq.predicates...), - withSigners: crq.withSigners.Clone(), - // clone intermediate query. - sql: crq.sql.Clone(), - path: crq.path, - } -} - -// WithSigners tells the query-builder to eager-load the nodes that are connected to -// the "signers" edge. The optional arguments are used to configure the query builder of the edge. -func (crq *CorrectnessReportQuery) WithSigners(opts ...func(*SignerQuery)) *CorrectnessReportQuery { - query := (&SignerClient{config: crq.config}).Query() - for _, opt := range opts { - opt(query) - } - crq.withSigners = query - return crq -} - -// 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 { -// SignersCount uint64 `json:"signersCount,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.CorrectnessReport.Query(). -// GroupBy(correctnessreport.FieldSignersCount). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (crq *CorrectnessReportQuery) GroupBy(field string, fields ...string) *CorrectnessReportGroupBy { - crq.ctx.Fields = append([]string{field}, fields...) - grbuild := &CorrectnessReportGroupBy{build: crq} - grbuild.flds = &crq.ctx.Fields - grbuild.label = correctnessreport.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 { -// SignersCount uint64 `json:"signersCount,omitempty"` -// } -// -// client.CorrectnessReport.Query(). -// Select(correctnessreport.FieldSignersCount). -// Scan(ctx, &v) -func (crq *CorrectnessReportQuery) Select(fields ...string) *CorrectnessReportSelect { - crq.ctx.Fields = append(crq.ctx.Fields, fields...) - sbuild := &CorrectnessReportSelect{CorrectnessReportQuery: crq} - sbuild.label = correctnessreport.Label - sbuild.flds, sbuild.scan = &crq.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a CorrectnessReportSelect configured with the given aggregations. -func (crq *CorrectnessReportQuery) Aggregate(fns ...AggregateFunc) *CorrectnessReportSelect { - return crq.Select().Aggregate(fns...) -} - -func (crq *CorrectnessReportQuery) prepareQuery(ctx context.Context) error { - for _, inter := range crq.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, crq); err != nil { - return err - } - } - } - for _, f := range crq.ctx.Fields { - if !correctnessreport.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if crq.path != nil { - prev, err := crq.path(ctx) - if err != nil { - return err - } - crq.sql = prev - } - return nil -} - -func (crq *CorrectnessReportQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*CorrectnessReport, error) { - var ( - nodes = []*CorrectnessReport{} - _spec = crq.querySpec() - loadedTypes = [1]bool{ - crq.withSigners != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*CorrectnessReport).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &CorrectnessReport{config: crq.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(crq.modifiers) > 0 { - _spec.Modifiers = crq.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, crq.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := crq.withSigners; query != nil { - if err := crq.loadSigners(ctx, query, nodes, - func(n *CorrectnessReport) { n.Edges.Signers = []*Signer{} }, - func(n *CorrectnessReport, e *Signer) { n.Edges.Signers = append(n.Edges.Signers, e) }); err != nil { - return nil, err - } - } - for name, query := range crq.withNamedSigners { - if err := crq.loadSigners(ctx, query, nodes, - func(n *CorrectnessReport) { n.appendNamedSigners(name) }, - func(n *CorrectnessReport, e *Signer) { n.appendNamedSigners(name, e) }); err != nil { - return nil, err - } - } - for i := range crq.loadTotal { - if err := crq.loadTotal[i](ctx, nodes); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (crq *CorrectnessReportQuery) loadSigners(ctx context.Context, query *SignerQuery, nodes []*CorrectnessReport, init func(*CorrectnessReport), assign func(*CorrectnessReport, *Signer)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int]*CorrectnessReport) - nids := make(map[int]map[*CorrectnessReport]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(correctnessreport.SignersTable) - s.Join(joinT).On(s.C(signer.FieldID), joinT.C(correctnessreport.SignersPrimaryKey[1])) - s.Where(sql.InValues(joinT.C(correctnessreport.SignersPrimaryKey[0]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(correctnessreport.SignersPrimaryKey[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[*CorrectnessReport]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*Signer](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 "signers" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} - -func (crq *CorrectnessReportQuery) sqlCount(ctx context.Context) (int, error) { - _spec := crq.querySpec() - if len(crq.modifiers) > 0 { - _spec.Modifiers = crq.modifiers - } - _spec.Node.Columns = crq.ctx.Fields - if len(crq.ctx.Fields) > 0 { - _spec.Unique = crq.ctx.Unique != nil && *crq.ctx.Unique - } - return sqlgraph.CountNodes(ctx, crq.driver, _spec) -} - -func (crq *CorrectnessReportQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(correctnessreport.Table, correctnessreport.Columns, sqlgraph.NewFieldSpec(correctnessreport.FieldID, field.TypeInt)) - _spec.From = crq.sql - if unique := crq.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if crq.path != nil { - _spec.Unique = true - } - if fields := crq.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, correctnessreport.FieldID) - for i := range fields { - if fields[i] != correctnessreport.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := crq.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := crq.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := crq.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := crq.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (crq *CorrectnessReportQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(crq.driver.Dialect()) - t1 := builder.Table(correctnessreport.Table) - columns := crq.ctx.Fields - if len(columns) == 0 { - columns = correctnessreport.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if crq.sql != nil { - selector = crq.sql - selector.Select(selector.Columns(columns...)...) - } - if crq.ctx.Unique != nil && *crq.ctx.Unique { - selector.Distinct() - } - for _, p := range crq.predicates { - p(selector) - } - for _, p := range crq.order { - p(selector) - } - if offset := crq.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 := crq.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// WithNamedSigners tells the query-builder to eager-load the nodes that are connected to the "signers" -// edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (crq *CorrectnessReportQuery) WithNamedSigners(name string, opts ...func(*SignerQuery)) *CorrectnessReportQuery { - query := (&SignerClient{config: crq.config}).Query() - for _, opt := range opts { - opt(query) - } - if crq.withNamedSigners == nil { - crq.withNamedSigners = make(map[string]*SignerQuery) - } - crq.withNamedSigners[name] = query - return crq -} - -// CorrectnessReportGroupBy is the group-by builder for CorrectnessReport entities. -type CorrectnessReportGroupBy struct { - selector - build *CorrectnessReportQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (crgb *CorrectnessReportGroupBy) Aggregate(fns ...AggregateFunc) *CorrectnessReportGroupBy { - crgb.fns = append(crgb.fns, fns...) - return crgb -} - -// Scan applies the selector query and scans the result into the given value. -func (crgb *CorrectnessReportGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, crgb.build.ctx, "GroupBy") - if err := crgb.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*CorrectnessReportQuery, *CorrectnessReportGroupBy](ctx, crgb.build, crgb, crgb.build.inters, v) -} - -func (crgb *CorrectnessReportGroupBy) sqlScan(ctx context.Context, root *CorrectnessReportQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(crgb.fns)) - for _, fn := range crgb.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*crgb.flds)+len(crgb.fns)) - for _, f := range *crgb.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*crgb.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := crgb.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// CorrectnessReportSelect is the builder for selecting fields of CorrectnessReport entities. -type CorrectnessReportSelect struct { - *CorrectnessReportQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (crs *CorrectnessReportSelect) Aggregate(fns ...AggregateFunc) *CorrectnessReportSelect { - crs.fns = append(crs.fns, fns...) - return crs -} - -// Scan applies the selector query and scans the result into the given value. -func (crs *CorrectnessReportSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, crs.ctx, "Select") - if err := crs.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*CorrectnessReportQuery, *CorrectnessReportSelect](ctx, crs.CorrectnessReportQuery, crs, crs.inters, v) -} - -func (crs *CorrectnessReportSelect) sqlScan(ctx context.Context, root *CorrectnessReportQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(crs.fns)) - for _, fn := range crs.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*crs.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 := crs.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} diff --git a/internal/ent/correctnessreport_update.go b/internal/ent/correctnessreport_update.go deleted file mode 100644 index 2e6a0c99..00000000 --- a/internal/ent/correctnessreport_update.go +++ /dev/null @@ -1,633 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// CorrectnessReportUpdate is the builder for updating CorrectnessReport entities. -type CorrectnessReportUpdate struct { - config - hooks []Hook - mutation *CorrectnessReportMutation -} - -// Where appends a list predicates to the CorrectnessReportUpdate builder. -func (cru *CorrectnessReportUpdate) Where(ps ...predicate.CorrectnessReport) *CorrectnessReportUpdate { - cru.mutation.Where(ps...) - return cru -} - -// SetSignersCount sets the "signersCount" field. -func (cru *CorrectnessReportUpdate) SetSignersCount(u uint64) *CorrectnessReportUpdate { - cru.mutation.ResetSignersCount() - cru.mutation.SetSignersCount(u) - return cru -} - -// SetNillableSignersCount sets the "signersCount" field if the given value is not nil. -func (cru *CorrectnessReportUpdate) SetNillableSignersCount(u *uint64) *CorrectnessReportUpdate { - if u != nil { - cru.SetSignersCount(*u) - } - return cru -} - -// AddSignersCount adds u to the "signersCount" field. -func (cru *CorrectnessReportUpdate) AddSignersCount(u int64) *CorrectnessReportUpdate { - cru.mutation.AddSignersCount(u) - return cru -} - -// SetTimestamp sets the "timestamp" field. -func (cru *CorrectnessReportUpdate) SetTimestamp(u uint64) *CorrectnessReportUpdate { - cru.mutation.ResetTimestamp() - cru.mutation.SetTimestamp(u) - return cru -} - -// SetNillableTimestamp sets the "timestamp" field if the given value is not nil. -func (cru *CorrectnessReportUpdate) SetNillableTimestamp(u *uint64) *CorrectnessReportUpdate { - if u != nil { - cru.SetTimestamp(*u) - } - return cru -} - -// AddTimestamp adds u to the "timestamp" field. -func (cru *CorrectnessReportUpdate) AddTimestamp(u int64) *CorrectnessReportUpdate { - cru.mutation.AddTimestamp(u) - return cru -} - -// SetSignature sets the "signature" field. -func (cru *CorrectnessReportUpdate) SetSignature(b []byte) *CorrectnessReportUpdate { - cru.mutation.SetSignature(b) - return cru -} - -// SetHash sets the "hash" field. -func (cru *CorrectnessReportUpdate) SetHash(b []byte) *CorrectnessReportUpdate { - cru.mutation.SetHash(b) - return cru -} - -// SetTopic sets the "topic" field. -func (cru *CorrectnessReportUpdate) SetTopic(b []byte) *CorrectnessReportUpdate { - cru.mutation.SetTopic(b) - return cru -} - -// SetCorrect sets the "correct" field. -func (cru *CorrectnessReportUpdate) SetCorrect(b bool) *CorrectnessReportUpdate { - cru.mutation.SetCorrect(b) - return cru -} - -// SetNillableCorrect sets the "correct" field if the given value is not nil. -func (cru *CorrectnessReportUpdate) SetNillableCorrect(b *bool) *CorrectnessReportUpdate { - if b != nil { - cru.SetCorrect(*b) - } - return cru -} - -// SetConsensus sets the "consensus" field. -func (cru *CorrectnessReportUpdate) SetConsensus(b bool) *CorrectnessReportUpdate { - cru.mutation.SetConsensus(b) - return cru -} - -// SetNillableConsensus sets the "consensus" field if the given value is not nil. -func (cru *CorrectnessReportUpdate) SetNillableConsensus(b *bool) *CorrectnessReportUpdate { - if b != nil { - cru.SetConsensus(*b) - } - return cru -} - -// SetVoted sets the "voted" field. -func (cru *CorrectnessReportUpdate) SetVoted(hi *helpers.BigInt) *CorrectnessReportUpdate { - cru.mutation.SetVoted(hi) - return cru -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by IDs. -func (cru *CorrectnessReportUpdate) AddSignerIDs(ids ...int) *CorrectnessReportUpdate { - cru.mutation.AddSignerIDs(ids...) - return cru -} - -// AddSigners adds the "signers" edges to the Signer entity. -func (cru *CorrectnessReportUpdate) AddSigners(s ...*Signer) *CorrectnessReportUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return cru.AddSignerIDs(ids...) -} - -// Mutation returns the CorrectnessReportMutation object of the builder. -func (cru *CorrectnessReportUpdate) Mutation() *CorrectnessReportMutation { - return cru.mutation -} - -// ClearSigners clears all "signers" edges to the Signer entity. -func (cru *CorrectnessReportUpdate) ClearSigners() *CorrectnessReportUpdate { - cru.mutation.ClearSigners() - return cru -} - -// RemoveSignerIDs removes the "signers" edge to Signer entities by IDs. -func (cru *CorrectnessReportUpdate) RemoveSignerIDs(ids ...int) *CorrectnessReportUpdate { - cru.mutation.RemoveSignerIDs(ids...) - return cru -} - -// RemoveSigners removes "signers" edges to Signer entities. -func (cru *CorrectnessReportUpdate) RemoveSigners(s ...*Signer) *CorrectnessReportUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return cru.RemoveSignerIDs(ids...) -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (cru *CorrectnessReportUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, cru.sqlSave, cru.mutation, cru.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (cru *CorrectnessReportUpdate) SaveX(ctx context.Context) int { - affected, err := cru.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (cru *CorrectnessReportUpdate) Exec(ctx context.Context) error { - _, err := cru.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (cru *CorrectnessReportUpdate) ExecX(ctx context.Context) { - if err := cru.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (cru *CorrectnessReportUpdate) check() error { - if v, ok := cru.mutation.Signature(); ok { - if err := correctnessreport.SignatureValidator(v); err != nil { - return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "CorrectnessReport.signature": %w`, err)} - } - } - if v, ok := cru.mutation.Hash(); ok { - if err := correctnessreport.HashValidator(v); err != nil { - return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "CorrectnessReport.hash": %w`, err)} - } - } - if v, ok := cru.mutation.Topic(); ok { - if err := correctnessreport.TopicValidator(v); err != nil { - return &ValidationError{Name: "topic", err: fmt.Errorf(`ent: validator failed for field "CorrectnessReport.topic": %w`, err)} - } - } - return nil -} - -func (cru *CorrectnessReportUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := cru.check(); err != nil { - return n, err - } - _spec := sqlgraph.NewUpdateSpec(correctnessreport.Table, correctnessreport.Columns, sqlgraph.NewFieldSpec(correctnessreport.FieldID, field.TypeInt)) - if ps := cru.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := cru.mutation.SignersCount(); ok { - _spec.SetField(correctnessreport.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := cru.mutation.AddedSignersCount(); ok { - _spec.AddField(correctnessreport.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := cru.mutation.Timestamp(); ok { - _spec.SetField(correctnessreport.FieldTimestamp, field.TypeUint64, value) - } - if value, ok := cru.mutation.AddedTimestamp(); ok { - _spec.AddField(correctnessreport.FieldTimestamp, field.TypeUint64, value) - } - if value, ok := cru.mutation.Signature(); ok { - _spec.SetField(correctnessreport.FieldSignature, field.TypeBytes, value) - } - if value, ok := cru.mutation.Hash(); ok { - _spec.SetField(correctnessreport.FieldHash, field.TypeBytes, value) - } - if value, ok := cru.mutation.Topic(); ok { - _spec.SetField(correctnessreport.FieldTopic, field.TypeBytes, value) - } - if value, ok := cru.mutation.Correct(); ok { - _spec.SetField(correctnessreport.FieldCorrect, field.TypeBool, value) - } - if value, ok := cru.mutation.Consensus(); ok { - _spec.SetField(correctnessreport.FieldConsensus, field.TypeBool, value) - } - if value, ok := cru.mutation.Voted(); ok { - _spec.SetField(correctnessreport.FieldVoted, field.TypeUint, value) - } - if cru.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: correctnessreport.SignersTable, - Columns: correctnessreport.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := cru.mutation.RemovedSignersIDs(); len(nodes) > 0 && !cru.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: correctnessreport.SignersTable, - Columns: correctnessreport.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.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 := cru.mutation.SignersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: correctnessreport.SignersTable, - Columns: correctnessreport.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.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, cru.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{correctnessreport.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - cru.mutation.done = true - return n, nil -} - -// CorrectnessReportUpdateOne is the builder for updating a single CorrectnessReport entity. -type CorrectnessReportUpdateOne struct { - config - fields []string - hooks []Hook - mutation *CorrectnessReportMutation -} - -// SetSignersCount sets the "signersCount" field. -func (cruo *CorrectnessReportUpdateOne) SetSignersCount(u uint64) *CorrectnessReportUpdateOne { - cruo.mutation.ResetSignersCount() - cruo.mutation.SetSignersCount(u) - return cruo -} - -// SetNillableSignersCount sets the "signersCount" field if the given value is not nil. -func (cruo *CorrectnessReportUpdateOne) SetNillableSignersCount(u *uint64) *CorrectnessReportUpdateOne { - if u != nil { - cruo.SetSignersCount(*u) - } - return cruo -} - -// AddSignersCount adds u to the "signersCount" field. -func (cruo *CorrectnessReportUpdateOne) AddSignersCount(u int64) *CorrectnessReportUpdateOne { - cruo.mutation.AddSignersCount(u) - return cruo -} - -// SetTimestamp sets the "timestamp" field. -func (cruo *CorrectnessReportUpdateOne) SetTimestamp(u uint64) *CorrectnessReportUpdateOne { - cruo.mutation.ResetTimestamp() - cruo.mutation.SetTimestamp(u) - return cruo -} - -// SetNillableTimestamp sets the "timestamp" field if the given value is not nil. -func (cruo *CorrectnessReportUpdateOne) SetNillableTimestamp(u *uint64) *CorrectnessReportUpdateOne { - if u != nil { - cruo.SetTimestamp(*u) - } - return cruo -} - -// AddTimestamp adds u to the "timestamp" field. -func (cruo *CorrectnessReportUpdateOne) AddTimestamp(u int64) *CorrectnessReportUpdateOne { - cruo.mutation.AddTimestamp(u) - return cruo -} - -// SetSignature sets the "signature" field. -func (cruo *CorrectnessReportUpdateOne) SetSignature(b []byte) *CorrectnessReportUpdateOne { - cruo.mutation.SetSignature(b) - return cruo -} - -// SetHash sets the "hash" field. -func (cruo *CorrectnessReportUpdateOne) SetHash(b []byte) *CorrectnessReportUpdateOne { - cruo.mutation.SetHash(b) - return cruo -} - -// SetTopic sets the "topic" field. -func (cruo *CorrectnessReportUpdateOne) SetTopic(b []byte) *CorrectnessReportUpdateOne { - cruo.mutation.SetTopic(b) - return cruo -} - -// SetCorrect sets the "correct" field. -func (cruo *CorrectnessReportUpdateOne) SetCorrect(b bool) *CorrectnessReportUpdateOne { - cruo.mutation.SetCorrect(b) - return cruo -} - -// SetNillableCorrect sets the "correct" field if the given value is not nil. -func (cruo *CorrectnessReportUpdateOne) SetNillableCorrect(b *bool) *CorrectnessReportUpdateOne { - if b != nil { - cruo.SetCorrect(*b) - } - return cruo -} - -// SetConsensus sets the "consensus" field. -func (cruo *CorrectnessReportUpdateOne) SetConsensus(b bool) *CorrectnessReportUpdateOne { - cruo.mutation.SetConsensus(b) - return cruo -} - -// SetNillableConsensus sets the "consensus" field if the given value is not nil. -func (cruo *CorrectnessReportUpdateOne) SetNillableConsensus(b *bool) *CorrectnessReportUpdateOne { - if b != nil { - cruo.SetConsensus(*b) - } - return cruo -} - -// SetVoted sets the "voted" field. -func (cruo *CorrectnessReportUpdateOne) SetVoted(hi *helpers.BigInt) *CorrectnessReportUpdateOne { - cruo.mutation.SetVoted(hi) - return cruo -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by IDs. -func (cruo *CorrectnessReportUpdateOne) AddSignerIDs(ids ...int) *CorrectnessReportUpdateOne { - cruo.mutation.AddSignerIDs(ids...) - return cruo -} - -// AddSigners adds the "signers" edges to the Signer entity. -func (cruo *CorrectnessReportUpdateOne) AddSigners(s ...*Signer) *CorrectnessReportUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return cruo.AddSignerIDs(ids...) -} - -// Mutation returns the CorrectnessReportMutation object of the builder. -func (cruo *CorrectnessReportUpdateOne) Mutation() *CorrectnessReportMutation { - return cruo.mutation -} - -// ClearSigners clears all "signers" edges to the Signer entity. -func (cruo *CorrectnessReportUpdateOne) ClearSigners() *CorrectnessReportUpdateOne { - cruo.mutation.ClearSigners() - return cruo -} - -// RemoveSignerIDs removes the "signers" edge to Signer entities by IDs. -func (cruo *CorrectnessReportUpdateOne) RemoveSignerIDs(ids ...int) *CorrectnessReportUpdateOne { - cruo.mutation.RemoveSignerIDs(ids...) - return cruo -} - -// RemoveSigners removes "signers" edges to Signer entities. -func (cruo *CorrectnessReportUpdateOne) RemoveSigners(s ...*Signer) *CorrectnessReportUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return cruo.RemoveSignerIDs(ids...) -} - -// Where appends a list predicates to the CorrectnessReportUpdate builder. -func (cruo *CorrectnessReportUpdateOne) Where(ps ...predicate.CorrectnessReport) *CorrectnessReportUpdateOne { - cruo.mutation.Where(ps...) - return cruo -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (cruo *CorrectnessReportUpdateOne) Select(field string, fields ...string) *CorrectnessReportUpdateOne { - cruo.fields = append([]string{field}, fields...) - return cruo -} - -// Save executes the query and returns the updated CorrectnessReport entity. -func (cruo *CorrectnessReportUpdateOne) Save(ctx context.Context) (*CorrectnessReport, error) { - return withHooks(ctx, cruo.sqlSave, cruo.mutation, cruo.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (cruo *CorrectnessReportUpdateOne) SaveX(ctx context.Context) *CorrectnessReport { - node, err := cruo.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (cruo *CorrectnessReportUpdateOne) Exec(ctx context.Context) error { - _, err := cruo.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (cruo *CorrectnessReportUpdateOne) ExecX(ctx context.Context) { - if err := cruo.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (cruo *CorrectnessReportUpdateOne) check() error { - if v, ok := cruo.mutation.Signature(); ok { - if err := correctnessreport.SignatureValidator(v); err != nil { - return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "CorrectnessReport.signature": %w`, err)} - } - } - if v, ok := cruo.mutation.Hash(); ok { - if err := correctnessreport.HashValidator(v); err != nil { - return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "CorrectnessReport.hash": %w`, err)} - } - } - if v, ok := cruo.mutation.Topic(); ok { - if err := correctnessreport.TopicValidator(v); err != nil { - return &ValidationError{Name: "topic", err: fmt.Errorf(`ent: validator failed for field "CorrectnessReport.topic": %w`, err)} - } - } - return nil -} - -func (cruo *CorrectnessReportUpdateOne) sqlSave(ctx context.Context) (_node *CorrectnessReport, err error) { - if err := cruo.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(correctnessreport.Table, correctnessreport.Columns, sqlgraph.NewFieldSpec(correctnessreport.FieldID, field.TypeInt)) - id, ok := cruo.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "CorrectnessReport.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := cruo.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, correctnessreport.FieldID) - for _, f := range fields { - if !correctnessreport.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != correctnessreport.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := cruo.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := cruo.mutation.SignersCount(); ok { - _spec.SetField(correctnessreport.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := cruo.mutation.AddedSignersCount(); ok { - _spec.AddField(correctnessreport.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := cruo.mutation.Timestamp(); ok { - _spec.SetField(correctnessreport.FieldTimestamp, field.TypeUint64, value) - } - if value, ok := cruo.mutation.AddedTimestamp(); ok { - _spec.AddField(correctnessreport.FieldTimestamp, field.TypeUint64, value) - } - if value, ok := cruo.mutation.Signature(); ok { - _spec.SetField(correctnessreport.FieldSignature, field.TypeBytes, value) - } - if value, ok := cruo.mutation.Hash(); ok { - _spec.SetField(correctnessreport.FieldHash, field.TypeBytes, value) - } - if value, ok := cruo.mutation.Topic(); ok { - _spec.SetField(correctnessreport.FieldTopic, field.TypeBytes, value) - } - if value, ok := cruo.mutation.Correct(); ok { - _spec.SetField(correctnessreport.FieldCorrect, field.TypeBool, value) - } - if value, ok := cruo.mutation.Consensus(); ok { - _spec.SetField(correctnessreport.FieldConsensus, field.TypeBool, value) - } - if value, ok := cruo.mutation.Voted(); ok { - _spec.SetField(correctnessreport.FieldVoted, field.TypeUint, value) - } - if cruo.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: correctnessreport.SignersTable, - Columns: correctnessreport.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := cruo.mutation.RemovedSignersIDs(); len(nodes) > 0 && !cruo.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: correctnessreport.SignersTable, - Columns: correctnessreport.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.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 := cruo.mutation.SignersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: correctnessreport.SignersTable, - Columns: correctnessreport.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _node = &CorrectnessReport{config: cruo.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, cruo.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{correctnessreport.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - cruo.mutation.done = true - return _node, nil -} diff --git a/internal/ent/ent.go b/internal/ent/ent.go deleted file mode 100644 index a09b3a29..00000000 --- a/internal/ent/ent.go +++ /dev/null @@ -1,614 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "reflect" - "sync" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// 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{ - assetprice.Table: assetprice.ValidColumn, - correctnessreport.Table: correctnessreport.ValidColumn, - eventlog.Table: eventlog.ValidColumn, - signer.Table: signer.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/internal/ent/entc.go b/internal/ent/entc.go deleted file mode 100644 index 356218e5..00000000 --- a/internal/ent/entc.go +++ /dev/null @@ -1,32 +0,0 @@ -//go:build ignore - -package main - -import ( - "log" - - "entgo.io/contrib/entgql" - "entgo.io/ent/entc" - "entgo.io/ent/entc/gen" -) - -func main() { - ex, err := entgql.NewExtension( - // Tell Ent to generate a GraphQL schema for - // the Ent schema in a file named ent.graphql. - entgql.WithWhereInputs(true), - entgql.WithSchemaGenerator(), - entgql.WithSchemaPath("transport/server/gql/unchained.graphql"), - entgql.WithConfigPath("gqlgen.yml"), - ) - if err != nil { - log.Fatalf("creating entgql extension: %v", err) - } - opts := []entc.Option{ - entc.Extensions(ex), - } - config := &gen.Config{Features: []gen.Feature{gen.FeatureUpsert}} - if err := entc.Generate("./ent/schema", config, opts...); err != nil { - log.Fatalf("running ent codegen: %v", err) - } -} diff --git a/internal/ent/enttest/enttest.go b/internal/ent/enttest/enttest.go deleted file mode 100644 index 6accd20d..00000000 --- a/internal/ent/enttest/enttest.go +++ /dev/null @@ -1,84 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package enttest - -import ( - "context" - - "github.com/TimeleapLabs/unchained/internal/ent" - // required by schema hooks. - _ "github.com/TimeleapLabs/unchained/internal/ent/runtime" - - "entgo.io/ent/dialect/sql/schema" - "github.com/TimeleapLabs/unchained/internal/ent/migrate" -) - -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/internal/ent/eventlog.go b/internal/ent/eventlog.go deleted file mode 100644 index 5e8af9ed..00000000 --- a/internal/ent/eventlog.go +++ /dev/null @@ -1,278 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "encoding/json" - "fmt" - "github.com/TimeleapLabs/unchained/internal/model" - "strings" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" -) - -// EventLog is the model entity for the EventLog schema. -type EventLog struct { - config `json:"-"` - // ID of the ent. - ID int `json:"id,omitempty"` - // Block holds the value of the "block" field. - Block uint64 `json:"block,omitempty"` - // SignersCount holds the value of the "signersCount" field. - SignersCount uint64 `json:"signersCount,omitempty"` - // Signature holds the value of the "signature" field. - Signature []byte `json:"signature,omitempty"` - // Address holds the value of the "address" field. - Address string `json:"address,omitempty"` - // Chain holds the value of the "chain" field. - Chain string `json:"chain,omitempty"` - // Index holds the value of the "index" field. - Index uint64 `json:"index,omitempty"` - // Event holds the value of the "event" field. - Event string `json:"event,omitempty"` - // Transaction holds the value of the "transaction" field. - Transaction []byte `json:"transaction,omitempty"` - // Args holds the value of the "args" field. - Args []model.EventLogArg `json:"args,omitempty"` - // Consensus holds the value of the "consensus" field. - Consensus bool `json:"consensus,omitempty"` - // Voted holds the value of the "voted" field. - Voted *helpers.BigInt `json:"voted,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the EventLogQuery when eager-loading is set. - Edges EventLogEdges `json:"edges"` - selectValues sql.SelectValues -} - -// EventLogEdges holds the relations/edges for other nodes in the graph. -type EventLogEdges struct { - // Signers holds the value of the signers edge. - Signers []*Signer `json:"signers,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [1]bool - // totalCount holds the count of the edges above. - totalCount [1]map[string]int - - namedSigners map[string][]*Signer -} - -// SignersOrErr returns the Signers value or an error if the edge -// was not loaded in eager-loading. -func (e EventLogEdges) SignersOrErr() ([]*Signer, error) { - if e.loadedTypes[0] { - return e.Signers, nil - } - return nil, &NotLoadedError{edge: "signers"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*EventLog) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case eventlog.FieldSignature, eventlog.FieldTransaction, eventlog.FieldArgs: - values[i] = new([]byte) - case eventlog.FieldVoted: - values[i] = new(helpers.BigInt) - case eventlog.FieldConsensus: - values[i] = new(sql.NullBool) - case eventlog.FieldID, eventlog.FieldBlock, eventlog.FieldSignersCount, eventlog.FieldIndex: - values[i] = new(sql.NullInt64) - case eventlog.FieldAddress, eventlog.FieldChain, eventlog.FieldEvent: - 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 EventLog fields. -func (el *EventLog) 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 eventlog.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) - } - el.ID = int(value.Int64) - case eventlog.FieldBlock: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field block", values[i]) - } else if value.Valid { - el.Block = uint64(value.Int64) - } - case eventlog.FieldSignersCount: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field signersCount", values[i]) - } else if value.Valid { - el.SignersCount = uint64(value.Int64) - } - case eventlog.FieldSignature: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field signature", values[i]) - } else if value != nil { - el.Signature = *value - } - case eventlog.FieldAddress: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field address", values[i]) - } else if value.Valid { - el.Address = value.String - } - case eventlog.FieldChain: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field chain", values[i]) - } else if value.Valid { - el.Chain = value.String - } - case eventlog.FieldIndex: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field index", values[i]) - } else if value.Valid { - el.Index = uint64(value.Int64) - } - case eventlog.FieldEvent: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field event", values[i]) - } else if value.Valid { - el.Event = value.String - } - case eventlog.FieldTransaction: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field transaction", values[i]) - } else if value != nil { - el.Transaction = *value - } - case eventlog.FieldArgs: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field args", values[i]) - } else if value != nil && len(*value) > 0 { - if err := json.Unmarshal(*value, &el.Args); err != nil { - return fmt.Errorf("unmarshal field args: %w", err) - } - } - case eventlog.FieldConsensus: - if value, ok := values[i].(*sql.NullBool); !ok { - return fmt.Errorf("unexpected type %T for field consensus", values[i]) - } else if value.Valid { - el.Consensus = value.Bool - } - case eventlog.FieldVoted: - if value, ok := values[i].(*helpers.BigInt); !ok { - return fmt.Errorf("unexpected type %T for field voted", values[i]) - } else if value != nil { - el.Voted = value - } - default: - el.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the EventLog. -// This includes values selected through modifiers, order, etc. -func (el *EventLog) Value(name string) (ent.Value, error) { - return el.selectValues.Get(name) -} - -// QuerySigners queries the "signers" edge of the EventLog entity. -func (el *EventLog) QuerySigners() *SignerQuery { - return NewEventLogClient(el.config).QuerySigners(el) -} - -// Update returns a builder for updating this EventLog. -// Note that you need to call EventLog.Unwrap() before calling this method if this EventLog -// was returned from a transaction, and the transaction was committed or rolled back. -func (el *EventLog) Update() *EventLogUpdateOne { - return NewEventLogClient(el.config).UpdateOne(el) -} - -// Unwrap unwraps the EventLog 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 (el *EventLog) Unwrap() *EventLog { - _tx, ok := el.config.driver.(*txDriver) - if !ok { - panic("ent: EventLog is not a transactional entity") - } - el.config.driver = _tx.drv - return el -} - -// String implements the fmt.Stringer. -func (el *EventLog) String() string { - var builder strings.Builder - builder.WriteString("EventLog(") - builder.WriteString(fmt.Sprintf("id=%v, ", el.ID)) - builder.WriteString("block=") - builder.WriteString(fmt.Sprintf("%v", el.Block)) - builder.WriteString(", ") - builder.WriteString("signersCount=") - builder.WriteString(fmt.Sprintf("%v", el.SignersCount)) - builder.WriteString(", ") - builder.WriteString("signature=") - builder.WriteString(fmt.Sprintf("%v", el.Signature)) - builder.WriteString(", ") - builder.WriteString("address=") - builder.WriteString(el.Address) - builder.WriteString(", ") - builder.WriteString("chain=") - builder.WriteString(el.Chain) - builder.WriteString(", ") - builder.WriteString("index=") - builder.WriteString(fmt.Sprintf("%v", el.Index)) - builder.WriteString(", ") - builder.WriteString("event=") - builder.WriteString(el.Event) - builder.WriteString(", ") - builder.WriteString("transaction=") - builder.WriteString(fmt.Sprintf("%v", el.Transaction)) - builder.WriteString(", ") - builder.WriteString("args=") - builder.WriteString(fmt.Sprintf("%v", el.Args)) - builder.WriteString(", ") - builder.WriteString("consensus=") - builder.WriteString(fmt.Sprintf("%v", el.Consensus)) - builder.WriteString(", ") - builder.WriteString("voted=") - builder.WriteString(fmt.Sprintf("%v", el.Voted)) - builder.WriteByte(')') - return builder.String() -} - -// NamedSigners returns the Signers named value or an error if the edge was not -// loaded in eager-loading with this name. -func (el *EventLog) NamedSigners(name string) ([]*Signer, error) { - if el.Edges.namedSigners == nil { - return nil, &NotLoadedError{edge: name} - } - nodes, ok := el.Edges.namedSigners[name] - if !ok { - return nil, &NotLoadedError{edge: name} - } - return nodes, nil -} - -func (el *EventLog) appendNamedSigners(name string, edges ...*Signer) { - if el.Edges.namedSigners == nil { - el.Edges.namedSigners = make(map[string][]*Signer) - } - if len(edges) == 0 { - el.Edges.namedSigners[name] = []*Signer{} - } else { - el.Edges.namedSigners[name] = append(el.Edges.namedSigners[name], edges...) - } -} - -// EventLogs is a parsable slice of EventLog. -type EventLogs []*EventLog diff --git a/internal/ent/eventlog/eventlog.go b/internal/ent/eventlog/eventlog.go deleted file mode 100644 index 3ad5c92f..00000000 --- a/internal/ent/eventlog/eventlog.go +++ /dev/null @@ -1,156 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package eventlog - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the eventlog type in the database. - Label = "event_log" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldBlock holds the string denoting the block field in the database. - FieldBlock = "block" - // FieldSignersCount holds the string denoting the signerscount field in the database. - FieldSignersCount = "signers_count" - // FieldSignature holds the string denoting the signature field in the database. - FieldSignature = "signature" - // FieldAddress holds the string denoting the address field in the database. - FieldAddress = "address" - // FieldChain holds the string denoting the chain field in the database. - FieldChain = "chain" - // FieldIndex holds the string denoting the index field in the database. - FieldIndex = "index" - // FieldEvent holds the string denoting the event field in the database. - FieldEvent = "event" - // FieldTransaction holds the string denoting the transaction field in the database. - FieldTransaction = "transaction" - // FieldArgs holds the string denoting the args field in the database. - FieldArgs = "args" - // FieldConsensus holds the string denoting the consensus field in the database. - FieldConsensus = "consensus" - // FieldVoted holds the string denoting the voted field in the database. - FieldVoted = "voted" - // EdgeSigners holds the string denoting the signers edge name in mutations. - EdgeSigners = "signers" - // Table holds the table name of the eventlog in the database. - Table = "event_logs" - // SignersTable is the table that holds the signers relation/edge. The primary key declared below. - SignersTable = "event_log_signers" - // SignersInverseTable is the table name for the Signer entity. - // It exists in this package in order to avoid circular dependency with the "signer" package. - SignersInverseTable = "signers" -) - -// Columns holds all SQL columns for eventlog fields. -var Columns = []string{ - FieldID, - FieldBlock, - FieldSignersCount, - FieldSignature, - FieldAddress, - FieldChain, - FieldIndex, - FieldEvent, - FieldTransaction, - FieldArgs, - FieldConsensus, - FieldVoted, -} - -var ( - // SignersPrimaryKey and SignersColumn2 are the table columns denoting the - // primary key for the signers relation (M2M). - SignersPrimaryKey = []string{"event_log_id", "signer_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 -} - -var ( - // SignatureValidator is a validator for the "signature" field. It is called by the builders before save. - SignatureValidator func([]byte) error - // TransactionValidator is a validator for the "transaction" field. It is called by the builders before save. - TransactionValidator func([]byte) error - // DefaultConsensus holds the default value on creation for the "consensus" field. - DefaultConsensus bool -) - -// OrderOption defines the ordering options for the EventLog 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() -} - -// ByBlock orders the results by the block field. -func ByBlock(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldBlock, opts...).ToFunc() -} - -// BySignersCountField orders the results by the signersCount field. -func BySignersCountField(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSignersCount, opts...).ToFunc() -} - -// ByAddress orders the results by the address field. -func ByAddress(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldAddress, opts...).ToFunc() -} - -// ByChain orders the results by the chain field. -func ByChain(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldChain, opts...).ToFunc() -} - -// ByIndex orders the results by the index field. -func ByIndex(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldIndex, opts...).ToFunc() -} - -// ByEvent orders the results by the event field. -func ByEvent(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldEvent, opts...).ToFunc() -} - -// ByConsensus orders the results by the consensus field. -func ByConsensus(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldConsensus, opts...).ToFunc() -} - -// ByVoted orders the results by the voted field. -func ByVoted(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldVoted, opts...).ToFunc() -} - -// BySignersCount orders the results by signers count. -func BySignersCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newSignersStep(), opts...) - } -} - -// BySigners orders the results by signers terms. -func BySigners(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newSignersStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newSignersStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(SignersInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, SignersTable, SignersPrimaryKey...), - ) -} diff --git a/internal/ent/eventlog/where.go b/internal/ent/eventlog/where.go deleted file mode 100644 index 51d92d0a..00000000 --- a/internal/ent/eventlog/where.go +++ /dev/null @@ -1,588 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package eventlog - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldID, id)) -} - -// Block applies equality check predicate on the "block" field. It's identical to BlockEQ. -func Block(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldBlock, v)) -} - -// SignersCount applies equality check predicate on the "signersCount" field. It's identical to SignersCountEQ. -func SignersCount(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldSignersCount, v)) -} - -// Signature applies equality check predicate on the "signature" field. It's identical to SignatureEQ. -func Signature(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldSignature, v)) -} - -// Address applies equality check predicate on the "address" field. It's identical to AddressEQ. -func Address(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldAddress, v)) -} - -// Chain applies equality check predicate on the "chain" field. It's identical to ChainEQ. -func Chain(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldChain, v)) -} - -// Index applies equality check predicate on the "index" field. It's identical to IndexEQ. -func Index(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldIndex, v)) -} - -// Event applies equality check predicate on the "event" field. It's identical to EventEQ. -func Event(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldEvent, v)) -} - -// Transaction applies equality check predicate on the "transaction" field. It's identical to TransactionEQ. -func Transaction(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldTransaction, v)) -} - -// Consensus applies equality check predicate on the "consensus" field. It's identical to ConsensusEQ. -func Consensus(v bool) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldConsensus, v)) -} - -// Voted applies equality check predicate on the "voted" field. It's identical to VotedEQ. -func Voted(v *helpers.BigInt) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldVoted, v)) -} - -// BlockEQ applies the EQ predicate on the "block" field. -func BlockEQ(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldBlock, v)) -} - -// BlockNEQ applies the NEQ predicate on the "block" field. -func BlockNEQ(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldBlock, v)) -} - -// BlockIn applies the In predicate on the "block" field. -func BlockIn(vs ...uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldBlock, vs...)) -} - -// BlockNotIn applies the NotIn predicate on the "block" field. -func BlockNotIn(vs ...uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldBlock, vs...)) -} - -// BlockGT applies the GT predicate on the "block" field. -func BlockGT(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldBlock, v)) -} - -// BlockGTE applies the GTE predicate on the "block" field. -func BlockGTE(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldBlock, v)) -} - -// BlockLT applies the LT predicate on the "block" field. -func BlockLT(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldBlock, v)) -} - -// BlockLTE applies the LTE predicate on the "block" field. -func BlockLTE(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldBlock, v)) -} - -// SignersCountEQ applies the EQ predicate on the "signersCount" field. -func SignersCountEQ(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldSignersCount, v)) -} - -// SignersCountNEQ applies the NEQ predicate on the "signersCount" field. -func SignersCountNEQ(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldSignersCount, v)) -} - -// SignersCountIn applies the In predicate on the "signersCount" field. -func SignersCountIn(vs ...uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldSignersCount, vs...)) -} - -// SignersCountNotIn applies the NotIn predicate on the "signersCount" field. -func SignersCountNotIn(vs ...uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldSignersCount, vs...)) -} - -// SignersCountGT applies the GT predicate on the "signersCount" field. -func SignersCountGT(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldSignersCount, v)) -} - -// SignersCountGTE applies the GTE predicate on the "signersCount" field. -func SignersCountGTE(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldSignersCount, v)) -} - -// SignersCountLT applies the LT predicate on the "signersCount" field. -func SignersCountLT(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldSignersCount, v)) -} - -// SignersCountLTE applies the LTE predicate on the "signersCount" field. -func SignersCountLTE(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldSignersCount, v)) -} - -// SignatureEQ applies the EQ predicate on the "signature" field. -func SignatureEQ(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldSignature, v)) -} - -// SignatureNEQ applies the NEQ predicate on the "signature" field. -func SignatureNEQ(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldSignature, v)) -} - -// SignatureIn applies the In predicate on the "signature" field. -func SignatureIn(vs ...[]byte) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldSignature, vs...)) -} - -// SignatureNotIn applies the NotIn predicate on the "signature" field. -func SignatureNotIn(vs ...[]byte) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldSignature, vs...)) -} - -// SignatureGT applies the GT predicate on the "signature" field. -func SignatureGT(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldSignature, v)) -} - -// SignatureGTE applies the GTE predicate on the "signature" field. -func SignatureGTE(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldSignature, v)) -} - -// SignatureLT applies the LT predicate on the "signature" field. -func SignatureLT(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldSignature, v)) -} - -// SignatureLTE applies the LTE predicate on the "signature" field. -func SignatureLTE(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldSignature, v)) -} - -// AddressEQ applies the EQ predicate on the "address" field. -func AddressEQ(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldAddress, v)) -} - -// AddressNEQ applies the NEQ predicate on the "address" field. -func AddressNEQ(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldAddress, v)) -} - -// AddressIn applies the In predicate on the "address" field. -func AddressIn(vs ...string) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldAddress, vs...)) -} - -// AddressNotIn applies the NotIn predicate on the "address" field. -func AddressNotIn(vs ...string) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldAddress, vs...)) -} - -// AddressGT applies the GT predicate on the "address" field. -func AddressGT(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldAddress, v)) -} - -// AddressGTE applies the GTE predicate on the "address" field. -func AddressGTE(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldAddress, v)) -} - -// AddressLT applies the LT predicate on the "address" field. -func AddressLT(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldAddress, v)) -} - -// AddressLTE applies the LTE predicate on the "address" field. -func AddressLTE(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldAddress, v)) -} - -// AddressContains applies the Contains predicate on the "address" field. -func AddressContains(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldContains(FieldAddress, v)) -} - -// AddressHasPrefix applies the HasPrefix predicate on the "address" field. -func AddressHasPrefix(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldHasPrefix(FieldAddress, v)) -} - -// AddressHasSuffix applies the HasSuffix predicate on the "address" field. -func AddressHasSuffix(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldHasSuffix(FieldAddress, v)) -} - -// AddressEqualFold applies the EqualFold predicate on the "address" field. -func AddressEqualFold(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldEqualFold(FieldAddress, v)) -} - -// AddressContainsFold applies the ContainsFold predicate on the "address" field. -func AddressContainsFold(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldContainsFold(FieldAddress, v)) -} - -// ChainEQ applies the EQ predicate on the "chain" field. -func ChainEQ(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldChain, v)) -} - -// ChainNEQ applies the NEQ predicate on the "chain" field. -func ChainNEQ(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldChain, v)) -} - -// ChainIn applies the In predicate on the "chain" field. -func ChainIn(vs ...string) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldChain, vs...)) -} - -// ChainNotIn applies the NotIn predicate on the "chain" field. -func ChainNotIn(vs ...string) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldChain, vs...)) -} - -// ChainGT applies the GT predicate on the "chain" field. -func ChainGT(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldChain, v)) -} - -// ChainGTE applies the GTE predicate on the "chain" field. -func ChainGTE(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldChain, v)) -} - -// ChainLT applies the LT predicate on the "chain" field. -func ChainLT(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldChain, v)) -} - -// ChainLTE applies the LTE predicate on the "chain" field. -func ChainLTE(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldChain, v)) -} - -// ChainContains applies the Contains predicate on the "chain" field. -func ChainContains(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldContains(FieldChain, v)) -} - -// ChainHasPrefix applies the HasPrefix predicate on the "chain" field. -func ChainHasPrefix(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldHasPrefix(FieldChain, v)) -} - -// ChainHasSuffix applies the HasSuffix predicate on the "chain" field. -func ChainHasSuffix(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldHasSuffix(FieldChain, v)) -} - -// ChainEqualFold applies the EqualFold predicate on the "chain" field. -func ChainEqualFold(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldEqualFold(FieldChain, v)) -} - -// ChainContainsFold applies the ContainsFold predicate on the "chain" field. -func ChainContainsFold(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldContainsFold(FieldChain, v)) -} - -// IndexEQ applies the EQ predicate on the "index" field. -func IndexEQ(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldIndex, v)) -} - -// IndexNEQ applies the NEQ predicate on the "index" field. -func IndexNEQ(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldIndex, v)) -} - -// IndexIn applies the In predicate on the "index" field. -func IndexIn(vs ...uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldIndex, vs...)) -} - -// IndexNotIn applies the NotIn predicate on the "index" field. -func IndexNotIn(vs ...uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldIndex, vs...)) -} - -// IndexGT applies the GT predicate on the "index" field. -func IndexGT(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldIndex, v)) -} - -// IndexGTE applies the GTE predicate on the "index" field. -func IndexGTE(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldIndex, v)) -} - -// IndexLT applies the LT predicate on the "index" field. -func IndexLT(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldIndex, v)) -} - -// IndexLTE applies the LTE predicate on the "index" field. -func IndexLTE(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldIndex, v)) -} - -// EventEQ applies the EQ predicate on the "event" field. -func EventEQ(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldEvent, v)) -} - -// EventNEQ applies the NEQ predicate on the "event" field. -func EventNEQ(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldEvent, v)) -} - -// EventIn applies the In predicate on the "event" field. -func EventIn(vs ...string) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldEvent, vs...)) -} - -// EventNotIn applies the NotIn predicate on the "event" field. -func EventNotIn(vs ...string) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldEvent, vs...)) -} - -// EventGT applies the GT predicate on the "event" field. -func EventGT(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldEvent, v)) -} - -// EventGTE applies the GTE predicate on the "event" field. -func EventGTE(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldEvent, v)) -} - -// EventLT applies the LT predicate on the "event" field. -func EventLT(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldEvent, v)) -} - -// EventLTE applies the LTE predicate on the "event" field. -func EventLTE(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldEvent, v)) -} - -// EventContains applies the Contains predicate on the "event" field. -func EventContains(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldContains(FieldEvent, v)) -} - -// EventHasPrefix applies the HasPrefix predicate on the "event" field. -func EventHasPrefix(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldHasPrefix(FieldEvent, v)) -} - -// EventHasSuffix applies the HasSuffix predicate on the "event" field. -func EventHasSuffix(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldHasSuffix(FieldEvent, v)) -} - -// EventEqualFold applies the EqualFold predicate on the "event" field. -func EventEqualFold(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldEqualFold(FieldEvent, v)) -} - -// EventContainsFold applies the ContainsFold predicate on the "event" field. -func EventContainsFold(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldContainsFold(FieldEvent, v)) -} - -// TransactionEQ applies the EQ predicate on the "transaction" field. -func TransactionEQ(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldTransaction, v)) -} - -// TransactionNEQ applies the NEQ predicate on the "transaction" field. -func TransactionNEQ(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldTransaction, v)) -} - -// TransactionIn applies the In predicate on the "transaction" field. -func TransactionIn(vs ...[]byte) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldTransaction, vs...)) -} - -// TransactionNotIn applies the NotIn predicate on the "transaction" field. -func TransactionNotIn(vs ...[]byte) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldTransaction, vs...)) -} - -// TransactionGT applies the GT predicate on the "transaction" field. -func TransactionGT(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldTransaction, v)) -} - -// TransactionGTE applies the GTE predicate on the "transaction" field. -func TransactionGTE(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldTransaction, v)) -} - -// TransactionLT applies the LT predicate on the "transaction" field. -func TransactionLT(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldTransaction, v)) -} - -// TransactionLTE applies the LTE predicate on the "transaction" field. -func TransactionLTE(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldTransaction, v)) -} - -// ConsensusEQ applies the EQ predicate on the "consensus" field. -func ConsensusEQ(v bool) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldConsensus, v)) -} - -// ConsensusNEQ applies the NEQ predicate on the "consensus" field. -func ConsensusNEQ(v bool) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldConsensus, v)) -} - -// VotedEQ applies the EQ predicate on the "voted" field. -func VotedEQ(v *helpers.BigInt) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldVoted, v)) -} - -// VotedNEQ applies the NEQ predicate on the "voted" field. -func VotedNEQ(v *helpers.BigInt) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldVoted, v)) -} - -// VotedIn applies the In predicate on the "voted" field. -func VotedIn(vs ...*helpers.BigInt) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldVoted, vs...)) -} - -// VotedNotIn applies the NotIn predicate on the "voted" field. -func VotedNotIn(vs ...*helpers.BigInt) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldVoted, vs...)) -} - -// VotedGT applies the GT predicate on the "voted" field. -func VotedGT(v *helpers.BigInt) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldVoted, v)) -} - -// VotedGTE applies the GTE predicate on the "voted" field. -func VotedGTE(v *helpers.BigInt) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldVoted, v)) -} - -// VotedLT applies the LT predicate on the "voted" field. -func VotedLT(v *helpers.BigInt) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldVoted, v)) -} - -// VotedLTE applies the LTE predicate on the "voted" field. -func VotedLTE(v *helpers.BigInt) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldVoted, v)) -} - -// HasSigners applies the HasEdge predicate on the "signers" edge. -func HasSigners() predicate.EventLog { - return predicate.EventLog(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, SignersTable, SignersPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasSignersWith applies the HasEdge predicate on the "signers" edge with a given conditions (other predicates). -func HasSignersWith(preds ...predicate.Signer) predicate.EventLog { - return predicate.EventLog(func(s *sql.Selector) { - step := newSignersStep() - 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.EventLog) predicate.EventLog { - return predicate.EventLog(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.EventLog) predicate.EventLog { - return predicate.EventLog(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.EventLog) predicate.EventLog { - return predicate.EventLog(sql.NotPredicates(p)) -} diff --git a/internal/ent/eventlog_create.go b/internal/ent/eventlog_create.go deleted file mode 100644 index f6dde3f7..00000000 --- a/internal/ent/eventlog_create.go +++ /dev/null @@ -1,1109 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "github.com/TimeleapLabs/unchained/internal/model" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// EventLogCreate is the builder for creating a EventLog entity. -type EventLogCreate struct { - config - mutation *EventLogMutation - hooks []Hook - conflict []sql.ConflictOption -} - -// SetBlock sets the "block" field. -func (elc *EventLogCreate) SetBlock(u uint64) *EventLogCreate { - elc.mutation.SetBlock(u) - return elc -} - -// SetSignersCount sets the "signersCount" field. -func (elc *EventLogCreate) SetSignersCount(u uint64) *EventLogCreate { - elc.mutation.SetSignersCount(u) - return elc -} - -// SetSignature sets the "signature" field. -func (elc *EventLogCreate) SetSignature(b []byte) *EventLogCreate { - elc.mutation.SetSignature(b) - return elc -} - -// SetAddress sets the "address" field. -func (elc *EventLogCreate) SetAddress(s string) *EventLogCreate { - elc.mutation.SetAddress(s) - return elc -} - -// SetChain sets the "chain" field. -func (elc *EventLogCreate) SetChain(s string) *EventLogCreate { - elc.mutation.SetChain(s) - return elc -} - -// SetIndex sets the "index" field. -func (elc *EventLogCreate) SetIndex(u uint64) *EventLogCreate { - elc.mutation.SetIndex(u) - return elc -} - -// SetEvent sets the "event" field. -func (elc *EventLogCreate) SetEvent(s string) *EventLogCreate { - elc.mutation.SetEvent(s) - return elc -} - -// SetTransaction sets the "transaction" field. -func (elc *EventLogCreate) SetTransaction(b []byte) *EventLogCreate { - elc.mutation.SetTransaction(b) - return elc -} - -// SetArgs sets the "args" field. -func (elc *EventLogCreate) SetArgs(dla []model.EventLogArg) *EventLogCreate { - elc.mutation.SetArgs(dla) - return elc -} - -// SetConsensus sets the "consensus" field. -func (elc *EventLogCreate) SetConsensus(b bool) *EventLogCreate { - elc.mutation.SetConsensus(b) - return elc -} - -// SetNillableConsensus sets the "consensus" field if the given value is not nil. -func (elc *EventLogCreate) SetNillableConsensus(b *bool) *EventLogCreate { - if b != nil { - elc.SetConsensus(*b) - } - return elc -} - -// SetVoted sets the "voted" field. -func (elc *EventLogCreate) SetVoted(hi *helpers.BigInt) *EventLogCreate { - elc.mutation.SetVoted(hi) - return elc -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by IDs. -func (elc *EventLogCreate) AddSignerIDs(ids ...int) *EventLogCreate { - elc.mutation.AddSignerIDs(ids...) - return elc -} - -// AddSigners adds the "signers" edges to the Signer entity. -func (elc *EventLogCreate) AddSigners(s ...*Signer) *EventLogCreate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return elc.AddSignerIDs(ids...) -} - -// Mutation returns the EventLogMutation object of the builder. -func (elc *EventLogCreate) Mutation() *EventLogMutation { - return elc.mutation -} - -// Save creates the EventLog in the database. -func (elc *EventLogCreate) Save(ctx context.Context) (*EventLog, error) { - elc.defaults() - return withHooks(ctx, elc.sqlSave, elc.mutation, elc.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (elc *EventLogCreate) SaveX(ctx context.Context) *EventLog { - v, err := elc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (elc *EventLogCreate) Exec(ctx context.Context) error { - _, err := elc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (elc *EventLogCreate) ExecX(ctx context.Context) { - if err := elc.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (elc *EventLogCreate) defaults() { - if _, ok := elc.mutation.Consensus(); !ok { - v := eventlog.DefaultConsensus - elc.mutation.SetConsensus(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (elc *EventLogCreate) check() error { - if _, ok := elc.mutation.Block(); !ok { - return &ValidationError{Name: "block", err: errors.New(`ent: missing required field "EventLog.block"`)} - } - if _, ok := elc.mutation.SignersCount(); !ok { - return &ValidationError{Name: "signersCount", err: errors.New(`ent: missing required field "EventLog.signersCount"`)} - } - if _, ok := elc.mutation.Signature(); !ok { - return &ValidationError{Name: "signature", err: errors.New(`ent: missing required field "EventLog.signature"`)} - } - if v, ok := elc.mutation.Signature(); ok { - if err := eventlog.SignatureValidator(v); err != nil { - return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "EventLog.signature": %w`, err)} - } - } - if _, ok := elc.mutation.Address(); !ok { - return &ValidationError{Name: "address", err: errors.New(`ent: missing required field "EventLog.address"`)} - } - if _, ok := elc.mutation.Chain(); !ok { - return &ValidationError{Name: "chain", err: errors.New(`ent: missing required field "EventLog.chain"`)} - } - if _, ok := elc.mutation.Index(); !ok { - return &ValidationError{Name: "index", err: errors.New(`ent: missing required field "EventLog.index"`)} - } - if _, ok := elc.mutation.Event(); !ok { - return &ValidationError{Name: "event", err: errors.New(`ent: missing required field "EventLog.event"`)} - } - if _, ok := elc.mutation.Transaction(); !ok { - return &ValidationError{Name: "transaction", err: errors.New(`ent: missing required field "EventLog.transaction"`)} - } - if v, ok := elc.mutation.Transaction(); ok { - if err := eventlog.TransactionValidator(v); err != nil { - return &ValidationError{Name: "transaction", err: fmt.Errorf(`ent: validator failed for field "EventLog.transaction": %w`, err)} - } - } - if _, ok := elc.mutation.Args(); !ok { - return &ValidationError{Name: "args", err: errors.New(`ent: missing required field "EventLog.args"`)} - } - if _, ok := elc.mutation.Consensus(); !ok { - return &ValidationError{Name: "consensus", err: errors.New(`ent: missing required field "EventLog.consensus"`)} - } - if _, ok := elc.mutation.Voted(); !ok { - return &ValidationError{Name: "voted", err: errors.New(`ent: missing required field "EventLog.voted"`)} - } - if len(elc.mutation.SignersIDs()) == 0 { - return &ValidationError{Name: "signers", err: errors.New(`ent: missing required edge "EventLog.signers"`)} - } - return nil -} - -func (elc *EventLogCreate) sqlSave(ctx context.Context) (*EventLog, error) { - if err := elc.check(); err != nil { - return nil, err - } - _node, _spec := elc.createSpec() - if err := sqlgraph.CreateNode(ctx, elc.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) - elc.mutation.id = &_node.ID - elc.mutation.done = true - return _node, nil -} - -func (elc *EventLogCreate) createSpec() (*EventLog, *sqlgraph.CreateSpec) { - var ( - _node = &EventLog{config: elc.config} - _spec = sqlgraph.NewCreateSpec(eventlog.Table, sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt)) - ) - _spec.OnConflict = elc.conflict - if value, ok := elc.mutation.Block(); ok { - _spec.SetField(eventlog.FieldBlock, field.TypeUint64, value) - _node.Block = value - } - if value, ok := elc.mutation.SignersCount(); ok { - _spec.SetField(eventlog.FieldSignersCount, field.TypeUint64, value) - _node.SignersCount = value - } - if value, ok := elc.mutation.Signature(); ok { - _spec.SetField(eventlog.FieldSignature, field.TypeBytes, value) - _node.Signature = value - } - if value, ok := elc.mutation.Address(); ok { - _spec.SetField(eventlog.FieldAddress, field.TypeString, value) - _node.Address = value - } - if value, ok := elc.mutation.Chain(); ok { - _spec.SetField(eventlog.FieldChain, field.TypeString, value) - _node.Chain = value - } - if value, ok := elc.mutation.Index(); ok { - _spec.SetField(eventlog.FieldIndex, field.TypeUint64, value) - _node.Index = value - } - if value, ok := elc.mutation.Event(); ok { - _spec.SetField(eventlog.FieldEvent, field.TypeString, value) - _node.Event = value - } - if value, ok := elc.mutation.Transaction(); ok { - _spec.SetField(eventlog.FieldTransaction, field.TypeBytes, value) - _node.Transaction = value - } - if value, ok := elc.mutation.Args(); ok { - _spec.SetField(eventlog.FieldArgs, field.TypeJSON, value) - _node.Args = value - } - if value, ok := elc.mutation.Consensus(); ok { - _spec.SetField(eventlog.FieldConsensus, field.TypeBool, value) - _node.Consensus = value - } - if value, ok := elc.mutation.Voted(); ok { - _spec.SetField(eventlog.FieldVoted, field.TypeUint, value) - _node.Voted = value - } - if nodes := elc.mutation.SignersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: eventlog.SignersTable, - Columns: eventlog.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.EventLog.Create(). -// SetBlock(v). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.EventLogUpsert) { -// SetBlock(v+v). -// }). -// Exec(ctx) -func (elc *EventLogCreate) OnConflict(opts ...sql.ConflictOption) *EventLogUpsertOne { - elc.conflict = opts - return &EventLogUpsertOne{ - create: elc, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.EventLog.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (elc *EventLogCreate) OnConflictColumns(columns ...string) *EventLogUpsertOne { - elc.conflict = append(elc.conflict, sql.ConflictColumns(columns...)) - return &EventLogUpsertOne{ - create: elc, - } -} - -type ( - // EventLogUpsertOne is the builder for "upsert"-ing - // one EventLog node. - EventLogUpsertOne struct { - create *EventLogCreate - } - - // EventLogUpsert is the "OnConflict" setter. - EventLogUpsert struct { - *sql.UpdateSet - } -) - -// SetBlock sets the "block" field. -func (u *EventLogUpsert) SetBlock(v uint64) *EventLogUpsert { - u.Set(eventlog.FieldBlock, v) - return u -} - -// UpdateBlock sets the "block" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateBlock() *EventLogUpsert { - u.SetExcluded(eventlog.FieldBlock) - return u -} - -// AddBlock adds v to the "block" field. -func (u *EventLogUpsert) AddBlock(v uint64) *EventLogUpsert { - u.Add(eventlog.FieldBlock, v) - return u -} - -// SetSignersCount sets the "signersCount" field. -func (u *EventLogUpsert) SetSignersCount(v uint64) *EventLogUpsert { - u.Set(eventlog.FieldSignersCount, v) - return u -} - -// UpdateSignersCount sets the "signersCount" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateSignersCount() *EventLogUpsert { - u.SetExcluded(eventlog.FieldSignersCount) - return u -} - -// AddSignersCount adds v to the "signersCount" field. -func (u *EventLogUpsert) AddSignersCount(v uint64) *EventLogUpsert { - u.Add(eventlog.FieldSignersCount, v) - return u -} - -// SetSignature sets the "signature" field. -func (u *EventLogUpsert) SetSignature(v []byte) *EventLogUpsert { - u.Set(eventlog.FieldSignature, v) - return u -} - -// UpdateSignature sets the "signature" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateSignature() *EventLogUpsert { - u.SetExcluded(eventlog.FieldSignature) - return u -} - -// SetAddress sets the "address" field. -func (u *EventLogUpsert) SetAddress(v string) *EventLogUpsert { - u.Set(eventlog.FieldAddress, v) - return u -} - -// UpdateAddress sets the "address" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateAddress() *EventLogUpsert { - u.SetExcluded(eventlog.FieldAddress) - return u -} - -// SetChain sets the "chain" field. -func (u *EventLogUpsert) SetChain(v string) *EventLogUpsert { - u.Set(eventlog.FieldChain, v) - return u -} - -// UpdateChain sets the "chain" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateChain() *EventLogUpsert { - u.SetExcluded(eventlog.FieldChain) - return u -} - -// SetIndex sets the "index" field. -func (u *EventLogUpsert) SetIndex(v uint64) *EventLogUpsert { - u.Set(eventlog.FieldIndex, v) - return u -} - -// UpdateIndex sets the "index" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateIndex() *EventLogUpsert { - u.SetExcluded(eventlog.FieldIndex) - return u -} - -// AddIndex adds v to the "index" field. -func (u *EventLogUpsert) AddIndex(v uint64) *EventLogUpsert { - u.Add(eventlog.FieldIndex, v) - return u -} - -// SetEvent sets the "event" field. -func (u *EventLogUpsert) SetEvent(v string) *EventLogUpsert { - u.Set(eventlog.FieldEvent, v) - return u -} - -// UpdateEvent sets the "event" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateEvent() *EventLogUpsert { - u.SetExcluded(eventlog.FieldEvent) - return u -} - -// SetTransaction sets the "transaction" field. -func (u *EventLogUpsert) SetTransaction(v []byte) *EventLogUpsert { - u.Set(eventlog.FieldTransaction, v) - return u -} - -// UpdateTransaction sets the "transaction" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateTransaction() *EventLogUpsert { - u.SetExcluded(eventlog.FieldTransaction) - return u -} - -// SetArgs sets the "args" field. -func (u *EventLogUpsert) SetArgs(v []model.EventLogArg) *EventLogUpsert { - u.Set(eventlog.FieldArgs, v) - return u -} - -// UpdateArgs sets the "args" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateArgs() *EventLogUpsert { - u.SetExcluded(eventlog.FieldArgs) - return u -} - -// SetConsensus sets the "consensus" field. -func (u *EventLogUpsert) SetConsensus(v bool) *EventLogUpsert { - u.Set(eventlog.FieldConsensus, v) - return u -} - -// UpdateConsensus sets the "consensus" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateConsensus() *EventLogUpsert { - u.SetExcluded(eventlog.FieldConsensus) - return u -} - -// SetVoted sets the "voted" field. -func (u *EventLogUpsert) SetVoted(v *helpers.BigInt) *EventLogUpsert { - u.Set(eventlog.FieldVoted, v) - return u -} - -// UpdateVoted sets the "voted" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateVoted() *EventLogUpsert { - u.SetExcluded(eventlog.FieldVoted) - return u -} - -// UpdateNewValues updates the mutable fields using the new values that were set on create. -// Using this option is equivalent to using: -// -// client.EventLog.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *EventLogUpsertOne) UpdateNewValues() *EventLogUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.EventLog.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *EventLogUpsertOne) Ignore() *EventLogUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *EventLogUpsertOne) DoNothing() *EventLogUpsertOne { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the EventLogCreate.OnConflict -// documentation for more info. -func (u *EventLogUpsertOne) Update(set func(*EventLogUpsert)) *EventLogUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&EventLogUpsert{UpdateSet: update}) - })) - return u -} - -// SetBlock sets the "block" field. -func (u *EventLogUpsertOne) SetBlock(v uint64) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetBlock(v) - }) -} - -// AddBlock adds v to the "block" field. -func (u *EventLogUpsertOne) AddBlock(v uint64) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.AddBlock(v) - }) -} - -// UpdateBlock sets the "block" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateBlock() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateBlock() - }) -} - -// SetSignersCount sets the "signersCount" field. -func (u *EventLogUpsertOne) SetSignersCount(v uint64) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetSignersCount(v) - }) -} - -// AddSignersCount adds v to the "signersCount" field. -func (u *EventLogUpsertOne) AddSignersCount(v uint64) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.AddSignersCount(v) - }) -} - -// UpdateSignersCount sets the "signersCount" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateSignersCount() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateSignersCount() - }) -} - -// SetSignature sets the "signature" field. -func (u *EventLogUpsertOne) SetSignature(v []byte) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetSignature(v) - }) -} - -// UpdateSignature sets the "signature" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateSignature() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateSignature() - }) -} - -// SetAddress sets the "address" field. -func (u *EventLogUpsertOne) SetAddress(v string) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetAddress(v) - }) -} - -// UpdateAddress sets the "address" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateAddress() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateAddress() - }) -} - -// SetChain sets the "chain" field. -func (u *EventLogUpsertOne) SetChain(v string) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetChain(v) - }) -} - -// UpdateChain sets the "chain" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateChain() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateChain() - }) -} - -// SetIndex sets the "index" field. -func (u *EventLogUpsertOne) SetIndex(v uint64) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetIndex(v) - }) -} - -// AddIndex adds v to the "index" field. -func (u *EventLogUpsertOne) AddIndex(v uint64) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.AddIndex(v) - }) -} - -// UpdateIndex sets the "index" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateIndex() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateIndex() - }) -} - -// SetEvent sets the "event" field. -func (u *EventLogUpsertOne) SetEvent(v string) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetEvent(v) - }) -} - -// UpdateEvent sets the "event" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateEvent() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateEvent() - }) -} - -// SetTransaction sets the "transaction" field. -func (u *EventLogUpsertOne) SetTransaction(v []byte) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetTransaction(v) - }) -} - -// UpdateTransaction sets the "transaction" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateTransaction() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateTransaction() - }) -} - -// SetArgs sets the "args" field. -func (u *EventLogUpsertOne) SetArgs(v []model.EventLogArg) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetArgs(v) - }) -} - -// UpdateArgs sets the "args" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateArgs() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateArgs() - }) -} - -// SetConsensus sets the "consensus" field. -func (u *EventLogUpsertOne) SetConsensus(v bool) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetConsensus(v) - }) -} - -// UpdateConsensus sets the "consensus" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateConsensus() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateConsensus() - }) -} - -// SetVoted sets the "voted" field. -func (u *EventLogUpsertOne) SetVoted(v *helpers.BigInt) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetVoted(v) - }) -} - -// UpdateVoted sets the "voted" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateVoted() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateVoted() - }) -} - -// Exec executes the query. -func (u *EventLogUpsertOne) Exec(ctx context.Context) error { - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for EventLogCreate.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *EventLogUpsertOne) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} - -// Exec executes the UPSERT query and returns the inserted/updated ID. -func (u *EventLogUpsertOne) ID(ctx context.Context) (id int, err error) { - node, err := u.create.Save(ctx) - if err != nil { - return id, err - } - return node.ID, nil -} - -// IDX is like ID, but panics if an error occurs. -func (u *EventLogUpsertOne) IDX(ctx context.Context) int { - id, err := u.ID(ctx) - if err != nil { - panic(err) - } - return id -} - -// EventLogCreateBulk is the builder for creating many EventLog entities in bulk. -type EventLogCreateBulk struct { - config - err error - builders []*EventLogCreate - conflict []sql.ConflictOption -} - -// Save creates the EventLog entities in the database. -func (elcb *EventLogCreateBulk) Save(ctx context.Context) ([]*EventLog, error) { - if elcb.err != nil { - return nil, elcb.err - } - specs := make([]*sqlgraph.CreateSpec, len(elcb.builders)) - nodes := make([]*EventLog, len(elcb.builders)) - mutators := make([]Mutator, len(elcb.builders)) - for i := range elcb.builders { - func(i int, root context.Context) { - builder := elcb.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*EventLogMutation) - 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, elcb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - spec.OnConflict = elcb.conflict - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, elcb.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, elcb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (elcb *EventLogCreateBulk) SaveX(ctx context.Context) []*EventLog { - v, err := elcb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (elcb *EventLogCreateBulk) Exec(ctx context.Context) error { - _, err := elcb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (elcb *EventLogCreateBulk) ExecX(ctx context.Context) { - if err := elcb.Exec(ctx); err != nil { - panic(err) - } -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.EventLog.CreateBulk(builders...). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.EventLogUpsert) { -// SetBlock(v+v). -// }). -// Exec(ctx) -func (elcb *EventLogCreateBulk) OnConflict(opts ...sql.ConflictOption) *EventLogUpsertBulk { - elcb.conflict = opts - return &EventLogUpsertBulk{ - create: elcb, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.EventLog.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (elcb *EventLogCreateBulk) OnConflictColumns(columns ...string) *EventLogUpsertBulk { - elcb.conflict = append(elcb.conflict, sql.ConflictColumns(columns...)) - return &EventLogUpsertBulk{ - create: elcb, - } -} - -// EventLogUpsertBulk is the builder for "upsert"-ing -// a bulk of EventLog nodes. -type EventLogUpsertBulk struct { - create *EventLogCreateBulk -} - -// UpdateNewValues updates the mutable fields using the new values that -// were set on create. Using this option is equivalent to using: -// -// client.EventLog.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *EventLogUpsertBulk) UpdateNewValues() *EventLogUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.EventLog.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *EventLogUpsertBulk) Ignore() *EventLogUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *EventLogUpsertBulk) DoNothing() *EventLogUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the EventLogCreateBulk.OnConflict -// documentation for more info. -func (u *EventLogUpsertBulk) Update(set func(*EventLogUpsert)) *EventLogUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&EventLogUpsert{UpdateSet: update}) - })) - return u -} - -// SetBlock sets the "block" field. -func (u *EventLogUpsertBulk) SetBlock(v uint64) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetBlock(v) - }) -} - -// AddBlock adds v to the "block" field. -func (u *EventLogUpsertBulk) AddBlock(v uint64) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.AddBlock(v) - }) -} - -// UpdateBlock sets the "block" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateBlock() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateBlock() - }) -} - -// SetSignersCount sets the "signersCount" field. -func (u *EventLogUpsertBulk) SetSignersCount(v uint64) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetSignersCount(v) - }) -} - -// AddSignersCount adds v to the "signersCount" field. -func (u *EventLogUpsertBulk) AddSignersCount(v uint64) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.AddSignersCount(v) - }) -} - -// UpdateSignersCount sets the "signersCount" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateSignersCount() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateSignersCount() - }) -} - -// SetSignature sets the "signature" field. -func (u *EventLogUpsertBulk) SetSignature(v []byte) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetSignature(v) - }) -} - -// UpdateSignature sets the "signature" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateSignature() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateSignature() - }) -} - -// SetAddress sets the "address" field. -func (u *EventLogUpsertBulk) SetAddress(v string) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetAddress(v) - }) -} - -// UpdateAddress sets the "address" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateAddress() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateAddress() - }) -} - -// SetChain sets the "chain" field. -func (u *EventLogUpsertBulk) SetChain(v string) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetChain(v) - }) -} - -// UpdateChain sets the "chain" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateChain() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateChain() - }) -} - -// SetIndex sets the "index" field. -func (u *EventLogUpsertBulk) SetIndex(v uint64) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetIndex(v) - }) -} - -// AddIndex adds v to the "index" field. -func (u *EventLogUpsertBulk) AddIndex(v uint64) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.AddIndex(v) - }) -} - -// UpdateIndex sets the "index" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateIndex() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateIndex() - }) -} - -// SetEvent sets the "event" field. -func (u *EventLogUpsertBulk) SetEvent(v string) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetEvent(v) - }) -} - -// UpdateEvent sets the "event" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateEvent() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateEvent() - }) -} - -// SetTransaction sets the "transaction" field. -func (u *EventLogUpsertBulk) SetTransaction(v []byte) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetTransaction(v) - }) -} - -// UpdateTransaction sets the "transaction" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateTransaction() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateTransaction() - }) -} - -// SetArgs sets the "args" field. -func (u *EventLogUpsertBulk) SetArgs(v []model.EventLogArg) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetArgs(v) - }) -} - -// UpdateArgs sets the "args" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateArgs() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateArgs() - }) -} - -// SetConsensus sets the "consensus" field. -func (u *EventLogUpsertBulk) SetConsensus(v bool) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetConsensus(v) - }) -} - -// UpdateConsensus sets the "consensus" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateConsensus() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateConsensus() - }) -} - -// SetVoted sets the "voted" field. -func (u *EventLogUpsertBulk) SetVoted(v *helpers.BigInt) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetVoted(v) - }) -} - -// UpdateVoted sets the "voted" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateVoted() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateVoted() - }) -} - -// Exec executes the query. -func (u *EventLogUpsertBulk) Exec(ctx context.Context) error { - if u.create.err != nil { - return u.create.err - } - for i, b := range u.create.builders { - if len(b.conflict) != 0 { - return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the EventLogCreateBulk instead", i) - } - } - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for EventLogCreateBulk.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *EventLogUpsertBulk) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/ent/eventlog_delete.go b/internal/ent/eventlog_delete.go deleted file mode 100644 index 9ccd77a5..00000000 --- a/internal/ent/eventlog_delete.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" -) - -// EventLogDelete is the builder for deleting a EventLog entity. -type EventLogDelete struct { - config - hooks []Hook - mutation *EventLogMutation -} - -// Where appends a list predicates to the EventLogDelete builder. -func (eld *EventLogDelete) Where(ps ...predicate.EventLog) *EventLogDelete { - eld.mutation.Where(ps...) - return eld -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (eld *EventLogDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, eld.sqlExec, eld.mutation, eld.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (eld *EventLogDelete) ExecX(ctx context.Context) int { - n, err := eld.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (eld *EventLogDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(eventlog.Table, sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt)) - if ps := eld.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, eld.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - eld.mutation.done = true - return affected, err -} - -// EventLogDeleteOne is the builder for deleting a single EventLog entity. -type EventLogDeleteOne struct { - eld *EventLogDelete -} - -// Where appends a list predicates to the EventLogDelete builder. -func (eldo *EventLogDeleteOne) Where(ps ...predicate.EventLog) *EventLogDeleteOne { - eldo.eld.mutation.Where(ps...) - return eldo -} - -// Exec executes the deletion query. -func (eldo *EventLogDeleteOne) Exec(ctx context.Context) error { - n, err := eldo.eld.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{eventlog.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (eldo *EventLogDeleteOne) ExecX(ctx context.Context) { - if err := eldo.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/ent/eventlog_query.go b/internal/ent/eventlog_query.go deleted file mode 100644 index ff19f775..00000000 --- a/internal/ent/eventlog_query.go +++ /dev/null @@ -1,671 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "database/sql/driver" - "fmt" - "math" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// EventLogQuery is the builder for querying EventLog entities. -type EventLogQuery struct { - config - ctx *QueryContext - order []eventlog.OrderOption - inters []Interceptor - predicates []predicate.EventLog - withSigners *SignerQuery - modifiers []func(*sql.Selector) - loadTotal []func(context.Context, []*EventLog) error - withNamedSigners map[string]*SignerQuery - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the EventLogQuery builder. -func (elq *EventLogQuery) Where(ps ...predicate.EventLog) *EventLogQuery { - elq.predicates = append(elq.predicates, ps...) - return elq -} - -// Limit the number of records to be returned by this query. -func (elq *EventLogQuery) Limit(limit int) *EventLogQuery { - elq.ctx.Limit = &limit - return elq -} - -// Offset to start from. -func (elq *EventLogQuery) Offset(offset int) *EventLogQuery { - elq.ctx.Offset = &offset - return elq -} - -// 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 (elq *EventLogQuery) Unique(unique bool) *EventLogQuery { - elq.ctx.Unique = &unique - return elq -} - -// Order specifies how the records should be ordered. -func (elq *EventLogQuery) Order(o ...eventlog.OrderOption) *EventLogQuery { - elq.order = append(elq.order, o...) - return elq -} - -// QuerySigners chains the current query on the "signers" edge. -func (elq *EventLogQuery) QuerySigners() *SignerQuery { - query := (&SignerClient{config: elq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := elq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := elq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(eventlog.Table, eventlog.FieldID, selector), - sqlgraph.To(signer.Table, signer.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, eventlog.SignersTable, eventlog.SignersPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(elq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first EventLog entity from the query. -// Returns a *NotFoundError when no EventLog was found. -func (elq *EventLogQuery) First(ctx context.Context) (*EventLog, error) { - nodes, err := elq.Limit(1).All(setContextOp(ctx, elq.ctx, "First")) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{eventlog.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (elq *EventLogQuery) FirstX(ctx context.Context) *EventLog { - node, err := elq.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first EventLog ID from the query. -// Returns a *NotFoundError when no EventLog ID was found. -func (elq *EventLogQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = elq.Limit(1).IDs(setContextOp(ctx, elq.ctx, "FirstID")); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{eventlog.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (elq *EventLogQuery) FirstIDX(ctx context.Context) int { - id, err := elq.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single EventLog entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one EventLog entity is found. -// Returns a *NotFoundError when no EventLog entities are found. -func (elq *EventLogQuery) Only(ctx context.Context) (*EventLog, error) { - nodes, err := elq.Limit(2).All(setContextOp(ctx, elq.ctx, "Only")) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{eventlog.Label} - default: - return nil, &NotSingularError{eventlog.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (elq *EventLogQuery) OnlyX(ctx context.Context) *EventLog { - node, err := elq.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only EventLog ID in the query. -// Returns a *NotSingularError when more than one EventLog ID is found. -// Returns a *NotFoundError when no entities are found. -func (elq *EventLogQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = elq.Limit(2).IDs(setContextOp(ctx, elq.ctx, "OnlyID")); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{eventlog.Label} - default: - err = &NotSingularError{eventlog.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (elq *EventLogQuery) OnlyIDX(ctx context.Context) int { - id, err := elq.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of EventLogs. -func (elq *EventLogQuery) All(ctx context.Context) ([]*EventLog, error) { - ctx = setContextOp(ctx, elq.ctx, "All") - if err := elq.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*EventLog, *EventLogQuery]() - return withInterceptors[[]*EventLog](ctx, elq, qr, elq.inters) -} - -// AllX is like All, but panics if an error occurs. -func (elq *EventLogQuery) AllX(ctx context.Context) []*EventLog { - nodes, err := elq.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of EventLog IDs. -func (elq *EventLogQuery) IDs(ctx context.Context) (ids []int, err error) { - if elq.ctx.Unique == nil && elq.path != nil { - elq.Unique(true) - } - ctx = setContextOp(ctx, elq.ctx, "IDs") - if err = elq.Select(eventlog.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (elq *EventLogQuery) IDsX(ctx context.Context) []int { - ids, err := elq.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (elq *EventLogQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, elq.ctx, "Count") - if err := elq.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, elq, querierCount[*EventLogQuery](), elq.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (elq *EventLogQuery) CountX(ctx context.Context) int { - count, err := elq.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (elq *EventLogQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, elq.ctx, "Exist") - switch _, err := elq.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 (elq *EventLogQuery) ExistX(ctx context.Context) bool { - exist, err := elq.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the EventLogQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (elq *EventLogQuery) Clone() *EventLogQuery { - if elq == nil { - return nil - } - return &EventLogQuery{ - config: elq.config, - ctx: elq.ctx.Clone(), - order: append([]eventlog.OrderOption{}, elq.order...), - inters: append([]Interceptor{}, elq.inters...), - predicates: append([]predicate.EventLog{}, elq.predicates...), - withSigners: elq.withSigners.Clone(), - // clone intermediate query. - sql: elq.sql.Clone(), - path: elq.path, - } -} - -// WithSigners tells the query-builder to eager-load the nodes that are connected to -// the "signers" edge. The optional arguments are used to configure the query builder of the edge. -func (elq *EventLogQuery) WithSigners(opts ...func(*SignerQuery)) *EventLogQuery { - query := (&SignerClient{config: elq.config}).Query() - for _, opt := range opts { - opt(query) - } - elq.withSigners = query - return elq -} - -// 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 { -// Block uint64 `json:"block,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.EventLog.Query(). -// GroupBy(eventlog.FieldBlock). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (elq *EventLogQuery) GroupBy(field string, fields ...string) *EventLogGroupBy { - elq.ctx.Fields = append([]string{field}, fields...) - grbuild := &EventLogGroupBy{build: elq} - grbuild.flds = &elq.ctx.Fields - grbuild.label = eventlog.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 { -// Block uint64 `json:"block,omitempty"` -// } -// -// client.EventLog.Query(). -// Select(eventlog.FieldBlock). -// Scan(ctx, &v) -func (elq *EventLogQuery) Select(fields ...string) *EventLogSelect { - elq.ctx.Fields = append(elq.ctx.Fields, fields...) - sbuild := &EventLogSelect{EventLogQuery: elq} - sbuild.label = eventlog.Label - sbuild.flds, sbuild.scan = &elq.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a EventLogSelect configured with the given aggregations. -func (elq *EventLogQuery) Aggregate(fns ...AggregateFunc) *EventLogSelect { - return elq.Select().Aggregate(fns...) -} - -func (elq *EventLogQuery) prepareQuery(ctx context.Context) error { - for _, inter := range elq.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, elq); err != nil { - return err - } - } - } - for _, f := range elq.ctx.Fields { - if !eventlog.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if elq.path != nil { - prev, err := elq.path(ctx) - if err != nil { - return err - } - elq.sql = prev - } - return nil -} - -func (elq *EventLogQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*EventLog, error) { - var ( - nodes = []*EventLog{} - _spec = elq.querySpec() - loadedTypes = [1]bool{ - elq.withSigners != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*EventLog).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &EventLog{config: elq.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(elq.modifiers) > 0 { - _spec.Modifiers = elq.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, elq.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := elq.withSigners; query != nil { - if err := elq.loadSigners(ctx, query, nodes, - func(n *EventLog) { n.Edges.Signers = []*Signer{} }, - func(n *EventLog, e *Signer) { n.Edges.Signers = append(n.Edges.Signers, e) }); err != nil { - return nil, err - } - } - for name, query := range elq.withNamedSigners { - if err := elq.loadSigners(ctx, query, nodes, - func(n *EventLog) { n.appendNamedSigners(name) }, - func(n *EventLog, e *Signer) { n.appendNamedSigners(name, e) }); err != nil { - return nil, err - } - } - for i := range elq.loadTotal { - if err := elq.loadTotal[i](ctx, nodes); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (elq *EventLogQuery) loadSigners(ctx context.Context, query *SignerQuery, nodes []*EventLog, init func(*EventLog), assign func(*EventLog, *Signer)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int]*EventLog) - nids := make(map[int]map[*EventLog]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(eventlog.SignersTable) - s.Join(joinT).On(s.C(signer.FieldID), joinT.C(eventlog.SignersPrimaryKey[1])) - s.Where(sql.InValues(joinT.C(eventlog.SignersPrimaryKey[0]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(eventlog.SignersPrimaryKey[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[*EventLog]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*Signer](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 "signers" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} - -func (elq *EventLogQuery) sqlCount(ctx context.Context) (int, error) { - _spec := elq.querySpec() - if len(elq.modifiers) > 0 { - _spec.Modifiers = elq.modifiers - } - _spec.Node.Columns = elq.ctx.Fields - if len(elq.ctx.Fields) > 0 { - _spec.Unique = elq.ctx.Unique != nil && *elq.ctx.Unique - } - return sqlgraph.CountNodes(ctx, elq.driver, _spec) -} - -func (elq *EventLogQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(eventlog.Table, eventlog.Columns, sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt)) - _spec.From = elq.sql - if unique := elq.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if elq.path != nil { - _spec.Unique = true - } - if fields := elq.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, eventlog.FieldID) - for i := range fields { - if fields[i] != eventlog.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := elq.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := elq.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := elq.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := elq.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (elq *EventLogQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(elq.driver.Dialect()) - t1 := builder.Table(eventlog.Table) - columns := elq.ctx.Fields - if len(columns) == 0 { - columns = eventlog.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if elq.sql != nil { - selector = elq.sql - selector.Select(selector.Columns(columns...)...) - } - if elq.ctx.Unique != nil && *elq.ctx.Unique { - selector.Distinct() - } - for _, p := range elq.predicates { - p(selector) - } - for _, p := range elq.order { - p(selector) - } - if offset := elq.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 := elq.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// WithNamedSigners tells the query-builder to eager-load the nodes that are connected to the "signers" -// edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (elq *EventLogQuery) WithNamedSigners(name string, opts ...func(*SignerQuery)) *EventLogQuery { - query := (&SignerClient{config: elq.config}).Query() - for _, opt := range opts { - opt(query) - } - if elq.withNamedSigners == nil { - elq.withNamedSigners = make(map[string]*SignerQuery) - } - elq.withNamedSigners[name] = query - return elq -} - -// EventLogGroupBy is the group-by builder for EventLog entities. -type EventLogGroupBy struct { - selector - build *EventLogQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (elgb *EventLogGroupBy) Aggregate(fns ...AggregateFunc) *EventLogGroupBy { - elgb.fns = append(elgb.fns, fns...) - return elgb -} - -// Scan applies the selector query and scans the result into the given value. -func (elgb *EventLogGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, elgb.build.ctx, "GroupBy") - if err := elgb.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*EventLogQuery, *EventLogGroupBy](ctx, elgb.build, elgb, elgb.build.inters, v) -} - -func (elgb *EventLogGroupBy) sqlScan(ctx context.Context, root *EventLogQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(elgb.fns)) - for _, fn := range elgb.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*elgb.flds)+len(elgb.fns)) - for _, f := range *elgb.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*elgb.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := elgb.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// EventLogSelect is the builder for selecting fields of EventLog entities. -type EventLogSelect struct { - *EventLogQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (els *EventLogSelect) Aggregate(fns ...AggregateFunc) *EventLogSelect { - els.fns = append(els.fns, fns...) - return els -} - -// Scan applies the selector query and scans the result into the given value. -func (els *EventLogSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, els.ctx, "Select") - if err := els.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*EventLogQuery, *EventLogSelect](ctx, els.EventLogQuery, els, els.inters, v) -} - -func (els *EventLogSelect) sqlScan(ctx context.Context, root *EventLogQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(els.fns)) - for _, fn := range els.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*els.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 := els.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} diff --git a/internal/ent/eventlog_update.go b/internal/ent/eventlog_update.go deleted file mode 100644 index 00120a19..00000000 --- a/internal/ent/eventlog_update.go +++ /dev/null @@ -1,769 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "github.com/TimeleapLabs/unchained/internal/model" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/dialect/sql/sqljson" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// EventLogUpdate is the builder for updating EventLog entities. -type EventLogUpdate struct { - config - hooks []Hook - mutation *EventLogMutation -} - -// Where appends a list predicates to the EventLogUpdate builder. -func (elu *EventLogUpdate) Where(ps ...predicate.EventLog) *EventLogUpdate { - elu.mutation.Where(ps...) - return elu -} - -// SetBlock sets the "block" field. -func (elu *EventLogUpdate) SetBlock(u uint64) *EventLogUpdate { - elu.mutation.ResetBlock() - elu.mutation.SetBlock(u) - return elu -} - -// SetNillableBlock sets the "block" field if the given value is not nil. -func (elu *EventLogUpdate) SetNillableBlock(u *uint64) *EventLogUpdate { - if u != nil { - elu.SetBlock(*u) - } - return elu -} - -// AddBlock adds u to the "block" field. -func (elu *EventLogUpdate) AddBlock(u int64) *EventLogUpdate { - elu.mutation.AddBlock(u) - return elu -} - -// SetSignersCount sets the "signersCount" field. -func (elu *EventLogUpdate) SetSignersCount(u uint64) *EventLogUpdate { - elu.mutation.ResetSignersCount() - elu.mutation.SetSignersCount(u) - return elu -} - -// SetNillableSignersCount sets the "signersCount" field if the given value is not nil. -func (elu *EventLogUpdate) SetNillableSignersCount(u *uint64) *EventLogUpdate { - if u != nil { - elu.SetSignersCount(*u) - } - return elu -} - -// AddSignersCount adds u to the "signersCount" field. -func (elu *EventLogUpdate) AddSignersCount(u int64) *EventLogUpdate { - elu.mutation.AddSignersCount(u) - return elu -} - -// SetSignature sets the "signature" field. -func (elu *EventLogUpdate) SetSignature(b []byte) *EventLogUpdate { - elu.mutation.SetSignature(b) - return elu -} - -// SetAddress sets the "address" field. -func (elu *EventLogUpdate) SetAddress(s string) *EventLogUpdate { - elu.mutation.SetAddress(s) - return elu -} - -// SetNillableAddress sets the "address" field if the given value is not nil. -func (elu *EventLogUpdate) SetNillableAddress(s *string) *EventLogUpdate { - if s != nil { - elu.SetAddress(*s) - } - return elu -} - -// SetChain sets the "chain" field. -func (elu *EventLogUpdate) SetChain(s string) *EventLogUpdate { - elu.mutation.SetChain(s) - return elu -} - -// SetNillableChain sets the "chain" field if the given value is not nil. -func (elu *EventLogUpdate) SetNillableChain(s *string) *EventLogUpdate { - if s != nil { - elu.SetChain(*s) - } - return elu -} - -// SetIndex sets the "index" field. -func (elu *EventLogUpdate) SetIndex(u uint64) *EventLogUpdate { - elu.mutation.ResetIndex() - elu.mutation.SetIndex(u) - return elu -} - -// SetNillableIndex sets the "index" field if the given value is not nil. -func (elu *EventLogUpdate) SetNillableIndex(u *uint64) *EventLogUpdate { - if u != nil { - elu.SetIndex(*u) - } - return elu -} - -// AddIndex adds u to the "index" field. -func (elu *EventLogUpdate) AddIndex(u int64) *EventLogUpdate { - elu.mutation.AddIndex(u) - return elu -} - -// SetEvent sets the "event" field. -func (elu *EventLogUpdate) SetEvent(s string) *EventLogUpdate { - elu.mutation.SetEvent(s) - return elu -} - -// SetNillableEvent sets the "event" field if the given value is not nil. -func (elu *EventLogUpdate) SetNillableEvent(s *string) *EventLogUpdate { - if s != nil { - elu.SetEvent(*s) - } - return elu -} - -// SetTransaction sets the "transaction" field. -func (elu *EventLogUpdate) SetTransaction(b []byte) *EventLogUpdate { - elu.mutation.SetTransaction(b) - return elu -} - -// SetArgs sets the "args" field. -func (elu *EventLogUpdate) SetArgs(dla []model.EventLogArg) *EventLogUpdate { - elu.mutation.SetArgs(dla) - return elu -} - -// AppendArgs appends dla to the "args" field. -func (elu *EventLogUpdate) AppendArgs(dla []model.EventLogArg) *EventLogUpdate { - elu.mutation.AppendArgs(dla) - return elu -} - -// SetConsensus sets the "consensus" field. -func (elu *EventLogUpdate) SetConsensus(b bool) *EventLogUpdate { - elu.mutation.SetConsensus(b) - return elu -} - -// SetNillableConsensus sets the "consensus" field if the given value is not nil. -func (elu *EventLogUpdate) SetNillableConsensus(b *bool) *EventLogUpdate { - if b != nil { - elu.SetConsensus(*b) - } - return elu -} - -// SetVoted sets the "voted" field. -func (elu *EventLogUpdate) SetVoted(hi *helpers.BigInt) *EventLogUpdate { - elu.mutation.SetVoted(hi) - return elu -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by IDs. -func (elu *EventLogUpdate) AddSignerIDs(ids ...int) *EventLogUpdate { - elu.mutation.AddSignerIDs(ids...) - return elu -} - -// AddSigners adds the "signers" edges to the Signer entity. -func (elu *EventLogUpdate) AddSigners(s ...*Signer) *EventLogUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return elu.AddSignerIDs(ids...) -} - -// Mutation returns the EventLogMutation object of the builder. -func (elu *EventLogUpdate) Mutation() *EventLogMutation { - return elu.mutation -} - -// ClearSigners clears all "signers" edges to the Signer entity. -func (elu *EventLogUpdate) ClearSigners() *EventLogUpdate { - elu.mutation.ClearSigners() - return elu -} - -// RemoveSignerIDs removes the "signers" edge to Signer entities by IDs. -func (elu *EventLogUpdate) RemoveSignerIDs(ids ...int) *EventLogUpdate { - elu.mutation.RemoveSignerIDs(ids...) - return elu -} - -// RemoveSigners removes "signers" edges to Signer entities. -func (elu *EventLogUpdate) RemoveSigners(s ...*Signer) *EventLogUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return elu.RemoveSignerIDs(ids...) -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (elu *EventLogUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, elu.sqlSave, elu.mutation, elu.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (elu *EventLogUpdate) SaveX(ctx context.Context) int { - affected, err := elu.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (elu *EventLogUpdate) Exec(ctx context.Context) error { - _, err := elu.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (elu *EventLogUpdate) ExecX(ctx context.Context) { - if err := elu.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (elu *EventLogUpdate) check() error { - if v, ok := elu.mutation.Signature(); ok { - if err := eventlog.SignatureValidator(v); err != nil { - return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "EventLog.signature": %w`, err)} - } - } - if v, ok := elu.mutation.Transaction(); ok { - if err := eventlog.TransactionValidator(v); err != nil { - return &ValidationError{Name: "transaction", err: fmt.Errorf(`ent: validator failed for field "EventLog.transaction": %w`, err)} - } - } - return nil -} - -func (elu *EventLogUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := elu.check(); err != nil { - return n, err - } - _spec := sqlgraph.NewUpdateSpec(eventlog.Table, eventlog.Columns, sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt)) - if ps := elu.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := elu.mutation.Block(); ok { - _spec.SetField(eventlog.FieldBlock, field.TypeUint64, value) - } - if value, ok := elu.mutation.AddedBlock(); ok { - _spec.AddField(eventlog.FieldBlock, field.TypeUint64, value) - } - if value, ok := elu.mutation.SignersCount(); ok { - _spec.SetField(eventlog.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := elu.mutation.AddedSignersCount(); ok { - _spec.AddField(eventlog.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := elu.mutation.Signature(); ok { - _spec.SetField(eventlog.FieldSignature, field.TypeBytes, value) - } - if value, ok := elu.mutation.Address(); ok { - _spec.SetField(eventlog.FieldAddress, field.TypeString, value) - } - if value, ok := elu.mutation.Chain(); ok { - _spec.SetField(eventlog.FieldChain, field.TypeString, value) - } - if value, ok := elu.mutation.Index(); ok { - _spec.SetField(eventlog.FieldIndex, field.TypeUint64, value) - } - if value, ok := elu.mutation.AddedIndex(); ok { - _spec.AddField(eventlog.FieldIndex, field.TypeUint64, value) - } - if value, ok := elu.mutation.Event(); ok { - _spec.SetField(eventlog.FieldEvent, field.TypeString, value) - } - if value, ok := elu.mutation.Transaction(); ok { - _spec.SetField(eventlog.FieldTransaction, field.TypeBytes, value) - } - if value, ok := elu.mutation.Args(); ok { - _spec.SetField(eventlog.FieldArgs, field.TypeJSON, value) - } - if value, ok := elu.mutation.AppendedArgs(); ok { - _spec.AddModifier(func(u *sql.UpdateBuilder) { - sqljson.Append(u, eventlog.FieldArgs, value) - }) - } - if value, ok := elu.mutation.Consensus(); ok { - _spec.SetField(eventlog.FieldConsensus, field.TypeBool, value) - } - if value, ok := elu.mutation.Voted(); ok { - _spec.SetField(eventlog.FieldVoted, field.TypeUint, value) - } - if elu.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: eventlog.SignersTable, - Columns: eventlog.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := elu.mutation.RemovedSignersIDs(); len(nodes) > 0 && !elu.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: eventlog.SignersTable, - Columns: eventlog.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.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 := elu.mutation.SignersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: eventlog.SignersTable, - Columns: eventlog.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.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, elu.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{eventlog.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - elu.mutation.done = true - return n, nil -} - -// EventLogUpdateOne is the builder for updating a single EventLog entity. -type EventLogUpdateOne struct { - config - fields []string - hooks []Hook - mutation *EventLogMutation -} - -// SetBlock sets the "block" field. -func (eluo *EventLogUpdateOne) SetBlock(u uint64) *EventLogUpdateOne { - eluo.mutation.ResetBlock() - eluo.mutation.SetBlock(u) - return eluo -} - -// SetNillableBlock sets the "block" field if the given value is not nil. -func (eluo *EventLogUpdateOne) SetNillableBlock(u *uint64) *EventLogUpdateOne { - if u != nil { - eluo.SetBlock(*u) - } - return eluo -} - -// AddBlock adds u to the "block" field. -func (eluo *EventLogUpdateOne) AddBlock(u int64) *EventLogUpdateOne { - eluo.mutation.AddBlock(u) - return eluo -} - -// SetSignersCount sets the "signersCount" field. -func (eluo *EventLogUpdateOne) SetSignersCount(u uint64) *EventLogUpdateOne { - eluo.mutation.ResetSignersCount() - eluo.mutation.SetSignersCount(u) - return eluo -} - -// SetNillableSignersCount sets the "signersCount" field if the given value is not nil. -func (eluo *EventLogUpdateOne) SetNillableSignersCount(u *uint64) *EventLogUpdateOne { - if u != nil { - eluo.SetSignersCount(*u) - } - return eluo -} - -// AddSignersCount adds u to the "signersCount" field. -func (eluo *EventLogUpdateOne) AddSignersCount(u int64) *EventLogUpdateOne { - eluo.mutation.AddSignersCount(u) - return eluo -} - -// SetSignature sets the "signature" field. -func (eluo *EventLogUpdateOne) SetSignature(b []byte) *EventLogUpdateOne { - eluo.mutation.SetSignature(b) - return eluo -} - -// SetAddress sets the "address" field. -func (eluo *EventLogUpdateOne) SetAddress(s string) *EventLogUpdateOne { - eluo.mutation.SetAddress(s) - return eluo -} - -// SetNillableAddress sets the "address" field if the given value is not nil. -func (eluo *EventLogUpdateOne) SetNillableAddress(s *string) *EventLogUpdateOne { - if s != nil { - eluo.SetAddress(*s) - } - return eluo -} - -// SetChain sets the "chain" field. -func (eluo *EventLogUpdateOne) SetChain(s string) *EventLogUpdateOne { - eluo.mutation.SetChain(s) - return eluo -} - -// SetNillableChain sets the "chain" field if the given value is not nil. -func (eluo *EventLogUpdateOne) SetNillableChain(s *string) *EventLogUpdateOne { - if s != nil { - eluo.SetChain(*s) - } - return eluo -} - -// SetIndex sets the "index" field. -func (eluo *EventLogUpdateOne) SetIndex(u uint64) *EventLogUpdateOne { - eluo.mutation.ResetIndex() - eluo.mutation.SetIndex(u) - return eluo -} - -// SetNillableIndex sets the "index" field if the given value is not nil. -func (eluo *EventLogUpdateOne) SetNillableIndex(u *uint64) *EventLogUpdateOne { - if u != nil { - eluo.SetIndex(*u) - } - return eluo -} - -// AddIndex adds u to the "index" field. -func (eluo *EventLogUpdateOne) AddIndex(u int64) *EventLogUpdateOne { - eluo.mutation.AddIndex(u) - return eluo -} - -// SetEvent sets the "event" field. -func (eluo *EventLogUpdateOne) SetEvent(s string) *EventLogUpdateOne { - eluo.mutation.SetEvent(s) - return eluo -} - -// SetNillableEvent sets the "event" field if the given value is not nil. -func (eluo *EventLogUpdateOne) SetNillableEvent(s *string) *EventLogUpdateOne { - if s != nil { - eluo.SetEvent(*s) - } - return eluo -} - -// SetTransaction sets the "transaction" field. -func (eluo *EventLogUpdateOne) SetTransaction(b []byte) *EventLogUpdateOne { - eluo.mutation.SetTransaction(b) - return eluo -} - -// SetArgs sets the "args" field. -func (eluo *EventLogUpdateOne) SetArgs(dla []model.EventLogArg) *EventLogUpdateOne { - eluo.mutation.SetArgs(dla) - return eluo -} - -// AppendArgs appends dla to the "args" field. -func (eluo *EventLogUpdateOne) AppendArgs(dla []model.EventLogArg) *EventLogUpdateOne { - eluo.mutation.AppendArgs(dla) - return eluo -} - -// SetConsensus sets the "consensus" field. -func (eluo *EventLogUpdateOne) SetConsensus(b bool) *EventLogUpdateOne { - eluo.mutation.SetConsensus(b) - return eluo -} - -// SetNillableConsensus sets the "consensus" field if the given value is not nil. -func (eluo *EventLogUpdateOne) SetNillableConsensus(b *bool) *EventLogUpdateOne { - if b != nil { - eluo.SetConsensus(*b) - } - return eluo -} - -// SetVoted sets the "voted" field. -func (eluo *EventLogUpdateOne) SetVoted(hi *helpers.BigInt) *EventLogUpdateOne { - eluo.mutation.SetVoted(hi) - return eluo -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by IDs. -func (eluo *EventLogUpdateOne) AddSignerIDs(ids ...int) *EventLogUpdateOne { - eluo.mutation.AddSignerIDs(ids...) - return eluo -} - -// AddSigners adds the "signers" edges to the Signer entity. -func (eluo *EventLogUpdateOne) AddSigners(s ...*Signer) *EventLogUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return eluo.AddSignerIDs(ids...) -} - -// Mutation returns the EventLogMutation object of the builder. -func (eluo *EventLogUpdateOne) Mutation() *EventLogMutation { - return eluo.mutation -} - -// ClearSigners clears all "signers" edges to the Signer entity. -func (eluo *EventLogUpdateOne) ClearSigners() *EventLogUpdateOne { - eluo.mutation.ClearSigners() - return eluo -} - -// RemoveSignerIDs removes the "signers" edge to Signer entities by IDs. -func (eluo *EventLogUpdateOne) RemoveSignerIDs(ids ...int) *EventLogUpdateOne { - eluo.mutation.RemoveSignerIDs(ids...) - return eluo -} - -// RemoveSigners removes "signers" edges to Signer entities. -func (eluo *EventLogUpdateOne) RemoveSigners(s ...*Signer) *EventLogUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return eluo.RemoveSignerIDs(ids...) -} - -// Where appends a list predicates to the EventLogUpdate builder. -func (eluo *EventLogUpdateOne) Where(ps ...predicate.EventLog) *EventLogUpdateOne { - eluo.mutation.Where(ps...) - return eluo -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (eluo *EventLogUpdateOne) Select(field string, fields ...string) *EventLogUpdateOne { - eluo.fields = append([]string{field}, fields...) - return eluo -} - -// Save executes the query and returns the updated EventLog entity. -func (eluo *EventLogUpdateOne) Save(ctx context.Context) (*EventLog, error) { - return withHooks(ctx, eluo.sqlSave, eluo.mutation, eluo.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (eluo *EventLogUpdateOne) SaveX(ctx context.Context) *EventLog { - node, err := eluo.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (eluo *EventLogUpdateOne) Exec(ctx context.Context) error { - _, err := eluo.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (eluo *EventLogUpdateOne) ExecX(ctx context.Context) { - if err := eluo.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (eluo *EventLogUpdateOne) check() error { - if v, ok := eluo.mutation.Signature(); ok { - if err := eventlog.SignatureValidator(v); err != nil { - return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "EventLog.signature": %w`, err)} - } - } - if v, ok := eluo.mutation.Transaction(); ok { - if err := eventlog.TransactionValidator(v); err != nil { - return &ValidationError{Name: "transaction", err: fmt.Errorf(`ent: validator failed for field "EventLog.transaction": %w`, err)} - } - } - return nil -} - -func (eluo *EventLogUpdateOne) sqlSave(ctx context.Context) (_node *EventLog, err error) { - if err := eluo.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(eventlog.Table, eventlog.Columns, sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt)) - id, ok := eluo.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EventLog.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := eluo.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, eventlog.FieldID) - for _, f := range fields { - if !eventlog.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != eventlog.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := eluo.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := eluo.mutation.Block(); ok { - _spec.SetField(eventlog.FieldBlock, field.TypeUint64, value) - } - if value, ok := eluo.mutation.AddedBlock(); ok { - _spec.AddField(eventlog.FieldBlock, field.TypeUint64, value) - } - if value, ok := eluo.mutation.SignersCount(); ok { - _spec.SetField(eventlog.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := eluo.mutation.AddedSignersCount(); ok { - _spec.AddField(eventlog.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := eluo.mutation.Signature(); ok { - _spec.SetField(eventlog.FieldSignature, field.TypeBytes, value) - } - if value, ok := eluo.mutation.Address(); ok { - _spec.SetField(eventlog.FieldAddress, field.TypeString, value) - } - if value, ok := eluo.mutation.Chain(); ok { - _spec.SetField(eventlog.FieldChain, field.TypeString, value) - } - if value, ok := eluo.mutation.Index(); ok { - _spec.SetField(eventlog.FieldIndex, field.TypeUint64, value) - } - if value, ok := eluo.mutation.AddedIndex(); ok { - _spec.AddField(eventlog.FieldIndex, field.TypeUint64, value) - } - if value, ok := eluo.mutation.Event(); ok { - _spec.SetField(eventlog.FieldEvent, field.TypeString, value) - } - if value, ok := eluo.mutation.Transaction(); ok { - _spec.SetField(eventlog.FieldTransaction, field.TypeBytes, value) - } - if value, ok := eluo.mutation.Args(); ok { - _spec.SetField(eventlog.FieldArgs, field.TypeJSON, value) - } - if value, ok := eluo.mutation.AppendedArgs(); ok { - _spec.AddModifier(func(u *sql.UpdateBuilder) { - sqljson.Append(u, eventlog.FieldArgs, value) - }) - } - if value, ok := eluo.mutation.Consensus(); ok { - _spec.SetField(eventlog.FieldConsensus, field.TypeBool, value) - } - if value, ok := eluo.mutation.Voted(); ok { - _spec.SetField(eventlog.FieldVoted, field.TypeUint, value) - } - if eluo.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: eventlog.SignersTable, - Columns: eventlog.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := eluo.mutation.RemovedSignersIDs(); len(nodes) > 0 && !eluo.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: eventlog.SignersTable, - Columns: eventlog.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.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 := eluo.mutation.SignersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: eventlog.SignersTable, - Columns: eventlog.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _node = &EventLog{config: eluo.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, eluo.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{eventlog.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - eluo.mutation.done = true - return _node, nil -} diff --git a/internal/ent/gql_collection.go b/internal/ent/gql_collection.go deleted file mode 100644 index b1a9b00d..00000000 --- a/internal/ent/gql_collection.go +++ /dev/null @@ -1,678 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - - "entgo.io/contrib/entgql" - "entgo.io/ent/dialect/sql" - "github.com/99designs/gqlgen/graphql" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. -func (ap *AssetPriceQuery) CollectFields(ctx context.Context, satisfies ...string) (*AssetPriceQuery, error) { - fc := graphql.GetFieldContext(ctx) - if fc == nil { - return ap, nil - } - if err := ap.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { - return nil, err - } - return ap, nil -} - -func (ap *AssetPriceQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { - path = append([]string(nil), path...) - var ( - unknownSeen bool - fieldSeen = make(map[string]struct{}, len(assetprice.Columns)) - selectedFields = []string{assetprice.FieldID} - ) - for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { - switch field.Name { - case "signers": - var ( - alias = field.Alias - path = append(path, alias) - query = (&SignerClient{config: ap.config}).Query() - ) - if err := query.collectField(ctx, opCtx, field, path, mayAddCondition(satisfies, signerImplementors)...); err != nil { - return err - } - ap.WithNamedSigners(alias, func(wq *SignerQuery) { - *wq = *query - }) - case "block": - if _, ok := fieldSeen[assetprice.FieldBlock]; !ok { - selectedFields = append(selectedFields, assetprice.FieldBlock) - fieldSeen[assetprice.FieldBlock] = struct{}{} - } - case "signerscount": - if _, ok := fieldSeen[assetprice.FieldSignersCount]; !ok { - selectedFields = append(selectedFields, assetprice.FieldSignersCount) - fieldSeen[assetprice.FieldSignersCount] = struct{}{} - } - case "price": - if _, ok := fieldSeen[assetprice.FieldPrice]; !ok { - selectedFields = append(selectedFields, assetprice.FieldPrice) - fieldSeen[assetprice.FieldPrice] = struct{}{} - } - case "signature": - if _, ok := fieldSeen[assetprice.FieldSignature]; !ok { - selectedFields = append(selectedFields, assetprice.FieldSignature) - fieldSeen[assetprice.FieldSignature] = struct{}{} - } - case "asset": - if _, ok := fieldSeen[assetprice.FieldAsset]; !ok { - selectedFields = append(selectedFields, assetprice.FieldAsset) - fieldSeen[assetprice.FieldAsset] = struct{}{} - } - case "chain": - if _, ok := fieldSeen[assetprice.FieldChain]; !ok { - selectedFields = append(selectedFields, assetprice.FieldChain) - fieldSeen[assetprice.FieldChain] = struct{}{} - } - case "pair": - if _, ok := fieldSeen[assetprice.FieldPair]; !ok { - selectedFields = append(selectedFields, assetprice.FieldPair) - fieldSeen[assetprice.FieldPair] = struct{}{} - } - case "consensus": - if _, ok := fieldSeen[assetprice.FieldConsensus]; !ok { - selectedFields = append(selectedFields, assetprice.FieldConsensus) - fieldSeen[assetprice.FieldConsensus] = struct{}{} - } - case "voted": - if _, ok := fieldSeen[assetprice.FieldVoted]; !ok { - selectedFields = append(selectedFields, assetprice.FieldVoted) - fieldSeen[assetprice.FieldVoted] = struct{}{} - } - case "id": - case "__typename": - default: - unknownSeen = true - } - } - if !unknownSeen { - ap.Select(selectedFields...) - } - return nil -} - -type assetpricePaginateArgs struct { - first, last *int - after, before *Cursor - opts []AssetPricePaginateOption -} - -func newAssetPricePaginateArgs(rv map[string]any) *assetpricePaginateArgs { - args := &assetpricePaginateArgs{} - if rv == nil { - return args - } - if v := rv[firstField]; v != nil { - args.first = v.(*int) - } - if v := rv[lastField]; v != nil { - args.last = v.(*int) - } - if v := rv[afterField]; v != nil { - args.after = v.(*Cursor) - } - if v := rv[beforeField]; v != nil { - args.before = v.(*Cursor) - } - if v, ok := rv[orderByField]; ok { - switch v := v.(type) { - case map[string]any: - var ( - err1, err2 error - order = &AssetPriceOrder{Field: &AssetPriceOrderField{}, Direction: entgql.OrderDirectionAsc} - ) - if d, ok := v[directionField]; ok { - err1 = order.Direction.UnmarshalGQL(d) - } - if f, ok := v[fieldField]; ok { - err2 = order.Field.UnmarshalGQL(f) - } - if err1 == nil && err2 == nil { - args.opts = append(args.opts, WithAssetPriceOrder(order)) - } - case *AssetPriceOrder: - if v != nil { - args.opts = append(args.opts, WithAssetPriceOrder(v)) - } - } - } - if v, ok := rv[whereField].(*AssetPriceWhereInput); ok { - args.opts = append(args.opts, WithAssetPriceFilter(v.Filter)) - } - return args -} - -// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. -func (cr *CorrectnessReportQuery) CollectFields(ctx context.Context, satisfies ...string) (*CorrectnessReportQuery, error) { - fc := graphql.GetFieldContext(ctx) - if fc == nil { - return cr, nil - } - if err := cr.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { - return nil, err - } - return cr, nil -} - -func (cr *CorrectnessReportQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { - path = append([]string(nil), path...) - var ( - unknownSeen bool - fieldSeen = make(map[string]struct{}, len(correctnessreport.Columns)) - selectedFields = []string{correctnessreport.FieldID} - ) - for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { - switch field.Name { - case "signers": - var ( - alias = field.Alias - path = append(path, alias) - query = (&SignerClient{config: cr.config}).Query() - ) - if err := query.collectField(ctx, opCtx, field, path, mayAddCondition(satisfies, signerImplementors)...); err != nil { - return err - } - cr.WithNamedSigners(alias, func(wq *SignerQuery) { - *wq = *query - }) - case "signerscount": - if _, ok := fieldSeen[correctnessreport.FieldSignersCount]; !ok { - selectedFields = append(selectedFields, correctnessreport.FieldSignersCount) - fieldSeen[correctnessreport.FieldSignersCount] = struct{}{} - } - case "timestamp": - if _, ok := fieldSeen[correctnessreport.FieldTimestamp]; !ok { - selectedFields = append(selectedFields, correctnessreport.FieldTimestamp) - fieldSeen[correctnessreport.FieldTimestamp] = struct{}{} - } - case "signature": - if _, ok := fieldSeen[correctnessreport.FieldSignature]; !ok { - selectedFields = append(selectedFields, correctnessreport.FieldSignature) - fieldSeen[correctnessreport.FieldSignature] = struct{}{} - } - case "hash": - if _, ok := fieldSeen[correctnessreport.FieldHash]; !ok { - selectedFields = append(selectedFields, correctnessreport.FieldHash) - fieldSeen[correctnessreport.FieldHash] = struct{}{} - } - case "topic": - if _, ok := fieldSeen[correctnessreport.FieldTopic]; !ok { - selectedFields = append(selectedFields, correctnessreport.FieldTopic) - fieldSeen[correctnessreport.FieldTopic] = struct{}{} - } - case "correct": - if _, ok := fieldSeen[correctnessreport.FieldCorrect]; !ok { - selectedFields = append(selectedFields, correctnessreport.FieldCorrect) - fieldSeen[correctnessreport.FieldCorrect] = struct{}{} - } - case "consensus": - if _, ok := fieldSeen[correctnessreport.FieldConsensus]; !ok { - selectedFields = append(selectedFields, correctnessreport.FieldConsensus) - fieldSeen[correctnessreport.FieldConsensus] = struct{}{} - } - case "voted": - if _, ok := fieldSeen[correctnessreport.FieldVoted]; !ok { - selectedFields = append(selectedFields, correctnessreport.FieldVoted) - fieldSeen[correctnessreport.FieldVoted] = struct{}{} - } - case "id": - case "__typename": - default: - unknownSeen = true - } - } - if !unknownSeen { - cr.Select(selectedFields...) - } - return nil -} - -type correctnessreportPaginateArgs struct { - first, last *int - after, before *Cursor - opts []CorrectnessReportPaginateOption -} - -func newCorrectnessReportPaginateArgs(rv map[string]any) *correctnessreportPaginateArgs { - args := &correctnessreportPaginateArgs{} - if rv == nil { - return args - } - if v := rv[firstField]; v != nil { - args.first = v.(*int) - } - if v := rv[lastField]; v != nil { - args.last = v.(*int) - } - if v := rv[afterField]; v != nil { - args.after = v.(*Cursor) - } - if v := rv[beforeField]; v != nil { - args.before = v.(*Cursor) - } - if v, ok := rv[orderByField]; ok { - switch v := v.(type) { - case map[string]any: - var ( - err1, err2 error - order = &CorrectnessReportOrder{Field: &CorrectnessReportOrderField{}, Direction: entgql.OrderDirectionAsc} - ) - if d, ok := v[directionField]; ok { - err1 = order.Direction.UnmarshalGQL(d) - } - if f, ok := v[fieldField]; ok { - err2 = order.Field.UnmarshalGQL(f) - } - if err1 == nil && err2 == nil { - args.opts = append(args.opts, WithCorrectnessReportOrder(order)) - } - case *CorrectnessReportOrder: - if v != nil { - args.opts = append(args.opts, WithCorrectnessReportOrder(v)) - } - } - } - if v, ok := rv[whereField].(*CorrectnessReportWhereInput); ok { - args.opts = append(args.opts, WithCorrectnessReportFilter(v.Filter)) - } - return args -} - -// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. -func (el *EventLogQuery) CollectFields(ctx context.Context, satisfies ...string) (*EventLogQuery, error) { - fc := graphql.GetFieldContext(ctx) - if fc == nil { - return el, nil - } - if err := el.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { - return nil, err - } - return el, nil -} - -func (el *EventLogQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { - path = append([]string(nil), path...) - var ( - unknownSeen bool - fieldSeen = make(map[string]struct{}, len(eventlog.Columns)) - selectedFields = []string{eventlog.FieldID} - ) - for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { - switch field.Name { - case "signers": - var ( - alias = field.Alias - path = append(path, alias) - query = (&SignerClient{config: el.config}).Query() - ) - if err := query.collectField(ctx, opCtx, field, path, mayAddCondition(satisfies, signerImplementors)...); err != nil { - return err - } - el.WithNamedSigners(alias, func(wq *SignerQuery) { - *wq = *query - }) - case "block": - if _, ok := fieldSeen[eventlog.FieldBlock]; !ok { - selectedFields = append(selectedFields, eventlog.FieldBlock) - fieldSeen[eventlog.FieldBlock] = struct{}{} - } - case "signerscount": - if _, ok := fieldSeen[eventlog.FieldSignersCount]; !ok { - selectedFields = append(selectedFields, eventlog.FieldSignersCount) - fieldSeen[eventlog.FieldSignersCount] = struct{}{} - } - case "signature": - if _, ok := fieldSeen[eventlog.FieldSignature]; !ok { - selectedFields = append(selectedFields, eventlog.FieldSignature) - fieldSeen[eventlog.FieldSignature] = struct{}{} - } - case "address": - if _, ok := fieldSeen[eventlog.FieldAddress]; !ok { - selectedFields = append(selectedFields, eventlog.FieldAddress) - fieldSeen[eventlog.FieldAddress] = struct{}{} - } - case "chain": - if _, ok := fieldSeen[eventlog.FieldChain]; !ok { - selectedFields = append(selectedFields, eventlog.FieldChain) - fieldSeen[eventlog.FieldChain] = struct{}{} - } - case "index": - if _, ok := fieldSeen[eventlog.FieldIndex]; !ok { - selectedFields = append(selectedFields, eventlog.FieldIndex) - fieldSeen[eventlog.FieldIndex] = struct{}{} - } - case "event": - if _, ok := fieldSeen[eventlog.FieldEvent]; !ok { - selectedFields = append(selectedFields, eventlog.FieldEvent) - fieldSeen[eventlog.FieldEvent] = struct{}{} - } - case "transaction": - if _, ok := fieldSeen[eventlog.FieldTransaction]; !ok { - selectedFields = append(selectedFields, eventlog.FieldTransaction) - fieldSeen[eventlog.FieldTransaction] = struct{}{} - } - case "args": - if _, ok := fieldSeen[eventlog.FieldArgs]; !ok { - selectedFields = append(selectedFields, eventlog.FieldArgs) - fieldSeen[eventlog.FieldArgs] = struct{}{} - } - case "consensus": - if _, ok := fieldSeen[eventlog.FieldConsensus]; !ok { - selectedFields = append(selectedFields, eventlog.FieldConsensus) - fieldSeen[eventlog.FieldConsensus] = struct{}{} - } - case "voted": - if _, ok := fieldSeen[eventlog.FieldVoted]; !ok { - selectedFields = append(selectedFields, eventlog.FieldVoted) - fieldSeen[eventlog.FieldVoted] = struct{}{} - } - case "id": - case "__typename": - default: - unknownSeen = true - } - } - if !unknownSeen { - el.Select(selectedFields...) - } - return nil -} - -type eventlogPaginateArgs struct { - first, last *int - after, before *Cursor - opts []EventLogPaginateOption -} - -func newEventLogPaginateArgs(rv map[string]any) *eventlogPaginateArgs { - args := &eventlogPaginateArgs{} - if rv == nil { - return args - } - if v := rv[firstField]; v != nil { - args.first = v.(*int) - } - if v := rv[lastField]; v != nil { - args.last = v.(*int) - } - if v := rv[afterField]; v != nil { - args.after = v.(*Cursor) - } - if v := rv[beforeField]; v != nil { - args.before = v.(*Cursor) - } - if v, ok := rv[orderByField]; ok { - switch v := v.(type) { - case map[string]any: - var ( - err1, err2 error - order = &EventLogOrder{Field: &EventLogOrderField{}, Direction: entgql.OrderDirectionAsc} - ) - if d, ok := v[directionField]; ok { - err1 = order.Direction.UnmarshalGQL(d) - } - if f, ok := v[fieldField]; ok { - err2 = order.Field.UnmarshalGQL(f) - } - if err1 == nil && err2 == nil { - args.opts = append(args.opts, WithEventLogOrder(order)) - } - case *EventLogOrder: - if v != nil { - args.opts = append(args.opts, WithEventLogOrder(v)) - } - } - } - if v, ok := rv[whereField].(*EventLogWhereInput); ok { - args.opts = append(args.opts, WithEventLogFilter(v.Filter)) - } - return args -} - -// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. -func (s *SignerQuery) CollectFields(ctx context.Context, satisfies ...string) (*SignerQuery, error) { - fc := graphql.GetFieldContext(ctx) - if fc == nil { - return s, nil - } - if err := s.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { - return nil, err - } - return s, nil -} - -func (s *SignerQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { - path = append([]string(nil), path...) - var ( - unknownSeen bool - fieldSeen = make(map[string]struct{}, len(signer.Columns)) - selectedFields = []string{signer.FieldID} - ) - for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { - switch field.Name { - case "assetprice": - var ( - alias = field.Alias - path = append(path, alias) - query = (&AssetPriceClient{config: s.config}).Query() - ) - if err := query.collectField(ctx, opCtx, field, path, mayAddCondition(satisfies, assetpriceImplementors)...); err != nil { - return err - } - s.WithNamedAssetPrice(alias, func(wq *AssetPriceQuery) { - *wq = *query - }) - case "eventlogs": - var ( - alias = field.Alias - path = append(path, alias) - query = (&EventLogClient{config: s.config}).Query() - ) - if err := query.collectField(ctx, opCtx, field, path, mayAddCondition(satisfies, eventlogImplementors)...); err != nil { - return err - } - s.WithNamedEventLogs(alias, func(wq *EventLogQuery) { - *wq = *query - }) - case "correctnessreport": - var ( - alias = field.Alias - path = append(path, alias) - query = (&CorrectnessReportClient{config: s.config}).Query() - ) - if err := query.collectField(ctx, opCtx, field, path, mayAddCondition(satisfies, correctnessreportImplementors)...); err != nil { - return err - } - s.WithNamedCorrectnessReport(alias, func(wq *CorrectnessReportQuery) { - *wq = *query - }) - case "name": - if _, ok := fieldSeen[signer.FieldName]; !ok { - selectedFields = append(selectedFields, signer.FieldName) - fieldSeen[signer.FieldName] = struct{}{} - } - case "evm": - if _, ok := fieldSeen[signer.FieldEvm]; !ok { - selectedFields = append(selectedFields, signer.FieldEvm) - fieldSeen[signer.FieldEvm] = struct{}{} - } - case "key": - if _, ok := fieldSeen[signer.FieldKey]; !ok { - selectedFields = append(selectedFields, signer.FieldKey) - fieldSeen[signer.FieldKey] = struct{}{} - } - case "shortkey": - if _, ok := fieldSeen[signer.FieldShortkey]; !ok { - selectedFields = append(selectedFields, signer.FieldShortkey) - fieldSeen[signer.FieldShortkey] = struct{}{} - } - case "points": - if _, ok := fieldSeen[signer.FieldPoints]; !ok { - selectedFields = append(selectedFields, signer.FieldPoints) - fieldSeen[signer.FieldPoints] = struct{}{} - } - case "id": - case "__typename": - default: - unknownSeen = true - } - } - if !unknownSeen { - s.Select(selectedFields...) - } - return nil -} - -type signerPaginateArgs struct { - first, last *int - after, before *Cursor - opts []SignerPaginateOption -} - -func newSignerPaginateArgs(rv map[string]any) *signerPaginateArgs { - args := &signerPaginateArgs{} - if rv == nil { - return args - } - if v := rv[firstField]; v != nil { - args.first = v.(*int) - } - if v := rv[lastField]; v != nil { - args.last = v.(*int) - } - if v := rv[afterField]; v != nil { - args.after = v.(*Cursor) - } - if v := rv[beforeField]; v != nil { - args.before = v.(*Cursor) - } - if v, ok := rv[orderByField]; ok { - switch v := v.(type) { - case map[string]any: - var ( - err1, err2 error - order = &SignerOrder{Field: &SignerOrderField{}, Direction: entgql.OrderDirectionAsc} - ) - if d, ok := v[directionField]; ok { - err1 = order.Direction.UnmarshalGQL(d) - } - if f, ok := v[fieldField]; ok { - err2 = order.Field.UnmarshalGQL(f) - } - if err1 == nil && err2 == nil { - args.opts = append(args.opts, WithSignerOrder(order)) - } - case *SignerOrder: - if v != nil { - args.opts = append(args.opts, WithSignerOrder(v)) - } - } - } - if v, ok := rv[whereField].(*SignerWhereInput); ok { - args.opts = append(args.opts, WithSignerFilter(v.Filter)) - } - return args -} - -const ( - afterField = "after" - firstField = "first" - beforeField = "before" - lastField = "last" - orderByField = "orderBy" - directionField = "direction" - fieldField = "field" - whereField = "where" -) - -func fieldArgs(ctx context.Context, whereInput any, path ...string) map[string]any { - field := collectedField(ctx, path...) - if field == nil || field.Arguments == nil { - return nil - } - oc := graphql.GetOperationContext(ctx) - args := field.ArgumentMap(oc.Variables) - return unmarshalArgs(ctx, whereInput, args) -} - -// unmarshalArgs allows extracting the field arguments from their raw representation. -func unmarshalArgs(ctx context.Context, whereInput any, args map[string]any) map[string]any { - for _, k := range []string{firstField, lastField} { - v, ok := args[k] - if !ok { - continue - } - i, err := graphql.UnmarshalInt(v) - if err == nil { - args[k] = &i - } - } - for _, k := range []string{beforeField, afterField} { - v, ok := args[k] - if !ok { - continue - } - c := &Cursor{} - if c.UnmarshalGQL(v) == nil { - args[k] = c - } - } - if v, ok := args[whereField]; ok && whereInput != nil { - if err := graphql.UnmarshalInputFromContext(ctx, v, whereInput); err == nil { - args[whereField] = whereInput - } - } - - return args -} - -func limitRows(partitionBy string, limit int, orderBy ...sql.Querier) func(s *sql.Selector) { - return func(s *sql.Selector) { - d := sql.Dialect(s.Dialect()) - s.SetDistinct(false) - with := d.With("src_query"). - As(s.Clone()). - With("limited_query"). - As( - d.Select("*"). - AppendSelectExprAs( - sql.RowNumber().PartitionBy(partitionBy).OrderExpr(orderBy...), - "row_number", - ). - From(d.Table("src_query")), - ) - t := d.Table("limited_query").As(s.TableName()) - *s = *d.Select(s.UnqualifiedColumns()...). - From(t). - Where(sql.LTE(t.C("row_number"), limit)). - Prefix(with) - } -} - -// mayAddCondition appends another type condition to the satisfies list -// if it does not exist in the list. -func mayAddCondition(satisfies []string, typeCond []string) []string { -Cond: - for _, c := range typeCond { - for _, s := range satisfies { - if c == s { - continue Cond - } - } - satisfies = append(satisfies, c) - } - return satisfies -} diff --git a/internal/ent/gql_edge.go b/internal/ent/gql_edge.go deleted file mode 100644 index a6cb9e8d..00000000 --- a/internal/ent/gql_edge.go +++ /dev/null @@ -1,81 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - - "github.com/99designs/gqlgen/graphql" -) - -func (ap *AssetPrice) Signers(ctx context.Context) (result []*Signer, err error) { - if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { - result, err = ap.NamedSigners(graphql.GetFieldContext(ctx).Field.Alias) - } else { - result, err = ap.Edges.SignersOrErr() - } - if IsNotLoaded(err) { - result, err = ap.QuerySigners().All(ctx) - } - return result, err -} - -func (cr *CorrectnessReport) Signers(ctx context.Context) (result []*Signer, err error) { - if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { - result, err = cr.NamedSigners(graphql.GetFieldContext(ctx).Field.Alias) - } else { - result, err = cr.Edges.SignersOrErr() - } - if IsNotLoaded(err) { - result, err = cr.QuerySigners().All(ctx) - } - return result, err -} - -func (el *EventLog) Signers(ctx context.Context) (result []*Signer, err error) { - if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { - result, err = el.NamedSigners(graphql.GetFieldContext(ctx).Field.Alias) - } else { - result, err = el.Edges.SignersOrErr() - } - if IsNotLoaded(err) { - result, err = el.QuerySigners().All(ctx) - } - return result, err -} - -func (s *Signer) AssetPrice(ctx context.Context) (result []*AssetPrice, err error) { - if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { - result, err = s.NamedAssetPrice(graphql.GetFieldContext(ctx).Field.Alias) - } else { - result, err = s.Edges.AssetPriceOrErr() - } - if IsNotLoaded(err) { - result, err = s.QueryAssetPrice().All(ctx) - } - return result, err -} - -func (s *Signer) EventLogs(ctx context.Context) (result []*EventLog, err error) { - if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { - result, err = s.NamedEventLogs(graphql.GetFieldContext(ctx).Field.Alias) - } else { - result, err = s.Edges.EventLogsOrErr() - } - if IsNotLoaded(err) { - result, err = s.QueryEventLogs().All(ctx) - } - return result, err -} - -func (s *Signer) CorrectnessReport(ctx context.Context) (result []*CorrectnessReport, err error) { - if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { - result, err = s.NamedCorrectnessReport(graphql.GetFieldContext(ctx).Field.Alias) - } else { - result, err = s.Edges.CorrectnessReportOrErr() - } - if IsNotLoaded(err) { - result, err = s.QueryCorrectnessReport().All(ctx) - } - return result, err -} diff --git a/internal/ent/gql_node.go b/internal/ent/gql_node.go deleted file mode 100644 index ac4e7c6a..00000000 --- a/internal/ent/gql_node.go +++ /dev/null @@ -1,348 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "fmt" - "sync" - "sync/atomic" - - "entgo.io/contrib/entgql" - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/schema" - "github.com/99designs/gqlgen/graphql" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/signer" - "github.com/hashicorp/go-multierror" - "golang.org/x/sync/semaphore" -) - -// Noder wraps the basic Node method. -type Noder interface { - IsNode() -} - -var assetpriceImplementors = []string{"AssetPrice", "Node"} - -// IsNode implements the Node interface check for GQLGen. -func (*AssetPrice) IsNode() {} - -var correctnessreportImplementors = []string{"CorrectnessReport", "Node"} - -// IsNode implements the Node interface check for GQLGen. -func (*CorrectnessReport) IsNode() {} - -var eventlogImplementors = []string{"EventLog", "Node"} - -// IsNode implements the Node interface check for GQLGen. -func (*EventLog) IsNode() {} - -var signerImplementors = []string{"Signer", "Node"} - -// IsNode implements the Node interface check for GQLGen. -func (*Signer) IsNode() {} - -var errNodeInvalidID = &NotFoundError{"node"} - -// NodeOption allows configuring the Noder execution using functional options. -type NodeOption func(*nodeOptions) - -// WithNodeType sets the node Type resolver function (i.e. the table to query). -// If was not provided, the table will be derived from the universal-id -// configuration as described in: https://entgo.io/docs/migrate/#universal-ids. -func WithNodeType(f func(context.Context, int) (string, error)) NodeOption { - return func(o *nodeOptions) { - o.nodeType = f - } -} - -// WithFixedNodeType sets the Type of the node to a fixed value. -func WithFixedNodeType(t string) NodeOption { - return WithNodeType(func(context.Context, int) (string, error) { - return t, nil - }) -} - -type nodeOptions struct { - nodeType func(context.Context, int) (string, error) -} - -func (c *Client) newNodeOpts(opts []NodeOption) *nodeOptions { - nopts := &nodeOptions{} - for _, opt := range opts { - opt(nopts) - } - if nopts.nodeType == nil { - nopts.nodeType = func(ctx context.Context, id int) (string, error) { - return c.tables.nodeType(ctx, c.driver, id) - } - } - return nopts -} - -// Noder returns a Node by its id. If the NodeType was not provided, it will -// be derived from the id value according to the universal-id configuration. -// -// c.Noder(ctx, id) -// c.Noder(ctx, id, ent.WithNodeType(typeResolver)) -func (c *Client) Noder(ctx context.Context, id int, opts ...NodeOption) (_ Noder, err error) { - defer func() { - if IsNotFound(err) { - err = multierror.Append(err, entgql.ErrNodeNotFound(id)) - } - }() - table, err := c.newNodeOpts(opts).nodeType(ctx, id) - if err != nil { - return nil, err - } - return c.noder(ctx, table, id) -} - -func (c *Client) noder(ctx context.Context, table string, id int) (Noder, error) { - switch table { - case assetprice.Table: - query := c.AssetPrice.Query(). - Where(assetprice.ID(id)) - query, err := query.CollectFields(ctx, assetpriceImplementors...) - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err - } - return n, nil - case correctnessreport.Table: - query := c.CorrectnessReport.Query(). - Where(correctnessreport.ID(id)) - query, err := query.CollectFields(ctx, correctnessreportImplementors...) - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err - } - return n, nil - case eventlog.Table: - query := c.EventLog.Query(). - Where(eventlog.ID(id)) - query, err := query.CollectFields(ctx, eventlogImplementors...) - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err - } - return n, nil - case signer.Table: - query := c.Signer.Query(). - Where(signer.ID(id)) - query, err := query.CollectFields(ctx, signerImplementors...) - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err - } - return n, nil - default: - return nil, fmt.Errorf("cannot resolve noder from table %q: %w", table, errNodeInvalidID) - } -} - -func (c *Client) Noders(ctx context.Context, ids []int, opts ...NodeOption) ([]Noder, error) { - switch len(ids) { - case 1: - noder, err := c.Noder(ctx, ids[0], opts...) - if err != nil { - return nil, err - } - return []Noder{noder}, nil - case 0: - return []Noder{}, nil - } - - noders := make([]Noder, len(ids)) - errors := make([]error, len(ids)) - tables := make(map[string][]int) - id2idx := make(map[int][]int, len(ids)) - nopts := c.newNodeOpts(opts) - for i, id := range ids { - table, err := nopts.nodeType(ctx, id) - if err != nil { - errors[i] = err - continue - } - tables[table] = append(tables[table], id) - id2idx[id] = append(id2idx[id], i) - } - - for table, ids := range tables { - nodes, err := c.noders(ctx, table, ids) - if err != nil { - for _, id := range ids { - for _, idx := range id2idx[id] { - errors[idx] = err - } - } - } else { - for i, id := range ids { - for _, idx := range id2idx[id] { - noders[idx] = nodes[i] - } - } - } - } - - for i, id := range ids { - if errors[i] == nil { - if noders[i] != nil { - continue - } - errors[i] = entgql.ErrNodeNotFound(id) - } else if IsNotFound(errors[i]) { - errors[i] = multierror.Append(errors[i], entgql.ErrNodeNotFound(id)) - } - ctx := graphql.WithPathContext(ctx, - graphql.NewPathWithIndex(i), - ) - graphql.AddError(ctx, errors[i]) - } - return noders, nil -} - -func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, error) { - noders := make([]Noder, len(ids)) - idmap := make(map[int][]*Noder, len(ids)) - for i, id := range ids { - idmap[id] = append(idmap[id], &noders[i]) - } - switch table { - case assetprice.Table: - query := c.AssetPrice.Query(). - Where(assetprice.IDIn(ids...)) - query, err := query.CollectFields(ctx, assetpriceImplementors...) - if err != nil { - return nil, err - } - nodes, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, node := range nodes { - for _, noder := range idmap[node.ID] { - *noder = node - } - } - case correctnessreport.Table: - query := c.CorrectnessReport.Query(). - Where(correctnessreport.IDIn(ids...)) - query, err := query.CollectFields(ctx, correctnessreportImplementors...) - if err != nil { - return nil, err - } - nodes, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, node := range nodes { - for _, noder := range idmap[node.ID] { - *noder = node - } - } - case eventlog.Table: - query := c.EventLog.Query(). - Where(eventlog.IDIn(ids...)) - query, err := query.CollectFields(ctx, eventlogImplementors...) - if err != nil { - return nil, err - } - nodes, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, node := range nodes { - for _, noder := range idmap[node.ID] { - *noder = node - } - } - case signer.Table: - query := c.Signer.Query(). - Where(signer.IDIn(ids...)) - query, err := query.CollectFields(ctx, signerImplementors...) - if err != nil { - return nil, err - } - nodes, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, node := range nodes { - for _, noder := range idmap[node.ID] { - *noder = node - } - } - default: - return nil, fmt.Errorf("cannot resolve noders from table %q: %w", table, errNodeInvalidID) - } - return noders, nil -} - -type tables struct { - once sync.Once - sem *semaphore.Weighted - value atomic.Value -} - -func (t *tables) nodeType(ctx context.Context, drv dialect.Driver, id int) (string, error) { - tables, err := t.Load(ctx, drv) - if err != nil { - return "", err - } - idx := int(id / (1<<32 - 1)) - if idx < 0 || idx >= len(tables) { - return "", fmt.Errorf("cannot resolve table from id %v: %w", id, errNodeInvalidID) - } - return tables[idx], nil -} - -func (t *tables) Load(ctx context.Context, drv dialect.Driver) ([]string, error) { - if tables := t.value.Load(); tables != nil { - return tables.([]string), nil - } - t.once.Do(func() { t.sem = semaphore.NewWeighted(1) }) - if err := t.sem.Acquire(ctx, 1); err != nil { - return nil, err - } - defer t.sem.Release(1) - if tables := t.value.Load(); tables != nil { - return tables.([]string), nil - } - tables, err := t.load(ctx, drv) - if err == nil { - t.value.Store(tables) - } - return tables, err -} - -func (*tables) load(ctx context.Context, drv dialect.Driver) ([]string, error) { - rows := &sql.Rows{} - query, args := sql.Dialect(drv.Dialect()). - Select("type"). - From(sql.Table(schema.TypeTable)). - OrderBy(sql.Asc("id")). - Query() - if err := drv.Query(ctx, query, args, rows); err != nil { - return nil, err - } - defer rows.Close() - var tables []string - return tables, sql.ScanSlice(rows, &tables) -} diff --git a/internal/ent/gql_pagination.go b/internal/ent/gql_pagination.go deleted file mode 100644 index 73161af9..00000000 --- a/internal/ent/gql_pagination.go +++ /dev/null @@ -1,1282 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "io" - "strconv" - - "entgo.io/contrib/entgql" - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/errcode" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/signer" - "github.com/vektah/gqlparser/v2/gqlerror" -) - -// Common entgql types. -type ( - Cursor = entgql.Cursor[int] - PageInfo = entgql.PageInfo[int] - OrderDirection = entgql.OrderDirection -) - -func orderFunc(o OrderDirection, field string) func(*sql.Selector) { - if o == entgql.OrderDirectionDesc { - return Desc(field) - } - return Asc(field) -} - -const errInvalidPagination = "INVALID_PAGINATION" - -func validateFirstLast(first, last *int) (err *gqlerror.Error) { - switch { - case first != nil && last != nil: - err = &gqlerror.Error{ - Message: "Passing both `first` and `last` to paginate a connection is not supported.", - } - case first != nil && *first < 0: - err = &gqlerror.Error{ - Message: "`first` on a connection cannot be less than zero.", - } - errcode.Set(err, errInvalidPagination) - case last != nil && *last < 0: - err = &gqlerror.Error{ - Message: "`last` on a connection cannot be less than zero.", - } - errcode.Set(err, errInvalidPagination) - } - return err -} - -func collectedField(ctx context.Context, path ...string) *graphql.CollectedField { - fc := graphql.GetFieldContext(ctx) - if fc == nil { - return nil - } - field := fc.Field - oc := graphql.GetOperationContext(ctx) -walk: - for _, name := range path { - for _, f := range graphql.CollectFields(oc, field.Selections, nil) { - if f.Alias == name { - field = f - continue walk - } - } - return nil - } - return &field -} - -func hasCollectedField(ctx context.Context, path ...string) bool { - if graphql.GetFieldContext(ctx) == nil { - return true - } - return collectedField(ctx, path...) != nil -} - -const ( - edgesField = "edges" - nodeField = "node" - pageInfoField = "pageInfo" - totalCountField = "totalCount" -) - -func paginateLimit(first, last *int) int { - var limit int - if first != nil { - limit = *first + 1 - } else if last != nil { - limit = *last + 1 - } - return limit -} - -// AssetPriceEdge is the edge representation of AssetPrice. -type AssetPriceEdge struct { - Node *AssetPrice `json:"node"` - Cursor Cursor `json:"cursor"` -} - -// AssetPriceConnection is the connection containing edges to AssetPrice. -type AssetPriceConnection struct { - Edges []*AssetPriceEdge `json:"edges"` - PageInfo PageInfo `json:"pageInfo"` - TotalCount int `json:"totalCount"` -} - -func (c *AssetPriceConnection) build(nodes []*AssetPrice, pager *assetpricePager, after *Cursor, first *int, before *Cursor, last *int) { - c.PageInfo.HasNextPage = before != nil - c.PageInfo.HasPreviousPage = after != nil - if first != nil && *first+1 == len(nodes) { - c.PageInfo.HasNextPage = true - nodes = nodes[:len(nodes)-1] - } else if last != nil && *last+1 == len(nodes) { - c.PageInfo.HasPreviousPage = true - nodes = nodes[:len(nodes)-1] - } - var nodeAt func(int) *AssetPrice - if last != nil { - n := len(nodes) - 1 - nodeAt = func(i int) *AssetPrice { - return nodes[n-i] - } - } else { - nodeAt = func(i int) *AssetPrice { - return nodes[i] - } - } - c.Edges = make([]*AssetPriceEdge, len(nodes)) - for i := range nodes { - node := nodeAt(i) - c.Edges[i] = &AssetPriceEdge{ - Node: node, - Cursor: pager.toCursor(node), - } - } - if l := len(c.Edges); l > 0 { - c.PageInfo.StartCursor = &c.Edges[0].Cursor - c.PageInfo.EndCursor = &c.Edges[l-1].Cursor - } - if c.TotalCount == 0 { - c.TotalCount = len(nodes) - } -} - -// AssetPricePaginateOption enables pagination customization. -type AssetPricePaginateOption func(*assetpricePager) error - -// WithAssetPriceOrder configures pagination ordering. -func WithAssetPriceOrder(order *AssetPriceOrder) AssetPricePaginateOption { - if order == nil { - order = DefaultAssetPriceOrder - } - o := *order - return func(pager *assetpricePager) error { - if err := o.Direction.Validate(); err != nil { - return err - } - if o.Field == nil { - o.Field = DefaultAssetPriceOrder.Field - } - pager.order = &o - return nil - } -} - -// WithAssetPriceFilter configures pagination filter. -func WithAssetPriceFilter(filter func(*AssetPriceQuery) (*AssetPriceQuery, error)) AssetPricePaginateOption { - return func(pager *assetpricePager) error { - if filter == nil { - return errors.New("AssetPriceQuery filter cannot be nil") - } - pager.filter = filter - return nil - } -} - -type assetpricePager struct { - reverse bool - order *AssetPriceOrder - filter func(*AssetPriceQuery) (*AssetPriceQuery, error) -} - -func newAssetPricePager(opts []AssetPricePaginateOption, reverse bool) (*assetpricePager, error) { - pager := &assetpricePager{reverse: reverse} - for _, opt := range opts { - if err := opt(pager); err != nil { - return nil, err - } - } - if pager.order == nil { - pager.order = DefaultAssetPriceOrder - } - return pager, nil -} - -func (p *assetpricePager) applyFilter(query *AssetPriceQuery) (*AssetPriceQuery, error) { - if p.filter != nil { - return p.filter(query) - } - return query, nil -} - -func (p *assetpricePager) toCursor(ap *AssetPrice) Cursor { - return p.order.Field.toCursor(ap) -} - -func (p *assetpricePager) applyCursors(query *AssetPriceQuery, after, before *Cursor) (*AssetPriceQuery, error) { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - for _, predicate := range entgql.CursorsPredicate(after, before, DefaultAssetPriceOrder.Field.column, p.order.Field.column, direction) { - query = query.Where(predicate) - } - return query, nil -} - -func (p *assetpricePager) applyOrder(query *AssetPriceQuery) *AssetPriceQuery { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) - if p.order.Field != DefaultAssetPriceOrder.Field { - query = query.Order(DefaultAssetPriceOrder.Field.toTerm(direction.OrderTermOption())) - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) - } - return query -} - -func (p *assetpricePager) orderExpr(query *AssetPriceQuery) sql.Querier { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) - } - return sql.ExprFunc(func(b *sql.Builder) { - b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) - if p.order.Field != DefaultAssetPriceOrder.Field { - b.Comma().Ident(DefaultAssetPriceOrder.Field.column).Pad().WriteString(string(direction)) - } - }) -} - -// Paginate executes the query and returns a relay based cursor connection to AssetPrice. -func (ap *AssetPriceQuery) Paginate( - ctx context.Context, after *Cursor, first *int, - before *Cursor, last *int, opts ...AssetPricePaginateOption, -) (*AssetPriceConnection, error) { - if err := validateFirstLast(first, last); err != nil { - return nil, err - } - pager, err := newAssetPricePager(opts, last != nil) - if err != nil { - return nil, err - } - if ap, err = pager.applyFilter(ap); err != nil { - return nil, err - } - conn := &AssetPriceConnection{Edges: []*AssetPriceEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) - if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { - hasPagination := after != nil || first != nil || before != nil || last != nil - if hasPagination || ignoredEdges { - c := ap.Clone() - c.ctx.Fields = nil - if conn.TotalCount, err = c.Count(ctx); err != nil { - return nil, err - } - conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 - conn.PageInfo.HasPreviousPage = last != nil && conn.TotalCount > 0 - } - } - if ignoredEdges || (first != nil && *first == 0) || (last != nil && *last == 0) { - return conn, nil - } - if ap, err = pager.applyCursors(ap, after, before); err != nil { - return nil, err - } - if limit := paginateLimit(first, last); limit != 0 { - ap.Limit(limit) - } - if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := ap.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { - return nil, err - } - } - ap = pager.applyOrder(ap) - nodes, err := ap.All(ctx) - if err != nil { - return nil, err - } - conn.build(nodes, pager, after, first, before, last) - return conn, nil -} - -var ( - // AssetPriceOrderFieldBlock orders AssetPrice by block. - AssetPriceOrderFieldBlock = &AssetPriceOrderField{ - Value: func(ap *AssetPrice) (ent.Value, error) { - return ap.Block, nil - }, - column: assetprice.FieldBlock, - toTerm: assetprice.ByBlock, - toCursor: func(ap *AssetPrice) Cursor { - return Cursor{ - ID: ap.ID, - Value: ap.Block, - } - }, - } -) - -// String implement fmt.Stringer interface. -func (f AssetPriceOrderField) String() string { - var str string - switch f.column { - case AssetPriceOrderFieldBlock.column: - str = "BLOCK" - } - return str -} - -// MarshalGQL implements graphql.Marshaler interface. -func (f AssetPriceOrderField) MarshalGQL(w io.Writer) { - io.WriteString(w, strconv.Quote(f.String())) -} - -// UnmarshalGQL implements graphql.Unmarshaler interface. -func (f *AssetPriceOrderField) UnmarshalGQL(v interface{}) error { - str, ok := v.(string) - if !ok { - return fmt.Errorf("AssetPriceOrderField %T must be a string", v) - } - switch str { - case "BLOCK": - *f = *AssetPriceOrderFieldBlock - default: - return fmt.Errorf("%s is not a valid AssetPriceOrderField", str) - } - return nil -} - -// AssetPriceOrderField defines the ordering field of AssetPrice. -type AssetPriceOrderField struct { - // Value extracts the ordering value from the given AssetPrice. - Value func(*AssetPrice) (ent.Value, error) - column string // field or computed. - toTerm func(...sql.OrderTermOption) assetprice.OrderOption - toCursor func(*AssetPrice) Cursor -} - -// AssetPriceOrder defines the ordering of AssetPrice. -type AssetPriceOrder struct { - Direction OrderDirection `json:"direction"` - Field *AssetPriceOrderField `json:"field"` -} - -// DefaultAssetPriceOrder is the default ordering of AssetPrice. -var DefaultAssetPriceOrder = &AssetPriceOrder{ - Direction: entgql.OrderDirectionAsc, - Field: &AssetPriceOrderField{ - Value: func(ap *AssetPrice) (ent.Value, error) { - return ap.ID, nil - }, - column: assetprice.FieldID, - toTerm: assetprice.ByID, - toCursor: func(ap *AssetPrice) Cursor { - return Cursor{ID: ap.ID} - }, - }, -} - -// ToEdge converts AssetPrice into AssetPriceEdge. -func (ap *AssetPrice) ToEdge(order *AssetPriceOrder) *AssetPriceEdge { - if order == nil { - order = DefaultAssetPriceOrder - } - return &AssetPriceEdge{ - Node: ap, - Cursor: order.Field.toCursor(ap), - } -} - -// CorrectnessReportEdge is the edge representation of CorrectnessReport. -type CorrectnessReportEdge struct { - Node *CorrectnessReport `json:"node"` - Cursor Cursor `json:"cursor"` -} - -// CorrectnessReportConnection is the connection containing edges to CorrectnessReport. -type CorrectnessReportConnection struct { - Edges []*CorrectnessReportEdge `json:"edges"` - PageInfo PageInfo `json:"pageInfo"` - TotalCount int `json:"totalCount"` -} - -func (c *CorrectnessReportConnection) build(nodes []*CorrectnessReport, pager *correctnessreportPager, after *Cursor, first *int, before *Cursor, last *int) { - c.PageInfo.HasNextPage = before != nil - c.PageInfo.HasPreviousPage = after != nil - if first != nil && *first+1 == len(nodes) { - c.PageInfo.HasNextPage = true - nodes = nodes[:len(nodes)-1] - } else if last != nil && *last+1 == len(nodes) { - c.PageInfo.HasPreviousPage = true - nodes = nodes[:len(nodes)-1] - } - var nodeAt func(int) *CorrectnessReport - if last != nil { - n := len(nodes) - 1 - nodeAt = func(i int) *CorrectnessReport { - return nodes[n-i] - } - } else { - nodeAt = func(i int) *CorrectnessReport { - return nodes[i] - } - } - c.Edges = make([]*CorrectnessReportEdge, len(nodes)) - for i := range nodes { - node := nodeAt(i) - c.Edges[i] = &CorrectnessReportEdge{ - Node: node, - Cursor: pager.toCursor(node), - } - } - if l := len(c.Edges); l > 0 { - c.PageInfo.StartCursor = &c.Edges[0].Cursor - c.PageInfo.EndCursor = &c.Edges[l-1].Cursor - } - if c.TotalCount == 0 { - c.TotalCount = len(nodes) - } -} - -// CorrectnessReportPaginateOption enables pagination customization. -type CorrectnessReportPaginateOption func(*correctnessreportPager) error - -// WithCorrectnessReportOrder configures pagination ordering. -func WithCorrectnessReportOrder(order *CorrectnessReportOrder) CorrectnessReportPaginateOption { - if order == nil { - order = DefaultCorrectnessReportOrder - } - o := *order - return func(pager *correctnessreportPager) error { - if err := o.Direction.Validate(); err != nil { - return err - } - if o.Field == nil { - o.Field = DefaultCorrectnessReportOrder.Field - } - pager.order = &o - return nil - } -} - -// WithCorrectnessReportFilter configures pagination filter. -func WithCorrectnessReportFilter(filter func(*CorrectnessReportQuery) (*CorrectnessReportQuery, error)) CorrectnessReportPaginateOption { - return func(pager *correctnessreportPager) error { - if filter == nil { - return errors.New("CorrectnessReportQuery filter cannot be nil") - } - pager.filter = filter - return nil - } -} - -type correctnessreportPager struct { - reverse bool - order *CorrectnessReportOrder - filter func(*CorrectnessReportQuery) (*CorrectnessReportQuery, error) -} - -func newCorrectnessReportPager(opts []CorrectnessReportPaginateOption, reverse bool) (*correctnessreportPager, error) { - pager := &correctnessreportPager{reverse: reverse} - for _, opt := range opts { - if err := opt(pager); err != nil { - return nil, err - } - } - if pager.order == nil { - pager.order = DefaultCorrectnessReportOrder - } - return pager, nil -} - -func (p *correctnessreportPager) applyFilter(query *CorrectnessReportQuery) (*CorrectnessReportQuery, error) { - if p.filter != nil { - return p.filter(query) - } - return query, nil -} - -func (p *correctnessreportPager) toCursor(cr *CorrectnessReport) Cursor { - return p.order.Field.toCursor(cr) -} - -func (p *correctnessreportPager) applyCursors(query *CorrectnessReportQuery, after, before *Cursor) (*CorrectnessReportQuery, error) { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - for _, predicate := range entgql.CursorsPredicate(after, before, DefaultCorrectnessReportOrder.Field.column, p.order.Field.column, direction) { - query = query.Where(predicate) - } - return query, nil -} - -func (p *correctnessreportPager) applyOrder(query *CorrectnessReportQuery) *CorrectnessReportQuery { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) - if p.order.Field != DefaultCorrectnessReportOrder.Field { - query = query.Order(DefaultCorrectnessReportOrder.Field.toTerm(direction.OrderTermOption())) - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) - } - return query -} - -func (p *correctnessreportPager) orderExpr(query *CorrectnessReportQuery) sql.Querier { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) - } - return sql.ExprFunc(func(b *sql.Builder) { - b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) - if p.order.Field != DefaultCorrectnessReportOrder.Field { - b.Comma().Ident(DefaultCorrectnessReportOrder.Field.column).Pad().WriteString(string(direction)) - } - }) -} - -// Paginate executes the query and returns a relay based cursor connection to CorrectnessReport. -func (cr *CorrectnessReportQuery) Paginate( - ctx context.Context, after *Cursor, first *int, - before *Cursor, last *int, opts ...CorrectnessReportPaginateOption, -) (*CorrectnessReportConnection, error) { - if err := validateFirstLast(first, last); err != nil { - return nil, err - } - pager, err := newCorrectnessReportPager(opts, last != nil) - if err != nil { - return nil, err - } - if cr, err = pager.applyFilter(cr); err != nil { - return nil, err - } - conn := &CorrectnessReportConnection{Edges: []*CorrectnessReportEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) - if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { - hasPagination := after != nil || first != nil || before != nil || last != nil - if hasPagination || ignoredEdges { - c := cr.Clone() - c.ctx.Fields = nil - if conn.TotalCount, err = c.Count(ctx); err != nil { - return nil, err - } - conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 - conn.PageInfo.HasPreviousPage = last != nil && conn.TotalCount > 0 - } - } - if ignoredEdges || (first != nil && *first == 0) || (last != nil && *last == 0) { - return conn, nil - } - if cr, err = pager.applyCursors(cr, after, before); err != nil { - return nil, err - } - if limit := paginateLimit(first, last); limit != 0 { - cr.Limit(limit) - } - if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := cr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { - return nil, err - } - } - cr = pager.applyOrder(cr) - nodes, err := cr.All(ctx) - if err != nil { - return nil, err - } - conn.build(nodes, pager, after, first, before, last) - return conn, nil -} - -var ( - // CorrectnessReportOrderFieldTimestamp orders CorrectnessReport by timestamp. - CorrectnessReportOrderFieldTimestamp = &CorrectnessReportOrderField{ - Value: func(cr *CorrectnessReport) (ent.Value, error) { - return cr.Timestamp, nil - }, - column: correctnessreport.FieldTimestamp, - toTerm: correctnessreport.ByTimestamp, - toCursor: func(cr *CorrectnessReport) Cursor { - return Cursor{ - ID: cr.ID, - Value: cr.Timestamp, - } - }, - } -) - -// String implement fmt.Stringer interface. -func (f CorrectnessReportOrderField) String() string { - var str string - switch f.column { - case CorrectnessReportOrderFieldTimestamp.column: - str = "TIMESTAMP" - } - return str -} - -// MarshalGQL implements graphql.Marshaler interface. -func (f CorrectnessReportOrderField) MarshalGQL(w io.Writer) { - io.WriteString(w, strconv.Quote(f.String())) -} - -// UnmarshalGQL implements graphql.Unmarshaler interface. -func (f *CorrectnessReportOrderField) UnmarshalGQL(v interface{}) error { - str, ok := v.(string) - if !ok { - return fmt.Errorf("CorrectnessReportOrderField %T must be a string", v) - } - switch str { - case "TIMESTAMP": - *f = *CorrectnessReportOrderFieldTimestamp - default: - return fmt.Errorf("%s is not a valid CorrectnessReportOrderField", str) - } - return nil -} - -// CorrectnessReportOrderField defines the ordering field of CorrectnessReport. -type CorrectnessReportOrderField struct { - // Value extracts the ordering value from the given CorrectnessReport. - Value func(*CorrectnessReport) (ent.Value, error) - column string // field or computed. - toTerm func(...sql.OrderTermOption) correctnessreport.OrderOption - toCursor func(*CorrectnessReport) Cursor -} - -// CorrectnessReportOrder defines the ordering of CorrectnessReport. -type CorrectnessReportOrder struct { - Direction OrderDirection `json:"direction"` - Field *CorrectnessReportOrderField `json:"field"` -} - -// DefaultCorrectnessReportOrder is the default ordering of CorrectnessReport. -var DefaultCorrectnessReportOrder = &CorrectnessReportOrder{ - Direction: entgql.OrderDirectionAsc, - Field: &CorrectnessReportOrderField{ - Value: func(cr *CorrectnessReport) (ent.Value, error) { - return cr.ID, nil - }, - column: correctnessreport.FieldID, - toTerm: correctnessreport.ByID, - toCursor: func(cr *CorrectnessReport) Cursor { - return Cursor{ID: cr.ID} - }, - }, -} - -// ToEdge converts CorrectnessReport into CorrectnessReportEdge. -func (cr *CorrectnessReport) ToEdge(order *CorrectnessReportOrder) *CorrectnessReportEdge { - if order == nil { - order = DefaultCorrectnessReportOrder - } - return &CorrectnessReportEdge{ - Node: cr, - Cursor: order.Field.toCursor(cr), - } -} - -// EventLogEdge is the edge representation of EventLog. -type EventLogEdge struct { - Node *EventLog `json:"node"` - Cursor Cursor `json:"cursor"` -} - -// EventLogConnection is the connection containing edges to EventLog. -type EventLogConnection struct { - Edges []*EventLogEdge `json:"edges"` - PageInfo PageInfo `json:"pageInfo"` - TotalCount int `json:"totalCount"` -} - -func (c *EventLogConnection) build(nodes []*EventLog, pager *eventlogPager, after *Cursor, first *int, before *Cursor, last *int) { - c.PageInfo.HasNextPage = before != nil - c.PageInfo.HasPreviousPage = after != nil - if first != nil && *first+1 == len(nodes) { - c.PageInfo.HasNextPage = true - nodes = nodes[:len(nodes)-1] - } else if last != nil && *last+1 == len(nodes) { - c.PageInfo.HasPreviousPage = true - nodes = nodes[:len(nodes)-1] - } - var nodeAt func(int) *EventLog - if last != nil { - n := len(nodes) - 1 - nodeAt = func(i int) *EventLog { - return nodes[n-i] - } - } else { - nodeAt = func(i int) *EventLog { - return nodes[i] - } - } - c.Edges = make([]*EventLogEdge, len(nodes)) - for i := range nodes { - node := nodeAt(i) - c.Edges[i] = &EventLogEdge{ - Node: node, - Cursor: pager.toCursor(node), - } - } - if l := len(c.Edges); l > 0 { - c.PageInfo.StartCursor = &c.Edges[0].Cursor - c.PageInfo.EndCursor = &c.Edges[l-1].Cursor - } - if c.TotalCount == 0 { - c.TotalCount = len(nodes) - } -} - -// EventLogPaginateOption enables pagination customization. -type EventLogPaginateOption func(*eventlogPager) error - -// WithEventLogOrder configures pagination ordering. -func WithEventLogOrder(order *EventLogOrder) EventLogPaginateOption { - if order == nil { - order = DefaultEventLogOrder - } - o := *order - return func(pager *eventlogPager) error { - if err := o.Direction.Validate(); err != nil { - return err - } - if o.Field == nil { - o.Field = DefaultEventLogOrder.Field - } - pager.order = &o - return nil - } -} - -// WithEventLogFilter configures pagination filter. -func WithEventLogFilter(filter func(*EventLogQuery) (*EventLogQuery, error)) EventLogPaginateOption { - return func(pager *eventlogPager) error { - if filter == nil { - return errors.New("EventLogQuery filter cannot be nil") - } - pager.filter = filter - return nil - } -} - -type eventlogPager struct { - reverse bool - order *EventLogOrder - filter func(*EventLogQuery) (*EventLogQuery, error) -} - -func newEventLogPager(opts []EventLogPaginateOption, reverse bool) (*eventlogPager, error) { - pager := &eventlogPager{reverse: reverse} - for _, opt := range opts { - if err := opt(pager); err != nil { - return nil, err - } - } - if pager.order == nil { - pager.order = DefaultEventLogOrder - } - return pager, nil -} - -func (p *eventlogPager) applyFilter(query *EventLogQuery) (*EventLogQuery, error) { - if p.filter != nil { - return p.filter(query) - } - return query, nil -} - -func (p *eventlogPager) toCursor(el *EventLog) Cursor { - return p.order.Field.toCursor(el) -} - -func (p *eventlogPager) applyCursors(query *EventLogQuery, after, before *Cursor) (*EventLogQuery, error) { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - for _, predicate := range entgql.CursorsPredicate(after, before, DefaultEventLogOrder.Field.column, p.order.Field.column, direction) { - query = query.Where(predicate) - } - return query, nil -} - -func (p *eventlogPager) applyOrder(query *EventLogQuery) *EventLogQuery { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) - if p.order.Field != DefaultEventLogOrder.Field { - query = query.Order(DefaultEventLogOrder.Field.toTerm(direction.OrderTermOption())) - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) - } - return query -} - -func (p *eventlogPager) orderExpr(query *EventLogQuery) sql.Querier { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) - } - return sql.ExprFunc(func(b *sql.Builder) { - b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) - if p.order.Field != DefaultEventLogOrder.Field { - b.Comma().Ident(DefaultEventLogOrder.Field.column).Pad().WriteString(string(direction)) - } - }) -} - -// Paginate executes the query and returns a relay based cursor connection to EventLog. -func (el *EventLogQuery) Paginate( - ctx context.Context, after *Cursor, first *int, - before *Cursor, last *int, opts ...EventLogPaginateOption, -) (*EventLogConnection, error) { - if err := validateFirstLast(first, last); err != nil { - return nil, err - } - pager, err := newEventLogPager(opts, last != nil) - if err != nil { - return nil, err - } - if el, err = pager.applyFilter(el); err != nil { - return nil, err - } - conn := &EventLogConnection{Edges: []*EventLogEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) - if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { - hasPagination := after != nil || first != nil || before != nil || last != nil - if hasPagination || ignoredEdges { - c := el.Clone() - c.ctx.Fields = nil - if conn.TotalCount, err = c.Count(ctx); err != nil { - return nil, err - } - conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 - conn.PageInfo.HasPreviousPage = last != nil && conn.TotalCount > 0 - } - } - if ignoredEdges || (first != nil && *first == 0) || (last != nil && *last == 0) { - return conn, nil - } - if el, err = pager.applyCursors(el, after, before); err != nil { - return nil, err - } - if limit := paginateLimit(first, last); limit != 0 { - el.Limit(limit) - } - if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := el.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { - return nil, err - } - } - el = pager.applyOrder(el) - nodes, err := el.All(ctx) - if err != nil { - return nil, err - } - conn.build(nodes, pager, after, first, before, last) - return conn, nil -} - -var ( - // EventLogOrderFieldBlock orders EventLog by block. - EventLogOrderFieldBlock = &EventLogOrderField{ - Value: func(el *EventLog) (ent.Value, error) { - return el.Block, nil - }, - column: eventlog.FieldBlock, - toTerm: eventlog.ByBlock, - toCursor: func(el *EventLog) Cursor { - return Cursor{ - ID: el.ID, - Value: el.Block, - } - }, - } -) - -// String implement fmt.Stringer interface. -func (f EventLogOrderField) String() string { - var str string - switch f.column { - case EventLogOrderFieldBlock.column: - str = "BLOCK" - } - return str -} - -// MarshalGQL implements graphql.Marshaler interface. -func (f EventLogOrderField) MarshalGQL(w io.Writer) { - io.WriteString(w, strconv.Quote(f.String())) -} - -// UnmarshalGQL implements graphql.Unmarshaler interface. -func (f *EventLogOrderField) UnmarshalGQL(v interface{}) error { - str, ok := v.(string) - if !ok { - return fmt.Errorf("EventLogOrderField %T must be a string", v) - } - switch str { - case "BLOCK": - *f = *EventLogOrderFieldBlock - default: - return fmt.Errorf("%s is not a valid EventLogOrderField", str) - } - return nil -} - -// EventLogOrderField defines the ordering field of EventLog. -type EventLogOrderField struct { - // Value extracts the ordering value from the given EventLog. - Value func(*EventLog) (ent.Value, error) - column string // field or computed. - toTerm func(...sql.OrderTermOption) eventlog.OrderOption - toCursor func(*EventLog) Cursor -} - -// EventLogOrder defines the ordering of EventLog. -type EventLogOrder struct { - Direction OrderDirection `json:"direction"` - Field *EventLogOrderField `json:"field"` -} - -// DefaultEventLogOrder is the default ordering of EventLog. -var DefaultEventLogOrder = &EventLogOrder{ - Direction: entgql.OrderDirectionAsc, - Field: &EventLogOrderField{ - Value: func(el *EventLog) (ent.Value, error) { - return el.ID, nil - }, - column: eventlog.FieldID, - toTerm: eventlog.ByID, - toCursor: func(el *EventLog) Cursor { - return Cursor{ID: el.ID} - }, - }, -} - -// ToEdge converts EventLog into EventLogEdge. -func (el *EventLog) ToEdge(order *EventLogOrder) *EventLogEdge { - if order == nil { - order = DefaultEventLogOrder - } - return &EventLogEdge{ - Node: el, - Cursor: order.Field.toCursor(el), - } -} - -// SignerEdge is the edge representation of Signer. -type SignerEdge struct { - Node *Signer `json:"node"` - Cursor Cursor `json:"cursor"` -} - -// SignerConnection is the connection containing edges to Signer. -type SignerConnection struct { - Edges []*SignerEdge `json:"edges"` - PageInfo PageInfo `json:"pageInfo"` - TotalCount int `json:"totalCount"` -} - -func (c *SignerConnection) build(nodes []*Signer, pager *signerPager, after *Cursor, first *int, before *Cursor, last *int) { - c.PageInfo.HasNextPage = before != nil - c.PageInfo.HasPreviousPage = after != nil - if first != nil && *first+1 == len(nodes) { - c.PageInfo.HasNextPage = true - nodes = nodes[:len(nodes)-1] - } else if last != nil && *last+1 == len(nodes) { - c.PageInfo.HasPreviousPage = true - nodes = nodes[:len(nodes)-1] - } - var nodeAt func(int) *Signer - if last != nil { - n := len(nodes) - 1 - nodeAt = func(i int) *Signer { - return nodes[n-i] - } - } else { - nodeAt = func(i int) *Signer { - return nodes[i] - } - } - c.Edges = make([]*SignerEdge, len(nodes)) - for i := range nodes { - node := nodeAt(i) - c.Edges[i] = &SignerEdge{ - Node: node, - Cursor: pager.toCursor(node), - } - } - if l := len(c.Edges); l > 0 { - c.PageInfo.StartCursor = &c.Edges[0].Cursor - c.PageInfo.EndCursor = &c.Edges[l-1].Cursor - } - if c.TotalCount == 0 { - c.TotalCount = len(nodes) - } -} - -// SignerPaginateOption enables pagination customization. -type SignerPaginateOption func(*signerPager) error - -// WithSignerOrder configures pagination ordering. -func WithSignerOrder(order *SignerOrder) SignerPaginateOption { - if order == nil { - order = DefaultSignerOrder - } - o := *order - return func(pager *signerPager) error { - if err := o.Direction.Validate(); err != nil { - return err - } - if o.Field == nil { - o.Field = DefaultSignerOrder.Field - } - pager.order = &o - return nil - } -} - -// WithSignerFilter configures pagination filter. -func WithSignerFilter(filter func(*SignerQuery) (*SignerQuery, error)) SignerPaginateOption { - return func(pager *signerPager) error { - if filter == nil { - return errors.New("SignerQuery filter cannot be nil") - } - pager.filter = filter - return nil - } -} - -type signerPager struct { - reverse bool - order *SignerOrder - filter func(*SignerQuery) (*SignerQuery, error) -} - -func newSignerPager(opts []SignerPaginateOption, reverse bool) (*signerPager, error) { - pager := &signerPager{reverse: reverse} - for _, opt := range opts { - if err := opt(pager); err != nil { - return nil, err - } - } - if pager.order == nil { - pager.order = DefaultSignerOrder - } - return pager, nil -} - -func (p *signerPager) applyFilter(query *SignerQuery) (*SignerQuery, error) { - if p.filter != nil { - return p.filter(query) - } - return query, nil -} - -func (p *signerPager) toCursor(s *Signer) Cursor { - return p.order.Field.toCursor(s) -} - -func (p *signerPager) applyCursors(query *SignerQuery, after, before *Cursor) (*SignerQuery, error) { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - for _, predicate := range entgql.CursorsPredicate(after, before, DefaultSignerOrder.Field.column, p.order.Field.column, direction) { - query = query.Where(predicate) - } - return query, nil -} - -func (p *signerPager) applyOrder(query *SignerQuery) *SignerQuery { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) - if p.order.Field != DefaultSignerOrder.Field { - query = query.Order(DefaultSignerOrder.Field.toTerm(direction.OrderTermOption())) - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) - } - return query -} - -func (p *signerPager) orderExpr(query *SignerQuery) sql.Querier { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) - } - return sql.ExprFunc(func(b *sql.Builder) { - b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) - if p.order.Field != DefaultSignerOrder.Field { - b.Comma().Ident(DefaultSignerOrder.Field.column).Pad().WriteString(string(direction)) - } - }) -} - -// Paginate executes the query and returns a relay based cursor connection to Signer. -func (s *SignerQuery) Paginate( - ctx context.Context, after *Cursor, first *int, - before *Cursor, last *int, opts ...SignerPaginateOption, -) (*SignerConnection, error) { - if err := validateFirstLast(first, last); err != nil { - return nil, err - } - pager, err := newSignerPager(opts, last != nil) - if err != nil { - return nil, err - } - if s, err = pager.applyFilter(s); err != nil { - return nil, err - } - conn := &SignerConnection{Edges: []*SignerEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) - if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { - hasPagination := after != nil || first != nil || before != nil || last != nil - if hasPagination || ignoredEdges { - c := s.Clone() - c.ctx.Fields = nil - if conn.TotalCount, err = c.Count(ctx); err != nil { - return nil, err - } - conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 - conn.PageInfo.HasPreviousPage = last != nil && conn.TotalCount > 0 - } - } - if ignoredEdges || (first != nil && *first == 0) || (last != nil && *last == 0) { - return conn, nil - } - if s, err = pager.applyCursors(s, after, before); err != nil { - return nil, err - } - if limit := paginateLimit(first, last); limit != 0 { - s.Limit(limit) - } - if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := s.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { - return nil, err - } - } - s = pager.applyOrder(s) - nodes, err := s.All(ctx) - if err != nil { - return nil, err - } - conn.build(nodes, pager, after, first, before, last) - return conn, nil -} - -var ( - // SignerOrderFieldPoints orders Signer by points. - SignerOrderFieldPoints = &SignerOrderField{ - Value: func(s *Signer) (ent.Value, error) { - return s.Points, nil - }, - column: signer.FieldPoints, - toTerm: signer.ByPoints, - toCursor: func(s *Signer) Cursor { - return Cursor{ - ID: s.ID, - Value: s.Points, - } - }, - } -) - -// String implement fmt.Stringer interface. -func (f SignerOrderField) String() string { - var str string - switch f.column { - case SignerOrderFieldPoints.column: - str = "POINTS" - } - return str -} - -// MarshalGQL implements graphql.Marshaler interface. -func (f SignerOrderField) MarshalGQL(w io.Writer) { - io.WriteString(w, strconv.Quote(f.String())) -} - -// UnmarshalGQL implements graphql.Unmarshaler interface. -func (f *SignerOrderField) UnmarshalGQL(v interface{}) error { - str, ok := v.(string) - if !ok { - return fmt.Errorf("SignerOrderField %T must be a string", v) - } - switch str { - case "POINTS": - *f = *SignerOrderFieldPoints - default: - return fmt.Errorf("%s is not a valid SignerOrderField", str) - } - return nil -} - -// SignerOrderField defines the ordering field of Signer. -type SignerOrderField struct { - // Value extracts the ordering value from the given Signer. - Value func(*Signer) (ent.Value, error) - column string // field or computed. - toTerm func(...sql.OrderTermOption) signer.OrderOption - toCursor func(*Signer) Cursor -} - -// SignerOrder defines the ordering of Signer. -type SignerOrder struct { - Direction OrderDirection `json:"direction"` - Field *SignerOrderField `json:"field"` -} - -// DefaultSignerOrder is the default ordering of Signer. -var DefaultSignerOrder = &SignerOrder{ - Direction: entgql.OrderDirectionAsc, - Field: &SignerOrderField{ - Value: func(s *Signer) (ent.Value, error) { - return s.ID, nil - }, - column: signer.FieldID, - toTerm: signer.ByID, - toCursor: func(s *Signer) Cursor { - return Cursor{ID: s.ID} - }, - }, -} - -// ToEdge converts Signer into SignerEdge. -func (s *Signer) ToEdge(order *SignerOrder) *SignerEdge { - if order == nil { - order = DefaultSignerOrder - } - return &SignerEdge{ - Node: s, - Cursor: order.Field.toCursor(s), - } -} diff --git a/internal/ent/gql_transaction.go b/internal/ent/gql_transaction.go deleted file mode 100644 index 96117136..00000000 --- a/internal/ent/gql_transaction.go +++ /dev/null @@ -1,30 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "database/sql/driver" - "errors" -) - -// OpenTx opens a transaction and returns a transactional -// context along with the created transaction. -func (c *Client) OpenTx(ctx context.Context) (context.Context, driver.Tx, error) { - tx, err := c.Tx(ctx) - if err != nil { - return nil, nil, err - } - ctx = NewTxContext(ctx, tx) - ctx = NewContext(ctx, tx.Client()) - return ctx, tx, nil -} - -// OpenTxFromContext open transactions from client stored in context. -func OpenTxFromContext(ctx context.Context) (context.Context, driver.Tx, error) { - client := FromContext(ctx) - if client == nil { - return nil, nil, errors.New("no client attached to context") - } - return client.OpenTx(ctx) -} diff --git a/internal/ent/gql_where_input.go b/internal/ent/gql_where_input.go deleted file mode 100644 index 4977eded..00000000 --- a/internal/ent/gql_where_input.go +++ /dev/null @@ -1,1563 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "errors" - "fmt" - - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// AssetPriceWhereInput represents a where input for filtering AssetPrice queries. -type AssetPriceWhereInput struct { - Predicates []predicate.AssetPrice `json:"-"` - Not *AssetPriceWhereInput `json:"not,omitempty"` - Or []*AssetPriceWhereInput `json:"or,omitempty"` - And []*AssetPriceWhereInput `json:"and,omitempty"` - - // "id" field predicates. - ID *int `json:"id,omitempty"` - IDNEQ *int `json:"idNEQ,omitempty"` - IDIn []int `json:"idIn,omitempty"` - IDNotIn []int `json:"idNotIn,omitempty"` - IDGT *int `json:"idGT,omitempty"` - IDGTE *int `json:"idGTE,omitempty"` - IDLT *int `json:"idLT,omitempty"` - IDLTE *int `json:"idLTE,omitempty"` - - // "block" field predicates. - Block *uint64 `json:"block,omitempty"` - BlockNEQ *uint64 `json:"blockNEQ,omitempty"` - BlockIn []uint64 `json:"blockIn,omitempty"` - BlockNotIn []uint64 `json:"blockNotIn,omitempty"` - BlockGT *uint64 `json:"blockGT,omitempty"` - BlockGTE *uint64 `json:"blockGTE,omitempty"` - BlockLT *uint64 `json:"blockLT,omitempty"` - BlockLTE *uint64 `json:"blockLTE,omitempty"` - - // "signersCount" field predicates. - SignersCount *uint64 `json:"signerscount,omitempty"` - SignersCountNEQ *uint64 `json:"signerscountNEQ,omitempty"` - SignersCountIn []uint64 `json:"signerscountIn,omitempty"` - SignersCountNotIn []uint64 `json:"signerscountNotIn,omitempty"` - SignersCountGT *uint64 `json:"signerscountGT,omitempty"` - SignersCountGTE *uint64 `json:"signerscountGTE,omitempty"` - SignersCountLT *uint64 `json:"signerscountLT,omitempty"` - SignersCountLTE *uint64 `json:"signerscountLTE,omitempty"` - SignersCountIsNil bool `json:"signerscountIsNil,omitempty"` - SignersCountNotNil bool `json:"signerscountNotNil,omitempty"` - - // "price" field predicates. - Price *helpers.BigInt `json:"price,omitempty"` - PriceNEQ *helpers.BigInt `json:"priceNEQ,omitempty"` - PriceIn []*helpers.BigInt `json:"priceIn,omitempty"` - PriceNotIn []*helpers.BigInt `json:"priceNotIn,omitempty"` - PriceGT *helpers.BigInt `json:"priceGT,omitempty"` - PriceGTE *helpers.BigInt `json:"priceGTE,omitempty"` - PriceLT *helpers.BigInt `json:"priceLT,omitempty"` - PriceLTE *helpers.BigInt `json:"priceLTE,omitempty"` - - // "asset" field predicates. - Asset *string `json:"asset,omitempty"` - AssetNEQ *string `json:"assetNEQ,omitempty"` - AssetIn []string `json:"assetIn,omitempty"` - AssetNotIn []string `json:"assetNotIn,omitempty"` - AssetGT *string `json:"assetGT,omitempty"` - AssetGTE *string `json:"assetGTE,omitempty"` - AssetLT *string `json:"assetLT,omitempty"` - AssetLTE *string `json:"assetLTE,omitempty"` - AssetContains *string `json:"assetContains,omitempty"` - AssetHasPrefix *string `json:"assetHasPrefix,omitempty"` - AssetHasSuffix *string `json:"assetHasSuffix,omitempty"` - AssetIsNil bool `json:"assetIsNil,omitempty"` - AssetNotNil bool `json:"assetNotNil,omitempty"` - AssetEqualFold *string `json:"assetEqualFold,omitempty"` - AssetContainsFold *string `json:"assetContainsFold,omitempty"` - - // "chain" field predicates. - Chain *string `json:"chain,omitempty"` - ChainNEQ *string `json:"chainNEQ,omitempty"` - ChainIn []string `json:"chainIn,omitempty"` - ChainNotIn []string `json:"chainNotIn,omitempty"` - ChainGT *string `json:"chainGT,omitempty"` - ChainGTE *string `json:"chainGTE,omitempty"` - ChainLT *string `json:"chainLT,omitempty"` - ChainLTE *string `json:"chainLTE,omitempty"` - ChainContains *string `json:"chainContains,omitempty"` - ChainHasPrefix *string `json:"chainHasPrefix,omitempty"` - ChainHasSuffix *string `json:"chainHasSuffix,omitempty"` - ChainIsNil bool `json:"chainIsNil,omitempty"` - ChainNotNil bool `json:"chainNotNil,omitempty"` - ChainEqualFold *string `json:"chainEqualFold,omitempty"` - ChainContainsFold *string `json:"chainContainsFold,omitempty"` - - // "pair" field predicates. - Pair *string `json:"pair,omitempty"` - PairNEQ *string `json:"pairNEQ,omitempty"` - PairIn []string `json:"pairIn,omitempty"` - PairNotIn []string `json:"pairNotIn,omitempty"` - PairGT *string `json:"pairGT,omitempty"` - PairGTE *string `json:"pairGTE,omitempty"` - PairLT *string `json:"pairLT,omitempty"` - PairLTE *string `json:"pairLTE,omitempty"` - PairContains *string `json:"pairContains,omitempty"` - PairHasPrefix *string `json:"pairHasPrefix,omitempty"` - PairHasSuffix *string `json:"pairHasSuffix,omitempty"` - PairIsNil bool `json:"pairIsNil,omitempty"` - PairNotNil bool `json:"pairNotNil,omitempty"` - PairEqualFold *string `json:"pairEqualFold,omitempty"` - PairContainsFold *string `json:"pairContainsFold,omitempty"` - - // "consensus" field predicates. - Consensus *bool `json:"consensus,omitempty"` - ConsensusNEQ *bool `json:"consensusNEQ,omitempty"` - - // "voted" field predicates. - Voted *helpers.BigInt `json:"voted,omitempty"` - VotedNEQ *helpers.BigInt `json:"votedNEQ,omitempty"` - VotedIn []*helpers.BigInt `json:"votedIn,omitempty"` - VotedNotIn []*helpers.BigInt `json:"votedNotIn,omitempty"` - VotedGT *helpers.BigInt `json:"votedGT,omitempty"` - VotedGTE *helpers.BigInt `json:"votedGTE,omitempty"` - VotedLT *helpers.BigInt `json:"votedLT,omitempty"` - VotedLTE *helpers.BigInt `json:"votedLTE,omitempty"` - - // "signers" edge predicates. - HasSigners *bool `json:"hasSigners,omitempty"` - HasSignersWith []*SignerWhereInput `json:"hasSignersWith,omitempty"` -} - -// AddPredicates adds custom predicates to the where input to be used during the filtering phase. -func (i *AssetPriceWhereInput) AddPredicates(predicates ...predicate.AssetPrice) { - i.Predicates = append(i.Predicates, predicates...) -} - -// Filter applies the AssetPriceWhereInput filter on the AssetPriceQuery builder. -func (i *AssetPriceWhereInput) Filter(q *AssetPriceQuery) (*AssetPriceQuery, error) { - if i == nil { - return q, nil - } - p, err := i.P() - if err != nil { - if err == ErrEmptyAssetPriceWhereInput { - return q, nil - } - return nil, err - } - return q.Where(p), nil -} - -// ErrEmptyAssetPriceWhereInput is returned in case the AssetPriceWhereInput is empty. -var ErrEmptyAssetPriceWhereInput = errors.New("ent: empty predicate AssetPriceWhereInput") - -// P returns a predicate for filtering assetprices. -// An error is returned if the input is empty or invalid. -func (i *AssetPriceWhereInput) P() (predicate.AssetPrice, error) { - var predicates []predicate.AssetPrice - if i.Not != nil { - p, err := i.Not.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'not'", err) - } - predicates = append(predicates, assetprice.Not(p)) - } - switch n := len(i.Or); { - case n == 1: - p, err := i.Or[0].P() - if err != nil { - return nil, fmt.Errorf("%w: field 'or'", err) - } - predicates = append(predicates, p) - case n > 1: - or := make([]predicate.AssetPrice, 0, n) - for _, w := range i.Or { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'or'", err) - } - or = append(or, p) - } - predicates = append(predicates, assetprice.Or(or...)) - } - switch n := len(i.And); { - case n == 1: - p, err := i.And[0].P() - if err != nil { - return nil, fmt.Errorf("%w: field 'and'", err) - } - predicates = append(predicates, p) - case n > 1: - and := make([]predicate.AssetPrice, 0, n) - for _, w := range i.And { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'and'", err) - } - and = append(and, p) - } - predicates = append(predicates, assetprice.And(and...)) - } - predicates = append(predicates, i.Predicates...) - if i.ID != nil { - predicates = append(predicates, assetprice.IDEQ(*i.ID)) - } - if i.IDNEQ != nil { - predicates = append(predicates, assetprice.IDNEQ(*i.IDNEQ)) - } - if len(i.IDIn) > 0 { - predicates = append(predicates, assetprice.IDIn(i.IDIn...)) - } - if len(i.IDNotIn) > 0 { - predicates = append(predicates, assetprice.IDNotIn(i.IDNotIn...)) - } - if i.IDGT != nil { - predicates = append(predicates, assetprice.IDGT(*i.IDGT)) - } - if i.IDGTE != nil { - predicates = append(predicates, assetprice.IDGTE(*i.IDGTE)) - } - if i.IDLT != nil { - predicates = append(predicates, assetprice.IDLT(*i.IDLT)) - } - if i.IDLTE != nil { - predicates = append(predicates, assetprice.IDLTE(*i.IDLTE)) - } - if i.Block != nil { - predicates = append(predicates, assetprice.BlockEQ(*i.Block)) - } - if i.BlockNEQ != nil { - predicates = append(predicates, assetprice.BlockNEQ(*i.BlockNEQ)) - } - if len(i.BlockIn) > 0 { - predicates = append(predicates, assetprice.BlockIn(i.BlockIn...)) - } - if len(i.BlockNotIn) > 0 { - predicates = append(predicates, assetprice.BlockNotIn(i.BlockNotIn...)) - } - if i.BlockGT != nil { - predicates = append(predicates, assetprice.BlockGT(*i.BlockGT)) - } - if i.BlockGTE != nil { - predicates = append(predicates, assetprice.BlockGTE(*i.BlockGTE)) - } - if i.BlockLT != nil { - predicates = append(predicates, assetprice.BlockLT(*i.BlockLT)) - } - if i.BlockLTE != nil { - predicates = append(predicates, assetprice.BlockLTE(*i.BlockLTE)) - } - if i.SignersCount != nil { - predicates = append(predicates, assetprice.SignersCountEQ(*i.SignersCount)) - } - if i.SignersCountNEQ != nil { - predicates = append(predicates, assetprice.SignersCountNEQ(*i.SignersCountNEQ)) - } - if len(i.SignersCountIn) > 0 { - predicates = append(predicates, assetprice.SignersCountIn(i.SignersCountIn...)) - } - if len(i.SignersCountNotIn) > 0 { - predicates = append(predicates, assetprice.SignersCountNotIn(i.SignersCountNotIn...)) - } - if i.SignersCountGT != nil { - predicates = append(predicates, assetprice.SignersCountGT(*i.SignersCountGT)) - } - if i.SignersCountGTE != nil { - predicates = append(predicates, assetprice.SignersCountGTE(*i.SignersCountGTE)) - } - if i.SignersCountLT != nil { - predicates = append(predicates, assetprice.SignersCountLT(*i.SignersCountLT)) - } - if i.SignersCountLTE != nil { - predicates = append(predicates, assetprice.SignersCountLTE(*i.SignersCountLTE)) - } - if i.SignersCountIsNil { - predicates = append(predicates, assetprice.SignersCountIsNil()) - } - if i.SignersCountNotNil { - predicates = append(predicates, assetprice.SignersCountNotNil()) - } - if i.Price != nil { - predicates = append(predicates, assetprice.PriceEQ(i.Price)) - } - if i.PriceNEQ != nil { - predicates = append(predicates, assetprice.PriceNEQ(i.PriceNEQ)) - } - if len(i.PriceIn) > 0 { - predicates = append(predicates, assetprice.PriceIn(i.PriceIn...)) - } - if len(i.PriceNotIn) > 0 { - predicates = append(predicates, assetprice.PriceNotIn(i.PriceNotIn...)) - } - if i.PriceGT != nil { - predicates = append(predicates, assetprice.PriceGT(i.PriceGT)) - } - if i.PriceGTE != nil { - predicates = append(predicates, assetprice.PriceGTE(i.PriceGTE)) - } - if i.PriceLT != nil { - predicates = append(predicates, assetprice.PriceLT(i.PriceLT)) - } - if i.PriceLTE != nil { - predicates = append(predicates, assetprice.PriceLTE(i.PriceLTE)) - } - if i.Asset != nil { - predicates = append(predicates, assetprice.AssetEQ(*i.Asset)) - } - if i.AssetNEQ != nil { - predicates = append(predicates, assetprice.AssetNEQ(*i.AssetNEQ)) - } - if len(i.AssetIn) > 0 { - predicates = append(predicates, assetprice.AssetIn(i.AssetIn...)) - } - if len(i.AssetNotIn) > 0 { - predicates = append(predicates, assetprice.AssetNotIn(i.AssetNotIn...)) - } - if i.AssetGT != nil { - predicates = append(predicates, assetprice.AssetGT(*i.AssetGT)) - } - if i.AssetGTE != nil { - predicates = append(predicates, assetprice.AssetGTE(*i.AssetGTE)) - } - if i.AssetLT != nil { - predicates = append(predicates, assetprice.AssetLT(*i.AssetLT)) - } - if i.AssetLTE != nil { - predicates = append(predicates, assetprice.AssetLTE(*i.AssetLTE)) - } - if i.AssetContains != nil { - predicates = append(predicates, assetprice.AssetContains(*i.AssetContains)) - } - if i.AssetHasPrefix != nil { - predicates = append(predicates, assetprice.AssetHasPrefix(*i.AssetHasPrefix)) - } - if i.AssetHasSuffix != nil { - predicates = append(predicates, assetprice.AssetHasSuffix(*i.AssetHasSuffix)) - } - if i.AssetIsNil { - predicates = append(predicates, assetprice.AssetIsNil()) - } - if i.AssetNotNil { - predicates = append(predicates, assetprice.AssetNotNil()) - } - if i.AssetEqualFold != nil { - predicates = append(predicates, assetprice.AssetEqualFold(*i.AssetEqualFold)) - } - if i.AssetContainsFold != nil { - predicates = append(predicates, assetprice.AssetContainsFold(*i.AssetContainsFold)) - } - if i.Chain != nil { - predicates = append(predicates, assetprice.ChainEQ(*i.Chain)) - } - if i.ChainNEQ != nil { - predicates = append(predicates, assetprice.ChainNEQ(*i.ChainNEQ)) - } - if len(i.ChainIn) > 0 { - predicates = append(predicates, assetprice.ChainIn(i.ChainIn...)) - } - if len(i.ChainNotIn) > 0 { - predicates = append(predicates, assetprice.ChainNotIn(i.ChainNotIn...)) - } - if i.ChainGT != nil { - predicates = append(predicates, assetprice.ChainGT(*i.ChainGT)) - } - if i.ChainGTE != nil { - predicates = append(predicates, assetprice.ChainGTE(*i.ChainGTE)) - } - if i.ChainLT != nil { - predicates = append(predicates, assetprice.ChainLT(*i.ChainLT)) - } - if i.ChainLTE != nil { - predicates = append(predicates, assetprice.ChainLTE(*i.ChainLTE)) - } - if i.ChainContains != nil { - predicates = append(predicates, assetprice.ChainContains(*i.ChainContains)) - } - if i.ChainHasPrefix != nil { - predicates = append(predicates, assetprice.ChainHasPrefix(*i.ChainHasPrefix)) - } - if i.ChainHasSuffix != nil { - predicates = append(predicates, assetprice.ChainHasSuffix(*i.ChainHasSuffix)) - } - if i.ChainIsNil { - predicates = append(predicates, assetprice.ChainIsNil()) - } - if i.ChainNotNil { - predicates = append(predicates, assetprice.ChainNotNil()) - } - if i.ChainEqualFold != nil { - predicates = append(predicates, assetprice.ChainEqualFold(*i.ChainEqualFold)) - } - if i.ChainContainsFold != nil { - predicates = append(predicates, assetprice.ChainContainsFold(*i.ChainContainsFold)) - } - if i.Pair != nil { - predicates = append(predicates, assetprice.PairEQ(*i.Pair)) - } - if i.PairNEQ != nil { - predicates = append(predicates, assetprice.PairNEQ(*i.PairNEQ)) - } - if len(i.PairIn) > 0 { - predicates = append(predicates, assetprice.PairIn(i.PairIn...)) - } - if len(i.PairNotIn) > 0 { - predicates = append(predicates, assetprice.PairNotIn(i.PairNotIn...)) - } - if i.PairGT != nil { - predicates = append(predicates, assetprice.PairGT(*i.PairGT)) - } - if i.PairGTE != nil { - predicates = append(predicates, assetprice.PairGTE(*i.PairGTE)) - } - if i.PairLT != nil { - predicates = append(predicates, assetprice.PairLT(*i.PairLT)) - } - if i.PairLTE != nil { - predicates = append(predicates, assetprice.PairLTE(*i.PairLTE)) - } - if i.PairContains != nil { - predicates = append(predicates, assetprice.PairContains(*i.PairContains)) - } - if i.PairHasPrefix != nil { - predicates = append(predicates, assetprice.PairHasPrefix(*i.PairHasPrefix)) - } - if i.PairHasSuffix != nil { - predicates = append(predicates, assetprice.PairHasSuffix(*i.PairHasSuffix)) - } - if i.PairIsNil { - predicates = append(predicates, assetprice.PairIsNil()) - } - if i.PairNotNil { - predicates = append(predicates, assetprice.PairNotNil()) - } - if i.PairEqualFold != nil { - predicates = append(predicates, assetprice.PairEqualFold(*i.PairEqualFold)) - } - if i.PairContainsFold != nil { - predicates = append(predicates, assetprice.PairContainsFold(*i.PairContainsFold)) - } - if i.Consensus != nil { - predicates = append(predicates, assetprice.ConsensusEQ(*i.Consensus)) - } - if i.ConsensusNEQ != nil { - predicates = append(predicates, assetprice.ConsensusNEQ(*i.ConsensusNEQ)) - } - if i.Voted != nil { - predicates = append(predicates, assetprice.VotedEQ(i.Voted)) - } - if i.VotedNEQ != nil { - predicates = append(predicates, assetprice.VotedNEQ(i.VotedNEQ)) - } - if len(i.VotedIn) > 0 { - predicates = append(predicates, assetprice.VotedIn(i.VotedIn...)) - } - if len(i.VotedNotIn) > 0 { - predicates = append(predicates, assetprice.VotedNotIn(i.VotedNotIn...)) - } - if i.VotedGT != nil { - predicates = append(predicates, assetprice.VotedGT(i.VotedGT)) - } - if i.VotedGTE != nil { - predicates = append(predicates, assetprice.VotedGTE(i.VotedGTE)) - } - if i.VotedLT != nil { - predicates = append(predicates, assetprice.VotedLT(i.VotedLT)) - } - if i.VotedLTE != nil { - predicates = append(predicates, assetprice.VotedLTE(i.VotedLTE)) - } - - if i.HasSigners != nil { - p := assetprice.HasSigners() - if !*i.HasSigners { - p = assetprice.Not(p) - } - predicates = append(predicates, p) - } - if len(i.HasSignersWith) > 0 { - with := make([]predicate.Signer, 0, len(i.HasSignersWith)) - for _, w := range i.HasSignersWith { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'HasSignersWith'", err) - } - with = append(with, p) - } - predicates = append(predicates, assetprice.HasSignersWith(with...)) - } - switch len(predicates) { - case 0: - return nil, ErrEmptyAssetPriceWhereInput - case 1: - return predicates[0], nil - default: - return assetprice.And(predicates...), nil - } -} - -// CorrectnessReportWhereInput represents a where input for filtering CorrectnessReport queries. -type CorrectnessReportWhereInput struct { - Predicates []predicate.CorrectnessReport `json:"-"` - Not *CorrectnessReportWhereInput `json:"not,omitempty"` - Or []*CorrectnessReportWhereInput `json:"or,omitempty"` - And []*CorrectnessReportWhereInput `json:"and,omitempty"` - - // "id" field predicates. - ID *int `json:"id,omitempty"` - IDNEQ *int `json:"idNEQ,omitempty"` - IDIn []int `json:"idIn,omitempty"` - IDNotIn []int `json:"idNotIn,omitempty"` - IDGT *int `json:"idGT,omitempty"` - IDGTE *int `json:"idGTE,omitempty"` - IDLT *int `json:"idLT,omitempty"` - IDLTE *int `json:"idLTE,omitempty"` - - // "signersCount" field predicates. - SignersCount *uint64 `json:"signerscount,omitempty"` - SignersCountNEQ *uint64 `json:"signerscountNEQ,omitempty"` - SignersCountIn []uint64 `json:"signerscountIn,omitempty"` - SignersCountNotIn []uint64 `json:"signerscountNotIn,omitempty"` - SignersCountGT *uint64 `json:"signerscountGT,omitempty"` - SignersCountGTE *uint64 `json:"signerscountGTE,omitempty"` - SignersCountLT *uint64 `json:"signerscountLT,omitempty"` - SignersCountLTE *uint64 `json:"signerscountLTE,omitempty"` - - // "timestamp" field predicates. - Timestamp *uint64 `json:"timestamp,omitempty"` - TimestampNEQ *uint64 `json:"timestampNEQ,omitempty"` - TimestampIn []uint64 `json:"timestampIn,omitempty"` - TimestampNotIn []uint64 `json:"timestampNotIn,omitempty"` - TimestampGT *uint64 `json:"timestampGT,omitempty"` - TimestampGTE *uint64 `json:"timestampGTE,omitempty"` - TimestampLT *uint64 `json:"timestampLT,omitempty"` - TimestampLTE *uint64 `json:"timestampLTE,omitempty"` - - // "correct" field predicates. - Correct *bool `json:"correct,omitempty"` - CorrectNEQ *bool `json:"correctNEQ,omitempty"` - - // "consensus" field predicates. - Consensus *bool `json:"consensus,omitempty"` - ConsensusNEQ *bool `json:"consensusNEQ,omitempty"` - - // "voted" field predicates. - Voted *helpers.BigInt `json:"voted,omitempty"` - VotedNEQ *helpers.BigInt `json:"votedNEQ,omitempty"` - VotedIn []*helpers.BigInt `json:"votedIn,omitempty"` - VotedNotIn []*helpers.BigInt `json:"votedNotIn,omitempty"` - VotedGT *helpers.BigInt `json:"votedGT,omitempty"` - VotedGTE *helpers.BigInt `json:"votedGTE,omitempty"` - VotedLT *helpers.BigInt `json:"votedLT,omitempty"` - VotedLTE *helpers.BigInt `json:"votedLTE,omitempty"` - - // "signers" edge predicates. - HasSigners *bool `json:"hasSigners,omitempty"` - HasSignersWith []*SignerWhereInput `json:"hasSignersWith,omitempty"` -} - -// AddPredicates adds custom predicates to the where input to be used during the filtering phase. -func (i *CorrectnessReportWhereInput) AddPredicates(predicates ...predicate.CorrectnessReport) { - i.Predicates = append(i.Predicates, predicates...) -} - -// Filter applies the CorrectnessReportWhereInput filter on the CorrectnessReportQuery builder. -func (i *CorrectnessReportWhereInput) Filter(q *CorrectnessReportQuery) (*CorrectnessReportQuery, error) { - if i == nil { - return q, nil - } - p, err := i.P() - if err != nil { - if err == ErrEmptyCorrectnessReportWhereInput { - return q, nil - } - return nil, err - } - return q.Where(p), nil -} - -// ErrEmptyCorrectnessReportWhereInput is returned in case the CorrectnessReportWhereInput is empty. -var ErrEmptyCorrectnessReportWhereInput = errors.New("ent: empty predicate CorrectnessReportWhereInput") - -// P returns a predicate for filtering correctnessreports. -// An error is returned if the input is empty or invalid. -func (i *CorrectnessReportWhereInput) P() (predicate.CorrectnessReport, error) { - var predicates []predicate.CorrectnessReport - if i.Not != nil { - p, err := i.Not.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'not'", err) - } - predicates = append(predicates, correctnessreport.Not(p)) - } - switch n := len(i.Or); { - case n == 1: - p, err := i.Or[0].P() - if err != nil { - return nil, fmt.Errorf("%w: field 'or'", err) - } - predicates = append(predicates, p) - case n > 1: - or := make([]predicate.CorrectnessReport, 0, n) - for _, w := range i.Or { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'or'", err) - } - or = append(or, p) - } - predicates = append(predicates, correctnessreport.Or(or...)) - } - switch n := len(i.And); { - case n == 1: - p, err := i.And[0].P() - if err != nil { - return nil, fmt.Errorf("%w: field 'and'", err) - } - predicates = append(predicates, p) - case n > 1: - and := make([]predicate.CorrectnessReport, 0, n) - for _, w := range i.And { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'and'", err) - } - and = append(and, p) - } - predicates = append(predicates, correctnessreport.And(and...)) - } - predicates = append(predicates, i.Predicates...) - if i.ID != nil { - predicates = append(predicates, correctnessreport.IDEQ(*i.ID)) - } - if i.IDNEQ != nil { - predicates = append(predicates, correctnessreport.IDNEQ(*i.IDNEQ)) - } - if len(i.IDIn) > 0 { - predicates = append(predicates, correctnessreport.IDIn(i.IDIn...)) - } - if len(i.IDNotIn) > 0 { - predicates = append(predicates, correctnessreport.IDNotIn(i.IDNotIn...)) - } - if i.IDGT != nil { - predicates = append(predicates, correctnessreport.IDGT(*i.IDGT)) - } - if i.IDGTE != nil { - predicates = append(predicates, correctnessreport.IDGTE(*i.IDGTE)) - } - if i.IDLT != nil { - predicates = append(predicates, correctnessreport.IDLT(*i.IDLT)) - } - if i.IDLTE != nil { - predicates = append(predicates, correctnessreport.IDLTE(*i.IDLTE)) - } - if i.SignersCount != nil { - predicates = append(predicates, correctnessreport.SignersCountEQ(*i.SignersCount)) - } - if i.SignersCountNEQ != nil { - predicates = append(predicates, correctnessreport.SignersCountNEQ(*i.SignersCountNEQ)) - } - if len(i.SignersCountIn) > 0 { - predicates = append(predicates, correctnessreport.SignersCountIn(i.SignersCountIn...)) - } - if len(i.SignersCountNotIn) > 0 { - predicates = append(predicates, correctnessreport.SignersCountNotIn(i.SignersCountNotIn...)) - } - if i.SignersCountGT != nil { - predicates = append(predicates, correctnessreport.SignersCountGT(*i.SignersCountGT)) - } - if i.SignersCountGTE != nil { - predicates = append(predicates, correctnessreport.SignersCountGTE(*i.SignersCountGTE)) - } - if i.SignersCountLT != nil { - predicates = append(predicates, correctnessreport.SignersCountLT(*i.SignersCountLT)) - } - if i.SignersCountLTE != nil { - predicates = append(predicates, correctnessreport.SignersCountLTE(*i.SignersCountLTE)) - } - if i.Timestamp != nil { - predicates = append(predicates, correctnessreport.TimestampEQ(*i.Timestamp)) - } - if i.TimestampNEQ != nil { - predicates = append(predicates, correctnessreport.TimestampNEQ(*i.TimestampNEQ)) - } - if len(i.TimestampIn) > 0 { - predicates = append(predicates, correctnessreport.TimestampIn(i.TimestampIn...)) - } - if len(i.TimestampNotIn) > 0 { - predicates = append(predicates, correctnessreport.TimestampNotIn(i.TimestampNotIn...)) - } - if i.TimestampGT != nil { - predicates = append(predicates, correctnessreport.TimestampGT(*i.TimestampGT)) - } - if i.TimestampGTE != nil { - predicates = append(predicates, correctnessreport.TimestampGTE(*i.TimestampGTE)) - } - if i.TimestampLT != nil { - predicates = append(predicates, correctnessreport.TimestampLT(*i.TimestampLT)) - } - if i.TimestampLTE != nil { - predicates = append(predicates, correctnessreport.TimestampLTE(*i.TimestampLTE)) - } - if i.Correct != nil { - predicates = append(predicates, correctnessreport.CorrectEQ(*i.Correct)) - } - if i.CorrectNEQ != nil { - predicates = append(predicates, correctnessreport.CorrectNEQ(*i.CorrectNEQ)) - } - if i.Consensus != nil { - predicates = append(predicates, correctnessreport.ConsensusEQ(*i.Consensus)) - } - if i.ConsensusNEQ != nil { - predicates = append(predicates, correctnessreport.ConsensusNEQ(*i.ConsensusNEQ)) - } - if i.Voted != nil { - predicates = append(predicates, correctnessreport.VotedEQ(i.Voted)) - } - if i.VotedNEQ != nil { - predicates = append(predicates, correctnessreport.VotedNEQ(i.VotedNEQ)) - } - if len(i.VotedIn) > 0 { - predicates = append(predicates, correctnessreport.VotedIn(i.VotedIn...)) - } - if len(i.VotedNotIn) > 0 { - predicates = append(predicates, correctnessreport.VotedNotIn(i.VotedNotIn...)) - } - if i.VotedGT != nil { - predicates = append(predicates, correctnessreport.VotedGT(i.VotedGT)) - } - if i.VotedGTE != nil { - predicates = append(predicates, correctnessreport.VotedGTE(i.VotedGTE)) - } - if i.VotedLT != nil { - predicates = append(predicates, correctnessreport.VotedLT(i.VotedLT)) - } - if i.VotedLTE != nil { - predicates = append(predicates, correctnessreport.VotedLTE(i.VotedLTE)) - } - - if i.HasSigners != nil { - p := correctnessreport.HasSigners() - if !*i.HasSigners { - p = correctnessreport.Not(p) - } - predicates = append(predicates, p) - } - if len(i.HasSignersWith) > 0 { - with := make([]predicate.Signer, 0, len(i.HasSignersWith)) - for _, w := range i.HasSignersWith { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'HasSignersWith'", err) - } - with = append(with, p) - } - predicates = append(predicates, correctnessreport.HasSignersWith(with...)) - } - switch len(predicates) { - case 0: - return nil, ErrEmptyCorrectnessReportWhereInput - case 1: - return predicates[0], nil - default: - return correctnessreport.And(predicates...), nil - } -} - -// EventLogWhereInput represents a where input for filtering EventLog queries. -type EventLogWhereInput struct { - Predicates []predicate.EventLog `json:"-"` - Not *EventLogWhereInput `json:"not,omitempty"` - Or []*EventLogWhereInput `json:"or,omitempty"` - And []*EventLogWhereInput `json:"and,omitempty"` - - // "id" field predicates. - ID *int `json:"id,omitempty"` - IDNEQ *int `json:"idNEQ,omitempty"` - IDIn []int `json:"idIn,omitempty"` - IDNotIn []int `json:"idNotIn,omitempty"` - IDGT *int `json:"idGT,omitempty"` - IDGTE *int `json:"idGTE,omitempty"` - IDLT *int `json:"idLT,omitempty"` - IDLTE *int `json:"idLTE,omitempty"` - - // "block" field predicates. - Block *uint64 `json:"block,omitempty"` - BlockNEQ *uint64 `json:"blockNEQ,omitempty"` - BlockIn []uint64 `json:"blockIn,omitempty"` - BlockNotIn []uint64 `json:"blockNotIn,omitempty"` - BlockGT *uint64 `json:"blockGT,omitempty"` - BlockGTE *uint64 `json:"blockGTE,omitempty"` - BlockLT *uint64 `json:"blockLT,omitempty"` - BlockLTE *uint64 `json:"blockLTE,omitempty"` - - // "signersCount" field predicates. - SignersCount *uint64 `json:"signerscount,omitempty"` - SignersCountNEQ *uint64 `json:"signerscountNEQ,omitempty"` - SignersCountIn []uint64 `json:"signerscountIn,omitempty"` - SignersCountNotIn []uint64 `json:"signerscountNotIn,omitempty"` - SignersCountGT *uint64 `json:"signerscountGT,omitempty"` - SignersCountGTE *uint64 `json:"signerscountGTE,omitempty"` - SignersCountLT *uint64 `json:"signerscountLT,omitempty"` - SignersCountLTE *uint64 `json:"signerscountLTE,omitempty"` - - // "address" field predicates. - Address *string `json:"address,omitempty"` - AddressNEQ *string `json:"addressNEQ,omitempty"` - AddressIn []string `json:"addressIn,omitempty"` - AddressNotIn []string `json:"addressNotIn,omitempty"` - AddressGT *string `json:"addressGT,omitempty"` - AddressGTE *string `json:"addressGTE,omitempty"` - AddressLT *string `json:"addressLT,omitempty"` - AddressLTE *string `json:"addressLTE,omitempty"` - AddressContains *string `json:"addressContains,omitempty"` - AddressHasPrefix *string `json:"addressHasPrefix,omitempty"` - AddressHasSuffix *string `json:"addressHasSuffix,omitempty"` - AddressEqualFold *string `json:"addressEqualFold,omitempty"` - AddressContainsFold *string `json:"addressContainsFold,omitempty"` - - // "chain" field predicates. - Chain *string `json:"chain,omitempty"` - ChainNEQ *string `json:"chainNEQ,omitempty"` - ChainIn []string `json:"chainIn,omitempty"` - ChainNotIn []string `json:"chainNotIn,omitempty"` - ChainGT *string `json:"chainGT,omitempty"` - ChainGTE *string `json:"chainGTE,omitempty"` - ChainLT *string `json:"chainLT,omitempty"` - ChainLTE *string `json:"chainLTE,omitempty"` - ChainContains *string `json:"chainContains,omitempty"` - ChainHasPrefix *string `json:"chainHasPrefix,omitempty"` - ChainHasSuffix *string `json:"chainHasSuffix,omitempty"` - ChainEqualFold *string `json:"chainEqualFold,omitempty"` - ChainContainsFold *string `json:"chainContainsFold,omitempty"` - - // "index" field predicates. - Index *uint64 `json:"index,omitempty"` - IndexNEQ *uint64 `json:"indexNEQ,omitempty"` - IndexIn []uint64 `json:"indexIn,omitempty"` - IndexNotIn []uint64 `json:"indexNotIn,omitempty"` - IndexGT *uint64 `json:"indexGT,omitempty"` - IndexGTE *uint64 `json:"indexGTE,omitempty"` - IndexLT *uint64 `json:"indexLT,omitempty"` - IndexLTE *uint64 `json:"indexLTE,omitempty"` - - // "event" field predicates. - Event *string `json:"event,omitempty"` - EventNEQ *string `json:"eventNEQ,omitempty"` - EventIn []string `json:"eventIn,omitempty"` - EventNotIn []string `json:"eventNotIn,omitempty"` - EventGT *string `json:"eventGT,omitempty"` - EventGTE *string `json:"eventGTE,omitempty"` - EventLT *string `json:"eventLT,omitempty"` - EventLTE *string `json:"eventLTE,omitempty"` - EventContains *string `json:"eventContains,omitempty"` - EventHasPrefix *string `json:"eventHasPrefix,omitempty"` - EventHasSuffix *string `json:"eventHasSuffix,omitempty"` - EventEqualFold *string `json:"eventEqualFold,omitempty"` - EventContainsFold *string `json:"eventContainsFold,omitempty"` - - // "consensus" field predicates. - Consensus *bool `json:"consensus,omitempty"` - ConsensusNEQ *bool `json:"consensusNEQ,omitempty"` - - // "voted" field predicates. - Voted *helpers.BigInt `json:"voted,omitempty"` - VotedNEQ *helpers.BigInt `json:"votedNEQ,omitempty"` - VotedIn []*helpers.BigInt `json:"votedIn,omitempty"` - VotedNotIn []*helpers.BigInt `json:"votedNotIn,omitempty"` - VotedGT *helpers.BigInt `json:"votedGT,omitempty"` - VotedGTE *helpers.BigInt `json:"votedGTE,omitempty"` - VotedLT *helpers.BigInt `json:"votedLT,omitempty"` - VotedLTE *helpers.BigInt `json:"votedLTE,omitempty"` - - // "signers" edge predicates. - HasSigners *bool `json:"hasSigners,omitempty"` - HasSignersWith []*SignerWhereInput `json:"hasSignersWith,omitempty"` -} - -// AddPredicates adds custom predicates to the where input to be used during the filtering phase. -func (i *EventLogWhereInput) AddPredicates(predicates ...predicate.EventLog) { - i.Predicates = append(i.Predicates, predicates...) -} - -// Filter applies the EventLogWhereInput filter on the EventLogQuery builder. -func (i *EventLogWhereInput) Filter(q *EventLogQuery) (*EventLogQuery, error) { - if i == nil { - return q, nil - } - p, err := i.P() - if err != nil { - if err == ErrEmptyEventLogWhereInput { - return q, nil - } - return nil, err - } - return q.Where(p), nil -} - -// ErrEmptyEventLogWhereInput is returned in case the EventLogWhereInput is empty. -var ErrEmptyEventLogWhereInput = errors.New("ent: empty predicate EventLogWhereInput") - -// P returns a predicate for filtering eventlogs. -// An error is returned if the input is empty or invalid. -func (i *EventLogWhereInput) P() (predicate.EventLog, error) { - var predicates []predicate.EventLog - if i.Not != nil { - p, err := i.Not.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'not'", err) - } - predicates = append(predicates, eventlog.Not(p)) - } - switch n := len(i.Or); { - case n == 1: - p, err := i.Or[0].P() - if err != nil { - return nil, fmt.Errorf("%w: field 'or'", err) - } - predicates = append(predicates, p) - case n > 1: - or := make([]predicate.EventLog, 0, n) - for _, w := range i.Or { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'or'", err) - } - or = append(or, p) - } - predicates = append(predicates, eventlog.Or(or...)) - } - switch n := len(i.And); { - case n == 1: - p, err := i.And[0].P() - if err != nil { - return nil, fmt.Errorf("%w: field 'and'", err) - } - predicates = append(predicates, p) - case n > 1: - and := make([]predicate.EventLog, 0, n) - for _, w := range i.And { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'and'", err) - } - and = append(and, p) - } - predicates = append(predicates, eventlog.And(and...)) - } - predicates = append(predicates, i.Predicates...) - if i.ID != nil { - predicates = append(predicates, eventlog.IDEQ(*i.ID)) - } - if i.IDNEQ != nil { - predicates = append(predicates, eventlog.IDNEQ(*i.IDNEQ)) - } - if len(i.IDIn) > 0 { - predicates = append(predicates, eventlog.IDIn(i.IDIn...)) - } - if len(i.IDNotIn) > 0 { - predicates = append(predicates, eventlog.IDNotIn(i.IDNotIn...)) - } - if i.IDGT != nil { - predicates = append(predicates, eventlog.IDGT(*i.IDGT)) - } - if i.IDGTE != nil { - predicates = append(predicates, eventlog.IDGTE(*i.IDGTE)) - } - if i.IDLT != nil { - predicates = append(predicates, eventlog.IDLT(*i.IDLT)) - } - if i.IDLTE != nil { - predicates = append(predicates, eventlog.IDLTE(*i.IDLTE)) - } - if i.Block != nil { - predicates = append(predicates, eventlog.BlockEQ(*i.Block)) - } - if i.BlockNEQ != nil { - predicates = append(predicates, eventlog.BlockNEQ(*i.BlockNEQ)) - } - if len(i.BlockIn) > 0 { - predicates = append(predicates, eventlog.BlockIn(i.BlockIn...)) - } - if len(i.BlockNotIn) > 0 { - predicates = append(predicates, eventlog.BlockNotIn(i.BlockNotIn...)) - } - if i.BlockGT != nil { - predicates = append(predicates, eventlog.BlockGT(*i.BlockGT)) - } - if i.BlockGTE != nil { - predicates = append(predicates, eventlog.BlockGTE(*i.BlockGTE)) - } - if i.BlockLT != nil { - predicates = append(predicates, eventlog.BlockLT(*i.BlockLT)) - } - if i.BlockLTE != nil { - predicates = append(predicates, eventlog.BlockLTE(*i.BlockLTE)) - } - if i.SignersCount != nil { - predicates = append(predicates, eventlog.SignersCountEQ(*i.SignersCount)) - } - if i.SignersCountNEQ != nil { - predicates = append(predicates, eventlog.SignersCountNEQ(*i.SignersCountNEQ)) - } - if len(i.SignersCountIn) > 0 { - predicates = append(predicates, eventlog.SignersCountIn(i.SignersCountIn...)) - } - if len(i.SignersCountNotIn) > 0 { - predicates = append(predicates, eventlog.SignersCountNotIn(i.SignersCountNotIn...)) - } - if i.SignersCountGT != nil { - predicates = append(predicates, eventlog.SignersCountGT(*i.SignersCountGT)) - } - if i.SignersCountGTE != nil { - predicates = append(predicates, eventlog.SignersCountGTE(*i.SignersCountGTE)) - } - if i.SignersCountLT != nil { - predicates = append(predicates, eventlog.SignersCountLT(*i.SignersCountLT)) - } - if i.SignersCountLTE != nil { - predicates = append(predicates, eventlog.SignersCountLTE(*i.SignersCountLTE)) - } - if i.Address != nil { - predicates = append(predicates, eventlog.AddressEQ(*i.Address)) - } - if i.AddressNEQ != nil { - predicates = append(predicates, eventlog.AddressNEQ(*i.AddressNEQ)) - } - if len(i.AddressIn) > 0 { - predicates = append(predicates, eventlog.AddressIn(i.AddressIn...)) - } - if len(i.AddressNotIn) > 0 { - predicates = append(predicates, eventlog.AddressNotIn(i.AddressNotIn...)) - } - if i.AddressGT != nil { - predicates = append(predicates, eventlog.AddressGT(*i.AddressGT)) - } - if i.AddressGTE != nil { - predicates = append(predicates, eventlog.AddressGTE(*i.AddressGTE)) - } - if i.AddressLT != nil { - predicates = append(predicates, eventlog.AddressLT(*i.AddressLT)) - } - if i.AddressLTE != nil { - predicates = append(predicates, eventlog.AddressLTE(*i.AddressLTE)) - } - if i.AddressContains != nil { - predicates = append(predicates, eventlog.AddressContains(*i.AddressContains)) - } - if i.AddressHasPrefix != nil { - predicates = append(predicates, eventlog.AddressHasPrefix(*i.AddressHasPrefix)) - } - if i.AddressHasSuffix != nil { - predicates = append(predicates, eventlog.AddressHasSuffix(*i.AddressHasSuffix)) - } - if i.AddressEqualFold != nil { - predicates = append(predicates, eventlog.AddressEqualFold(*i.AddressEqualFold)) - } - if i.AddressContainsFold != nil { - predicates = append(predicates, eventlog.AddressContainsFold(*i.AddressContainsFold)) - } - if i.Chain != nil { - predicates = append(predicates, eventlog.ChainEQ(*i.Chain)) - } - if i.ChainNEQ != nil { - predicates = append(predicates, eventlog.ChainNEQ(*i.ChainNEQ)) - } - if len(i.ChainIn) > 0 { - predicates = append(predicates, eventlog.ChainIn(i.ChainIn...)) - } - if len(i.ChainNotIn) > 0 { - predicates = append(predicates, eventlog.ChainNotIn(i.ChainNotIn...)) - } - if i.ChainGT != nil { - predicates = append(predicates, eventlog.ChainGT(*i.ChainGT)) - } - if i.ChainGTE != nil { - predicates = append(predicates, eventlog.ChainGTE(*i.ChainGTE)) - } - if i.ChainLT != nil { - predicates = append(predicates, eventlog.ChainLT(*i.ChainLT)) - } - if i.ChainLTE != nil { - predicates = append(predicates, eventlog.ChainLTE(*i.ChainLTE)) - } - if i.ChainContains != nil { - predicates = append(predicates, eventlog.ChainContains(*i.ChainContains)) - } - if i.ChainHasPrefix != nil { - predicates = append(predicates, eventlog.ChainHasPrefix(*i.ChainHasPrefix)) - } - if i.ChainHasSuffix != nil { - predicates = append(predicates, eventlog.ChainHasSuffix(*i.ChainHasSuffix)) - } - if i.ChainEqualFold != nil { - predicates = append(predicates, eventlog.ChainEqualFold(*i.ChainEqualFold)) - } - if i.ChainContainsFold != nil { - predicates = append(predicates, eventlog.ChainContainsFold(*i.ChainContainsFold)) - } - if i.Index != nil { - predicates = append(predicates, eventlog.IndexEQ(*i.Index)) - } - if i.IndexNEQ != nil { - predicates = append(predicates, eventlog.IndexNEQ(*i.IndexNEQ)) - } - if len(i.IndexIn) > 0 { - predicates = append(predicates, eventlog.IndexIn(i.IndexIn...)) - } - if len(i.IndexNotIn) > 0 { - predicates = append(predicates, eventlog.IndexNotIn(i.IndexNotIn...)) - } - if i.IndexGT != nil { - predicates = append(predicates, eventlog.IndexGT(*i.IndexGT)) - } - if i.IndexGTE != nil { - predicates = append(predicates, eventlog.IndexGTE(*i.IndexGTE)) - } - if i.IndexLT != nil { - predicates = append(predicates, eventlog.IndexLT(*i.IndexLT)) - } - if i.IndexLTE != nil { - predicates = append(predicates, eventlog.IndexLTE(*i.IndexLTE)) - } - if i.Event != nil { - predicates = append(predicates, eventlog.EventEQ(*i.Event)) - } - if i.EventNEQ != nil { - predicates = append(predicates, eventlog.EventNEQ(*i.EventNEQ)) - } - if len(i.EventIn) > 0 { - predicates = append(predicates, eventlog.EventIn(i.EventIn...)) - } - if len(i.EventNotIn) > 0 { - predicates = append(predicates, eventlog.EventNotIn(i.EventNotIn...)) - } - if i.EventGT != nil { - predicates = append(predicates, eventlog.EventGT(*i.EventGT)) - } - if i.EventGTE != nil { - predicates = append(predicates, eventlog.EventGTE(*i.EventGTE)) - } - if i.EventLT != nil { - predicates = append(predicates, eventlog.EventLT(*i.EventLT)) - } - if i.EventLTE != nil { - predicates = append(predicates, eventlog.EventLTE(*i.EventLTE)) - } - if i.EventContains != nil { - predicates = append(predicates, eventlog.EventContains(*i.EventContains)) - } - if i.EventHasPrefix != nil { - predicates = append(predicates, eventlog.EventHasPrefix(*i.EventHasPrefix)) - } - if i.EventHasSuffix != nil { - predicates = append(predicates, eventlog.EventHasSuffix(*i.EventHasSuffix)) - } - if i.EventEqualFold != nil { - predicates = append(predicates, eventlog.EventEqualFold(*i.EventEqualFold)) - } - if i.EventContainsFold != nil { - predicates = append(predicates, eventlog.EventContainsFold(*i.EventContainsFold)) - } - if i.Consensus != nil { - predicates = append(predicates, eventlog.ConsensusEQ(*i.Consensus)) - } - if i.ConsensusNEQ != nil { - predicates = append(predicates, eventlog.ConsensusNEQ(*i.ConsensusNEQ)) - } - if i.Voted != nil { - predicates = append(predicates, eventlog.VotedEQ(i.Voted)) - } - if i.VotedNEQ != nil { - predicates = append(predicates, eventlog.VotedNEQ(i.VotedNEQ)) - } - if len(i.VotedIn) > 0 { - predicates = append(predicates, eventlog.VotedIn(i.VotedIn...)) - } - if len(i.VotedNotIn) > 0 { - predicates = append(predicates, eventlog.VotedNotIn(i.VotedNotIn...)) - } - if i.VotedGT != nil { - predicates = append(predicates, eventlog.VotedGT(i.VotedGT)) - } - if i.VotedGTE != nil { - predicates = append(predicates, eventlog.VotedGTE(i.VotedGTE)) - } - if i.VotedLT != nil { - predicates = append(predicates, eventlog.VotedLT(i.VotedLT)) - } - if i.VotedLTE != nil { - predicates = append(predicates, eventlog.VotedLTE(i.VotedLTE)) - } - - if i.HasSigners != nil { - p := eventlog.HasSigners() - if !*i.HasSigners { - p = eventlog.Not(p) - } - predicates = append(predicates, p) - } - if len(i.HasSignersWith) > 0 { - with := make([]predicate.Signer, 0, len(i.HasSignersWith)) - for _, w := range i.HasSignersWith { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'HasSignersWith'", err) - } - with = append(with, p) - } - predicates = append(predicates, eventlog.HasSignersWith(with...)) - } - switch len(predicates) { - case 0: - return nil, ErrEmptyEventLogWhereInput - case 1: - return predicates[0], nil - default: - return eventlog.And(predicates...), nil - } -} - -// SignerWhereInput represents a where input for filtering Signer queries. -type SignerWhereInput struct { - Predicates []predicate.Signer `json:"-"` - Not *SignerWhereInput `json:"not,omitempty"` - Or []*SignerWhereInput `json:"or,omitempty"` - And []*SignerWhereInput `json:"and,omitempty"` - - // "id" field predicates. - ID *int `json:"id,omitempty"` - IDNEQ *int `json:"idNEQ,omitempty"` - IDIn []int `json:"idIn,omitempty"` - IDNotIn []int `json:"idNotIn,omitempty"` - IDGT *int `json:"idGT,omitempty"` - IDGTE *int `json:"idGTE,omitempty"` - IDLT *int `json:"idLT,omitempty"` - IDLTE *int `json:"idLTE,omitempty"` - - // "name" field predicates. - Name *string `json:"name,omitempty"` - NameNEQ *string `json:"nameNEQ,omitempty"` - NameIn []string `json:"nameIn,omitempty"` - NameNotIn []string `json:"nameNotIn,omitempty"` - NameGT *string `json:"nameGT,omitempty"` - NameGTE *string `json:"nameGTE,omitempty"` - NameLT *string `json:"nameLT,omitempty"` - NameLTE *string `json:"nameLTE,omitempty"` - NameContains *string `json:"nameContains,omitempty"` - NameHasPrefix *string `json:"nameHasPrefix,omitempty"` - NameHasSuffix *string `json:"nameHasSuffix,omitempty"` - NameEqualFold *string `json:"nameEqualFold,omitempty"` - NameContainsFold *string `json:"nameContainsFold,omitempty"` - - // "evm" field predicates. - Evm *string `json:"evm,omitempty"` - EvmNEQ *string `json:"evmNEQ,omitempty"` - EvmIn []string `json:"evmIn,omitempty"` - EvmNotIn []string `json:"evmNotIn,omitempty"` - EvmGT *string `json:"evmGT,omitempty"` - EvmGTE *string `json:"evmGTE,omitempty"` - EvmLT *string `json:"evmLT,omitempty"` - EvmLTE *string `json:"evmLTE,omitempty"` - EvmContains *string `json:"evmContains,omitempty"` - EvmHasPrefix *string `json:"evmHasPrefix,omitempty"` - EvmHasSuffix *string `json:"evmHasSuffix,omitempty"` - EvmIsNil bool `json:"evmIsNil,omitempty"` - EvmNotNil bool `json:"evmNotNil,omitempty"` - EvmEqualFold *string `json:"evmEqualFold,omitempty"` - EvmContainsFold *string `json:"evmContainsFold,omitempty"` - - // "points" field predicates. - Points *int64 `json:"points,omitempty"` - PointsNEQ *int64 `json:"pointsNEQ,omitempty"` - PointsIn []int64 `json:"pointsIn,omitempty"` - PointsNotIn []int64 `json:"pointsNotIn,omitempty"` - PointsGT *int64 `json:"pointsGT,omitempty"` - PointsGTE *int64 `json:"pointsGTE,omitempty"` - PointsLT *int64 `json:"pointsLT,omitempty"` - PointsLTE *int64 `json:"pointsLTE,omitempty"` - - // "assetPrice" edge predicates. - HasAssetPrice *bool `json:"hasAssetPrice,omitempty"` - HasAssetPriceWith []*AssetPriceWhereInput `json:"hasAssetPriceWith,omitempty"` - - // "eventLogs" edge predicates. - HasEventLogs *bool `json:"hasEventLogs,omitempty"` - HasEventLogsWith []*EventLogWhereInput `json:"hasEventLogsWith,omitempty"` - - // "correctnessReport" edge predicates. - HasCorrectnessReport *bool `json:"hasCorrectnessReport,omitempty"` - HasCorrectnessReportWith []*CorrectnessReportWhereInput `json:"hasCorrectnessReportWith,omitempty"` -} - -// AddPredicates adds custom predicates to the where input to be used during the filtering phase. -func (i *SignerWhereInput) AddPredicates(predicates ...predicate.Signer) { - i.Predicates = append(i.Predicates, predicates...) -} - -// Filter applies the SignerWhereInput filter on the SignerQuery builder. -func (i *SignerWhereInput) Filter(q *SignerQuery) (*SignerQuery, error) { - if i == nil { - return q, nil - } - p, err := i.P() - if err != nil { - if err == ErrEmptySignerWhereInput { - return q, nil - } - return nil, err - } - return q.Where(p), nil -} - -// ErrEmptySignerWhereInput is returned in case the SignerWhereInput is empty. -var ErrEmptySignerWhereInput = errors.New("ent: empty predicate SignerWhereInput") - -// P returns a predicate for filtering signers. -// An error is returned if the input is empty or invalid. -func (i *SignerWhereInput) P() (predicate.Signer, error) { - var predicates []predicate.Signer - if i.Not != nil { - p, err := i.Not.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'not'", err) - } - predicates = append(predicates, signer.Not(p)) - } - switch n := len(i.Or); { - case n == 1: - p, err := i.Or[0].P() - if err != nil { - return nil, fmt.Errorf("%w: field 'or'", err) - } - predicates = append(predicates, p) - case n > 1: - or := make([]predicate.Signer, 0, n) - for _, w := range i.Or { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'or'", err) - } - or = append(or, p) - } - predicates = append(predicates, signer.Or(or...)) - } - switch n := len(i.And); { - case n == 1: - p, err := i.And[0].P() - if err != nil { - return nil, fmt.Errorf("%w: field 'and'", err) - } - predicates = append(predicates, p) - case n > 1: - and := make([]predicate.Signer, 0, n) - for _, w := range i.And { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'and'", err) - } - and = append(and, p) - } - predicates = append(predicates, signer.And(and...)) - } - predicates = append(predicates, i.Predicates...) - if i.ID != nil { - predicates = append(predicates, signer.IDEQ(*i.ID)) - } - if i.IDNEQ != nil { - predicates = append(predicates, signer.IDNEQ(*i.IDNEQ)) - } - if len(i.IDIn) > 0 { - predicates = append(predicates, signer.IDIn(i.IDIn...)) - } - if len(i.IDNotIn) > 0 { - predicates = append(predicates, signer.IDNotIn(i.IDNotIn...)) - } - if i.IDGT != nil { - predicates = append(predicates, signer.IDGT(*i.IDGT)) - } - if i.IDGTE != nil { - predicates = append(predicates, signer.IDGTE(*i.IDGTE)) - } - if i.IDLT != nil { - predicates = append(predicates, signer.IDLT(*i.IDLT)) - } - if i.IDLTE != nil { - predicates = append(predicates, signer.IDLTE(*i.IDLTE)) - } - if i.Name != nil { - predicates = append(predicates, signer.NameEQ(*i.Name)) - } - if i.NameNEQ != nil { - predicates = append(predicates, signer.NameNEQ(*i.NameNEQ)) - } - if len(i.NameIn) > 0 { - predicates = append(predicates, signer.NameIn(i.NameIn...)) - } - if len(i.NameNotIn) > 0 { - predicates = append(predicates, signer.NameNotIn(i.NameNotIn...)) - } - if i.NameGT != nil { - predicates = append(predicates, signer.NameGT(*i.NameGT)) - } - if i.NameGTE != nil { - predicates = append(predicates, signer.NameGTE(*i.NameGTE)) - } - if i.NameLT != nil { - predicates = append(predicates, signer.NameLT(*i.NameLT)) - } - if i.NameLTE != nil { - predicates = append(predicates, signer.NameLTE(*i.NameLTE)) - } - if i.NameContains != nil { - predicates = append(predicates, signer.NameContains(*i.NameContains)) - } - if i.NameHasPrefix != nil { - predicates = append(predicates, signer.NameHasPrefix(*i.NameHasPrefix)) - } - if i.NameHasSuffix != nil { - predicates = append(predicates, signer.NameHasSuffix(*i.NameHasSuffix)) - } - if i.NameEqualFold != nil { - predicates = append(predicates, signer.NameEqualFold(*i.NameEqualFold)) - } - if i.NameContainsFold != nil { - predicates = append(predicates, signer.NameContainsFold(*i.NameContainsFold)) - } - if i.Evm != nil { - predicates = append(predicates, signer.EvmEQ(*i.Evm)) - } - if i.EvmNEQ != nil { - predicates = append(predicates, signer.EvmNEQ(*i.EvmNEQ)) - } - if len(i.EvmIn) > 0 { - predicates = append(predicates, signer.EvmIn(i.EvmIn...)) - } - if len(i.EvmNotIn) > 0 { - predicates = append(predicates, signer.EvmNotIn(i.EvmNotIn...)) - } - if i.EvmGT != nil { - predicates = append(predicates, signer.EvmGT(*i.EvmGT)) - } - if i.EvmGTE != nil { - predicates = append(predicates, signer.EvmGTE(*i.EvmGTE)) - } - if i.EvmLT != nil { - predicates = append(predicates, signer.EvmLT(*i.EvmLT)) - } - if i.EvmLTE != nil { - predicates = append(predicates, signer.EvmLTE(*i.EvmLTE)) - } - if i.EvmContains != nil { - predicates = append(predicates, signer.EvmContains(*i.EvmContains)) - } - if i.EvmHasPrefix != nil { - predicates = append(predicates, signer.EvmHasPrefix(*i.EvmHasPrefix)) - } - if i.EvmHasSuffix != nil { - predicates = append(predicates, signer.EvmHasSuffix(*i.EvmHasSuffix)) - } - if i.EvmIsNil { - predicates = append(predicates, signer.EvmIsNil()) - } - if i.EvmNotNil { - predicates = append(predicates, signer.EvmNotNil()) - } - if i.EvmEqualFold != nil { - predicates = append(predicates, signer.EvmEqualFold(*i.EvmEqualFold)) - } - if i.EvmContainsFold != nil { - predicates = append(predicates, signer.EvmContainsFold(*i.EvmContainsFold)) - } - if i.Points != nil { - predicates = append(predicates, signer.PointsEQ(*i.Points)) - } - if i.PointsNEQ != nil { - predicates = append(predicates, signer.PointsNEQ(*i.PointsNEQ)) - } - if len(i.PointsIn) > 0 { - predicates = append(predicates, signer.PointsIn(i.PointsIn...)) - } - if len(i.PointsNotIn) > 0 { - predicates = append(predicates, signer.PointsNotIn(i.PointsNotIn...)) - } - if i.PointsGT != nil { - predicates = append(predicates, signer.PointsGT(*i.PointsGT)) - } - if i.PointsGTE != nil { - predicates = append(predicates, signer.PointsGTE(*i.PointsGTE)) - } - if i.PointsLT != nil { - predicates = append(predicates, signer.PointsLT(*i.PointsLT)) - } - if i.PointsLTE != nil { - predicates = append(predicates, signer.PointsLTE(*i.PointsLTE)) - } - - if i.HasAssetPrice != nil { - p := signer.HasAssetPrice() - if !*i.HasAssetPrice { - p = signer.Not(p) - } - predicates = append(predicates, p) - } - if len(i.HasAssetPriceWith) > 0 { - with := make([]predicate.AssetPrice, 0, len(i.HasAssetPriceWith)) - for _, w := range i.HasAssetPriceWith { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'HasAssetPriceWith'", err) - } - with = append(with, p) - } - predicates = append(predicates, signer.HasAssetPriceWith(with...)) - } - if i.HasEventLogs != nil { - p := signer.HasEventLogs() - if !*i.HasEventLogs { - p = signer.Not(p) - } - predicates = append(predicates, p) - } - if len(i.HasEventLogsWith) > 0 { - with := make([]predicate.EventLog, 0, len(i.HasEventLogsWith)) - for _, w := range i.HasEventLogsWith { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'HasEventLogsWith'", err) - } - with = append(with, p) - } - predicates = append(predicates, signer.HasEventLogsWith(with...)) - } - if i.HasCorrectnessReport != nil { - p := signer.HasCorrectnessReport() - if !*i.HasCorrectnessReport { - p = signer.Not(p) - } - predicates = append(predicates, p) - } - if len(i.HasCorrectnessReportWith) > 0 { - with := make([]predicate.CorrectnessReport, 0, len(i.HasCorrectnessReportWith)) - for _, w := range i.HasCorrectnessReportWith { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'HasCorrectnessReportWith'", err) - } - with = append(with, p) - } - predicates = append(predicates, signer.HasCorrectnessReportWith(with...)) - } - switch len(predicates) { - case 0: - return nil, ErrEmptySignerWhereInput - case 1: - return predicates[0], nil - default: - return signer.And(predicates...), nil - } -} diff --git a/internal/ent/helpers/bigint.go b/internal/ent/helpers/bigint.go deleted file mode 100644 index 4510de16..00000000 --- a/internal/ent/helpers/bigint.go +++ /dev/null @@ -1,34 +0,0 @@ -package helpers - -import ( - "database/sql" - "database/sql/driver" - "fmt" - "math/big" -) - -type BigInt struct { - big.Int -} - -const ( - BaseOfNumbers = 10 -) - -func (b *BigInt) Scan(src any) error { - var i sql.NullString - if err := i.Scan(src); err != nil { - return err - } - if !i.Valid { - return nil - } - if _, ok := b.Int.SetString(i.String, BaseOfNumbers); ok { - return nil - } - return fmt.Errorf("could not scan type %T with value %v into BigInt", src, src) -} - -func (b *BigInt) Value() (driver.Value, error) { - return b.String(), nil -} diff --git a/internal/ent/hook/hook.go b/internal/ent/hook/hook.go deleted file mode 100644 index cd8a4b49..00000000 --- a/internal/ent/hook/hook.go +++ /dev/null @@ -1,235 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package hook - -import ( - "context" - "fmt" - - "github.com/TimeleapLabs/unchained/internal/ent" -) - -// The AssetPriceFunc type is an adapter to allow the use of ordinary -// function as AssetPrice mutator. -type AssetPriceFunc func(context.Context, *ent.AssetPriceMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f AssetPriceFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.AssetPriceMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AssetPriceMutation", m) -} - -// The CorrectnessReportFunc type is an adapter to allow the use of ordinary -// function as CorrectnessReport mutator. -type CorrectnessReportFunc func(context.Context, *ent.CorrectnessReportMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f CorrectnessReportFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.CorrectnessReportMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.CorrectnessReportMutation", m) -} - -// The EventLogFunc type is an adapter to allow the use of ordinary -// function as EventLog mutator. -type EventLogFunc func(context.Context, *ent.EventLogMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f EventLogFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.EventLogMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EventLogMutation", m) -} - -// The SignerFunc type is an adapter to allow the use of ordinary -// function as Signer mutator. -type SignerFunc func(context.Context, *ent.SignerMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f SignerFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.SignerMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SignerMutation", 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/internal/ent/migrate/migrate.go b/internal/ent/migrate/migrate.go deleted file mode 100644 index 1956a6bf..00000000 --- a/internal/ent/migrate/migrate.go +++ /dev/null @@ -1,64 +0,0 @@ -// 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/internal/ent/migrate/schema.go b/internal/ent/migrate/schema.go deleted file mode 100644 index 0ae7b317..00000000 --- a/internal/ent/migrate/schema.go +++ /dev/null @@ -1,226 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package migrate - -import ( - "entgo.io/ent/dialect/sql/schema" - "entgo.io/ent/schema/field" -) - -var ( - // AssetPricesColumns holds the columns for the "asset_prices" table. - AssetPricesColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, - {Name: "block", Type: field.TypeUint64}, - {Name: "signers_count", Type: field.TypeUint64, Nullable: true}, - {Name: "price", Type: field.TypeUint, SchemaType: map[string]string{"postgres": "numeric(78, 0)", "sqlite3": "numeric(78, 0)"}}, - {Name: "signature", Type: field.TypeBytes, Size: 48}, - {Name: "asset", Type: field.TypeString, Nullable: true}, - {Name: "chain", Type: field.TypeString, Nullable: true}, - {Name: "pair", Type: field.TypeString, Nullable: true}, - {Name: "consensus", Type: field.TypeBool, Default: false}, - {Name: "voted", Type: field.TypeUint, SchemaType: map[string]string{"postgres": "numeric(78, 0)", "sqlite3": "numeric(78, 0)"}}, - } - // AssetPricesTable holds the schema information for the "asset_prices" table. - AssetPricesTable = &schema.Table{ - Name: "asset_prices", - Columns: AssetPricesColumns, - PrimaryKey: []*schema.Column{AssetPricesColumns[0]}, - Indexes: []*schema.Index{ - { - Name: "assetprice_block_chain_asset_pair", - Unique: true, - Columns: []*schema.Column{AssetPricesColumns[1], AssetPricesColumns[6], AssetPricesColumns[5], AssetPricesColumns[7]}, - }, - { - Name: "assetprice_block_chain_asset_pair_price_consensus", - Unique: false, - Columns: []*schema.Column{AssetPricesColumns[1], AssetPricesColumns[6], AssetPricesColumns[5], AssetPricesColumns[7], AssetPricesColumns[3], AssetPricesColumns[8]}, - }, - }, - } - // CorrectnessReportsColumns holds the columns for the "correctness_reports" table. - CorrectnessReportsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, - {Name: "signers_count", Type: field.TypeUint64}, - {Name: "timestamp", Type: field.TypeUint64}, - {Name: "signature", Type: field.TypeBytes, Size: 48}, - {Name: "hash", Type: field.TypeBytes, Size: 64}, - {Name: "topic", Type: field.TypeBytes, Size: 64}, - {Name: "correct", Type: field.TypeBool}, - {Name: "consensus", Type: field.TypeBool, Default: false}, - {Name: "voted", Type: field.TypeUint, SchemaType: map[string]string{"postgres": "numeric(78, 0)", "sqlite3": "numeric(78, 0)"}}, - } - // CorrectnessReportsTable holds the schema information for the "correctness_reports" table. - CorrectnessReportsTable = &schema.Table{ - Name: "correctness_reports", - Columns: CorrectnessReportsColumns, - PrimaryKey: []*schema.Column{CorrectnessReportsColumns[0]}, - Indexes: []*schema.Index{ - { - Name: "correctnessreport_topic_hash", - Unique: true, - Columns: []*schema.Column{CorrectnessReportsColumns[5], CorrectnessReportsColumns[4]}, - }, - { - Name: "correctnessreport_topic_timestamp_hash", - Unique: false, - Columns: []*schema.Column{CorrectnessReportsColumns[5], CorrectnessReportsColumns[2], CorrectnessReportsColumns[4]}, - }, - }, - } - // EventLogsColumns holds the columns for the "event_logs" table. - EventLogsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, - {Name: "block", Type: field.TypeUint64}, - {Name: "signers_count", Type: field.TypeUint64}, - {Name: "signature", Type: field.TypeBytes, Size: 48}, - {Name: "address", Type: field.TypeString}, - {Name: "chain", Type: field.TypeString}, - {Name: "index", Type: field.TypeUint64}, - {Name: "event", Type: field.TypeString}, - {Name: "transaction", Type: field.TypeBytes, Size: 32}, - {Name: "args", Type: field.TypeJSON}, - {Name: "consensus", Type: field.TypeBool, Default: false}, - {Name: "voted", Type: field.TypeUint, SchemaType: map[string]string{"postgres": "numeric(78, 0)", "sqlite3": "numeric(78, 0)"}}, - } - // EventLogsTable holds the schema information for the "event_logs" table. - EventLogsTable = &schema.Table{ - Name: "event_logs", - Columns: EventLogsColumns, - PrimaryKey: []*schema.Column{EventLogsColumns[0]}, - Indexes: []*schema.Index{ - { - Name: "eventlog_block_transaction_index", - Unique: true, - Columns: []*schema.Column{EventLogsColumns[1], EventLogsColumns[8], EventLogsColumns[6]}, - }, - { - Name: "eventlog_block_address_event_consensus", - Unique: false, - Columns: []*schema.Column{EventLogsColumns[1], EventLogsColumns[4], EventLogsColumns[7], EventLogsColumns[10]}, - }, - }, - } - // SignersColumns holds the columns for the "signers" table. - SignersColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, - {Name: "name", Type: field.TypeString}, - {Name: "evm", Type: field.TypeString, Nullable: true}, - {Name: "key", Type: field.TypeBytes, Unique: true, Size: 96}, - {Name: "shortkey", Type: field.TypeBytes, Unique: true, Size: 96}, - {Name: "points", Type: field.TypeInt64}, - } - // SignersTable holds the schema information for the "signers" table. - SignersTable = &schema.Table{ - Name: "signers", - Columns: SignersColumns, - PrimaryKey: []*schema.Column{SignersColumns[0]}, - Indexes: []*schema.Index{ - { - Name: "signer_key", - Unique: true, - Columns: []*schema.Column{SignersColumns[3]}, - }, - { - Name: "signer_shortkey", - Unique: true, - Columns: []*schema.Column{SignersColumns[4]}, - }, - }, - } - // AssetPriceSignersColumns holds the columns for the "asset_price_signers" table. - AssetPriceSignersColumns = []*schema.Column{ - {Name: "asset_price_id", Type: field.TypeInt}, - {Name: "signer_id", Type: field.TypeInt}, - } - // AssetPriceSignersTable holds the schema information for the "asset_price_signers" table. - AssetPriceSignersTable = &schema.Table{ - Name: "asset_price_signers", - Columns: AssetPriceSignersColumns, - PrimaryKey: []*schema.Column{AssetPriceSignersColumns[0], AssetPriceSignersColumns[1]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "asset_price_signers_asset_price_id", - Columns: []*schema.Column{AssetPriceSignersColumns[0]}, - RefColumns: []*schema.Column{AssetPricesColumns[0]}, - OnDelete: schema.Cascade, - }, - { - Symbol: "asset_price_signers_signer_id", - Columns: []*schema.Column{AssetPriceSignersColumns[1]}, - RefColumns: []*schema.Column{SignersColumns[0]}, - OnDelete: schema.Cascade, - }, - }, - } - // CorrectnessReportSignersColumns holds the columns for the "correctness_report_signers" table. - CorrectnessReportSignersColumns = []*schema.Column{ - {Name: "correctness_report_id", Type: field.TypeInt}, - {Name: "signer_id", Type: field.TypeInt}, - } - // CorrectnessReportSignersTable holds the schema information for the "correctness_report_signers" table. - CorrectnessReportSignersTable = &schema.Table{ - Name: "correctness_report_signers", - Columns: CorrectnessReportSignersColumns, - PrimaryKey: []*schema.Column{CorrectnessReportSignersColumns[0], CorrectnessReportSignersColumns[1]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "correctness_report_signers_correctness_report_id", - Columns: []*schema.Column{CorrectnessReportSignersColumns[0]}, - RefColumns: []*schema.Column{CorrectnessReportsColumns[0]}, - OnDelete: schema.Cascade, - }, - { - Symbol: "correctness_report_signers_signer_id", - Columns: []*schema.Column{CorrectnessReportSignersColumns[1]}, - RefColumns: []*schema.Column{SignersColumns[0]}, - OnDelete: schema.Cascade, - }, - }, - } - // EventLogSignersColumns holds the columns for the "event_log_signers" table. - EventLogSignersColumns = []*schema.Column{ - {Name: "event_log_id", Type: field.TypeInt}, - {Name: "signer_id", Type: field.TypeInt}, - } - // EventLogSignersTable holds the schema information for the "event_log_signers" table. - EventLogSignersTable = &schema.Table{ - Name: "event_log_signers", - Columns: EventLogSignersColumns, - PrimaryKey: []*schema.Column{EventLogSignersColumns[0], EventLogSignersColumns[1]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "event_log_signers_event_log_id", - Columns: []*schema.Column{EventLogSignersColumns[0]}, - RefColumns: []*schema.Column{EventLogsColumns[0]}, - OnDelete: schema.Cascade, - }, - { - Symbol: "event_log_signers_signer_id", - Columns: []*schema.Column{EventLogSignersColumns[1]}, - RefColumns: []*schema.Column{SignersColumns[0]}, - OnDelete: schema.Cascade, - }, - }, - } - // Tables holds all the tables in the schema. - Tables = []*schema.Table{ - AssetPricesTable, - CorrectnessReportsTable, - EventLogsTable, - SignersTable, - AssetPriceSignersTable, - CorrectnessReportSignersTable, - EventLogSignersTable, - } -) - -func init() { - AssetPriceSignersTable.ForeignKeys[0].RefTable = AssetPricesTable - AssetPriceSignersTable.ForeignKeys[1].RefTable = SignersTable - CorrectnessReportSignersTable.ForeignKeys[0].RefTable = CorrectnessReportsTable - CorrectnessReportSignersTable.ForeignKeys[1].RefTable = SignersTable - EventLogSignersTable.ForeignKeys[0].RefTable = EventLogsTable - EventLogSignersTable.ForeignKeys[1].RefTable = SignersTable -} diff --git a/internal/ent/mutation.go b/internal/ent/mutation.go deleted file mode 100644 index ddcde87d..00000000 --- a/internal/ent/mutation.go +++ /dev/null @@ -1,3837 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "github.com/TimeleapLabs/unchained/internal/model" - "sync" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -const ( - // Operation types. - OpCreate = ent.OpCreate - OpDelete = ent.OpDelete - OpDeleteOne = ent.OpDeleteOne - OpUpdate = ent.OpUpdate - OpUpdateOne = ent.OpUpdateOne - - // Node types. - TypeAssetPrice = "AssetPrice" - TypeCorrectnessReport = "CorrectnessReport" - TypeEventLog = "EventLog" - TypeSigner = "Signer" -) - -// AssetPriceMutation represents an operation that mutates the AssetPrice nodes in the graph. -type AssetPriceMutation struct { - config - op Op - typ string - id *int - block *uint64 - addblock *int64 - signersCount *uint64 - addsignersCount *int64 - price **helpers.BigInt - signature *[]byte - asset *string - chain *string - pair *string - consensus *bool - voted **helpers.BigInt - clearedFields map[string]struct{} - signers map[int]struct{} - removedsigners map[int]struct{} - clearedsigners bool - done bool - oldValue func(context.Context) (*AssetPrice, error) - predicates []predicate.AssetPrice -} - -var _ ent.Mutation = (*AssetPriceMutation)(nil) - -// assetpriceOption allows management of the mutation configuration using functional options. -type assetpriceOption func(*AssetPriceMutation) - -// newAssetPriceMutation creates new mutation for the AssetPrice entity. -func newAssetPriceMutation(c config, op Op, opts ...assetpriceOption) *AssetPriceMutation { - m := &AssetPriceMutation{ - config: c, - op: op, - typ: TypeAssetPrice, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withAssetPriceID sets the ID field of the mutation. -func withAssetPriceID(id int) assetpriceOption { - return func(m *AssetPriceMutation) { - var ( - err error - once sync.Once - value *AssetPrice - ) - m.oldValue = func(ctx context.Context) (*AssetPrice, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().AssetPrice.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withAssetPrice sets the old AssetPrice of the mutation. -func withAssetPrice(node *AssetPrice) assetpriceOption { - return func(m *AssetPriceMutation) { - m.oldValue = func(context.Context) (*AssetPrice, 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 AssetPriceMutation) 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 AssetPriceMutation) 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 *AssetPriceMutation) 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 *AssetPriceMutation) 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().AssetPrice.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetBlock sets the "block" field. -func (m *AssetPriceMutation) SetBlock(u uint64) { - m.block = &u - m.addblock = nil -} - -// Block returns the value of the "block" field in the mutation. -func (m *AssetPriceMutation) Block() (r uint64, exists bool) { - v := m.block - if v == nil { - return - } - return *v, true -} - -// OldBlock returns the old "block" field's value of the AssetPrice entity. -// If the AssetPrice 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 *AssetPriceMutation) OldBlock(ctx context.Context) (v uint64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBlock is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBlock requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldBlock: %w", err) - } - return oldValue.Block, nil -} - -// AddBlock adds u to the "block" field. -func (m *AssetPriceMutation) AddBlock(u int64) { - if m.addblock != nil { - *m.addblock += u - } else { - m.addblock = &u - } -} - -// AddedBlock returns the value that was added to the "block" field in this mutation. -func (m *AssetPriceMutation) AddedBlock() (r int64, exists bool) { - v := m.addblock - if v == nil { - return - } - return *v, true -} - -// ResetBlock resets all changes to the "block" field. -func (m *AssetPriceMutation) ResetBlock() { - m.block = nil - m.addblock = nil -} - -// SetSignersCount sets the "signersCount" field. -func (m *AssetPriceMutation) SetSignersCount(u uint64) { - m.signersCount = &u - m.addsignersCount = nil -} - -// SignersCount returns the value of the "signersCount" field in the mutation. -func (m *AssetPriceMutation) SignersCount() (r uint64, exists bool) { - v := m.signersCount - if v == nil { - return - } - return *v, true -} - -// OldSignersCount returns the old "signersCount" field's value of the AssetPrice entity. -// If the AssetPrice 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 *AssetPriceMutation) OldSignersCount(ctx context.Context) (v *uint64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSignersCount is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSignersCount requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSignersCount: %w", err) - } - return oldValue.SignersCount, nil -} - -// AddSignersCount adds u to the "signersCount" field. -func (m *AssetPriceMutation) AddSignersCount(u int64) { - if m.addsignersCount != nil { - *m.addsignersCount += u - } else { - m.addsignersCount = &u - } -} - -// AddedSignersCount returns the value that was added to the "signersCount" field in this mutation. -func (m *AssetPriceMutation) AddedSignersCount() (r int64, exists bool) { - v := m.addsignersCount - if v == nil { - return - } - return *v, true -} - -// ClearSignersCount clears the value of the "signersCount" field. -func (m *AssetPriceMutation) ClearSignersCount() { - m.signersCount = nil - m.addsignersCount = nil - m.clearedFields[assetprice.FieldSignersCount] = struct{}{} -} - -// SignersCountCleared returns if the "signersCount" field was cleared in this mutation. -func (m *AssetPriceMutation) SignersCountCleared() bool { - _, ok := m.clearedFields[assetprice.FieldSignersCount] - return ok -} - -// ResetSignersCount resets all changes to the "signersCount" field. -func (m *AssetPriceMutation) ResetSignersCount() { - m.signersCount = nil - m.addsignersCount = nil - delete(m.clearedFields, assetprice.FieldSignersCount) -} - -// SetPrice sets the "price" field. -func (m *AssetPriceMutation) SetPrice(hi *helpers.BigInt) { - m.price = &hi -} - -// Price returns the value of the "price" field in the mutation. -func (m *AssetPriceMutation) Price() (r *helpers.BigInt, exists bool) { - v := m.price - if v == nil { - return - } - return *v, true -} - -// OldPrice returns the old "price" field's value of the AssetPrice entity. -// If the AssetPrice 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 *AssetPriceMutation) OldPrice(ctx context.Context) (v *helpers.BigInt, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPrice is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPrice requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPrice: %w", err) - } - return oldValue.Price, nil -} - -// ResetPrice resets all changes to the "price" field. -func (m *AssetPriceMutation) ResetPrice() { - m.price = nil -} - -// SetSignature sets the "signature" field. -func (m *AssetPriceMutation) SetSignature(b []byte) { - m.signature = &b -} - -// Signature returns the value of the "signature" field in the mutation. -func (m *AssetPriceMutation) Signature() (r []byte, exists bool) { - v := m.signature - if v == nil { - return - } - return *v, true -} - -// OldSignature returns the old "signature" field's value of the AssetPrice entity. -// If the AssetPrice 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 *AssetPriceMutation) OldSignature(ctx context.Context) (v []byte, 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 *AssetPriceMutation) ResetSignature() { - m.signature = nil -} - -// SetAsset sets the "asset" field. -func (m *AssetPriceMutation) SetAsset(s string) { - m.asset = &s -} - -// Asset returns the value of the "asset" field in the mutation. -func (m *AssetPriceMutation) Asset() (r string, exists bool) { - v := m.asset - if v == nil { - return - } - return *v, true -} - -// OldAsset returns the old "asset" field's value of the AssetPrice entity. -// If the AssetPrice 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 *AssetPriceMutation) OldAsset(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAsset is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAsset requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldAsset: %w", err) - } - return oldValue.Asset, nil -} - -// ClearAsset clears the value of the "asset" field. -func (m *AssetPriceMutation) ClearAsset() { - m.asset = nil - m.clearedFields[assetprice.FieldAsset] = struct{}{} -} - -// AssetCleared returns if the "asset" field was cleared in this mutation. -func (m *AssetPriceMutation) AssetCleared() bool { - _, ok := m.clearedFields[assetprice.FieldAsset] - return ok -} - -// ResetAsset resets all changes to the "asset" field. -func (m *AssetPriceMutation) ResetAsset() { - m.asset = nil - delete(m.clearedFields, assetprice.FieldAsset) -} - -// SetChain sets the "chain" field. -func (m *AssetPriceMutation) SetChain(s string) { - m.chain = &s -} - -// Chain returns the value of the "chain" field in the mutation. -func (m *AssetPriceMutation) Chain() (r string, exists bool) { - v := m.chain - if v == nil { - return - } - return *v, true -} - -// OldChain returns the old "chain" field's value of the AssetPrice entity. -// If the AssetPrice 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 *AssetPriceMutation) OldChain(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldChain is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldChain requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldChain: %w", err) - } - return oldValue.Chain, nil -} - -// ClearChain clears the value of the "chain" field. -func (m *AssetPriceMutation) ClearChain() { - m.chain = nil - m.clearedFields[assetprice.FieldChain] = struct{}{} -} - -// ChainCleared returns if the "chain" field was cleared in this mutation. -func (m *AssetPriceMutation) ChainCleared() bool { - _, ok := m.clearedFields[assetprice.FieldChain] - return ok -} - -// ResetChain resets all changes to the "chain" field. -func (m *AssetPriceMutation) ResetChain() { - m.chain = nil - delete(m.clearedFields, assetprice.FieldChain) -} - -// SetPair sets the "pair" field. -func (m *AssetPriceMutation) SetPair(s string) { - m.pair = &s -} - -// Pair returns the value of the "pair" field in the mutation. -func (m *AssetPriceMutation) Pair() (r string, exists bool) { - v := m.pair - if v == nil { - return - } - return *v, true -} - -// OldPair returns the old "pair" field's value of the AssetPrice entity. -// If the AssetPrice 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 *AssetPriceMutation) OldPair(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPair is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPair requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPair: %w", err) - } - return oldValue.Pair, nil -} - -// ClearPair clears the value of the "pair" field. -func (m *AssetPriceMutation) ClearPair() { - m.pair = nil - m.clearedFields[assetprice.FieldPair] = struct{}{} -} - -// PairCleared returns if the "pair" field was cleared in this mutation. -func (m *AssetPriceMutation) PairCleared() bool { - _, ok := m.clearedFields[assetprice.FieldPair] - return ok -} - -// ResetPair resets all changes to the "pair" field. -func (m *AssetPriceMutation) ResetPair() { - m.pair = nil - delete(m.clearedFields, assetprice.FieldPair) -} - -// SetConsensus sets the "consensus" field. -func (m *AssetPriceMutation) SetConsensus(b bool) { - m.consensus = &b -} - -// Consensus returns the value of the "consensus" field in the mutation. -func (m *AssetPriceMutation) Consensus() (r bool, exists bool) { - v := m.consensus - if v == nil { - return - } - return *v, true -} - -// OldConsensus returns the old "consensus" field's value of the AssetPrice entity. -// If the AssetPrice 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 *AssetPriceMutation) OldConsensus(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldConsensus is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldConsensus requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldConsensus: %w", err) - } - return oldValue.Consensus, nil -} - -// ResetConsensus resets all changes to the "consensus" field. -func (m *AssetPriceMutation) ResetConsensus() { - m.consensus = nil -} - -// SetVoted sets the "voted" field. -func (m *AssetPriceMutation) SetVoted(hi *helpers.BigInt) { - m.voted = &hi -} - -// Voted returns the value of the "voted" field in the mutation. -func (m *AssetPriceMutation) Voted() (r *helpers.BigInt, exists bool) { - v := m.voted - if v == nil { - return - } - return *v, true -} - -// OldVoted returns the old "voted" field's value of the AssetPrice entity. -// If the AssetPrice 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 *AssetPriceMutation) OldVoted(ctx context.Context) (v *helpers.BigInt, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVoted is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVoted requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldVoted: %w", err) - } - return oldValue.Voted, nil -} - -// ResetVoted resets all changes to the "voted" field. -func (m *AssetPriceMutation) ResetVoted() { - m.voted = nil -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by ids. -func (m *AssetPriceMutation) AddSignerIDs(ids ...int) { - if m.signers == nil { - m.signers = make(map[int]struct{}) - } - for i := range ids { - m.signers[ids[i]] = struct{}{} - } -} - -// ClearSigners clears the "signers" edge to the Signer entity. -func (m *AssetPriceMutation) ClearSigners() { - m.clearedsigners = true -} - -// SignersCleared reports if the "signers" edge to the Signer entity was cleared. -func (m *AssetPriceMutation) SignersCleared() bool { - return m.clearedsigners -} - -// RemoveSignerIDs removes the "signers" edge to the Signer entity by IDs. -func (m *AssetPriceMutation) RemoveSignerIDs(ids ...int) { - if m.removedsigners == nil { - m.removedsigners = make(map[int]struct{}) - } - for i := range ids { - delete(m.signers, ids[i]) - m.removedsigners[ids[i]] = struct{}{} - } -} - -// RemovedSigners returns the removed IDs of the "signers" edge to the Signer entity. -func (m *AssetPriceMutation) RemovedSignersIDs() (ids []int) { - for id := range m.removedsigners { - ids = append(ids, id) - } - return -} - -// SignersIDs returns the "signers" edge IDs in the mutation. -func (m *AssetPriceMutation) SignersIDs() (ids []int) { - for id := range m.signers { - ids = append(ids, id) - } - return -} - -// ResetSigners resets all changes to the "signers" edge. -func (m *AssetPriceMutation) ResetSigners() { - m.signers = nil - m.clearedsigners = false - m.removedsigners = nil -} - -// Where appends a list predicates to the AssetPriceMutation builder. -func (m *AssetPriceMutation) Where(ps ...predicate.AssetPrice) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the AssetPriceMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *AssetPriceMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.AssetPrice, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *AssetPriceMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *AssetPriceMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (AssetPrice). -func (m *AssetPriceMutation) 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 *AssetPriceMutation) Fields() []string { - fields := make([]string, 0, 9) - if m.block != nil { - fields = append(fields, assetprice.FieldBlock) - } - if m.signersCount != nil { - fields = append(fields, assetprice.FieldSignersCount) - } - if m.price != nil { - fields = append(fields, assetprice.FieldPrice) - } - if m.signature != nil { - fields = append(fields, assetprice.FieldSignature) - } - if m.asset != nil { - fields = append(fields, assetprice.FieldAsset) - } - if m.chain != nil { - fields = append(fields, assetprice.FieldChain) - } - if m.pair != nil { - fields = append(fields, assetprice.FieldPair) - } - if m.consensus != nil { - fields = append(fields, assetprice.FieldConsensus) - } - if m.voted != nil { - fields = append(fields, assetprice.FieldVoted) - } - 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 *AssetPriceMutation) Field(name string) (ent.Value, bool) { - switch name { - case assetprice.FieldBlock: - return m.Block() - case assetprice.FieldSignersCount: - return m.SignersCount() - case assetprice.FieldPrice: - return m.Price() - case assetprice.FieldSignature: - return m.Signature() - case assetprice.FieldAsset: - return m.Asset() - case assetprice.FieldChain: - return m.Chain() - case assetprice.FieldPair: - return m.Pair() - case assetprice.FieldConsensus: - return m.Consensus() - case assetprice.FieldVoted: - return m.Voted() - } - 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 *AssetPriceMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case assetprice.FieldBlock: - return m.OldBlock(ctx) - case assetprice.FieldSignersCount: - return m.OldSignersCount(ctx) - case assetprice.FieldPrice: - return m.OldPrice(ctx) - case assetprice.FieldSignature: - return m.OldSignature(ctx) - case assetprice.FieldAsset: - return m.OldAsset(ctx) - case assetprice.FieldChain: - return m.OldChain(ctx) - case assetprice.FieldPair: - return m.OldPair(ctx) - case assetprice.FieldConsensus: - return m.OldConsensus(ctx) - case assetprice.FieldVoted: - return m.OldVoted(ctx) - } - return nil, fmt.Errorf("unknown AssetPrice 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 *AssetPriceMutation) SetField(name string, value ent.Value) error { - switch name { - case assetprice.FieldBlock: - v, ok := value.(uint64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetBlock(v) - return nil - case assetprice.FieldSignersCount: - v, ok := value.(uint64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSignersCount(v) - return nil - case assetprice.FieldPrice: - v, ok := value.(*helpers.BigInt) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPrice(v) - return nil - case assetprice.FieldSignature: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSignature(v) - return nil - case assetprice.FieldAsset: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAsset(v) - return nil - case assetprice.FieldChain: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetChain(v) - return nil - case assetprice.FieldPair: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPair(v) - return nil - case assetprice.FieldConsensus: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetConsensus(v) - return nil - case assetprice.FieldVoted: - v, ok := value.(*helpers.BigInt) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetVoted(v) - return nil - } - return fmt.Errorf("unknown AssetPrice field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *AssetPriceMutation) AddedFields() []string { - var fields []string - if m.addblock != nil { - fields = append(fields, assetprice.FieldBlock) - } - if m.addsignersCount != nil { - fields = append(fields, assetprice.FieldSignersCount) - } - 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 *AssetPriceMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case assetprice.FieldBlock: - return m.AddedBlock() - case assetprice.FieldSignersCount: - return m.AddedSignersCount() - } - 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 *AssetPriceMutation) AddField(name string, value ent.Value) error { - switch name { - case assetprice.FieldBlock: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddBlock(v) - return nil - case assetprice.FieldSignersCount: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddSignersCount(v) - return nil - } - return fmt.Errorf("unknown AssetPrice numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *AssetPriceMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(assetprice.FieldSignersCount) { - fields = append(fields, assetprice.FieldSignersCount) - } - if m.FieldCleared(assetprice.FieldAsset) { - fields = append(fields, assetprice.FieldAsset) - } - if m.FieldCleared(assetprice.FieldChain) { - fields = append(fields, assetprice.FieldChain) - } - if m.FieldCleared(assetprice.FieldPair) { - fields = append(fields, assetprice.FieldPair) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *AssetPriceMutation) 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 *AssetPriceMutation) ClearField(name string) error { - switch name { - case assetprice.FieldSignersCount: - m.ClearSignersCount() - return nil - case assetprice.FieldAsset: - m.ClearAsset() - return nil - case assetprice.FieldChain: - m.ClearChain() - return nil - case assetprice.FieldPair: - m.ClearPair() - return nil - } - return fmt.Errorf("unknown AssetPrice 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 *AssetPriceMutation) ResetField(name string) error { - switch name { - case assetprice.FieldBlock: - m.ResetBlock() - return nil - case assetprice.FieldSignersCount: - m.ResetSignersCount() - return nil - case assetprice.FieldPrice: - m.ResetPrice() - return nil - case assetprice.FieldSignature: - m.ResetSignature() - return nil - case assetprice.FieldAsset: - m.ResetAsset() - return nil - case assetprice.FieldChain: - m.ResetChain() - return nil - case assetprice.FieldPair: - m.ResetPair() - return nil - case assetprice.FieldConsensus: - m.ResetConsensus() - return nil - case assetprice.FieldVoted: - m.ResetVoted() - return nil - } - return fmt.Errorf("unknown AssetPrice field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *AssetPriceMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.signers != nil { - edges = append(edges, assetprice.EdgeSigners) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *AssetPriceMutation) AddedIDs(name string) []ent.Value { - switch name { - case assetprice.EdgeSigners: - ids := make([]ent.Value, 0, len(m.signers)) - for id := range m.signers { - ids = append(ids, id) - } - return ids - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *AssetPriceMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) - if m.removedsigners != nil { - edges = append(edges, assetprice.EdgeSigners) - } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *AssetPriceMutation) RemovedIDs(name string) []ent.Value { - switch name { - case assetprice.EdgeSigners: - ids := make([]ent.Value, 0, len(m.removedsigners)) - for id := range m.removedsigners { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *AssetPriceMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.clearedsigners { - edges = append(edges, assetprice.EdgeSigners) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *AssetPriceMutation) EdgeCleared(name string) bool { - switch name { - case assetprice.EdgeSigners: - return m.clearedsigners - } - 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 *AssetPriceMutation) ClearEdge(name string) error { - switch name { - } - return fmt.Errorf("unknown AssetPrice 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 *AssetPriceMutation) ResetEdge(name string) error { - switch name { - case assetprice.EdgeSigners: - m.ResetSigners() - return nil - } - return fmt.Errorf("unknown AssetPrice edge %s", name) -} - -// CorrectnessReportMutation represents an operation that mutates the CorrectnessReport nodes in the graph. -type CorrectnessReportMutation struct { - config - op Op - typ string - id *int - signersCount *uint64 - addsignersCount *int64 - timestamp *uint64 - addtimestamp *int64 - signature *[]byte - hash *[]byte - topic *[]byte - correct *bool - consensus *bool - voted **helpers.BigInt - clearedFields map[string]struct{} - signers map[int]struct{} - removedsigners map[int]struct{} - clearedsigners bool - done bool - oldValue func(context.Context) (*CorrectnessReport, error) - predicates []predicate.CorrectnessReport -} - -var _ ent.Mutation = (*CorrectnessReportMutation)(nil) - -// correctnessreportOption allows management of the mutation configuration using functional options. -type correctnessreportOption func(*CorrectnessReportMutation) - -// newCorrectnessReportMutation creates new mutation for the CorrectnessReport entity. -func newCorrectnessReportMutation(c config, op Op, opts ...correctnessreportOption) *CorrectnessReportMutation { - m := &CorrectnessReportMutation{ - config: c, - op: op, - typ: TypeCorrectnessReport, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withCorrectnessReportID sets the ID field of the mutation. -func withCorrectnessReportID(id int) correctnessreportOption { - return func(m *CorrectnessReportMutation) { - var ( - err error - once sync.Once - value *CorrectnessReport - ) - m.oldValue = func(ctx context.Context) (*CorrectnessReport, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().CorrectnessReport.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withCorrectnessReport sets the old CorrectnessReport of the mutation. -func withCorrectnessReport(node *CorrectnessReport) correctnessreportOption { - return func(m *CorrectnessReportMutation) { - m.oldValue = func(context.Context) (*CorrectnessReport, 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 CorrectnessReportMutation) 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 CorrectnessReportMutation) 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 *CorrectnessReportMutation) 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 *CorrectnessReportMutation) 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().CorrectnessReport.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetSignersCount sets the "signersCount" field. -func (m *CorrectnessReportMutation) SetSignersCount(u uint64) { - m.signersCount = &u - m.addsignersCount = nil -} - -// SignersCount returns the value of the "signersCount" field in the mutation. -func (m *CorrectnessReportMutation) SignersCount() (r uint64, exists bool) { - v := m.signersCount - if v == nil { - return - } - return *v, true -} - -// OldSignersCount returns the old "signersCount" field's value of the CorrectnessReport entity. -// If the CorrectnessReport 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 *CorrectnessReportMutation) OldSignersCount(ctx context.Context) (v uint64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSignersCount is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSignersCount requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSignersCount: %w", err) - } - return oldValue.SignersCount, nil -} - -// AddSignersCount adds u to the "signersCount" field. -func (m *CorrectnessReportMutation) AddSignersCount(u int64) { - if m.addsignersCount != nil { - *m.addsignersCount += u - } else { - m.addsignersCount = &u - } -} - -// AddedSignersCount returns the value that was added to the "signersCount" field in this mutation. -func (m *CorrectnessReportMutation) AddedSignersCount() (r int64, exists bool) { - v := m.addsignersCount - if v == nil { - return - } - return *v, true -} - -// ResetSignersCount resets all changes to the "signersCount" field. -func (m *CorrectnessReportMutation) ResetSignersCount() { - m.signersCount = nil - m.addsignersCount = nil -} - -// SetTimestamp sets the "timestamp" field. -func (m *CorrectnessReportMutation) SetTimestamp(u uint64) { - m.timestamp = &u - m.addtimestamp = nil -} - -// Timestamp returns the value of the "timestamp" field in the mutation. -func (m *CorrectnessReportMutation) Timestamp() (r uint64, exists bool) { - v := m.timestamp - if v == nil { - return - } - return *v, true -} - -// OldTimestamp returns the old "timestamp" field's value of the CorrectnessReport entity. -// If the CorrectnessReport 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 *CorrectnessReportMutation) OldTimestamp(ctx context.Context) (v uint64, 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 u to the "timestamp" field. -func (m *CorrectnessReportMutation) AddTimestamp(u int64) { - if m.addtimestamp != nil { - *m.addtimestamp += u - } else { - m.addtimestamp = &u - } -} - -// AddedTimestamp returns the value that was added to the "timestamp" field in this mutation. -func (m *CorrectnessReportMutation) AddedTimestamp() (r int64, exists bool) { - v := m.addtimestamp - if v == nil { - return - } - return *v, true -} - -// ResetTimestamp resets all changes to the "timestamp" field. -func (m *CorrectnessReportMutation) ResetTimestamp() { - m.timestamp = nil - m.addtimestamp = nil -} - -// SetSignature sets the "signature" field. -func (m *CorrectnessReportMutation) SetSignature(b []byte) { - m.signature = &b -} - -// Signature returns the value of the "signature" field in the mutation. -func (m *CorrectnessReportMutation) Signature() (r []byte, exists bool) { - v := m.signature - if v == nil { - return - } - return *v, true -} - -// OldSignature returns the old "signature" field's value of the CorrectnessReport entity. -// If the CorrectnessReport 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 *CorrectnessReportMutation) OldSignature(ctx context.Context) (v []byte, 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 *CorrectnessReportMutation) ResetSignature() { - m.signature = nil -} - -// SetHash sets the "hash" field. -func (m *CorrectnessReportMutation) SetHash(b []byte) { - m.hash = &b -} - -// Hash returns the value of the "hash" field in the mutation. -func (m *CorrectnessReportMutation) Hash() (r []byte, exists bool) { - v := m.hash - if v == nil { - return - } - return *v, true -} - -// OldHash returns the old "hash" field's value of the CorrectnessReport entity. -// If the CorrectnessReport 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 *CorrectnessReportMutation) OldHash(ctx context.Context) (v []byte, 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 *CorrectnessReportMutation) ResetHash() { - m.hash = nil -} - -// SetTopic sets the "topic" field. -func (m *CorrectnessReportMutation) SetTopic(b []byte) { - m.topic = &b -} - -// Topic returns the value of the "topic" field in the mutation. -func (m *CorrectnessReportMutation) Topic() (r []byte, exists bool) { - v := m.topic - if v == nil { - return - } - return *v, true -} - -// OldTopic returns the old "topic" field's value of the CorrectnessReport entity. -// If the CorrectnessReport 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 *CorrectnessReportMutation) OldTopic(ctx context.Context) (v []byte, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTopic is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTopic requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTopic: %w", err) - } - return oldValue.Topic, nil -} - -// ResetTopic resets all changes to the "topic" field. -func (m *CorrectnessReportMutation) ResetTopic() { - m.topic = nil -} - -// SetCorrect sets the "correct" field. -func (m *CorrectnessReportMutation) SetCorrect(b bool) { - m.correct = &b -} - -// Correct returns the value of the "correct" field in the mutation. -func (m *CorrectnessReportMutation) Correct() (r bool, exists bool) { - v := m.correct - if v == nil { - return - } - return *v, true -} - -// OldCorrect returns the old "correct" field's value of the CorrectnessReport entity. -// If the CorrectnessReport 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 *CorrectnessReportMutation) OldCorrect(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCorrect is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCorrect requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCorrect: %w", err) - } - return oldValue.Correct, nil -} - -// ResetCorrect resets all changes to the "correct" field. -func (m *CorrectnessReportMutation) ResetCorrect() { - m.correct = nil -} - -// SetConsensus sets the "consensus" field. -func (m *CorrectnessReportMutation) SetConsensus(b bool) { - m.consensus = &b -} - -// Consensus returns the value of the "consensus" field in the mutation. -func (m *CorrectnessReportMutation) Consensus() (r bool, exists bool) { - v := m.consensus - if v == nil { - return - } - return *v, true -} - -// OldConsensus returns the old "consensus" field's value of the CorrectnessReport entity. -// If the CorrectnessReport 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 *CorrectnessReportMutation) OldConsensus(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldConsensus is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldConsensus requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldConsensus: %w", err) - } - return oldValue.Consensus, nil -} - -// ResetConsensus resets all changes to the "consensus" field. -func (m *CorrectnessReportMutation) ResetConsensus() { - m.consensus = nil -} - -// SetVoted sets the "voted" field. -func (m *CorrectnessReportMutation) SetVoted(hi *helpers.BigInt) { - m.voted = &hi -} - -// Voted returns the value of the "voted" field in the mutation. -func (m *CorrectnessReportMutation) Voted() (r *helpers.BigInt, exists bool) { - v := m.voted - if v == nil { - return - } - return *v, true -} - -// OldVoted returns the old "voted" field's value of the CorrectnessReport entity. -// If the CorrectnessReport 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 *CorrectnessReportMutation) OldVoted(ctx context.Context) (v *helpers.BigInt, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVoted is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVoted requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldVoted: %w", err) - } - return oldValue.Voted, nil -} - -// ResetVoted resets all changes to the "voted" field. -func (m *CorrectnessReportMutation) ResetVoted() { - m.voted = nil -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by ids. -func (m *CorrectnessReportMutation) AddSignerIDs(ids ...int) { - if m.signers == nil { - m.signers = make(map[int]struct{}) - } - for i := range ids { - m.signers[ids[i]] = struct{}{} - } -} - -// ClearSigners clears the "signers" edge to the Signer entity. -func (m *CorrectnessReportMutation) ClearSigners() { - m.clearedsigners = true -} - -// SignersCleared reports if the "signers" edge to the Signer entity was cleared. -func (m *CorrectnessReportMutation) SignersCleared() bool { - return m.clearedsigners -} - -// RemoveSignerIDs removes the "signers" edge to the Signer entity by IDs. -func (m *CorrectnessReportMutation) RemoveSignerIDs(ids ...int) { - if m.removedsigners == nil { - m.removedsigners = make(map[int]struct{}) - } - for i := range ids { - delete(m.signers, ids[i]) - m.removedsigners[ids[i]] = struct{}{} - } -} - -// RemovedSigners returns the removed IDs of the "signers" edge to the Signer entity. -func (m *CorrectnessReportMutation) RemovedSignersIDs() (ids []int) { - for id := range m.removedsigners { - ids = append(ids, id) - } - return -} - -// SignersIDs returns the "signers" edge IDs in the mutation. -func (m *CorrectnessReportMutation) SignersIDs() (ids []int) { - for id := range m.signers { - ids = append(ids, id) - } - return -} - -// ResetSigners resets all changes to the "signers" edge. -func (m *CorrectnessReportMutation) ResetSigners() { - m.signers = nil - m.clearedsigners = false - m.removedsigners = nil -} - -// Where appends a list predicates to the CorrectnessReportMutation builder. -func (m *CorrectnessReportMutation) Where(ps ...predicate.CorrectnessReport) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the CorrectnessReportMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *CorrectnessReportMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.CorrectnessReport, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *CorrectnessReportMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *CorrectnessReportMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (CorrectnessReport). -func (m *CorrectnessReportMutation) 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 *CorrectnessReportMutation) Fields() []string { - fields := make([]string, 0, 8) - if m.signersCount != nil { - fields = append(fields, correctnessreport.FieldSignersCount) - } - if m.timestamp != nil { - fields = append(fields, correctnessreport.FieldTimestamp) - } - if m.signature != nil { - fields = append(fields, correctnessreport.FieldSignature) - } - if m.hash != nil { - fields = append(fields, correctnessreport.FieldHash) - } - if m.topic != nil { - fields = append(fields, correctnessreport.FieldTopic) - } - if m.correct != nil { - fields = append(fields, correctnessreport.FieldCorrect) - } - if m.consensus != nil { - fields = append(fields, correctnessreport.FieldConsensus) - } - if m.voted != nil { - fields = append(fields, correctnessreport.FieldVoted) - } - 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 *CorrectnessReportMutation) Field(name string) (ent.Value, bool) { - switch name { - case correctnessreport.FieldSignersCount: - return m.SignersCount() - case correctnessreport.FieldTimestamp: - return m.Timestamp() - case correctnessreport.FieldSignature: - return m.Signature() - case correctnessreport.FieldHash: - return m.Hash() - case correctnessreport.FieldTopic: - return m.Topic() - case correctnessreport.FieldCorrect: - return m.Correct() - case correctnessreport.FieldConsensus: - return m.Consensus() - case correctnessreport.FieldVoted: - return m.Voted() - } - 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 *CorrectnessReportMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case correctnessreport.FieldSignersCount: - return m.OldSignersCount(ctx) - case correctnessreport.FieldTimestamp: - return m.OldTimestamp(ctx) - case correctnessreport.FieldSignature: - return m.OldSignature(ctx) - case correctnessreport.FieldHash: - return m.OldHash(ctx) - case correctnessreport.FieldTopic: - return m.OldTopic(ctx) - case correctnessreport.FieldCorrect: - return m.OldCorrect(ctx) - case correctnessreport.FieldConsensus: - return m.OldConsensus(ctx) - case correctnessreport.FieldVoted: - return m.OldVoted(ctx) - } - return nil, fmt.Errorf("unknown CorrectnessReport 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 *CorrectnessReportMutation) SetField(name string, value ent.Value) error { - switch name { - case correctnessreport.FieldSignersCount: - v, ok := value.(uint64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSignersCount(v) - return nil - case correctnessreport.FieldTimestamp: - v, ok := value.(uint64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTimestamp(v) - return nil - case correctnessreport.FieldSignature: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSignature(v) - return nil - case correctnessreport.FieldHash: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetHash(v) - return nil - case correctnessreport.FieldTopic: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTopic(v) - return nil - case correctnessreport.FieldCorrect: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCorrect(v) - return nil - case correctnessreport.FieldConsensus: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetConsensus(v) - return nil - case correctnessreport.FieldVoted: - v, ok := value.(*helpers.BigInt) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetVoted(v) - return nil - } - return fmt.Errorf("unknown CorrectnessReport field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *CorrectnessReportMutation) AddedFields() []string { - var fields []string - if m.addsignersCount != nil { - fields = append(fields, correctnessreport.FieldSignersCount) - } - if m.addtimestamp != nil { - fields = append(fields, correctnessreport.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 *CorrectnessReportMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case correctnessreport.FieldSignersCount: - return m.AddedSignersCount() - case correctnessreport.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 *CorrectnessReportMutation) AddField(name string, value ent.Value) error { - switch name { - case correctnessreport.FieldSignersCount: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddSignersCount(v) - return nil - case correctnessreport.FieldTimestamp: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddTimestamp(v) - return nil - } - return fmt.Errorf("unknown CorrectnessReport numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *CorrectnessReportMutation) ClearedFields() []string { - return nil -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *CorrectnessReportMutation) 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 *CorrectnessReportMutation) ClearField(name string) error { - return fmt.Errorf("unknown CorrectnessReport 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 *CorrectnessReportMutation) ResetField(name string) error { - switch name { - case correctnessreport.FieldSignersCount: - m.ResetSignersCount() - return nil - case correctnessreport.FieldTimestamp: - m.ResetTimestamp() - return nil - case correctnessreport.FieldSignature: - m.ResetSignature() - return nil - case correctnessreport.FieldHash: - m.ResetHash() - return nil - case correctnessreport.FieldTopic: - m.ResetTopic() - return nil - case correctnessreport.FieldCorrect: - m.ResetCorrect() - return nil - case correctnessreport.FieldConsensus: - m.ResetConsensus() - return nil - case correctnessreport.FieldVoted: - m.ResetVoted() - return nil - } - return fmt.Errorf("unknown CorrectnessReport field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *CorrectnessReportMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.signers != nil { - edges = append(edges, correctnessreport.EdgeSigners) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *CorrectnessReportMutation) AddedIDs(name string) []ent.Value { - switch name { - case correctnessreport.EdgeSigners: - ids := make([]ent.Value, 0, len(m.signers)) - for id := range m.signers { - ids = append(ids, id) - } - return ids - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *CorrectnessReportMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) - if m.removedsigners != nil { - edges = append(edges, correctnessreport.EdgeSigners) - } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *CorrectnessReportMutation) RemovedIDs(name string) []ent.Value { - switch name { - case correctnessreport.EdgeSigners: - ids := make([]ent.Value, 0, len(m.removedsigners)) - for id := range m.removedsigners { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *CorrectnessReportMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.clearedsigners { - edges = append(edges, correctnessreport.EdgeSigners) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *CorrectnessReportMutation) EdgeCleared(name string) bool { - switch name { - case correctnessreport.EdgeSigners: - return m.clearedsigners - } - 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 *CorrectnessReportMutation) ClearEdge(name string) error { - switch name { - } - return fmt.Errorf("unknown CorrectnessReport 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 *CorrectnessReportMutation) ResetEdge(name string) error { - switch name { - case correctnessreport.EdgeSigners: - m.ResetSigners() - return nil - } - return fmt.Errorf("unknown CorrectnessReport edge %s", name) -} - -// EventLogMutation represents an operation that mutates the EventLog nodes in the graph. -type EventLogMutation struct { - config - op Op - typ string - id *int - block *uint64 - addblock *int64 - signersCount *uint64 - addsignersCount *int64 - signature *[]byte - address *string - chain *string - index *uint64 - addindex *int64 - event *string - transaction *[]byte - args *[]model.EventLogArg - appendargs []model.EventLogArg - consensus *bool - voted **helpers.BigInt - clearedFields map[string]struct{} - signers map[int]struct{} - removedsigners map[int]struct{} - clearedsigners bool - done bool - oldValue func(context.Context) (*EventLog, error) - predicates []predicate.EventLog -} - -var _ ent.Mutation = (*EventLogMutation)(nil) - -// eventlogOption allows management of the mutation configuration using functional options. -type eventlogOption func(*EventLogMutation) - -// newEventLogMutation creates new mutation for the EventLog entity. -func newEventLogMutation(c config, op Op, opts ...eventlogOption) *EventLogMutation { - m := &EventLogMutation{ - config: c, - op: op, - typ: TypeEventLog, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withEventLogID sets the ID field of the mutation. -func withEventLogID(id int) eventlogOption { - return func(m *EventLogMutation) { - var ( - err error - once sync.Once - value *EventLog - ) - m.oldValue = func(ctx context.Context) (*EventLog, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().EventLog.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withEventLog sets the old EventLog of the mutation. -func withEventLog(node *EventLog) eventlogOption { - return func(m *EventLogMutation) { - m.oldValue = func(context.Context) (*EventLog, 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 EventLogMutation) 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 EventLogMutation) 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 *EventLogMutation) 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 *EventLogMutation) 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().EventLog.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetBlock sets the "block" field. -func (m *EventLogMutation) SetBlock(u uint64) { - m.block = &u - m.addblock = nil -} - -// Block returns the value of the "block" field in the mutation. -func (m *EventLogMutation) Block() (r uint64, exists bool) { - v := m.block - if v == nil { - return - } - return *v, true -} - -// OldBlock returns the old "block" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldBlock(ctx context.Context) (v uint64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBlock is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBlock requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldBlock: %w", err) - } - return oldValue.Block, nil -} - -// AddBlock adds u to the "block" field. -func (m *EventLogMutation) AddBlock(u int64) { - if m.addblock != nil { - *m.addblock += u - } else { - m.addblock = &u - } -} - -// AddedBlock returns the value that was added to the "block" field in this mutation. -func (m *EventLogMutation) AddedBlock() (r int64, exists bool) { - v := m.addblock - if v == nil { - return - } - return *v, true -} - -// ResetBlock resets all changes to the "block" field. -func (m *EventLogMutation) ResetBlock() { - m.block = nil - m.addblock = nil -} - -// SetSignersCount sets the "signersCount" field. -func (m *EventLogMutation) SetSignersCount(u uint64) { - m.signersCount = &u - m.addsignersCount = nil -} - -// SignersCount returns the value of the "signersCount" field in the mutation. -func (m *EventLogMutation) SignersCount() (r uint64, exists bool) { - v := m.signersCount - if v == nil { - return - } - return *v, true -} - -// OldSignersCount returns the old "signersCount" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldSignersCount(ctx context.Context) (v uint64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSignersCount is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSignersCount requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSignersCount: %w", err) - } - return oldValue.SignersCount, nil -} - -// AddSignersCount adds u to the "signersCount" field. -func (m *EventLogMutation) AddSignersCount(u int64) { - if m.addsignersCount != nil { - *m.addsignersCount += u - } else { - m.addsignersCount = &u - } -} - -// AddedSignersCount returns the value that was added to the "signersCount" field in this mutation. -func (m *EventLogMutation) AddedSignersCount() (r int64, exists bool) { - v := m.addsignersCount - if v == nil { - return - } - return *v, true -} - -// ResetSignersCount resets all changes to the "signersCount" field. -func (m *EventLogMutation) ResetSignersCount() { - m.signersCount = nil - m.addsignersCount = nil -} - -// SetSignature sets the "signature" field. -func (m *EventLogMutation) SetSignature(b []byte) { - m.signature = &b -} - -// Signature returns the value of the "signature" field in the mutation. -func (m *EventLogMutation) Signature() (r []byte, exists bool) { - v := m.signature - if v == nil { - return - } - return *v, true -} - -// OldSignature returns the old "signature" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldSignature(ctx context.Context) (v []byte, 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 *EventLogMutation) ResetSignature() { - m.signature = nil -} - -// SetAddress sets the "address" field. -func (m *EventLogMutation) SetAddress(s string) { - m.address = &s -} - -// Address returns the value of the "address" field in the mutation. -func (m *EventLogMutation) Address() (r string, exists bool) { - v := m.address - if v == nil { - return - } - return *v, true -} - -// OldAddress returns the old "address" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldAddress(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAddress is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAddress requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldAddress: %w", err) - } - return oldValue.Address, nil -} - -// ResetAddress resets all changes to the "address" field. -func (m *EventLogMutation) ResetAddress() { - m.address = nil -} - -// SetChain sets the "chain" field. -func (m *EventLogMutation) SetChain(s string) { - m.chain = &s -} - -// Chain returns the value of the "chain" field in the mutation. -func (m *EventLogMutation) Chain() (r string, exists bool) { - v := m.chain - if v == nil { - return - } - return *v, true -} - -// OldChain returns the old "chain" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldChain(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldChain is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldChain requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldChain: %w", err) - } - return oldValue.Chain, nil -} - -// ResetChain resets all changes to the "chain" field. -func (m *EventLogMutation) ResetChain() { - m.chain = nil -} - -// SetIndex sets the "index" field. -func (m *EventLogMutation) SetIndex(u uint64) { - m.index = &u - m.addindex = nil -} - -// Index returns the value of the "index" field in the mutation. -func (m *EventLogMutation) Index() (r uint64, exists bool) { - v := m.index - if v == nil { - return - } - return *v, true -} - -// OldIndex returns the old "index" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldIndex(ctx context.Context) (v uint64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIndex is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIndex requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldIndex: %w", err) - } - return oldValue.Index, nil -} - -// AddIndex adds u to the "index" field. -func (m *EventLogMutation) AddIndex(u int64) { - if m.addindex != nil { - *m.addindex += u - } else { - m.addindex = &u - } -} - -// AddedIndex returns the value that was added to the "index" field in this mutation. -func (m *EventLogMutation) AddedIndex() (r int64, exists bool) { - v := m.addindex - if v == nil { - return - } - return *v, true -} - -// ResetIndex resets all changes to the "index" field. -func (m *EventLogMutation) ResetIndex() { - m.index = nil - m.addindex = nil -} - -// SetEvent sets the "event" field. -func (m *EventLogMutation) SetEvent(s string) { - m.event = &s -} - -// Event returns the value of the "event" field in the mutation. -func (m *EventLogMutation) Event() (r string, exists bool) { - v := m.event - if v == nil { - return - } - return *v, true -} - -// OldEvent returns the old "event" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldEvent(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEvent is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEvent requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldEvent: %w", err) - } - return oldValue.Event, nil -} - -// ResetEvent resets all changes to the "event" field. -func (m *EventLogMutation) ResetEvent() { - m.event = nil -} - -// SetTransaction sets the "transaction" field. -func (m *EventLogMutation) SetTransaction(b []byte) { - m.transaction = &b -} - -// Transaction returns the value of the "transaction" field in the mutation. -func (m *EventLogMutation) Transaction() (r []byte, exists bool) { - v := m.transaction - if v == nil { - return - } - return *v, true -} - -// OldTransaction returns the old "transaction" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldTransaction(ctx context.Context) (v []byte, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTransaction is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTransaction requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTransaction: %w", err) - } - return oldValue.Transaction, nil -} - -// ResetTransaction resets all changes to the "transaction" field. -func (m *EventLogMutation) ResetTransaction() { - m.transaction = nil -} - -// SetArgs sets the "args" field. -func (m *EventLogMutation) SetArgs(dla []model.EventLogArg) { - m.args = &dla - m.appendargs = nil -} - -// Args returns the value of the "args" field in the mutation. -func (m *EventLogMutation) Args() (r []model.EventLogArg, exists bool) { - v := m.args - if v == nil { - return - } - return *v, true -} - -// OldArgs returns the old "args" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldArgs(ctx context.Context) (v []model.EventLogArg, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldArgs is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldArgs requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldArgs: %w", err) - } - return oldValue.Args, nil -} - -// AppendArgs adds dla to the "args" field. -func (m *EventLogMutation) AppendArgs(dla []model.EventLogArg) { - m.appendargs = append(m.appendargs, dla...) -} - -// AppendedArgs returns the list of values that were appended to the "args" field in this mutation. -func (m *EventLogMutation) AppendedArgs() ([]model.EventLogArg, bool) { - if len(m.appendargs) == 0 { - return nil, false - } - return m.appendargs, true -} - -// ResetArgs resets all changes to the "args" field. -func (m *EventLogMutation) ResetArgs() { - m.args = nil - m.appendargs = nil -} - -// SetConsensus sets the "consensus" field. -func (m *EventLogMutation) SetConsensus(b bool) { - m.consensus = &b -} - -// Consensus returns the value of the "consensus" field in the mutation. -func (m *EventLogMutation) Consensus() (r bool, exists bool) { - v := m.consensus - if v == nil { - return - } - return *v, true -} - -// OldConsensus returns the old "consensus" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldConsensus(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldConsensus is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldConsensus requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldConsensus: %w", err) - } - return oldValue.Consensus, nil -} - -// ResetConsensus resets all changes to the "consensus" field. -func (m *EventLogMutation) ResetConsensus() { - m.consensus = nil -} - -// SetVoted sets the "voted" field. -func (m *EventLogMutation) SetVoted(hi *helpers.BigInt) { - m.voted = &hi -} - -// Voted returns the value of the "voted" field in the mutation. -func (m *EventLogMutation) Voted() (r *helpers.BigInt, exists bool) { - v := m.voted - if v == nil { - return - } - return *v, true -} - -// OldVoted returns the old "voted" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldVoted(ctx context.Context) (v *helpers.BigInt, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVoted is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVoted requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldVoted: %w", err) - } - return oldValue.Voted, nil -} - -// ResetVoted resets all changes to the "voted" field. -func (m *EventLogMutation) ResetVoted() { - m.voted = nil -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by ids. -func (m *EventLogMutation) AddSignerIDs(ids ...int) { - if m.signers == nil { - m.signers = make(map[int]struct{}) - } - for i := range ids { - m.signers[ids[i]] = struct{}{} - } -} - -// ClearSigners clears the "signers" edge to the Signer entity. -func (m *EventLogMutation) ClearSigners() { - m.clearedsigners = true -} - -// SignersCleared reports if the "signers" edge to the Signer entity was cleared. -func (m *EventLogMutation) SignersCleared() bool { - return m.clearedsigners -} - -// RemoveSignerIDs removes the "signers" edge to the Signer entity by IDs. -func (m *EventLogMutation) RemoveSignerIDs(ids ...int) { - if m.removedsigners == nil { - m.removedsigners = make(map[int]struct{}) - } - for i := range ids { - delete(m.signers, ids[i]) - m.removedsigners[ids[i]] = struct{}{} - } -} - -// RemovedSigners returns the removed IDs of the "signers" edge to the Signer entity. -func (m *EventLogMutation) RemovedSignersIDs() (ids []int) { - for id := range m.removedsigners { - ids = append(ids, id) - } - return -} - -// SignersIDs returns the "signers" edge IDs in the mutation. -func (m *EventLogMutation) SignersIDs() (ids []int) { - for id := range m.signers { - ids = append(ids, id) - } - return -} - -// ResetSigners resets all changes to the "signers" edge. -func (m *EventLogMutation) ResetSigners() { - m.signers = nil - m.clearedsigners = false - m.removedsigners = nil -} - -// Where appends a list predicates to the EventLogMutation builder. -func (m *EventLogMutation) Where(ps ...predicate.EventLog) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the EventLogMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *EventLogMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.EventLog, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *EventLogMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *EventLogMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (EventLog). -func (m *EventLogMutation) 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 *EventLogMutation) Fields() []string { - fields := make([]string, 0, 11) - if m.block != nil { - fields = append(fields, eventlog.FieldBlock) - } - if m.signersCount != nil { - fields = append(fields, eventlog.FieldSignersCount) - } - if m.signature != nil { - fields = append(fields, eventlog.FieldSignature) - } - if m.address != nil { - fields = append(fields, eventlog.FieldAddress) - } - if m.chain != nil { - fields = append(fields, eventlog.FieldChain) - } - if m.index != nil { - fields = append(fields, eventlog.FieldIndex) - } - if m.event != nil { - fields = append(fields, eventlog.FieldEvent) - } - if m.transaction != nil { - fields = append(fields, eventlog.FieldTransaction) - } - if m.args != nil { - fields = append(fields, eventlog.FieldArgs) - } - if m.consensus != nil { - fields = append(fields, eventlog.FieldConsensus) - } - if m.voted != nil { - fields = append(fields, eventlog.FieldVoted) - } - 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 *EventLogMutation) Field(name string) (ent.Value, bool) { - switch name { - case eventlog.FieldBlock: - return m.Block() - case eventlog.FieldSignersCount: - return m.SignersCount() - case eventlog.FieldSignature: - return m.Signature() - case eventlog.FieldAddress: - return m.Address() - case eventlog.FieldChain: - return m.Chain() - case eventlog.FieldIndex: - return m.Index() - case eventlog.FieldEvent: - return m.Event() - case eventlog.FieldTransaction: - return m.Transaction() - case eventlog.FieldArgs: - return m.Args() - case eventlog.FieldConsensus: - return m.Consensus() - case eventlog.FieldVoted: - return m.Voted() - } - 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 *EventLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case eventlog.FieldBlock: - return m.OldBlock(ctx) - case eventlog.FieldSignersCount: - return m.OldSignersCount(ctx) - case eventlog.FieldSignature: - return m.OldSignature(ctx) - case eventlog.FieldAddress: - return m.OldAddress(ctx) - case eventlog.FieldChain: - return m.OldChain(ctx) - case eventlog.FieldIndex: - return m.OldIndex(ctx) - case eventlog.FieldEvent: - return m.OldEvent(ctx) - case eventlog.FieldTransaction: - return m.OldTransaction(ctx) - case eventlog.FieldArgs: - return m.OldArgs(ctx) - case eventlog.FieldConsensus: - return m.OldConsensus(ctx) - case eventlog.FieldVoted: - return m.OldVoted(ctx) - } - return nil, fmt.Errorf("unknown EventLog 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 *EventLogMutation) SetField(name string, value ent.Value) error { - switch name { - case eventlog.FieldBlock: - v, ok := value.(uint64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetBlock(v) - return nil - case eventlog.FieldSignersCount: - v, ok := value.(uint64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSignersCount(v) - return nil - case eventlog.FieldSignature: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSignature(v) - return nil - case eventlog.FieldAddress: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAddress(v) - return nil - case eventlog.FieldChain: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetChain(v) - return nil - case eventlog.FieldIndex: - v, ok := value.(uint64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetIndex(v) - return nil - case eventlog.FieldEvent: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetEvent(v) - return nil - case eventlog.FieldTransaction: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTransaction(v) - return nil - case eventlog.FieldArgs: - v, ok := value.([]model.EventLogArg) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetArgs(v) - return nil - case eventlog.FieldConsensus: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetConsensus(v) - return nil - case eventlog.FieldVoted: - v, ok := value.(*helpers.BigInt) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetVoted(v) - return nil - } - return fmt.Errorf("unknown EventLog field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *EventLogMutation) AddedFields() []string { - var fields []string - if m.addblock != nil { - fields = append(fields, eventlog.FieldBlock) - } - if m.addsignersCount != nil { - fields = append(fields, eventlog.FieldSignersCount) - } - if m.addindex != nil { - fields = append(fields, eventlog.FieldIndex) - } - 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 *EventLogMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case eventlog.FieldBlock: - return m.AddedBlock() - case eventlog.FieldSignersCount: - return m.AddedSignersCount() - case eventlog.FieldIndex: - return m.AddedIndex() - } - 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 *EventLogMutation) AddField(name string, value ent.Value) error { - switch name { - case eventlog.FieldBlock: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddBlock(v) - return nil - case eventlog.FieldSignersCount: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddSignersCount(v) - return nil - case eventlog.FieldIndex: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddIndex(v) - return nil - } - return fmt.Errorf("unknown EventLog numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *EventLogMutation) ClearedFields() []string { - return nil -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *EventLogMutation) 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 *EventLogMutation) ClearField(name string) error { - return fmt.Errorf("unknown EventLog 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 *EventLogMutation) ResetField(name string) error { - switch name { - case eventlog.FieldBlock: - m.ResetBlock() - return nil - case eventlog.FieldSignersCount: - m.ResetSignersCount() - return nil - case eventlog.FieldSignature: - m.ResetSignature() - return nil - case eventlog.FieldAddress: - m.ResetAddress() - return nil - case eventlog.FieldChain: - m.ResetChain() - return nil - case eventlog.FieldIndex: - m.ResetIndex() - return nil - case eventlog.FieldEvent: - m.ResetEvent() - return nil - case eventlog.FieldTransaction: - m.ResetTransaction() - return nil - case eventlog.FieldArgs: - m.ResetArgs() - return nil - case eventlog.FieldConsensus: - m.ResetConsensus() - return nil - case eventlog.FieldVoted: - m.ResetVoted() - return nil - } - return fmt.Errorf("unknown EventLog field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *EventLogMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.signers != nil { - edges = append(edges, eventlog.EdgeSigners) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *EventLogMutation) AddedIDs(name string) []ent.Value { - switch name { - case eventlog.EdgeSigners: - ids := make([]ent.Value, 0, len(m.signers)) - for id := range m.signers { - ids = append(ids, id) - } - return ids - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *EventLogMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) - if m.removedsigners != nil { - edges = append(edges, eventlog.EdgeSigners) - } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *EventLogMutation) RemovedIDs(name string) []ent.Value { - switch name { - case eventlog.EdgeSigners: - ids := make([]ent.Value, 0, len(m.removedsigners)) - for id := range m.removedsigners { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *EventLogMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.clearedsigners { - edges = append(edges, eventlog.EdgeSigners) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *EventLogMutation) EdgeCleared(name string) bool { - switch name { - case eventlog.EdgeSigners: - return m.clearedsigners - } - 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 *EventLogMutation) ClearEdge(name string) error { - switch name { - } - return fmt.Errorf("unknown EventLog 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 *EventLogMutation) ResetEdge(name string) error { - switch name { - case eventlog.EdgeSigners: - m.ResetSigners() - return nil - } - return fmt.Errorf("unknown EventLog edge %s", name) -} - -// SignerMutation represents an operation that mutates the Signer nodes in the graph. -type SignerMutation struct { - config - op Op - typ string - id *int - name *string - evm *string - key *[]byte - shortkey *[]byte - points *int64 - addpoints *int64 - clearedFields map[string]struct{} - assetPrice map[int]struct{} - removedassetPrice map[int]struct{} - clearedassetPrice bool - eventLogs map[int]struct{} - removedeventLogs map[int]struct{} - clearedeventLogs bool - correctnessReport map[int]struct{} - removedcorrectnessReport map[int]struct{} - clearedcorrectnessReport bool - done bool - oldValue func(context.Context) (*Signer, error) - predicates []predicate.Signer -} - -var _ ent.Mutation = (*SignerMutation)(nil) - -// signerOption allows management of the mutation configuration using functional options. -type signerOption func(*SignerMutation) - -// newSignerMutation creates new mutation for the Signer entity. -func newSignerMutation(c config, op Op, opts ...signerOption) *SignerMutation { - m := &SignerMutation{ - config: c, - op: op, - typ: TypeSigner, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withSignerID sets the ID field of the mutation. -func withSignerID(id int) signerOption { - return func(m *SignerMutation) { - var ( - err error - once sync.Once - value *Signer - ) - m.oldValue = func(ctx context.Context) (*Signer, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().Signer.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withSigner sets the old Signer of the mutation. -func withSigner(node *Signer) signerOption { - return func(m *SignerMutation) { - m.oldValue = func(context.Context) (*Signer, 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 SignerMutation) 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 SignerMutation) 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 *SignerMutation) 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 *SignerMutation) 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().Signer.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetName sets the "name" field. -func (m *SignerMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *SignerMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return - } - return *v, true -} - -// OldName returns the old "name" field's value of the Signer entity. -// If the Signer 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 *SignerMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *SignerMutation) ResetName() { - m.name = nil -} - -// SetEvm sets the "evm" field. -func (m *SignerMutation) SetEvm(s string) { - m.evm = &s -} - -// Evm returns the value of the "evm" field in the mutation. -func (m *SignerMutation) Evm() (r string, exists bool) { - v := m.evm - if v == nil { - return - } - return *v, true -} - -// OldEvm returns the old "evm" field's value of the Signer entity. -// If the Signer 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 *SignerMutation) OldEvm(ctx context.Context) (v *string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEvm is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEvm requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldEvm: %w", err) - } - return oldValue.Evm, nil -} - -// ClearEvm clears the value of the "evm" field. -func (m *SignerMutation) ClearEvm() { - m.evm = nil - m.clearedFields[signer.FieldEvm] = struct{}{} -} - -// EvmCleared returns if the "evm" field was cleared in this mutation. -func (m *SignerMutation) EvmCleared() bool { - _, ok := m.clearedFields[signer.FieldEvm] - return ok -} - -// ResetEvm resets all changes to the "evm" field. -func (m *SignerMutation) ResetEvm() { - m.evm = nil - delete(m.clearedFields, signer.FieldEvm) -} - -// SetKey sets the "key" field. -func (m *SignerMutation) SetKey(b []byte) { - m.key = &b -} - -// Key returns the value of the "key" field in the mutation. -func (m *SignerMutation) Key() (r []byte, exists bool) { - v := m.key - if v == nil { - return - } - return *v, true -} - -// OldKey returns the old "key" field's value of the Signer entity. -// If the Signer 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 *SignerMutation) OldKey(ctx context.Context) (v []byte, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldKey is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldKey requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldKey: %w", err) - } - return oldValue.Key, nil -} - -// ResetKey resets all changes to the "key" field. -func (m *SignerMutation) ResetKey() { - m.key = nil -} - -// SetShortkey sets the "shortkey" field. -func (m *SignerMutation) SetShortkey(b []byte) { - m.shortkey = &b -} - -// Shortkey returns the value of the "shortkey" field in the mutation. -func (m *SignerMutation) Shortkey() (r []byte, exists bool) { - v := m.shortkey - if v == nil { - return - } - return *v, true -} - -// OldShortkey returns the old "shortkey" field's value of the Signer entity. -// If the Signer 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 *SignerMutation) OldShortkey(ctx context.Context) (v []byte, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldShortkey is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldShortkey requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldShortkey: %w", err) - } - return oldValue.Shortkey, nil -} - -// ResetShortkey resets all changes to the "shortkey" field. -func (m *SignerMutation) ResetShortkey() { - m.shortkey = nil -} - -// SetPoints sets the "points" field. -func (m *SignerMutation) SetPoints(i int64) { - m.points = &i - m.addpoints = nil -} - -// Points returns the value of the "points" field in the mutation. -func (m *SignerMutation) Points() (r int64, exists bool) { - v := m.points - if v == nil { - return - } - return *v, true -} - -// OldPoints returns the old "points" field's value of the Signer entity. -// If the Signer 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 *SignerMutation) OldPoints(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPoints is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPoints requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPoints: %w", err) - } - return oldValue.Points, nil -} - -// AddPoints adds i to the "points" field. -func (m *SignerMutation) AddPoints(i int64) { - if m.addpoints != nil { - *m.addpoints += i - } else { - m.addpoints = &i - } -} - -// AddedPoints returns the value that was added to the "points" field in this mutation. -func (m *SignerMutation) AddedPoints() (r int64, exists bool) { - v := m.addpoints - if v == nil { - return - } - return *v, true -} - -// ResetPoints resets all changes to the "points" field. -func (m *SignerMutation) ResetPoints() { - m.points = nil - m.addpoints = nil -} - -// AddAssetPriceIDs adds the "assetPrice" edge to the AssetPrice entity by ids. -func (m *SignerMutation) AddAssetPriceIDs(ids ...int) { - if m.assetPrice == nil { - m.assetPrice = make(map[int]struct{}) - } - for i := range ids { - m.assetPrice[ids[i]] = struct{}{} - } -} - -// ClearAssetPrice clears the "assetPrice" edge to the AssetPrice entity. -func (m *SignerMutation) ClearAssetPrice() { - m.clearedassetPrice = true -} - -// AssetPriceCleared reports if the "assetPrice" edge to the AssetPrice entity was cleared. -func (m *SignerMutation) AssetPriceCleared() bool { - return m.clearedassetPrice -} - -// RemoveAssetPriceIDs removes the "assetPrice" edge to the AssetPrice entity by IDs. -func (m *SignerMutation) RemoveAssetPriceIDs(ids ...int) { - if m.removedassetPrice == nil { - m.removedassetPrice = make(map[int]struct{}) - } - for i := range ids { - delete(m.assetPrice, ids[i]) - m.removedassetPrice[ids[i]] = struct{}{} - } -} - -// RemovedAssetPrice returns the removed IDs of the "assetPrice" edge to the AssetPrice entity. -func (m *SignerMutation) RemovedAssetPriceIDs() (ids []int) { - for id := range m.removedassetPrice { - ids = append(ids, id) - } - return -} - -// AssetPriceIDs returns the "assetPrice" edge IDs in the mutation. -func (m *SignerMutation) AssetPriceIDs() (ids []int) { - for id := range m.assetPrice { - ids = append(ids, id) - } - return -} - -// ResetAssetPrice resets all changes to the "assetPrice" edge. -func (m *SignerMutation) ResetAssetPrice() { - m.assetPrice = nil - m.clearedassetPrice = false - m.removedassetPrice = nil -} - -// AddEventLogIDs adds the "eventLogs" edge to the EventLog entity by ids. -func (m *SignerMutation) AddEventLogIDs(ids ...int) { - if m.eventLogs == nil { - m.eventLogs = make(map[int]struct{}) - } - for i := range ids { - m.eventLogs[ids[i]] = struct{}{} - } -} - -// ClearEventLogs clears the "eventLogs" edge to the EventLog entity. -func (m *SignerMutation) ClearEventLogs() { - m.clearedeventLogs = true -} - -// EventLogsCleared reports if the "eventLogs" edge to the EventLog entity was cleared. -func (m *SignerMutation) EventLogsCleared() bool { - return m.clearedeventLogs -} - -// RemoveEventLogIDs removes the "eventLogs" edge to the EventLog entity by IDs. -func (m *SignerMutation) RemoveEventLogIDs(ids ...int) { - if m.removedeventLogs == nil { - m.removedeventLogs = make(map[int]struct{}) - } - for i := range ids { - delete(m.eventLogs, ids[i]) - m.removedeventLogs[ids[i]] = struct{}{} - } -} - -// RemovedEventLogs returns the removed IDs of the "eventLogs" edge to the EventLog entity. -func (m *SignerMutation) RemovedEventLogsIDs() (ids []int) { - for id := range m.removedeventLogs { - ids = append(ids, id) - } - return -} - -// EventLogsIDs returns the "eventLogs" edge IDs in the mutation. -func (m *SignerMutation) EventLogsIDs() (ids []int) { - for id := range m.eventLogs { - ids = append(ids, id) - } - return -} - -// ResetEventLogs resets all changes to the "eventLogs" edge. -func (m *SignerMutation) ResetEventLogs() { - m.eventLogs = nil - m.clearedeventLogs = false - m.removedeventLogs = nil -} - -// AddCorrectnessReportIDs adds the "correctnessReport" edge to the CorrectnessReport entity by ids. -func (m *SignerMutation) AddCorrectnessReportIDs(ids ...int) { - if m.correctnessReport == nil { - m.correctnessReport = make(map[int]struct{}) - } - for i := range ids { - m.correctnessReport[ids[i]] = struct{}{} - } -} - -// ClearCorrectnessReport clears the "correctnessReport" edge to the CorrectnessReport entity. -func (m *SignerMutation) ClearCorrectnessReport() { - m.clearedcorrectnessReport = true -} - -// CorrectnessReportCleared reports if the "correctnessReport" edge to the CorrectnessReport entity was cleared. -func (m *SignerMutation) CorrectnessReportCleared() bool { - return m.clearedcorrectnessReport -} - -// RemoveCorrectnessReportIDs removes the "correctnessReport" edge to the CorrectnessReport entity by IDs. -func (m *SignerMutation) RemoveCorrectnessReportIDs(ids ...int) { - if m.removedcorrectnessReport == nil { - m.removedcorrectnessReport = make(map[int]struct{}) - } - for i := range ids { - delete(m.correctnessReport, ids[i]) - m.removedcorrectnessReport[ids[i]] = struct{}{} - } -} - -// RemovedCorrectnessReport returns the removed IDs of the "correctnessReport" edge to the CorrectnessReport entity. -func (m *SignerMutation) RemovedCorrectnessReportIDs() (ids []int) { - for id := range m.removedcorrectnessReport { - ids = append(ids, id) - } - return -} - -// CorrectnessReportIDs returns the "correctnessReport" edge IDs in the mutation. -func (m *SignerMutation) CorrectnessReportIDs() (ids []int) { - for id := range m.correctnessReport { - ids = append(ids, id) - } - return -} - -// ResetCorrectnessReport resets all changes to the "correctnessReport" edge. -func (m *SignerMutation) ResetCorrectnessReport() { - m.correctnessReport = nil - m.clearedcorrectnessReport = false - m.removedcorrectnessReport = nil -} - -// Where appends a list predicates to the SignerMutation builder. -func (m *SignerMutation) Where(ps ...predicate.Signer) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the SignerMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *SignerMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Signer, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *SignerMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *SignerMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (Signer). -func (m *SignerMutation) 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 *SignerMutation) Fields() []string { - fields := make([]string, 0, 5) - if m.name != nil { - fields = append(fields, signer.FieldName) - } - if m.evm != nil { - fields = append(fields, signer.FieldEvm) - } - if m.key != nil { - fields = append(fields, signer.FieldKey) - } - if m.shortkey != nil { - fields = append(fields, signer.FieldShortkey) - } - if m.points != nil { - fields = append(fields, signer.FieldPoints) - } - 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 *SignerMutation) Field(name string) (ent.Value, bool) { - switch name { - case signer.FieldName: - return m.Name() - case signer.FieldEvm: - return m.Evm() - case signer.FieldKey: - return m.Key() - case signer.FieldShortkey: - return m.Shortkey() - case signer.FieldPoints: - return m.Points() - } - 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 *SignerMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case signer.FieldName: - return m.OldName(ctx) - case signer.FieldEvm: - return m.OldEvm(ctx) - case signer.FieldKey: - return m.OldKey(ctx) - case signer.FieldShortkey: - return m.OldShortkey(ctx) - case signer.FieldPoints: - return m.OldPoints(ctx) - } - return nil, fmt.Errorf("unknown Signer 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 *SignerMutation) SetField(name string, value ent.Value) error { - switch name { - case signer.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case signer.FieldEvm: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetEvm(v) - return nil - case signer.FieldKey: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetKey(v) - return nil - case signer.FieldShortkey: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetShortkey(v) - return nil - case signer.FieldPoints: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPoints(v) - return nil - } - return fmt.Errorf("unknown Signer field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *SignerMutation) AddedFields() []string { - var fields []string - if m.addpoints != nil { - fields = append(fields, signer.FieldPoints) - } - 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 *SignerMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case signer.FieldPoints: - return m.AddedPoints() - } - 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 *SignerMutation) AddField(name string, value ent.Value) error { - switch name { - case signer.FieldPoints: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddPoints(v) - return nil - } - return fmt.Errorf("unknown Signer numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *SignerMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(signer.FieldEvm) { - fields = append(fields, signer.FieldEvm) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *SignerMutation) 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 *SignerMutation) ClearField(name string) error { - switch name { - case signer.FieldEvm: - m.ClearEvm() - return nil - } - return fmt.Errorf("unknown Signer 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 *SignerMutation) ResetField(name string) error { - switch name { - case signer.FieldName: - m.ResetName() - return nil - case signer.FieldEvm: - m.ResetEvm() - return nil - case signer.FieldKey: - m.ResetKey() - return nil - case signer.FieldShortkey: - m.ResetShortkey() - return nil - case signer.FieldPoints: - m.ResetPoints() - return nil - } - return fmt.Errorf("unknown Signer field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *SignerMutation) AddedEdges() []string { - edges := make([]string, 0, 3) - if m.assetPrice != nil { - edges = append(edges, signer.EdgeAssetPrice) - } - if m.eventLogs != nil { - edges = append(edges, signer.EdgeEventLogs) - } - if m.correctnessReport != nil { - edges = append(edges, signer.EdgeCorrectnessReport) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *SignerMutation) AddedIDs(name string) []ent.Value { - switch name { - case signer.EdgeAssetPrice: - ids := make([]ent.Value, 0, len(m.assetPrice)) - for id := range m.assetPrice { - ids = append(ids, id) - } - return ids - case signer.EdgeEventLogs: - ids := make([]ent.Value, 0, len(m.eventLogs)) - for id := range m.eventLogs { - ids = append(ids, id) - } - return ids - case signer.EdgeCorrectnessReport: - ids := make([]ent.Value, 0, len(m.correctnessReport)) - for id := range m.correctnessReport { - ids = append(ids, id) - } - return ids - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *SignerMutation) RemovedEdges() []string { - edges := make([]string, 0, 3) - if m.removedassetPrice != nil { - edges = append(edges, signer.EdgeAssetPrice) - } - if m.removedeventLogs != nil { - edges = append(edges, signer.EdgeEventLogs) - } - if m.removedcorrectnessReport != nil { - edges = append(edges, signer.EdgeCorrectnessReport) - } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *SignerMutation) RemovedIDs(name string) []ent.Value { - switch name { - case signer.EdgeAssetPrice: - ids := make([]ent.Value, 0, len(m.removedassetPrice)) - for id := range m.removedassetPrice { - ids = append(ids, id) - } - return ids - case signer.EdgeEventLogs: - ids := make([]ent.Value, 0, len(m.removedeventLogs)) - for id := range m.removedeventLogs { - ids = append(ids, id) - } - return ids - case signer.EdgeCorrectnessReport: - ids := make([]ent.Value, 0, len(m.removedcorrectnessReport)) - for id := range m.removedcorrectnessReport { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *SignerMutation) ClearedEdges() []string { - edges := make([]string, 0, 3) - if m.clearedassetPrice { - edges = append(edges, signer.EdgeAssetPrice) - } - if m.clearedeventLogs { - edges = append(edges, signer.EdgeEventLogs) - } - if m.clearedcorrectnessReport { - edges = append(edges, signer.EdgeCorrectnessReport) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *SignerMutation) EdgeCleared(name string) bool { - switch name { - case signer.EdgeAssetPrice: - return m.clearedassetPrice - case signer.EdgeEventLogs: - return m.clearedeventLogs - case signer.EdgeCorrectnessReport: - return m.clearedcorrectnessReport - } - 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 *SignerMutation) ClearEdge(name string) error { - switch name { - } - return fmt.Errorf("unknown Signer 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 *SignerMutation) ResetEdge(name string) error { - switch name { - case signer.EdgeAssetPrice: - m.ResetAssetPrice() - return nil - case signer.EdgeEventLogs: - m.ResetEventLogs() - return nil - case signer.EdgeCorrectnessReport: - m.ResetCorrectnessReport() - return nil - } - return fmt.Errorf("unknown Signer edge %s", name) -} diff --git a/internal/ent/predicate/predicate.go b/internal/ent/predicate/predicate.go deleted file mode 100644 index e42f1360..00000000 --- a/internal/ent/predicate/predicate.go +++ /dev/null @@ -1,19 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package predicate - -import ( - "entgo.io/ent/dialect/sql" -) - -// AssetPrice is the predicate function for assetprice builders. -type AssetPrice func(*sql.Selector) - -// CorrectnessReport is the predicate function for correctnessreport builders. -type CorrectnessReport func(*sql.Selector) - -// EventLog is the predicate function for eventlog builders. -type EventLog func(*sql.Selector) - -// Signer is the predicate function for signer builders. -type Signer func(*sql.Selector) diff --git a/internal/ent/runtime.go b/internal/ent/runtime.go deleted file mode 100644 index 3880c15d..00000000 --- a/internal/ent/runtime.go +++ /dev/null @@ -1,101 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/schema" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// 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() { - assetpriceFields := schema.AssetPrice{}.Fields() - _ = assetpriceFields - // assetpriceDescSignature is the schema descriptor for signature field. - assetpriceDescSignature := assetpriceFields[3].Descriptor() - // assetprice.SignatureValidator is a validator for the "signature" field. It is called by the builders before save. - assetprice.SignatureValidator = assetpriceDescSignature.Validators[0].(func([]byte) error) - // assetpriceDescConsensus is the schema descriptor for consensus field. - assetpriceDescConsensus := assetpriceFields[7].Descriptor() - // assetprice.DefaultConsensus holds the default value on creation for the consensus field. - assetprice.DefaultConsensus = assetpriceDescConsensus.Default.(bool) - correctnessreportFields := schema.CorrectnessReport{}.Fields() - _ = correctnessreportFields - // correctnessreportDescSignature is the schema descriptor for signature field. - correctnessreportDescSignature := correctnessreportFields[2].Descriptor() - // correctnessreport.SignatureValidator is a validator for the "signature" field. It is called by the builders before save. - correctnessreport.SignatureValidator = correctnessreportDescSignature.Validators[0].(func([]byte) error) - // correctnessreportDescHash is the schema descriptor for hash field. - correctnessreportDescHash := correctnessreportFields[3].Descriptor() - // correctnessreport.HashValidator is a validator for the "hash" field. It is called by the builders before save. - correctnessreport.HashValidator = correctnessreportDescHash.Validators[0].(func([]byte) error) - // correctnessreportDescTopic is the schema descriptor for topic field. - correctnessreportDescTopic := correctnessreportFields[4].Descriptor() - // correctnessreport.TopicValidator is a validator for the "topic" field. It is called by the builders before save. - correctnessreport.TopicValidator = correctnessreportDescTopic.Validators[0].(func([]byte) error) - // correctnessreportDescConsensus is the schema descriptor for consensus field. - correctnessreportDescConsensus := correctnessreportFields[6].Descriptor() - // correctnessreport.DefaultConsensus holds the default value on creation for the consensus field. - correctnessreport.DefaultConsensus = correctnessreportDescConsensus.Default.(bool) - eventlogFields := schema.EventLog{}.Fields() - _ = eventlogFields - // eventlogDescSignature is the schema descriptor for signature field. - eventlogDescSignature := eventlogFields[2].Descriptor() - // eventlog.SignatureValidator is a validator for the "signature" field. It is called by the builders before save. - eventlog.SignatureValidator = eventlogDescSignature.Validators[0].(func([]byte) error) - // eventlogDescTransaction is the schema descriptor for transaction field. - eventlogDescTransaction := eventlogFields[7].Descriptor() - // eventlog.TransactionValidator is a validator for the "transaction" field. It is called by the builders before save. - eventlog.TransactionValidator = eventlogDescTransaction.Validators[0].(func([]byte) error) - // eventlogDescConsensus is the schema descriptor for consensus field. - eventlogDescConsensus := eventlogFields[9].Descriptor() - // eventlog.DefaultConsensus holds the default value on creation for the consensus field. - eventlog.DefaultConsensus = eventlogDescConsensus.Default.(bool) - signerFields := schema.Signer{}.Fields() - _ = signerFields - // signerDescName is the schema descriptor for name field. - signerDescName := signerFields[0].Descriptor() - // signer.NameValidator is a validator for the "name" field. It is called by the builders before save. - signer.NameValidator = signerDescName.Validators[0].(func(string) error) - // signerDescKey is the schema descriptor for key field. - signerDescKey := signerFields[2].Descriptor() - // signer.KeyValidator is a validator for the "key" field. It is called by the builders before save. - signer.KeyValidator = func() func([]byte) error { - validators := signerDescKey.Validators - fns := [...]func([]byte) error{ - validators[0].(func([]byte) error), - validators[1].(func([]byte) error), - } - return func(key []byte) error { - for _, fn := range fns { - if err := fn(key); err != nil { - return err - } - } - return nil - } - }() - // signerDescShortkey is the schema descriptor for shortkey field. - signerDescShortkey := signerFields[3].Descriptor() - // signer.ShortkeyValidator is a validator for the "shortkey" field. It is called by the builders before save. - signer.ShortkeyValidator = func() func([]byte) error { - validators := signerDescShortkey.Validators - fns := [...]func([]byte) error{ - validators[0].(func([]byte) error), - validators[1].(func([]byte) error), - } - return func(shortkey []byte) error { - for _, fn := range fns { - if err := fn(shortkey); err != nil { - return err - } - } - return nil - } - }() -} diff --git a/internal/ent/runtime/runtime.go b/internal/ent/runtime/runtime.go deleted file mode 100644 index 075ef70c..00000000 --- a/internal/ent/runtime/runtime.go +++ /dev/null @@ -1,10 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package runtime - -// The schema-stitching logic is generated in github.com/TimeleapLabs/unchained/internal/ent/runtime.go - -const ( - Version = "v0.13.1" // Version of ent codegen. - Sum = "h1:uD8QwN1h6SNphdCCzmkMN3feSUzNnVvV/WIkHKMbzOE=" // Sum of ent codegen. -) diff --git a/internal/ent/schema/assetprice.go b/internal/ent/schema/assetprice.go deleted file mode 100644 index c6aa6a1c..00000000 --- a/internal/ent/schema/assetprice.go +++ /dev/null @@ -1,77 +0,0 @@ -package schema - -import ( - "entgo.io/contrib/entgql" - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "entgo.io/ent/schema/index" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" -) - -// DataSet holds the schema definition for the DataSet entity. -type AssetPrice struct { - ent.Schema -} - -// Fields of the DataSet. -func (AssetPrice) Fields() []ent.Field { - return []ent.Field{ - field.Uint64("block"). - Annotations( - entgql.Type("Uint"), - entgql.OrderField("BLOCK"), - ), - field.Uint64("signersCount").Nillable().Optional(). - Annotations(entgql.Type("Uint")), - field.Uint("price"). - GoType(new(helpers.BigInt)). - SchemaType(map[string]string{ - // Uint256 - dialect.SQLite: "numeric(78, 0)", - dialect.Postgres: "numeric(78, 0)", - }). - Annotations(entgql.Type("Uint")), - field.Bytes("signature"). - MaxLen(SignatureMaxLen). - Annotations(entgql.Type("Bytes")), - field.String("asset").Optional(), - field.String("chain").Optional(), - field.String("pair").Optional(), - field.Bool("consensus").Default(false). - Annotations(entgql.Type("Boolean")), - field.Uint("voted"). - GoType(new(helpers.BigInt)). - SchemaType(map[string]string{ - // Uint256 - dialect.SQLite: "numeric(78, 0)", - dialect.Postgres: "numeric(78, 0)", - }). - Annotations(entgql.Type("Uint")), - } -} - -// Edges of the DataSet. -func (AssetPrice) Edges() []ent.Edge { - return []ent.Edge{ - // TODO: Make these required on next migrate - edge.To("signers", Signer.Type).Required(), - } -} - -// Edges of the DataSet. -func (AssetPrice) Indexes() []ent.Index { - return []ent.Index{ - index.Fields("block", "chain", "asset", "pair").Unique(), - index.Fields("block", "chain", "asset", "pair", "price", "consensus"), - } -} - -func (AssetPrice) Annotations() []schema.Annotation { - return []schema.Annotation{ - entgql.RelayConnection(), - entgql.QueryField(), - } -} diff --git a/internal/ent/schema/correctness.go b/internal/ent/schema/correctness.go deleted file mode 100644 index 74c5d00f..00000000 --- a/internal/ent/schema/correctness.go +++ /dev/null @@ -1,75 +0,0 @@ -package schema - -import ( - "entgo.io/contrib/entgql" - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "entgo.io/ent/schema/index" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" -) - -// DataSet holds the schema definition for the DataSet entity. -type CorrectnessReport struct { - ent.Schema -} - -const ( - SignatureMaxLen = 48 - HashMaxLen = 64 -) - -// Fields of the DataSet. -func (CorrectnessReport) Fields() []ent.Field { - return []ent.Field{ - field.Uint64("signersCount"). - Annotations(entgql.Type("Uint")), - field.Uint64("timestamp"). - Annotations(entgql.OrderField("TIMESTAMP")). - Annotations(entgql.Type("Uint")), - field.Bytes("signature"). - MaxLen(SignatureMaxLen). - Annotations(entgql.Type("Bytes")), - field.Bytes("hash"). - MaxLen(HashMaxLen). - Annotations(entgql.Type("Bytes")), - field.Bytes("topic"). - MaxLen(HashMaxLen). - Annotations(entgql.Type("Bytes")), - field.Bool("correct"), - field.Bool("consensus").Default(false). - Annotations(entgql.Type("Boolean")), - field.Uint("voted"). - GoType(new(helpers.BigInt)). - SchemaType(map[string]string{ - // Uint256 - dialect.SQLite: "numeric(78, 0)", - dialect.Postgres: "numeric(78, 0)", - }). - Annotations(entgql.Type("Uint")), - } -} - -// Edges of the DataSet. -func (CorrectnessReport) Edges() []ent.Edge { - return []ent.Edge{ - edge.To("signers", Signer.Type).Required(), - } -} - -// Edges of the DataSet. -func (CorrectnessReport) Indexes() []ent.Index { - return []ent.Index{ - index.Fields("topic", "hash").Unique(), - index.Fields("topic", "timestamp", "hash"), - } -} - -func (CorrectnessReport) Annotations() []schema.Annotation { - return []schema.Annotation{ - entgql.RelayConnection(), - entgql.QueryField(), - } -} diff --git a/internal/ent/schema/eventlog.go b/internal/ent/schema/eventlog.go deleted file mode 100644 index cb1d7f4f..00000000 --- a/internal/ent/schema/eventlog.go +++ /dev/null @@ -1,80 +0,0 @@ -package schema - -import ( - "entgo.io/contrib/entgql" - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "entgo.io/ent/schema/index" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/model" -) - -// DataSet holds the schema definition for the DataSet entity. -type EventLog struct { - ent.Schema -} - -const ( - TransactionMaxLen = 32 -) - -// Fields of the DataSet. -func (EventLog) Fields() []ent.Field { - return []ent.Field{ - field.Uint64("block"). - Annotations( - entgql.Type("Uint"), - entgql.OrderField("BLOCK"), - ), - field.Uint64("signersCount"). - Annotations(entgql.Type("Uint")), - field.Bytes("signature"). - MaxLen(SignatureMaxLen). - Annotations(entgql.Type("Bytes")), - field.String("address"), - field.String("chain"), - field.Uint64("index"). - Annotations(entgql.Type("Uint")), - field.String("event"), - field.Bytes("transaction"). - MaxLen(TransactionMaxLen). - Annotations(entgql.Type("Bytes")), - field.JSON("args", []model.EventLogArg{}), - field.Bool("consensus").Default(false). - Annotations(entgql.Type("Boolean")), - field.Uint("voted"). - GoType(new(helpers.BigInt)). - SchemaType(map[string]string{ - // Uint256 - dialect.SQLite: "numeric(78, 0)", - dialect.Postgres: "numeric(78, 0)", - }). - Annotations(entgql.Type("Uint")), - } -} - -// Edges of the DataSet. -func (EventLog) Edges() []ent.Edge { - return []ent.Edge{ - // TODO: Make these required on next migrate - edge.To("signers", Signer.Type).Required(), - } -} - -// Edges of the DataSet. -func (EventLog) Indexes() []ent.Index { - return []ent.Index{ - index.Fields("block", "transaction", "index").Unique(), - index.Fields("block", "address", "event", "consensus"), - } -} - -func (EventLog) Annotations() []schema.Annotation { - return []schema.Annotation{ - entgql.RelayConnection(), - entgql.QueryField(), - } -} diff --git a/internal/ent/schema/signer.go b/internal/ent/schema/signer.go deleted file mode 100644 index 8344289d..00000000 --- a/internal/ent/schema/signer.go +++ /dev/null @@ -1,68 +0,0 @@ -package schema - -import ( - "entgo.io/contrib/entgql" - "entgo.io/ent" - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "entgo.io/ent/schema/index" -) - -// DataSet holds the schema definition for the DataSet entity. -type Signer struct { - ent.Schema -} - -const ( - KeyMaxLen = 96 -) - -// Fields of the DataSet. -func (Signer) Fields() []ent.Field { - return []ent.Field{ - field.String("name"). - NotEmpty(), - field.String("evm"). - Nillable(). - Optional(), - field.Bytes("key"). - MaxLen(KeyMaxLen). - Unique(). - NotEmpty(). - Annotations(entgql.Type("Bytes")), - field.Bytes("shortkey"). - MaxLen(KeyMaxLen). - Unique(). - NotEmpty(). - Annotations(entgql.Type("Bytes")), - field.Int64("points"). - Annotations(entgql.OrderField("POINTS")), - } -} - -// Edges of the DataSet. -func (Signer) Edges() []ent.Edge { - return []ent.Edge{ - edge.From("assetPrice", AssetPrice.Type).Ref("signers"), - edge.From("eventLogs", EventLog.Type).Ref("signers"), - edge.From("correctnessReport", CorrectnessReport.Type).Ref("signers"), - } -} - -// Indexes of the DataSet. -func (Signer) Indexes() []ent.Index { - return []ent.Index{ - index.Fields("key"). - Unique(), - index.Fields("shortkey"). - Unique(), - } -} - -func (Signer) Annotations() []schema.Annotation { - return []schema.Annotation{ - entgql.RelayConnection(), - entgql.QueryField(), - } -} diff --git a/internal/ent/signer.go b/internal/ent/signer.go deleted file mode 100644 index 9e88f167..00000000 --- a/internal/ent/signer.go +++ /dev/null @@ -1,288 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "fmt" - "strings" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// Signer is the model entity for the Signer schema. -type Signer struct { - config `json:"-"` - // ID of the ent. - ID int `json:"id,omitempty"` - // Name holds the value of the "name" field. - Name string `json:"name,omitempty"` - // Evm holds the value of the "evm" field. - Evm *string `json:"evm,omitempty"` - // Key holds the value of the "key" field. - Key []byte `json:"key,omitempty"` - // Shortkey holds the value of the "shortkey" field. - Shortkey []byte `json:"shortkey,omitempty"` - // Points holds the value of the "points" field. - Points int64 `json:"points,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the SignerQuery when eager-loading is set. - Edges SignerEdges `json:"edges"` - selectValues sql.SelectValues -} - -// SignerEdges holds the relations/edges for other nodes in the graph. -type SignerEdges struct { - // AssetPrice holds the value of the assetPrice edge. - AssetPrice []*AssetPrice `json:"assetPrice,omitempty"` - // EventLogs holds the value of the eventLogs edge. - EventLogs []*EventLog `json:"eventLogs,omitempty"` - // CorrectnessReport holds the value of the correctnessReport edge. - CorrectnessReport []*CorrectnessReport `json:"correctnessReport,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [3]bool - // totalCount holds the count of the edges above. - totalCount [3]map[string]int - - namedAssetPrice map[string][]*AssetPrice - namedEventLogs map[string][]*EventLog - namedCorrectnessReport map[string][]*CorrectnessReport -} - -// AssetPriceOrErr returns the AssetPrice value or an error if the edge -// was not loaded in eager-loading. -func (e SignerEdges) AssetPriceOrErr() ([]*AssetPrice, error) { - if e.loadedTypes[0] { - return e.AssetPrice, nil - } - return nil, &NotLoadedError{edge: "assetPrice"} -} - -// EventLogsOrErr returns the EventLogs value or an error if the edge -// was not loaded in eager-loading. -func (e SignerEdges) EventLogsOrErr() ([]*EventLog, error) { - if e.loadedTypes[1] { - return e.EventLogs, nil - } - return nil, &NotLoadedError{edge: "eventLogs"} -} - -// CorrectnessReportOrErr returns the CorrectnessReport value or an error if the edge -// was not loaded in eager-loading. -func (e SignerEdges) CorrectnessReportOrErr() ([]*CorrectnessReport, error) { - if e.loadedTypes[2] { - return e.CorrectnessReport, nil - } - return nil, &NotLoadedError{edge: "correctnessReport"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*Signer) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case signer.FieldKey, signer.FieldShortkey: - values[i] = new([]byte) - case signer.FieldID, signer.FieldPoints: - values[i] = new(sql.NullInt64) - case signer.FieldName, signer.FieldEvm: - 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 Signer fields. -func (s *Signer) 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 signer.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) - } - s.ID = int(value.Int64) - case signer.FieldName: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field name", values[i]) - } else if value.Valid { - s.Name = value.String - } - case signer.FieldEvm: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field evm", values[i]) - } else if value.Valid { - s.Evm = new(string) - *s.Evm = value.String - } - case signer.FieldKey: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field key", values[i]) - } else if value != nil { - s.Key = *value - } - case signer.FieldShortkey: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field shortkey", values[i]) - } else if value != nil { - s.Shortkey = *value - } - case signer.FieldPoints: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field points", values[i]) - } else if value.Valid { - s.Points = value.Int64 - } - default: - s.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the Signer. -// This includes values selected through modifiers, order, etc. -func (s *Signer) Value(name string) (ent.Value, error) { - return s.selectValues.Get(name) -} - -// QueryAssetPrice queries the "assetPrice" edge of the Signer entity. -func (s *Signer) QueryAssetPrice() *AssetPriceQuery { - return NewSignerClient(s.config).QueryAssetPrice(s) -} - -// QueryEventLogs queries the "eventLogs" edge of the Signer entity. -func (s *Signer) QueryEventLogs() *EventLogQuery { - return NewSignerClient(s.config).QueryEventLogs(s) -} - -// QueryCorrectnessReport queries the "correctnessReport" edge of the Signer entity. -func (s *Signer) QueryCorrectnessReport() *CorrectnessReportQuery { - return NewSignerClient(s.config).QueryCorrectnessReport(s) -} - -// Update returns a builder for updating this Signer. -// Note that you need to call Signer.Unwrap() before calling this method if this Signer -// was returned from a transaction, and the transaction was committed or rolled back. -func (s *Signer) Update() *SignerUpdateOne { - return NewSignerClient(s.config).UpdateOne(s) -} - -// Unwrap unwraps the Signer 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 (s *Signer) Unwrap() *Signer { - _tx, ok := s.config.driver.(*txDriver) - if !ok { - panic("ent: Signer is not a transactional entity") - } - s.config.driver = _tx.drv - return s -} - -// String implements the fmt.Stringer. -func (s *Signer) String() string { - var builder strings.Builder - builder.WriteString("Signer(") - builder.WriteString(fmt.Sprintf("id=%v, ", s.ID)) - builder.WriteString("name=") - builder.WriteString(s.Name) - builder.WriteString(", ") - if v := s.Evm; v != nil { - builder.WriteString("evm=") - builder.WriteString(*v) - } - builder.WriteString(", ") - builder.WriteString("key=") - builder.WriteString(fmt.Sprintf("%v", s.Key)) - builder.WriteString(", ") - builder.WriteString("shortkey=") - builder.WriteString(fmt.Sprintf("%v", s.Shortkey)) - builder.WriteString(", ") - builder.WriteString("points=") - builder.WriteString(fmt.Sprintf("%v", s.Points)) - builder.WriteByte(')') - return builder.String() -} - -// NamedAssetPrice returns the AssetPrice named value or an error if the edge was not -// loaded in eager-loading with this name. -func (s *Signer) NamedAssetPrice(name string) ([]*AssetPrice, error) { - if s.Edges.namedAssetPrice == nil { - return nil, &NotLoadedError{edge: name} - } - nodes, ok := s.Edges.namedAssetPrice[name] - if !ok { - return nil, &NotLoadedError{edge: name} - } - return nodes, nil -} - -func (s *Signer) appendNamedAssetPrice(name string, edges ...*AssetPrice) { - if s.Edges.namedAssetPrice == nil { - s.Edges.namedAssetPrice = make(map[string][]*AssetPrice) - } - if len(edges) == 0 { - s.Edges.namedAssetPrice[name] = []*AssetPrice{} - } else { - s.Edges.namedAssetPrice[name] = append(s.Edges.namedAssetPrice[name], edges...) - } -} - -// NamedEventLogs returns the EventLogs named value or an error if the edge was not -// loaded in eager-loading with this name. -func (s *Signer) NamedEventLogs(name string) ([]*EventLog, error) { - if s.Edges.namedEventLogs == nil { - return nil, &NotLoadedError{edge: name} - } - nodes, ok := s.Edges.namedEventLogs[name] - if !ok { - return nil, &NotLoadedError{edge: name} - } - return nodes, nil -} - -func (s *Signer) appendNamedEventLogs(name string, edges ...*EventLog) { - if s.Edges.namedEventLogs == nil { - s.Edges.namedEventLogs = make(map[string][]*EventLog) - } - if len(edges) == 0 { - s.Edges.namedEventLogs[name] = []*EventLog{} - } else { - s.Edges.namedEventLogs[name] = append(s.Edges.namedEventLogs[name], edges...) - } -} - -// NamedCorrectnessReport returns the CorrectnessReport named value or an error if the edge was not -// loaded in eager-loading with this name. -func (s *Signer) NamedCorrectnessReport(name string) ([]*CorrectnessReport, error) { - if s.Edges.namedCorrectnessReport == nil { - return nil, &NotLoadedError{edge: name} - } - nodes, ok := s.Edges.namedCorrectnessReport[name] - if !ok { - return nil, &NotLoadedError{edge: name} - } - return nodes, nil -} - -func (s *Signer) appendNamedCorrectnessReport(name string, edges ...*CorrectnessReport) { - if s.Edges.namedCorrectnessReport == nil { - s.Edges.namedCorrectnessReport = make(map[string][]*CorrectnessReport) - } - if len(edges) == 0 { - s.Edges.namedCorrectnessReport[name] = []*CorrectnessReport{} - } else { - s.Edges.namedCorrectnessReport[name] = append(s.Edges.namedCorrectnessReport[name], edges...) - } -} - -// Signers is a parsable slice of Signer. -type Signers []*Signer diff --git a/internal/ent/signer/signer.go b/internal/ent/signer/signer.go deleted file mode 100644 index 66e88841..00000000 --- a/internal/ent/signer/signer.go +++ /dev/null @@ -1,175 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package signer - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the signer type in the database. - Label = "signer" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldName holds the string denoting the name field in the database. - FieldName = "name" - // FieldEvm holds the string denoting the evm field in the database. - FieldEvm = "evm" - // FieldKey holds the string denoting the key field in the database. - FieldKey = "key" - // FieldShortkey holds the string denoting the shortkey field in the database. - FieldShortkey = "shortkey" - // FieldPoints holds the string denoting the points field in the database. - FieldPoints = "points" - // EdgeAssetPrice holds the string denoting the assetprice edge name in mutations. - EdgeAssetPrice = "assetPrice" - // EdgeEventLogs holds the string denoting the eventlogs edge name in mutations. - EdgeEventLogs = "eventLogs" - // EdgeCorrectnessReport holds the string denoting the correctnessreport edge name in mutations. - EdgeCorrectnessReport = "correctnessReport" - // Table holds the table name of the signer in the database. - Table = "signers" - // AssetPriceTable is the table that holds the assetPrice relation/edge. The primary key declared below. - AssetPriceTable = "asset_price_signers" - // AssetPriceInverseTable is the table name for the AssetPrice entity. - // It exists in this package in order to avoid circular dependency with the "assetprice" package. - AssetPriceInverseTable = "asset_prices" - // EventLogsTable is the table that holds the eventLogs relation/edge. The primary key declared below. - EventLogsTable = "event_log_signers" - // EventLogsInverseTable is the table name for the EventLog entity. - // It exists in this package in order to avoid circular dependency with the "eventlog" package. - EventLogsInverseTable = "event_logs" - // CorrectnessReportTable is the table that holds the correctnessReport relation/edge. The primary key declared below. - CorrectnessReportTable = "correctness_report_signers" - // CorrectnessReportInverseTable is the table name for the CorrectnessReport entity. - // It exists in this package in order to avoid circular dependency with the "correctnessreport" package. - CorrectnessReportInverseTable = "correctness_reports" -) - -// Columns holds all SQL columns for signer fields. -var Columns = []string{ - FieldID, - FieldName, - FieldEvm, - FieldKey, - FieldShortkey, - FieldPoints, -} - -var ( - // AssetPricePrimaryKey and AssetPriceColumn2 are the table columns denoting the - // primary key for the assetPrice relation (M2M). - AssetPricePrimaryKey = []string{"asset_price_id", "signer_id"} - // EventLogsPrimaryKey and EventLogsColumn2 are the table columns denoting the - // primary key for the eventLogs relation (M2M). - EventLogsPrimaryKey = []string{"event_log_id", "signer_id"} - // CorrectnessReportPrimaryKey and CorrectnessReportColumn2 are the table columns denoting the - // primary key for the correctnessReport relation (M2M). - CorrectnessReportPrimaryKey = []string{"correctness_report_id", "signer_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 -} - -var ( - // NameValidator is a validator for the "name" field. It is called by the builders before save. - NameValidator func(string) error - // KeyValidator is a validator for the "key" field. It is called by the builders before save. - KeyValidator func([]byte) error - // ShortkeyValidator is a validator for the "shortkey" field. It is called by the builders before save. - ShortkeyValidator func([]byte) error -) - -// OrderOption defines the ordering options for the Signer 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() -} - -// ByName orders the results by the name field. -func ByName(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldName, opts...).ToFunc() -} - -// ByEvm orders the results by the evm field. -func ByEvm(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldEvm, opts...).ToFunc() -} - -// ByPoints orders the results by the points field. -func ByPoints(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPoints, opts...).ToFunc() -} - -// ByAssetPriceCount orders the results by assetPrice count. -func ByAssetPriceCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newAssetPriceStep(), opts...) - } -} - -// ByAssetPrice orders the results by assetPrice terms. -func ByAssetPrice(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newAssetPriceStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByEventLogsCount orders the results by eventLogs count. -func ByEventLogsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newEventLogsStep(), opts...) - } -} - -// ByEventLogs orders the results by eventLogs terms. -func ByEventLogs(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newEventLogsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByCorrectnessReportCount orders the results by correctnessReport count. -func ByCorrectnessReportCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newCorrectnessReportStep(), opts...) - } -} - -// ByCorrectnessReport orders the results by correctnessReport terms. -func ByCorrectnessReport(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newCorrectnessReportStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newAssetPriceStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(AssetPriceInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, AssetPriceTable, AssetPricePrimaryKey...), - ) -} -func newEventLogsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(EventLogsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, EventLogsTable, EventLogsPrimaryKey...), - ) -} -func newCorrectnessReportStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(CorrectnessReportInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, CorrectnessReportTable, CorrectnessReportPrimaryKey...), - ) -} diff --git a/internal/ent/signer/where.go b/internal/ent/signer/where.go deleted file mode 100644 index 8e83872b..00000000 --- a/internal/ent/signer/where.go +++ /dev/null @@ -1,423 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package signer - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.Signer { - return predicate.Signer(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.Signer { - return predicate.Signer(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.Signer { - return predicate.Signer(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.Signer { - return predicate.Signer(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.Signer { - return predicate.Signer(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.Signer { - return predicate.Signer(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.Signer { - return predicate.Signer(sql.FieldLTE(FieldID, id)) -} - -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldName, v)) -} - -// Evm applies equality check predicate on the "evm" field. It's identical to EvmEQ. -func Evm(v string) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldEvm, v)) -} - -// Key applies equality check predicate on the "key" field. It's identical to KeyEQ. -func Key(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldKey, v)) -} - -// Shortkey applies equality check predicate on the "shortkey" field. It's identical to ShortkeyEQ. -func Shortkey(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldShortkey, v)) -} - -// Points applies equality check predicate on the "points" field. It's identical to PointsEQ. -func Points(v int64) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldPoints, v)) -} - -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldName, v)) -} - -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.Signer { - return predicate.Signer(sql.FieldNEQ(FieldName, v)) -} - -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.Signer { - return predicate.Signer(sql.FieldIn(FieldName, vs...)) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.Signer { - return predicate.Signer(sql.FieldNotIn(FieldName, vs...)) -} - -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.Signer { - return predicate.Signer(sql.FieldGT(FieldName, v)) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.Signer { - return predicate.Signer(sql.FieldGTE(FieldName, v)) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.Signer { - return predicate.Signer(sql.FieldLT(FieldName, v)) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.Signer { - return predicate.Signer(sql.FieldLTE(FieldName, v)) -} - -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.Signer { - return predicate.Signer(sql.FieldContains(FieldName, v)) -} - -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.Signer { - return predicate.Signer(sql.FieldHasPrefix(FieldName, v)) -} - -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.Signer { - return predicate.Signer(sql.FieldHasSuffix(FieldName, v)) -} - -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.Signer { - return predicate.Signer(sql.FieldEqualFold(FieldName, v)) -} - -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.Signer { - return predicate.Signer(sql.FieldContainsFold(FieldName, v)) -} - -// EvmEQ applies the EQ predicate on the "evm" field. -func EvmEQ(v string) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldEvm, v)) -} - -// EvmNEQ applies the NEQ predicate on the "evm" field. -func EvmNEQ(v string) predicate.Signer { - return predicate.Signer(sql.FieldNEQ(FieldEvm, v)) -} - -// EvmIn applies the In predicate on the "evm" field. -func EvmIn(vs ...string) predicate.Signer { - return predicate.Signer(sql.FieldIn(FieldEvm, vs...)) -} - -// EvmNotIn applies the NotIn predicate on the "evm" field. -func EvmNotIn(vs ...string) predicate.Signer { - return predicate.Signer(sql.FieldNotIn(FieldEvm, vs...)) -} - -// EvmGT applies the GT predicate on the "evm" field. -func EvmGT(v string) predicate.Signer { - return predicate.Signer(sql.FieldGT(FieldEvm, v)) -} - -// EvmGTE applies the GTE predicate on the "evm" field. -func EvmGTE(v string) predicate.Signer { - return predicate.Signer(sql.FieldGTE(FieldEvm, v)) -} - -// EvmLT applies the LT predicate on the "evm" field. -func EvmLT(v string) predicate.Signer { - return predicate.Signer(sql.FieldLT(FieldEvm, v)) -} - -// EvmLTE applies the LTE predicate on the "evm" field. -func EvmLTE(v string) predicate.Signer { - return predicate.Signer(sql.FieldLTE(FieldEvm, v)) -} - -// EvmContains applies the Contains predicate on the "evm" field. -func EvmContains(v string) predicate.Signer { - return predicate.Signer(sql.FieldContains(FieldEvm, v)) -} - -// EvmHasPrefix applies the HasPrefix predicate on the "evm" field. -func EvmHasPrefix(v string) predicate.Signer { - return predicate.Signer(sql.FieldHasPrefix(FieldEvm, v)) -} - -// EvmHasSuffix applies the HasSuffix predicate on the "evm" field. -func EvmHasSuffix(v string) predicate.Signer { - return predicate.Signer(sql.FieldHasSuffix(FieldEvm, v)) -} - -// EvmIsNil applies the IsNil predicate on the "evm" field. -func EvmIsNil() predicate.Signer { - return predicate.Signer(sql.FieldIsNull(FieldEvm)) -} - -// EvmNotNil applies the NotNil predicate on the "evm" field. -func EvmNotNil() predicate.Signer { - return predicate.Signer(sql.FieldNotNull(FieldEvm)) -} - -// EvmEqualFold applies the EqualFold predicate on the "evm" field. -func EvmEqualFold(v string) predicate.Signer { - return predicate.Signer(sql.FieldEqualFold(FieldEvm, v)) -} - -// EvmContainsFold applies the ContainsFold predicate on the "evm" field. -func EvmContainsFold(v string) predicate.Signer { - return predicate.Signer(sql.FieldContainsFold(FieldEvm, v)) -} - -// KeyEQ applies the EQ predicate on the "key" field. -func KeyEQ(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldKey, v)) -} - -// KeyNEQ applies the NEQ predicate on the "key" field. -func KeyNEQ(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldNEQ(FieldKey, v)) -} - -// KeyIn applies the In predicate on the "key" field. -func KeyIn(vs ...[]byte) predicate.Signer { - return predicate.Signer(sql.FieldIn(FieldKey, vs...)) -} - -// KeyNotIn applies the NotIn predicate on the "key" field. -func KeyNotIn(vs ...[]byte) predicate.Signer { - return predicate.Signer(sql.FieldNotIn(FieldKey, vs...)) -} - -// KeyGT applies the GT predicate on the "key" field. -func KeyGT(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldGT(FieldKey, v)) -} - -// KeyGTE applies the GTE predicate on the "key" field. -func KeyGTE(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldGTE(FieldKey, v)) -} - -// KeyLT applies the LT predicate on the "key" field. -func KeyLT(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldLT(FieldKey, v)) -} - -// KeyLTE applies the LTE predicate on the "key" field. -func KeyLTE(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldLTE(FieldKey, v)) -} - -// ShortkeyEQ applies the EQ predicate on the "shortkey" field. -func ShortkeyEQ(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldShortkey, v)) -} - -// ShortkeyNEQ applies the NEQ predicate on the "shortkey" field. -func ShortkeyNEQ(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldNEQ(FieldShortkey, v)) -} - -// ShortkeyIn applies the In predicate on the "shortkey" field. -func ShortkeyIn(vs ...[]byte) predicate.Signer { - return predicate.Signer(sql.FieldIn(FieldShortkey, vs...)) -} - -// ShortkeyNotIn applies the NotIn predicate on the "shortkey" field. -func ShortkeyNotIn(vs ...[]byte) predicate.Signer { - return predicate.Signer(sql.FieldNotIn(FieldShortkey, vs...)) -} - -// ShortkeyGT applies the GT predicate on the "shortkey" field. -func ShortkeyGT(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldGT(FieldShortkey, v)) -} - -// ShortkeyGTE applies the GTE predicate on the "shortkey" field. -func ShortkeyGTE(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldGTE(FieldShortkey, v)) -} - -// ShortkeyLT applies the LT predicate on the "shortkey" field. -func ShortkeyLT(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldLT(FieldShortkey, v)) -} - -// ShortkeyLTE applies the LTE predicate on the "shortkey" field. -func ShortkeyLTE(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldLTE(FieldShortkey, v)) -} - -// PointsEQ applies the EQ predicate on the "points" field. -func PointsEQ(v int64) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldPoints, v)) -} - -// PointsNEQ applies the NEQ predicate on the "points" field. -func PointsNEQ(v int64) predicate.Signer { - return predicate.Signer(sql.FieldNEQ(FieldPoints, v)) -} - -// PointsIn applies the In predicate on the "points" field. -func PointsIn(vs ...int64) predicate.Signer { - return predicate.Signer(sql.FieldIn(FieldPoints, vs...)) -} - -// PointsNotIn applies the NotIn predicate on the "points" field. -func PointsNotIn(vs ...int64) predicate.Signer { - return predicate.Signer(sql.FieldNotIn(FieldPoints, vs...)) -} - -// PointsGT applies the GT predicate on the "points" field. -func PointsGT(v int64) predicate.Signer { - return predicate.Signer(sql.FieldGT(FieldPoints, v)) -} - -// PointsGTE applies the GTE predicate on the "points" field. -func PointsGTE(v int64) predicate.Signer { - return predicate.Signer(sql.FieldGTE(FieldPoints, v)) -} - -// PointsLT applies the LT predicate on the "points" field. -func PointsLT(v int64) predicate.Signer { - return predicate.Signer(sql.FieldLT(FieldPoints, v)) -} - -// PointsLTE applies the LTE predicate on the "points" field. -func PointsLTE(v int64) predicate.Signer { - return predicate.Signer(sql.FieldLTE(FieldPoints, v)) -} - -// HasAssetPrice applies the HasEdge predicate on the "assetPrice" edge. -func HasAssetPrice() predicate.Signer { - return predicate.Signer(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, AssetPriceTable, AssetPricePrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasAssetPriceWith applies the HasEdge predicate on the "assetPrice" edge with a given conditions (other predicates). -func HasAssetPriceWith(preds ...predicate.AssetPrice) predicate.Signer { - return predicate.Signer(func(s *sql.Selector) { - step := newAssetPriceStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasEventLogs applies the HasEdge predicate on the "eventLogs" edge. -func HasEventLogs() predicate.Signer { - return predicate.Signer(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, EventLogsTable, EventLogsPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasEventLogsWith applies the HasEdge predicate on the "eventLogs" edge with a given conditions (other predicates). -func HasEventLogsWith(preds ...predicate.EventLog) predicate.Signer { - return predicate.Signer(func(s *sql.Selector) { - step := newEventLogsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasCorrectnessReport applies the HasEdge predicate on the "correctnessReport" edge. -func HasCorrectnessReport() predicate.Signer { - return predicate.Signer(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, CorrectnessReportTable, CorrectnessReportPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasCorrectnessReportWith applies the HasEdge predicate on the "correctnessReport" edge with a given conditions (other predicates). -func HasCorrectnessReportWith(preds ...predicate.CorrectnessReport) predicate.Signer { - return predicate.Signer(func(s *sql.Selector) { - step := newCorrectnessReportStep() - 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.Signer) predicate.Signer { - return predicate.Signer(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.Signer) predicate.Signer { - return predicate.Signer(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.Signer) predicate.Signer { - return predicate.Signer(sql.NotPredicates(p)) -} diff --git a/internal/ent/signer_create.go b/internal/ent/signer_create.go deleted file mode 100644 index 170ff05f..00000000 --- a/internal/ent/signer_create.go +++ /dev/null @@ -1,822 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// SignerCreate is the builder for creating a Signer entity. -type SignerCreate struct { - config - mutation *SignerMutation - hooks []Hook - conflict []sql.ConflictOption -} - -// SetName sets the "name" field. -func (sc *SignerCreate) SetName(s string) *SignerCreate { - sc.mutation.SetName(s) - return sc -} - -// SetEvm sets the "evm" field. -func (sc *SignerCreate) SetEvm(s string) *SignerCreate { - sc.mutation.SetEvm(s) - return sc -} - -// SetNillableEvm sets the "evm" field if the given value is not nil. -func (sc *SignerCreate) SetNillableEvm(s *string) *SignerCreate { - if s != nil { - sc.SetEvm(*s) - } - return sc -} - -// SetKey sets the "key" field. -func (sc *SignerCreate) SetKey(b []byte) *SignerCreate { - sc.mutation.SetKey(b) - return sc -} - -// SetShortkey sets the "shortkey" field. -func (sc *SignerCreate) SetShortkey(b []byte) *SignerCreate { - sc.mutation.SetShortkey(b) - return sc -} - -// SetPoints sets the "points" field. -func (sc *SignerCreate) SetPoints(i int64) *SignerCreate { - sc.mutation.SetPoints(i) - return sc -} - -// AddAssetPriceIDs adds the "assetPrice" edge to the AssetPrice entity by IDs. -func (sc *SignerCreate) AddAssetPriceIDs(ids ...int) *SignerCreate { - sc.mutation.AddAssetPriceIDs(ids...) - return sc -} - -// AddAssetPrice adds the "assetPrice" edges to the AssetPrice entity. -func (sc *SignerCreate) AddAssetPrice(a ...*AssetPrice) *SignerCreate { - ids := make([]int, len(a)) - for i := range a { - ids[i] = a[i].ID - } - return sc.AddAssetPriceIDs(ids...) -} - -// AddEventLogIDs adds the "eventLogs" edge to the EventLog entity by IDs. -func (sc *SignerCreate) AddEventLogIDs(ids ...int) *SignerCreate { - sc.mutation.AddEventLogIDs(ids...) - return sc -} - -// AddEventLogs adds the "eventLogs" edges to the EventLog entity. -func (sc *SignerCreate) AddEventLogs(e ...*EventLog) *SignerCreate { - ids := make([]int, len(e)) - for i := range e { - ids[i] = e[i].ID - } - return sc.AddEventLogIDs(ids...) -} - -// AddCorrectnessReportIDs adds the "correctnessReport" edge to the CorrectnessReport entity by IDs. -func (sc *SignerCreate) AddCorrectnessReportIDs(ids ...int) *SignerCreate { - sc.mutation.AddCorrectnessReportIDs(ids...) - return sc -} - -// AddCorrectnessReport adds the "correctnessReport" edges to the CorrectnessReport entity. -func (sc *SignerCreate) AddCorrectnessReport(c ...*CorrectnessReport) *SignerCreate { - ids := make([]int, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return sc.AddCorrectnessReportIDs(ids...) -} - -// Mutation returns the SignerMutation object of the builder. -func (sc *SignerCreate) Mutation() *SignerMutation { - return sc.mutation -} - -// Save creates the Signer in the database. -func (sc *SignerCreate) Save(ctx context.Context) (*Signer, error) { - return withHooks(ctx, sc.sqlSave, sc.mutation, sc.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (sc *SignerCreate) SaveX(ctx context.Context) *Signer { - v, err := sc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (sc *SignerCreate) Exec(ctx context.Context) error { - _, err := sc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (sc *SignerCreate) ExecX(ctx context.Context) { - if err := sc.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (sc *SignerCreate) check() error { - if _, ok := sc.mutation.Name(); !ok { - return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Signer.name"`)} - } - if v, ok := sc.mutation.Name(); ok { - if err := signer.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Signer.name": %w`, err)} - } - } - if _, ok := sc.mutation.Key(); !ok { - return &ValidationError{Name: "key", err: errors.New(`ent: missing required field "Signer.key"`)} - } - if v, ok := sc.mutation.Key(); ok { - if err := signer.KeyValidator(v); err != nil { - return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "Signer.key": %w`, err)} - } - } - if _, ok := sc.mutation.Shortkey(); !ok { - return &ValidationError{Name: "shortkey", err: errors.New(`ent: missing required field "Signer.shortkey"`)} - } - if v, ok := sc.mutation.Shortkey(); ok { - if err := signer.ShortkeyValidator(v); err != nil { - return &ValidationError{Name: "shortkey", err: fmt.Errorf(`ent: validator failed for field "Signer.shortkey": %w`, err)} - } - } - if _, ok := sc.mutation.Points(); !ok { - return &ValidationError{Name: "points", err: errors.New(`ent: missing required field "Signer.points"`)} - } - return nil -} - -func (sc *SignerCreate) sqlSave(ctx context.Context) (*Signer, error) { - if err := sc.check(); err != nil { - return nil, err - } - _node, _spec := sc.createSpec() - if err := sqlgraph.CreateNode(ctx, sc.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) - sc.mutation.id = &_node.ID - sc.mutation.done = true - return _node, nil -} - -func (sc *SignerCreate) createSpec() (*Signer, *sqlgraph.CreateSpec) { - var ( - _node = &Signer{config: sc.config} - _spec = sqlgraph.NewCreateSpec(signer.Table, sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt)) - ) - _spec.OnConflict = sc.conflict - if value, ok := sc.mutation.Name(); ok { - _spec.SetField(signer.FieldName, field.TypeString, value) - _node.Name = value - } - if value, ok := sc.mutation.Evm(); ok { - _spec.SetField(signer.FieldEvm, field.TypeString, value) - _node.Evm = &value - } - if value, ok := sc.mutation.Key(); ok { - _spec.SetField(signer.FieldKey, field.TypeBytes, value) - _node.Key = value - } - if value, ok := sc.mutation.Shortkey(); ok { - _spec.SetField(signer.FieldShortkey, field.TypeBytes, value) - _node.Shortkey = value - } - if value, ok := sc.mutation.Points(); ok { - _spec.SetField(signer.FieldPoints, field.TypeInt64, value) - _node.Points = value - } - if nodes := sc.mutation.AssetPriceIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.AssetPriceTable, - Columns: signer.AssetPricePrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := sc.mutation.EventLogsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.EventLogsTable, - Columns: signer.EventLogsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := sc.mutation.CorrectnessReportIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.CorrectnessReportTable, - Columns: signer.CorrectnessReportPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(correctnessreport.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.Signer.Create(). -// SetName(v). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.SignerUpsert) { -// SetName(v+v). -// }). -// Exec(ctx) -func (sc *SignerCreate) OnConflict(opts ...sql.ConflictOption) *SignerUpsertOne { - sc.conflict = opts - return &SignerUpsertOne{ - create: sc, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.Signer.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (sc *SignerCreate) OnConflictColumns(columns ...string) *SignerUpsertOne { - sc.conflict = append(sc.conflict, sql.ConflictColumns(columns...)) - return &SignerUpsertOne{ - create: sc, - } -} - -type ( - // SignerUpsertOne is the builder for "upsert"-ing - // one Signer node. - SignerUpsertOne struct { - create *SignerCreate - } - - // SignerUpsert is the "OnConflict" setter. - SignerUpsert struct { - *sql.UpdateSet - } -) - -// SetName sets the "name" field. -func (u *SignerUpsert) SetName(v string) *SignerUpsert { - u.Set(signer.FieldName, v) - return u -} - -// UpdateName sets the "name" field to the value that was provided on create. -func (u *SignerUpsert) UpdateName() *SignerUpsert { - u.SetExcluded(signer.FieldName) - return u -} - -// SetEvm sets the "evm" field. -func (u *SignerUpsert) SetEvm(v string) *SignerUpsert { - u.Set(signer.FieldEvm, v) - return u -} - -// UpdateEvm sets the "evm" field to the value that was provided on create. -func (u *SignerUpsert) UpdateEvm() *SignerUpsert { - u.SetExcluded(signer.FieldEvm) - return u -} - -// ClearEvm clears the value of the "evm" field. -func (u *SignerUpsert) ClearEvm() *SignerUpsert { - u.SetNull(signer.FieldEvm) - return u -} - -// SetKey sets the "key" field. -func (u *SignerUpsert) SetKey(v []byte) *SignerUpsert { - u.Set(signer.FieldKey, v) - return u -} - -// UpdateKey sets the "key" field to the value that was provided on create. -func (u *SignerUpsert) UpdateKey() *SignerUpsert { - u.SetExcluded(signer.FieldKey) - return u -} - -// SetShortkey sets the "shortkey" field. -func (u *SignerUpsert) SetShortkey(v []byte) *SignerUpsert { - u.Set(signer.FieldShortkey, v) - return u -} - -// UpdateShortkey sets the "shortkey" field to the value that was provided on create. -func (u *SignerUpsert) UpdateShortkey() *SignerUpsert { - u.SetExcluded(signer.FieldShortkey) - return u -} - -// SetPoints sets the "points" field. -func (u *SignerUpsert) SetPoints(v int64) *SignerUpsert { - u.Set(signer.FieldPoints, v) - return u -} - -// UpdatePoints sets the "points" field to the value that was provided on create. -func (u *SignerUpsert) UpdatePoints() *SignerUpsert { - u.SetExcluded(signer.FieldPoints) - return u -} - -// AddPoints adds v to the "points" field. -func (u *SignerUpsert) AddPoints(v int64) *SignerUpsert { - u.Add(signer.FieldPoints, v) - return u -} - -// UpdateNewValues updates the mutable fields using the new values that were set on create. -// Using this option is equivalent to using: -// -// client.Signer.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *SignerUpsertOne) UpdateNewValues() *SignerUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.Signer.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *SignerUpsertOne) Ignore() *SignerUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *SignerUpsertOne) DoNothing() *SignerUpsertOne { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the SignerCreate.OnConflict -// documentation for more info. -func (u *SignerUpsertOne) Update(set func(*SignerUpsert)) *SignerUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&SignerUpsert{UpdateSet: update}) - })) - return u -} - -// SetName sets the "name" field. -func (u *SignerUpsertOne) SetName(v string) *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.SetName(v) - }) -} - -// UpdateName sets the "name" field to the value that was provided on create. -func (u *SignerUpsertOne) UpdateName() *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.UpdateName() - }) -} - -// SetEvm sets the "evm" field. -func (u *SignerUpsertOne) SetEvm(v string) *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.SetEvm(v) - }) -} - -// UpdateEvm sets the "evm" field to the value that was provided on create. -func (u *SignerUpsertOne) UpdateEvm() *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.UpdateEvm() - }) -} - -// ClearEvm clears the value of the "evm" field. -func (u *SignerUpsertOne) ClearEvm() *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.ClearEvm() - }) -} - -// SetKey sets the "key" field. -func (u *SignerUpsertOne) SetKey(v []byte) *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.SetKey(v) - }) -} - -// UpdateKey sets the "key" field to the value that was provided on create. -func (u *SignerUpsertOne) UpdateKey() *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.UpdateKey() - }) -} - -// SetShortkey sets the "shortkey" field. -func (u *SignerUpsertOne) SetShortkey(v []byte) *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.SetShortkey(v) - }) -} - -// UpdateShortkey sets the "shortkey" field to the value that was provided on create. -func (u *SignerUpsertOne) UpdateShortkey() *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.UpdateShortkey() - }) -} - -// SetPoints sets the "points" field. -func (u *SignerUpsertOne) SetPoints(v int64) *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.SetPoints(v) - }) -} - -// AddPoints adds v to the "points" field. -func (u *SignerUpsertOne) AddPoints(v int64) *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.AddPoints(v) - }) -} - -// UpdatePoints sets the "points" field to the value that was provided on create. -func (u *SignerUpsertOne) UpdatePoints() *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.UpdatePoints() - }) -} - -// Exec executes the query. -func (u *SignerUpsertOne) Exec(ctx context.Context) error { - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for SignerCreate.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *SignerUpsertOne) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} - -// Exec executes the UPSERT query and returns the inserted/updated ID. -func (u *SignerUpsertOne) ID(ctx context.Context) (id int, err error) { - node, err := u.create.Save(ctx) - if err != nil { - return id, err - } - return node.ID, nil -} - -// IDX is like ID, but panics if an error occurs. -func (u *SignerUpsertOne) IDX(ctx context.Context) int { - id, err := u.ID(ctx) - if err != nil { - panic(err) - } - return id -} - -// SignerCreateBulk is the builder for creating many Signer entities in bulk. -type SignerCreateBulk struct { - config - err error - builders []*SignerCreate - conflict []sql.ConflictOption -} - -// Save creates the Signer entities in the database. -func (scb *SignerCreateBulk) Save(ctx context.Context) ([]*Signer, error) { - if scb.err != nil { - return nil, scb.err - } - specs := make([]*sqlgraph.CreateSpec, len(scb.builders)) - nodes := make([]*Signer, len(scb.builders)) - mutators := make([]Mutator, len(scb.builders)) - for i := range scb.builders { - func(i int, root context.Context) { - builder := scb.builders[i] - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*SignerMutation) - 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, scb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - spec.OnConflict = scb.conflict - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, scb.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, scb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (scb *SignerCreateBulk) SaveX(ctx context.Context) []*Signer { - v, err := scb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (scb *SignerCreateBulk) Exec(ctx context.Context) error { - _, err := scb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (scb *SignerCreateBulk) ExecX(ctx context.Context) { - if err := scb.Exec(ctx); err != nil { - panic(err) - } -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.Signer.CreateBulk(builders...). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.SignerUpsert) { -// SetName(v+v). -// }). -// Exec(ctx) -func (scb *SignerCreateBulk) OnConflict(opts ...sql.ConflictOption) *SignerUpsertBulk { - scb.conflict = opts - return &SignerUpsertBulk{ - create: scb, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.Signer.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (scb *SignerCreateBulk) OnConflictColumns(columns ...string) *SignerUpsertBulk { - scb.conflict = append(scb.conflict, sql.ConflictColumns(columns...)) - return &SignerUpsertBulk{ - create: scb, - } -} - -// SignerUpsertBulk is the builder for "upsert"-ing -// a bulk of Signer nodes. -type SignerUpsertBulk struct { - create *SignerCreateBulk -} - -// UpdateNewValues updates the mutable fields using the new values that -// were set on create. Using this option is equivalent to using: -// -// client.Signer.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *SignerUpsertBulk) UpdateNewValues() *SignerUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.Signer.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *SignerUpsertBulk) Ignore() *SignerUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *SignerUpsertBulk) DoNothing() *SignerUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the SignerCreateBulk.OnConflict -// documentation for more info. -func (u *SignerUpsertBulk) Update(set func(*SignerUpsert)) *SignerUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&SignerUpsert{UpdateSet: update}) - })) - return u -} - -// SetName sets the "name" field. -func (u *SignerUpsertBulk) SetName(v string) *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.SetName(v) - }) -} - -// UpdateName sets the "name" field to the value that was provided on create. -func (u *SignerUpsertBulk) UpdateName() *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.UpdateName() - }) -} - -// SetEvm sets the "evm" field. -func (u *SignerUpsertBulk) SetEvm(v string) *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.SetEvm(v) - }) -} - -// UpdateEvm sets the "evm" field to the value that was provided on create. -func (u *SignerUpsertBulk) UpdateEvm() *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.UpdateEvm() - }) -} - -// ClearEvm clears the value of the "evm" field. -func (u *SignerUpsertBulk) ClearEvm() *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.ClearEvm() - }) -} - -// SetKey sets the "key" field. -func (u *SignerUpsertBulk) SetKey(v []byte) *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.SetKey(v) - }) -} - -// UpdateKey sets the "key" field to the value that was provided on create. -func (u *SignerUpsertBulk) UpdateKey() *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.UpdateKey() - }) -} - -// SetShortkey sets the "shortkey" field. -func (u *SignerUpsertBulk) SetShortkey(v []byte) *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.SetShortkey(v) - }) -} - -// UpdateShortkey sets the "shortkey" field to the value that was provided on create. -func (u *SignerUpsertBulk) UpdateShortkey() *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.UpdateShortkey() - }) -} - -// SetPoints sets the "points" field. -func (u *SignerUpsertBulk) SetPoints(v int64) *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.SetPoints(v) - }) -} - -// AddPoints adds v to the "points" field. -func (u *SignerUpsertBulk) AddPoints(v int64) *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.AddPoints(v) - }) -} - -// UpdatePoints sets the "points" field to the value that was provided on create. -func (u *SignerUpsertBulk) UpdatePoints() *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.UpdatePoints() - }) -} - -// Exec executes the query. -func (u *SignerUpsertBulk) Exec(ctx context.Context) error { - if u.create.err != nil { - return u.create.err - } - for i, b := range u.create.builders { - if len(b.conflict) != 0 { - return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the SignerCreateBulk instead", i) - } - } - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for SignerCreateBulk.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *SignerUpsertBulk) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/ent/signer_delete.go b/internal/ent/signer_delete.go deleted file mode 100644 index e6d724ba..00000000 --- a/internal/ent/signer_delete.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// SignerDelete is the builder for deleting a Signer entity. -type SignerDelete struct { - config - hooks []Hook - mutation *SignerMutation -} - -// Where appends a list predicates to the SignerDelete builder. -func (sd *SignerDelete) Where(ps ...predicate.Signer) *SignerDelete { - sd.mutation.Where(ps...) - return sd -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (sd *SignerDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, sd.sqlExec, sd.mutation, sd.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (sd *SignerDelete) ExecX(ctx context.Context) int { - n, err := sd.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (sd *SignerDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(signer.Table, sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt)) - if ps := sd.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, sd.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - sd.mutation.done = true - return affected, err -} - -// SignerDeleteOne is the builder for deleting a single Signer entity. -type SignerDeleteOne struct { - sd *SignerDelete -} - -// Where appends a list predicates to the SignerDelete builder. -func (sdo *SignerDeleteOne) Where(ps ...predicate.Signer) *SignerDeleteOne { - sdo.sd.mutation.Where(ps...) - return sdo -} - -// Exec executes the deletion query. -func (sdo *SignerDeleteOne) Exec(ctx context.Context) error { - n, err := sdo.sd.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{signer.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (sdo *SignerDeleteOne) ExecX(ctx context.Context) { - if err := sdo.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/ent/signer_query.go b/internal/ent/signer_query.go deleted file mode 100644 index d189a69d..00000000 --- a/internal/ent/signer_query.go +++ /dev/null @@ -1,927 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "database/sql/driver" - "fmt" - "math" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// SignerQuery is the builder for querying Signer entities. -type SignerQuery struct { - config - ctx *QueryContext - order []signer.OrderOption - inters []Interceptor - predicates []predicate.Signer - withAssetPrice *AssetPriceQuery - withEventLogs *EventLogQuery - withCorrectnessReport *CorrectnessReportQuery - modifiers []func(*sql.Selector) - loadTotal []func(context.Context, []*Signer) error - withNamedAssetPrice map[string]*AssetPriceQuery - withNamedEventLogs map[string]*EventLogQuery - withNamedCorrectnessReport map[string]*CorrectnessReportQuery - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the SignerQuery builder. -func (sq *SignerQuery) Where(ps ...predicate.Signer) *SignerQuery { - sq.predicates = append(sq.predicates, ps...) - return sq -} - -// Limit the number of records to be returned by this query. -func (sq *SignerQuery) Limit(limit int) *SignerQuery { - sq.ctx.Limit = &limit - return sq -} - -// Offset to start from. -func (sq *SignerQuery) Offset(offset int) *SignerQuery { - sq.ctx.Offset = &offset - return sq -} - -// 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 (sq *SignerQuery) Unique(unique bool) *SignerQuery { - sq.ctx.Unique = &unique - return sq -} - -// Order specifies how the records should be ordered. -func (sq *SignerQuery) Order(o ...signer.OrderOption) *SignerQuery { - sq.order = append(sq.order, o...) - return sq -} - -// QueryAssetPrice chains the current query on the "assetPrice" edge. -func (sq *SignerQuery) QueryAssetPrice() *AssetPriceQuery { - query := (&AssetPriceClient{config: sq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := sq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := sq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(signer.Table, signer.FieldID, selector), - sqlgraph.To(assetprice.Table, assetprice.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, signer.AssetPriceTable, signer.AssetPricePrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryEventLogs chains the current query on the "eventLogs" edge. -func (sq *SignerQuery) QueryEventLogs() *EventLogQuery { - query := (&EventLogClient{config: sq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := sq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := sq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(signer.Table, signer.FieldID, selector), - sqlgraph.To(eventlog.Table, eventlog.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, signer.EventLogsTable, signer.EventLogsPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryCorrectnessReport chains the current query on the "correctnessReport" edge. -func (sq *SignerQuery) QueryCorrectnessReport() *CorrectnessReportQuery { - query := (&CorrectnessReportClient{config: sq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := sq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := sq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(signer.Table, signer.FieldID, selector), - sqlgraph.To(correctnessreport.Table, correctnessreport.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, signer.CorrectnessReportTable, signer.CorrectnessReportPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first Signer entity from the query. -// Returns a *NotFoundError when no Signer was found. -func (sq *SignerQuery) First(ctx context.Context) (*Signer, error) { - nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First")) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{signer.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (sq *SignerQuery) FirstX(ctx context.Context) *Signer { - node, err := sq.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first Signer ID from the query. -// Returns a *NotFoundError when no Signer ID was found. -func (sq *SignerQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, "FirstID")); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{signer.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (sq *SignerQuery) FirstIDX(ctx context.Context) int { - id, err := sq.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single Signer entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one Signer entity is found. -// Returns a *NotFoundError when no Signer entities are found. -func (sq *SignerQuery) Only(ctx context.Context) (*Signer, error) { - nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, "Only")) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{signer.Label} - default: - return nil, &NotSingularError{signer.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (sq *SignerQuery) OnlyX(ctx context.Context) *Signer { - node, err := sq.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only Signer ID in the query. -// Returns a *NotSingularError when more than one Signer ID is found. -// Returns a *NotFoundError when no entities are found. -func (sq *SignerQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, "OnlyID")); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{signer.Label} - default: - err = &NotSingularError{signer.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (sq *SignerQuery) OnlyIDX(ctx context.Context) int { - id, err := sq.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of Signers. -func (sq *SignerQuery) All(ctx context.Context) ([]*Signer, error) { - ctx = setContextOp(ctx, sq.ctx, "All") - if err := sq.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*Signer, *SignerQuery]() - return withInterceptors[[]*Signer](ctx, sq, qr, sq.inters) -} - -// AllX is like All, but panics if an error occurs. -func (sq *SignerQuery) AllX(ctx context.Context) []*Signer { - nodes, err := sq.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of Signer IDs. -func (sq *SignerQuery) IDs(ctx context.Context) (ids []int, err error) { - if sq.ctx.Unique == nil && sq.path != nil { - sq.Unique(true) - } - ctx = setContextOp(ctx, sq.ctx, "IDs") - if err = sq.Select(signer.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (sq *SignerQuery) IDsX(ctx context.Context) []int { - ids, err := sq.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (sq *SignerQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, sq.ctx, "Count") - if err := sq.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, sq, querierCount[*SignerQuery](), sq.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (sq *SignerQuery) CountX(ctx context.Context) int { - count, err := sq.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (sq *SignerQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, sq.ctx, "Exist") - switch _, err := sq.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 (sq *SignerQuery) ExistX(ctx context.Context) bool { - exist, err := sq.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the SignerQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (sq *SignerQuery) Clone() *SignerQuery { - if sq == nil { - return nil - } - return &SignerQuery{ - config: sq.config, - ctx: sq.ctx.Clone(), - order: append([]signer.OrderOption{}, sq.order...), - inters: append([]Interceptor{}, sq.inters...), - predicates: append([]predicate.Signer{}, sq.predicates...), - withAssetPrice: sq.withAssetPrice.Clone(), - withEventLogs: sq.withEventLogs.Clone(), - withCorrectnessReport: sq.withCorrectnessReport.Clone(), - // clone intermediate query. - sql: sq.sql.Clone(), - path: sq.path, - } -} - -// WithAssetPrice tells the query-builder to eager-load the nodes that are connected to -// the "assetPrice" edge. The optional arguments are used to configure the query builder of the edge. -func (sq *SignerQuery) WithAssetPrice(opts ...func(*AssetPriceQuery)) *SignerQuery { - query := (&AssetPriceClient{config: sq.config}).Query() - for _, opt := range opts { - opt(query) - } - sq.withAssetPrice = query - return sq -} - -// WithEventLogs tells the query-builder to eager-load the nodes that are connected to -// the "eventLogs" edge. The optional arguments are used to configure the query builder of the edge. -func (sq *SignerQuery) WithEventLogs(opts ...func(*EventLogQuery)) *SignerQuery { - query := (&EventLogClient{config: sq.config}).Query() - for _, opt := range opts { - opt(query) - } - sq.withEventLogs = query - return sq -} - -// WithCorrectnessReport tells the query-builder to eager-load the nodes that are connected to -// the "correctnessReport" edge. The optional arguments are used to configure the query builder of the edge. -func (sq *SignerQuery) WithCorrectnessReport(opts ...func(*CorrectnessReportQuery)) *SignerQuery { - query := (&CorrectnessReportClient{config: sq.config}).Query() - for _, opt := range opts { - opt(query) - } - sq.withCorrectnessReport = query - return sq -} - -// 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 { -// Name string `json:"name,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.Signer.Query(). -// GroupBy(signer.FieldName). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (sq *SignerQuery) GroupBy(field string, fields ...string) *SignerGroupBy { - sq.ctx.Fields = append([]string{field}, fields...) - grbuild := &SignerGroupBy{build: sq} - grbuild.flds = &sq.ctx.Fields - grbuild.label = signer.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 { -// Name string `json:"name,omitempty"` -// } -// -// client.Signer.Query(). -// Select(signer.FieldName). -// Scan(ctx, &v) -func (sq *SignerQuery) Select(fields ...string) *SignerSelect { - sq.ctx.Fields = append(sq.ctx.Fields, fields...) - sbuild := &SignerSelect{SignerQuery: sq} - sbuild.label = signer.Label - sbuild.flds, sbuild.scan = &sq.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a SignerSelect configured with the given aggregations. -func (sq *SignerQuery) Aggregate(fns ...AggregateFunc) *SignerSelect { - return sq.Select().Aggregate(fns...) -} - -func (sq *SignerQuery) prepareQuery(ctx context.Context) error { - for _, inter := range sq.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, sq); err != nil { - return err - } - } - } - for _, f := range sq.ctx.Fields { - if !signer.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if sq.path != nil { - prev, err := sq.path(ctx) - if err != nil { - return err - } - sq.sql = prev - } - return nil -} - -func (sq *SignerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Signer, error) { - var ( - nodes = []*Signer{} - _spec = sq.querySpec() - loadedTypes = [3]bool{ - sq.withAssetPrice != nil, - sq.withEventLogs != nil, - sq.withCorrectnessReport != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*Signer).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &Signer{config: sq.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(sq.modifiers) > 0 { - _spec.Modifiers = sq.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, sq.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := sq.withAssetPrice; query != nil { - if err := sq.loadAssetPrice(ctx, query, nodes, - func(n *Signer) { n.Edges.AssetPrice = []*AssetPrice{} }, - func(n *Signer, e *AssetPrice) { n.Edges.AssetPrice = append(n.Edges.AssetPrice, e) }); err != nil { - return nil, err - } - } - if query := sq.withEventLogs; query != nil { - if err := sq.loadEventLogs(ctx, query, nodes, - func(n *Signer) { n.Edges.EventLogs = []*EventLog{} }, - func(n *Signer, e *EventLog) { n.Edges.EventLogs = append(n.Edges.EventLogs, e) }); err != nil { - return nil, err - } - } - if query := sq.withCorrectnessReport; query != nil { - if err := sq.loadCorrectnessReport(ctx, query, nodes, - func(n *Signer) { n.Edges.CorrectnessReport = []*CorrectnessReport{} }, - func(n *Signer, e *CorrectnessReport) { - n.Edges.CorrectnessReport = append(n.Edges.CorrectnessReport, e) - }); err != nil { - return nil, err - } - } - for name, query := range sq.withNamedAssetPrice { - if err := sq.loadAssetPrice(ctx, query, nodes, - func(n *Signer) { n.appendNamedAssetPrice(name) }, - func(n *Signer, e *AssetPrice) { n.appendNamedAssetPrice(name, e) }); err != nil { - return nil, err - } - } - for name, query := range sq.withNamedEventLogs { - if err := sq.loadEventLogs(ctx, query, nodes, - func(n *Signer) { n.appendNamedEventLogs(name) }, - func(n *Signer, e *EventLog) { n.appendNamedEventLogs(name, e) }); err != nil { - return nil, err - } - } - for name, query := range sq.withNamedCorrectnessReport { - if err := sq.loadCorrectnessReport(ctx, query, nodes, - func(n *Signer) { n.appendNamedCorrectnessReport(name) }, - func(n *Signer, e *CorrectnessReport) { n.appendNamedCorrectnessReport(name, e) }); err != nil { - return nil, err - } - } - for i := range sq.loadTotal { - if err := sq.loadTotal[i](ctx, nodes); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (sq *SignerQuery) loadAssetPrice(ctx context.Context, query *AssetPriceQuery, nodes []*Signer, init func(*Signer), assign func(*Signer, *AssetPrice)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int]*Signer) - nids := make(map[int]map[*Signer]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(signer.AssetPriceTable) - s.Join(joinT).On(s.C(assetprice.FieldID), joinT.C(signer.AssetPricePrimaryKey[0])) - s.Where(sql.InValues(joinT.C(signer.AssetPricePrimaryKey[1]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(signer.AssetPricePrimaryKey[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[*Signer]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*AssetPrice](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 "assetPrice" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} -func (sq *SignerQuery) loadEventLogs(ctx context.Context, query *EventLogQuery, nodes []*Signer, init func(*Signer), assign func(*Signer, *EventLog)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int]*Signer) - nids := make(map[int]map[*Signer]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(signer.EventLogsTable) - s.Join(joinT).On(s.C(eventlog.FieldID), joinT.C(signer.EventLogsPrimaryKey[0])) - s.Where(sql.InValues(joinT.C(signer.EventLogsPrimaryKey[1]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(signer.EventLogsPrimaryKey[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[*Signer]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*EventLog](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 "eventLogs" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} -func (sq *SignerQuery) loadCorrectnessReport(ctx context.Context, query *CorrectnessReportQuery, nodes []*Signer, init func(*Signer), assign func(*Signer, *CorrectnessReport)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int]*Signer) - nids := make(map[int]map[*Signer]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(signer.CorrectnessReportTable) - s.Join(joinT).On(s.C(correctnessreport.FieldID), joinT.C(signer.CorrectnessReportPrimaryKey[0])) - s.Where(sql.InValues(joinT.C(signer.CorrectnessReportPrimaryKey[1]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(signer.CorrectnessReportPrimaryKey[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[*Signer]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*CorrectnessReport](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 "correctnessReport" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} - -func (sq *SignerQuery) sqlCount(ctx context.Context) (int, error) { - _spec := sq.querySpec() - if len(sq.modifiers) > 0 { - _spec.Modifiers = sq.modifiers - } - _spec.Node.Columns = sq.ctx.Fields - if len(sq.ctx.Fields) > 0 { - _spec.Unique = sq.ctx.Unique != nil && *sq.ctx.Unique - } - return sqlgraph.CountNodes(ctx, sq.driver, _spec) -} - -func (sq *SignerQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(signer.Table, signer.Columns, sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt)) - _spec.From = sq.sql - if unique := sq.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if sq.path != nil { - _spec.Unique = true - } - if fields := sq.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, signer.FieldID) - for i := range fields { - if fields[i] != signer.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := sq.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := sq.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := sq.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := sq.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (sq *SignerQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(sq.driver.Dialect()) - t1 := builder.Table(signer.Table) - columns := sq.ctx.Fields - if len(columns) == 0 { - columns = signer.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if sq.sql != nil { - selector = sq.sql - selector.Select(selector.Columns(columns...)...) - } - if sq.ctx.Unique != nil && *sq.ctx.Unique { - selector.Distinct() - } - for _, p := range sq.predicates { - p(selector) - } - for _, p := range sq.order { - p(selector) - } - if offset := sq.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 := sq.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// WithNamedAssetPrice tells the query-builder to eager-load the nodes that are connected to the "assetPrice" -// edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (sq *SignerQuery) WithNamedAssetPrice(name string, opts ...func(*AssetPriceQuery)) *SignerQuery { - query := (&AssetPriceClient{config: sq.config}).Query() - for _, opt := range opts { - opt(query) - } - if sq.withNamedAssetPrice == nil { - sq.withNamedAssetPrice = make(map[string]*AssetPriceQuery) - } - sq.withNamedAssetPrice[name] = query - return sq -} - -// WithNamedEventLogs tells the query-builder to eager-load the nodes that are connected to the "eventLogs" -// edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (sq *SignerQuery) WithNamedEventLogs(name string, opts ...func(*EventLogQuery)) *SignerQuery { - query := (&EventLogClient{config: sq.config}).Query() - for _, opt := range opts { - opt(query) - } - if sq.withNamedEventLogs == nil { - sq.withNamedEventLogs = make(map[string]*EventLogQuery) - } - sq.withNamedEventLogs[name] = query - return sq -} - -// WithNamedCorrectnessReport tells the query-builder to eager-load the nodes that are connected to the "correctnessReport" -// edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (sq *SignerQuery) WithNamedCorrectnessReport(name string, opts ...func(*CorrectnessReportQuery)) *SignerQuery { - query := (&CorrectnessReportClient{config: sq.config}).Query() - for _, opt := range opts { - opt(query) - } - if sq.withNamedCorrectnessReport == nil { - sq.withNamedCorrectnessReport = make(map[string]*CorrectnessReportQuery) - } - sq.withNamedCorrectnessReport[name] = query - return sq -} - -// SignerGroupBy is the group-by builder for Signer entities. -type SignerGroupBy struct { - selector - build *SignerQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (sgb *SignerGroupBy) Aggregate(fns ...AggregateFunc) *SignerGroupBy { - sgb.fns = append(sgb.fns, fns...) - return sgb -} - -// Scan applies the selector query and scans the result into the given value. -func (sgb *SignerGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, sgb.build.ctx, "GroupBy") - if err := sgb.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*SignerQuery, *SignerGroupBy](ctx, sgb.build, sgb, sgb.build.inters, v) -} - -func (sgb *SignerGroupBy) sqlScan(ctx context.Context, root *SignerQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(sgb.fns)) - for _, fn := range sgb.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*sgb.flds)+len(sgb.fns)) - for _, f := range *sgb.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*sgb.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := sgb.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// SignerSelect is the builder for selecting fields of Signer entities. -type SignerSelect struct { - *SignerQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (ss *SignerSelect) Aggregate(fns ...AggregateFunc) *SignerSelect { - ss.fns = append(ss.fns, fns...) - return ss -} - -// Scan applies the selector query and scans the result into the given value. -func (ss *SignerSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ss.ctx, "Select") - if err := ss.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*SignerQuery, *SignerSelect](ctx, ss.SignerQuery, ss, ss.inters, v) -} - -func (ss *SignerSelect) sqlScan(ctx context.Context, root *SignerQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(ss.fns)) - for _, fn := range ss.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*ss.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 := ss.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} diff --git a/internal/ent/signer_update.go b/internal/ent/signer_update.go deleted file mode 100644 index 3c48ffb2..00000000 --- a/internal/ent/signer_update.go +++ /dev/null @@ -1,886 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// SignerUpdate is the builder for updating Signer entities. -type SignerUpdate struct { - config - hooks []Hook - mutation *SignerMutation -} - -// Where appends a list predicates to the SignerUpdate builder. -func (su *SignerUpdate) Where(ps ...predicate.Signer) *SignerUpdate { - su.mutation.Where(ps...) - return su -} - -// SetName sets the "name" field. -func (su *SignerUpdate) SetName(s string) *SignerUpdate { - su.mutation.SetName(s) - return su -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (su *SignerUpdate) SetNillableName(s *string) *SignerUpdate { - if s != nil { - su.SetName(*s) - } - return su -} - -// SetEvm sets the "evm" field. -func (su *SignerUpdate) SetEvm(s string) *SignerUpdate { - su.mutation.SetEvm(s) - return su -} - -// SetNillableEvm sets the "evm" field if the given value is not nil. -func (su *SignerUpdate) SetNillableEvm(s *string) *SignerUpdate { - if s != nil { - su.SetEvm(*s) - } - return su -} - -// ClearEvm clears the value of the "evm" field. -func (su *SignerUpdate) ClearEvm() *SignerUpdate { - su.mutation.ClearEvm() - return su -} - -// SetKey sets the "key" field. -func (su *SignerUpdate) SetKey(b []byte) *SignerUpdate { - su.mutation.SetKey(b) - return su -} - -// SetShortkey sets the "shortkey" field. -func (su *SignerUpdate) SetShortkey(b []byte) *SignerUpdate { - su.mutation.SetShortkey(b) - return su -} - -// SetPoints sets the "points" field. -func (su *SignerUpdate) SetPoints(i int64) *SignerUpdate { - su.mutation.ResetPoints() - su.mutation.SetPoints(i) - return su -} - -// SetNillablePoints sets the "points" field if the given value is not nil. -func (su *SignerUpdate) SetNillablePoints(i *int64) *SignerUpdate { - if i != nil { - su.SetPoints(*i) - } - return su -} - -// AddPoints adds i to the "points" field. -func (su *SignerUpdate) AddPoints(i int64) *SignerUpdate { - su.mutation.AddPoints(i) - return su -} - -// AddAssetPriceIDs adds the "assetPrice" edge to the AssetPrice entity by IDs. -func (su *SignerUpdate) AddAssetPriceIDs(ids ...int) *SignerUpdate { - su.mutation.AddAssetPriceIDs(ids...) - return su -} - -// AddAssetPrice adds the "assetPrice" edges to the AssetPrice entity. -func (su *SignerUpdate) AddAssetPrice(a ...*AssetPrice) *SignerUpdate { - ids := make([]int, len(a)) - for i := range a { - ids[i] = a[i].ID - } - return su.AddAssetPriceIDs(ids...) -} - -// AddEventLogIDs adds the "eventLogs" edge to the EventLog entity by IDs. -func (su *SignerUpdate) AddEventLogIDs(ids ...int) *SignerUpdate { - su.mutation.AddEventLogIDs(ids...) - return su -} - -// AddEventLogs adds the "eventLogs" edges to the EventLog entity. -func (su *SignerUpdate) AddEventLogs(e ...*EventLog) *SignerUpdate { - ids := make([]int, len(e)) - for i := range e { - ids[i] = e[i].ID - } - return su.AddEventLogIDs(ids...) -} - -// AddCorrectnessReportIDs adds the "correctnessReport" edge to the CorrectnessReport entity by IDs. -func (su *SignerUpdate) AddCorrectnessReportIDs(ids ...int) *SignerUpdate { - su.mutation.AddCorrectnessReportIDs(ids...) - return su -} - -// AddCorrectnessReport adds the "correctnessReport" edges to the CorrectnessReport entity. -func (su *SignerUpdate) AddCorrectnessReport(c ...*CorrectnessReport) *SignerUpdate { - ids := make([]int, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return su.AddCorrectnessReportIDs(ids...) -} - -// Mutation returns the SignerMutation object of the builder. -func (su *SignerUpdate) Mutation() *SignerMutation { - return su.mutation -} - -// ClearAssetPrice clears all "assetPrice" edges to the AssetPrice entity. -func (su *SignerUpdate) ClearAssetPrice() *SignerUpdate { - su.mutation.ClearAssetPrice() - return su -} - -// RemoveAssetPriceIDs removes the "assetPrice" edge to AssetPrice entities by IDs. -func (su *SignerUpdate) RemoveAssetPriceIDs(ids ...int) *SignerUpdate { - su.mutation.RemoveAssetPriceIDs(ids...) - return su -} - -// RemoveAssetPrice removes "assetPrice" edges to AssetPrice entities. -func (su *SignerUpdate) RemoveAssetPrice(a ...*AssetPrice) *SignerUpdate { - ids := make([]int, len(a)) - for i := range a { - ids[i] = a[i].ID - } - return su.RemoveAssetPriceIDs(ids...) -} - -// ClearEventLogs clears all "eventLogs" edges to the EventLog entity. -func (su *SignerUpdate) ClearEventLogs() *SignerUpdate { - su.mutation.ClearEventLogs() - return su -} - -// RemoveEventLogIDs removes the "eventLogs" edge to EventLog entities by IDs. -func (su *SignerUpdate) RemoveEventLogIDs(ids ...int) *SignerUpdate { - su.mutation.RemoveEventLogIDs(ids...) - return su -} - -// RemoveEventLogs removes "eventLogs" edges to EventLog entities. -func (su *SignerUpdate) RemoveEventLogs(e ...*EventLog) *SignerUpdate { - ids := make([]int, len(e)) - for i := range e { - ids[i] = e[i].ID - } - return su.RemoveEventLogIDs(ids...) -} - -// ClearCorrectnessReport clears all "correctnessReport" edges to the CorrectnessReport entity. -func (su *SignerUpdate) ClearCorrectnessReport() *SignerUpdate { - su.mutation.ClearCorrectnessReport() - return su -} - -// RemoveCorrectnessReportIDs removes the "correctnessReport" edge to CorrectnessReport entities by IDs. -func (su *SignerUpdate) RemoveCorrectnessReportIDs(ids ...int) *SignerUpdate { - su.mutation.RemoveCorrectnessReportIDs(ids...) - return su -} - -// RemoveCorrectnessReport removes "correctnessReport" edges to CorrectnessReport entities. -func (su *SignerUpdate) RemoveCorrectnessReport(c ...*CorrectnessReport) *SignerUpdate { - ids := make([]int, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return su.RemoveCorrectnessReportIDs(ids...) -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (su *SignerUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, su.sqlSave, su.mutation, su.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (su *SignerUpdate) SaveX(ctx context.Context) int { - affected, err := su.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (su *SignerUpdate) Exec(ctx context.Context) error { - _, err := su.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (su *SignerUpdate) ExecX(ctx context.Context) { - if err := su.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (su *SignerUpdate) check() error { - if v, ok := su.mutation.Name(); ok { - if err := signer.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Signer.name": %w`, err)} - } - } - if v, ok := su.mutation.Key(); ok { - if err := signer.KeyValidator(v); err != nil { - return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "Signer.key": %w`, err)} - } - } - if v, ok := su.mutation.Shortkey(); ok { - if err := signer.ShortkeyValidator(v); err != nil { - return &ValidationError{Name: "shortkey", err: fmt.Errorf(`ent: validator failed for field "Signer.shortkey": %w`, err)} - } - } - return nil -} - -func (su *SignerUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := su.check(); err != nil { - return n, err - } - _spec := sqlgraph.NewUpdateSpec(signer.Table, signer.Columns, sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt)) - if ps := su.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := su.mutation.Name(); ok { - _spec.SetField(signer.FieldName, field.TypeString, value) - } - if value, ok := su.mutation.Evm(); ok { - _spec.SetField(signer.FieldEvm, field.TypeString, value) - } - if su.mutation.EvmCleared() { - _spec.ClearField(signer.FieldEvm, field.TypeString) - } - if value, ok := su.mutation.Key(); ok { - _spec.SetField(signer.FieldKey, field.TypeBytes, value) - } - if value, ok := su.mutation.Shortkey(); ok { - _spec.SetField(signer.FieldShortkey, field.TypeBytes, value) - } - if value, ok := su.mutation.Points(); ok { - _spec.SetField(signer.FieldPoints, field.TypeInt64, value) - } - if value, ok := su.mutation.AddedPoints(); ok { - _spec.AddField(signer.FieldPoints, field.TypeInt64, value) - } - if su.mutation.AssetPriceCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.AssetPriceTable, - Columns: signer.AssetPricePrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := su.mutation.RemovedAssetPriceIDs(); len(nodes) > 0 && !su.mutation.AssetPriceCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.AssetPriceTable, - Columns: signer.AssetPricePrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(assetprice.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 := su.mutation.AssetPriceIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.AssetPriceTable, - Columns: signer.AssetPricePrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if su.mutation.EventLogsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.EventLogsTable, - Columns: signer.EventLogsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := su.mutation.RemovedEventLogsIDs(); len(nodes) > 0 && !su.mutation.EventLogsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.EventLogsTable, - Columns: signer.EventLogsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(eventlog.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 := su.mutation.EventLogsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.EventLogsTable, - Columns: signer.EventLogsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if su.mutation.CorrectnessReportCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.CorrectnessReportTable, - Columns: signer.CorrectnessReportPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(correctnessreport.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := su.mutation.RemovedCorrectnessReportIDs(); len(nodes) > 0 && !su.mutation.CorrectnessReportCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.CorrectnessReportTable, - Columns: signer.CorrectnessReportPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(correctnessreport.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 := su.mutation.CorrectnessReportIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.CorrectnessReportTable, - Columns: signer.CorrectnessReportPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(correctnessreport.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, su.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{signer.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - su.mutation.done = true - return n, nil -} - -// SignerUpdateOne is the builder for updating a single Signer entity. -type SignerUpdateOne struct { - config - fields []string - hooks []Hook - mutation *SignerMutation -} - -// SetName sets the "name" field. -func (suo *SignerUpdateOne) SetName(s string) *SignerUpdateOne { - suo.mutation.SetName(s) - return suo -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (suo *SignerUpdateOne) SetNillableName(s *string) *SignerUpdateOne { - if s != nil { - suo.SetName(*s) - } - return suo -} - -// SetEvm sets the "evm" field. -func (suo *SignerUpdateOne) SetEvm(s string) *SignerUpdateOne { - suo.mutation.SetEvm(s) - return suo -} - -// SetNillableEvm sets the "evm" field if the given value is not nil. -func (suo *SignerUpdateOne) SetNillableEvm(s *string) *SignerUpdateOne { - if s != nil { - suo.SetEvm(*s) - } - return suo -} - -// ClearEvm clears the value of the "evm" field. -func (suo *SignerUpdateOne) ClearEvm() *SignerUpdateOne { - suo.mutation.ClearEvm() - return suo -} - -// SetKey sets the "key" field. -func (suo *SignerUpdateOne) SetKey(b []byte) *SignerUpdateOne { - suo.mutation.SetKey(b) - return suo -} - -// SetShortkey sets the "shortkey" field. -func (suo *SignerUpdateOne) SetShortkey(b []byte) *SignerUpdateOne { - suo.mutation.SetShortkey(b) - return suo -} - -// SetPoints sets the "points" field. -func (suo *SignerUpdateOne) SetPoints(i int64) *SignerUpdateOne { - suo.mutation.ResetPoints() - suo.mutation.SetPoints(i) - return suo -} - -// SetNillablePoints sets the "points" field if the given value is not nil. -func (suo *SignerUpdateOne) SetNillablePoints(i *int64) *SignerUpdateOne { - if i != nil { - suo.SetPoints(*i) - } - return suo -} - -// AddPoints adds i to the "points" field. -func (suo *SignerUpdateOne) AddPoints(i int64) *SignerUpdateOne { - suo.mutation.AddPoints(i) - return suo -} - -// AddAssetPriceIDs adds the "assetPrice" edge to the AssetPrice entity by IDs. -func (suo *SignerUpdateOne) AddAssetPriceIDs(ids ...int) *SignerUpdateOne { - suo.mutation.AddAssetPriceIDs(ids...) - return suo -} - -// AddAssetPrice adds the "assetPrice" edges to the AssetPrice entity. -func (suo *SignerUpdateOne) AddAssetPrice(a ...*AssetPrice) *SignerUpdateOne { - ids := make([]int, len(a)) - for i := range a { - ids[i] = a[i].ID - } - return suo.AddAssetPriceIDs(ids...) -} - -// AddEventLogIDs adds the "eventLogs" edge to the EventLog entity by IDs. -func (suo *SignerUpdateOne) AddEventLogIDs(ids ...int) *SignerUpdateOne { - suo.mutation.AddEventLogIDs(ids...) - return suo -} - -// AddEventLogs adds the "eventLogs" edges to the EventLog entity. -func (suo *SignerUpdateOne) AddEventLogs(e ...*EventLog) *SignerUpdateOne { - ids := make([]int, len(e)) - for i := range e { - ids[i] = e[i].ID - } - return suo.AddEventLogIDs(ids...) -} - -// AddCorrectnessReportIDs adds the "correctnessReport" edge to the CorrectnessReport entity by IDs. -func (suo *SignerUpdateOne) AddCorrectnessReportIDs(ids ...int) *SignerUpdateOne { - suo.mutation.AddCorrectnessReportIDs(ids...) - return suo -} - -// AddCorrectnessReport adds the "correctnessReport" edges to the CorrectnessReport entity. -func (suo *SignerUpdateOne) AddCorrectnessReport(c ...*CorrectnessReport) *SignerUpdateOne { - ids := make([]int, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return suo.AddCorrectnessReportIDs(ids...) -} - -// Mutation returns the SignerMutation object of the builder. -func (suo *SignerUpdateOne) Mutation() *SignerMutation { - return suo.mutation -} - -// ClearAssetPrice clears all "assetPrice" edges to the AssetPrice entity. -func (suo *SignerUpdateOne) ClearAssetPrice() *SignerUpdateOne { - suo.mutation.ClearAssetPrice() - return suo -} - -// RemoveAssetPriceIDs removes the "assetPrice" edge to AssetPrice entities by IDs. -func (suo *SignerUpdateOne) RemoveAssetPriceIDs(ids ...int) *SignerUpdateOne { - suo.mutation.RemoveAssetPriceIDs(ids...) - return suo -} - -// RemoveAssetPrice removes "assetPrice" edges to AssetPrice entities. -func (suo *SignerUpdateOne) RemoveAssetPrice(a ...*AssetPrice) *SignerUpdateOne { - ids := make([]int, len(a)) - for i := range a { - ids[i] = a[i].ID - } - return suo.RemoveAssetPriceIDs(ids...) -} - -// ClearEventLogs clears all "eventLogs" edges to the EventLog entity. -func (suo *SignerUpdateOne) ClearEventLogs() *SignerUpdateOne { - suo.mutation.ClearEventLogs() - return suo -} - -// RemoveEventLogIDs removes the "eventLogs" edge to EventLog entities by IDs. -func (suo *SignerUpdateOne) RemoveEventLogIDs(ids ...int) *SignerUpdateOne { - suo.mutation.RemoveEventLogIDs(ids...) - return suo -} - -// RemoveEventLogs removes "eventLogs" edges to EventLog entities. -func (suo *SignerUpdateOne) RemoveEventLogs(e ...*EventLog) *SignerUpdateOne { - ids := make([]int, len(e)) - for i := range e { - ids[i] = e[i].ID - } - return suo.RemoveEventLogIDs(ids...) -} - -// ClearCorrectnessReport clears all "correctnessReport" edges to the CorrectnessReport entity. -func (suo *SignerUpdateOne) ClearCorrectnessReport() *SignerUpdateOne { - suo.mutation.ClearCorrectnessReport() - return suo -} - -// RemoveCorrectnessReportIDs removes the "correctnessReport" edge to CorrectnessReport entities by IDs. -func (suo *SignerUpdateOne) RemoveCorrectnessReportIDs(ids ...int) *SignerUpdateOne { - suo.mutation.RemoveCorrectnessReportIDs(ids...) - return suo -} - -// RemoveCorrectnessReport removes "correctnessReport" edges to CorrectnessReport entities. -func (suo *SignerUpdateOne) RemoveCorrectnessReport(c ...*CorrectnessReport) *SignerUpdateOne { - ids := make([]int, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return suo.RemoveCorrectnessReportIDs(ids...) -} - -// Where appends a list predicates to the SignerUpdate builder. -func (suo *SignerUpdateOne) Where(ps ...predicate.Signer) *SignerUpdateOne { - suo.mutation.Where(ps...) - return suo -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (suo *SignerUpdateOne) Select(field string, fields ...string) *SignerUpdateOne { - suo.fields = append([]string{field}, fields...) - return suo -} - -// Save executes the query and returns the updated Signer entity. -func (suo *SignerUpdateOne) Save(ctx context.Context) (*Signer, error) { - return withHooks(ctx, suo.sqlSave, suo.mutation, suo.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (suo *SignerUpdateOne) SaveX(ctx context.Context) *Signer { - node, err := suo.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (suo *SignerUpdateOne) Exec(ctx context.Context) error { - _, err := suo.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (suo *SignerUpdateOne) ExecX(ctx context.Context) { - if err := suo.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (suo *SignerUpdateOne) check() error { - if v, ok := suo.mutation.Name(); ok { - if err := signer.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Signer.name": %w`, err)} - } - } - if v, ok := suo.mutation.Key(); ok { - if err := signer.KeyValidator(v); err != nil { - return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "Signer.key": %w`, err)} - } - } - if v, ok := suo.mutation.Shortkey(); ok { - if err := signer.ShortkeyValidator(v); err != nil { - return &ValidationError{Name: "shortkey", err: fmt.Errorf(`ent: validator failed for field "Signer.shortkey": %w`, err)} - } - } - return nil -} - -func (suo *SignerUpdateOne) sqlSave(ctx context.Context) (_node *Signer, err error) { - if err := suo.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(signer.Table, signer.Columns, sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt)) - id, ok := suo.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Signer.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := suo.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, signer.FieldID) - for _, f := range fields { - if !signer.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != signer.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := suo.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := suo.mutation.Name(); ok { - _spec.SetField(signer.FieldName, field.TypeString, value) - } - if value, ok := suo.mutation.Evm(); ok { - _spec.SetField(signer.FieldEvm, field.TypeString, value) - } - if suo.mutation.EvmCleared() { - _spec.ClearField(signer.FieldEvm, field.TypeString) - } - if value, ok := suo.mutation.Key(); ok { - _spec.SetField(signer.FieldKey, field.TypeBytes, value) - } - if value, ok := suo.mutation.Shortkey(); ok { - _spec.SetField(signer.FieldShortkey, field.TypeBytes, value) - } - if value, ok := suo.mutation.Points(); ok { - _spec.SetField(signer.FieldPoints, field.TypeInt64, value) - } - if value, ok := suo.mutation.AddedPoints(); ok { - _spec.AddField(signer.FieldPoints, field.TypeInt64, value) - } - if suo.mutation.AssetPriceCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.AssetPriceTable, - Columns: signer.AssetPricePrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := suo.mutation.RemovedAssetPriceIDs(); len(nodes) > 0 && !suo.mutation.AssetPriceCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.AssetPriceTable, - Columns: signer.AssetPricePrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(assetprice.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 := suo.mutation.AssetPriceIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.AssetPriceTable, - Columns: signer.AssetPricePrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if suo.mutation.EventLogsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.EventLogsTable, - Columns: signer.EventLogsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := suo.mutation.RemovedEventLogsIDs(); len(nodes) > 0 && !suo.mutation.EventLogsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.EventLogsTable, - Columns: signer.EventLogsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(eventlog.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 := suo.mutation.EventLogsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.EventLogsTable, - Columns: signer.EventLogsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if suo.mutation.CorrectnessReportCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.CorrectnessReportTable, - Columns: signer.CorrectnessReportPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(correctnessreport.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := suo.mutation.RemovedCorrectnessReportIDs(); len(nodes) > 0 && !suo.mutation.CorrectnessReportCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.CorrectnessReportTable, - Columns: signer.CorrectnessReportPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(correctnessreport.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 := suo.mutation.CorrectnessReportIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.CorrectnessReportTable, - Columns: signer.CorrectnessReportPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(correctnessreport.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _node = &Signer{config: suo.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{signer.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - suo.mutation.done = true - return _node, nil -} diff --git a/internal/ent/tx.go b/internal/ent/tx.go deleted file mode 100644 index 23c3301d..00000000 --- a/internal/ent/tx.go +++ /dev/null @@ -1,219 +0,0 @@ -// 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 - // AssetPrice is the client for interacting with the AssetPrice builders. - AssetPrice *AssetPriceClient - // CorrectnessReport is the client for interacting with the CorrectnessReport builders. - CorrectnessReport *CorrectnessReportClient - // EventLog is the client for interacting with the EventLog builders. - EventLog *EventLogClient - // Signer is the client for interacting with the Signer builders. - Signer *SignerClient - - // 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.AssetPrice = NewAssetPriceClient(tx.config) - tx.CorrectnessReport = NewCorrectnessReportClient(tx.config) - tx.EventLog = NewEventLogClient(tx.config) - tx.Signer = NewSignerClient(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: AssetPrice.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/internal/generate.go b/internal/generate.go index a37be673..4c8d5812 100644 --- a/internal/generate.go +++ b/internal/generate.go @@ -1,4 +1,3 @@ package main -//go:generate go run ./ent/entc.go //go:generate go run github.com/99designs/gqlgen diff --git a/internal/model/assetprice.go b/internal/model/assetprice.go index b609566d..19222a49 100644 --- a/internal/model/assetprice.go +++ b/internal/model/assetprice.go @@ -1,6 +1,10 @@ package model -import "math/big" +import ( + "bytes" + "encoding/gob" + "math/big" +) type AssetPrice struct { Pair string @@ -13,4 +17,14 @@ type AssetPrice struct { Consensus bool Voted big.Int SignerIDs []int + Signers []Signer +} + +func (a AssetPrice) Hash() []byte { + var b bytes.Buffer + err := gob.NewEncoder(&b).Encode(a) + if err != nil { + return nil + } + return b.Bytes() } diff --git a/internal/model/correctness.go b/internal/model/correctness.go index e119f97b..ba8be0f2 100644 --- a/internal/model/correctness.go +++ b/internal/model/correctness.go @@ -11,51 +11,6 @@ import ( sia "github.com/pouya-eghbali/go-sia/v2/pkg" ) -type CorrectnessReportPacket struct { - Correctness - Signature [48]byte -} - -func (c *CorrectnessReportPacket) Sia() sia.Sia { - return sia.New(). - EmbedBytes(c.Correctness.Sia().Bytes()). - AddByteArray8(c.Signature[:]) -} - -func (c *CorrectnessReportPacket) FromBytes(payload []byte) *CorrectnessReportPacket { - siaMessage := sia.NewFromBytes(payload) - - c.Correctness.FromSia(siaMessage) - copy(c.Signature[:], siaMessage.ReadByteArray8()) - - return c -} - -////// - -type BroadcastCorrectnessPacket struct { - Info Correctness - Signature [48]byte - Signer Signer -} - -func (b *BroadcastCorrectnessPacket) Sia() sia.Sia { - return sia.New(). - EmbedBytes(b.Info.Sia().Bytes()). - AddByteArray8(b.Signature[:]). - EmbedBytes(b.Signer.Sia().Bytes()) -} - -func (b *BroadcastCorrectnessPacket) FromBytes(payload []byte) *BroadcastCorrectnessPacket { - siaMessage := sia.NewFromBytes(payload) - - b.Info.FromSia(siaMessage) - copy(b.Signature[:], siaMessage.ReadByteArray8()) - b.Signer.FromSia(siaMessage) - - return b -} - type Correctness struct { SignersCount uint64 Signature []byte @@ -66,6 +21,8 @@ type Correctness struct { Hash []byte Topic [64]byte Correct bool + + Signers []Signer } func (c *Correctness) Sia() sia.Sia { @@ -90,12 +47,12 @@ func (c *Correctness) FromSia(sia sia.Sia) *Correctness { return c } -func (c *Correctness) Bls() (bls12381.G1Affine, error) { +func (c *Correctness) Bls() bls12381.G1Affine { hash, err := bls.Hash(c.Sia().Bytes()) if err != nil { utils.Logger.Error("Can't hash bls: %v", err) - return bls12381.G1Affine{}, err + return bls12381.G1Affine{} } - return hash, err + return hash } diff --git a/internal/model/dataframe.go b/internal/model/dataframe.go new file mode 100644 index 00000000..d49d3c26 --- /dev/null +++ b/internal/model/dataframe.go @@ -0,0 +1,9 @@ +package model + +import "time" + +type DataFrame struct { + Hash []byte `bson:"hash" json:"hash"` + Timestamp time.Time `bson:"timestamp" json:"timestamp"` + Data interface{} `bson:"data" gorm:"embedded" json:"data"` +} diff --git a/internal/model/logs.go b/internal/model/logs.go index 2d845702..f68ae5a4 100644 --- a/internal/model/logs.go +++ b/internal/model/logs.go @@ -2,9 +2,9 @@ package model import ( "encoding/json" + "math/big" "github.com/TimeleapLabs/unchained/internal/crypto/bls" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" "github.com/TimeleapLabs/unchained/internal/utils" bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" @@ -12,48 +12,6 @@ import ( sia "github.com/pouya-eghbali/go-sia/v2/pkg" ) -type EventLogReportPacket struct { - EventLog - Signature [48]byte -} - -func (e *EventLogReportPacket) Sia() sia.Sia { - return sia.New(). - EmbedBytes(e.EventLog.Sia().Bytes()). - AddByteArray8(e.Signature[:]) -} - -func (e *EventLogReportPacket) FromBytes(payload []byte) *EventLogReportPacket { - siaMessage := sia.NewFromBytes(payload) - e.EventLog.FromSia(siaMessage) - copy(e.Signature[:], siaMessage.ReadByteArray8()) - - return e -} - -type BroadcastEventPacket struct { - Info EventLog - Signature [48]byte - Signer Signer -} - -func (b *BroadcastEventPacket) Sia() sia.Sia { - return sia.New(). - EmbedBytes(b.Info.Sia().Bytes()). - AddByteArray8(b.Signature[:]). - EmbedBytes(b.Signer.Sia().Bytes()) -} - -func (b *BroadcastEventPacket) FromBytes(payload []byte) *BroadcastEventPacket { - siaMessage := sia.NewFromBytes(payload) - - b.Info.FromSia(siaMessage) - copy(b.Signature[:], siaMessage.ReadByteArray8()) - b.Signer.FromSia(siaMessage) - - return b -} - type EventLogArg struct { Name string `json:"Name"` Type string `json:"Type"` @@ -72,8 +30,9 @@ type EventLog struct { Consensus bool SignersCount uint64 SignerIDs []int + Signers []Signer Signature []byte - Voted *helpers.BigInt + Voted *big.Int } func (e *EventLog) Sia() sia.Sia { diff --git a/internal/model/price.go b/internal/model/price.go deleted file mode 100644 index 2422daf2..00000000 --- a/internal/model/price.go +++ /dev/null @@ -1,28 +0,0 @@ -package model - -import ( - sia "github.com/pouya-eghbali/go-sia/v2/pkg" -) - -type PriceReportPacket struct { - PriceInfo PriceInfo - Signature [48]byte -} - -func (p *PriceReportPacket) Sia() sia.Sia { - return sia.New(). - EmbedBytes(p.PriceInfo.Sia().Bytes()). - AddByteArray8(p.Signature[:]) -} - -func (p *PriceReportPacket) FromBytes(payload []byte) *PriceReportPacket { - siaMessage := sia.NewFromBytes(payload) - return p.FromSia(siaMessage) -} - -func (p *PriceReportPacket) FromSia(sia sia.Sia) *PriceReportPacket { - p.PriceInfo.FromSia(sia) - copy(p.Signature[:], sia.ReadByteArray8()) - - return p -} diff --git a/internal/model/proof.go b/internal/model/proof.go new file mode 100644 index 00000000..d69cd8e7 --- /dev/null +++ b/internal/model/proof.go @@ -0,0 +1,11 @@ +package model + +import "time" + +type Proof struct { + Hash []byte `bson:"hash" json:"hash"` + Timestamp time.Time `bson:"timestamp" json:"timestamp"` + Signature [48]byte `bson:"signature" json:"signature"` + Signers []Signer `bson:"signers" json:"signers"` + // list of signers (relations in Postgres, and an array in Mongo) +} diff --git a/internal/model/bls.go b/internal/model/signer.go similarity index 54% rename from internal/model/bls.go rename to internal/model/signer.go index ebbf554a..bd7d0606 100644 --- a/internal/model/bls.go +++ b/internal/model/signer.go @@ -1,7 +1,6 @@ package model import ( - bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" sia "github.com/pouya-eghbali/go-sia/v2/pkg" ) @@ -12,34 +11,6 @@ type Signer struct { ShortPublicKey [48]byte } -type Signature struct { - Signature bls12381.G1Affine - Signer Signer -} - -func (s *Signature) Sia() sia.Sia { - return sia.New(). - AddByteArray8(s.Signature.Marshal()). - EmbedBytes(s.Signer.Sia().Bytes()) -} - -func (s *Signature) FromBytes(payload []byte) *Signature { - siaMessage := sia.NewFromBytes(payload) - return s.FromSia(siaMessage) -} - -func (s *Signature) FromSia(sia sia.Sia) *Signature { - err := s.Signature.Unmarshal(sia.ReadByteArray8()) - - if err != nil { - s.Signature = bls12381.G1Affine{} - } - - s.Signer.FromSia(sia) - - return s -} - func (s *Signer) Sia() sia.Sia { return sia.New(). AddString8(s.Name). diff --git a/internal/model/uniswap.go b/internal/model/uniswap.go deleted file mode 100644 index 9b37c6e8..00000000 --- a/internal/model/uniswap.go +++ /dev/null @@ -1,115 +0,0 @@ -package model - -import ( - "math/big" - - "github.com/TimeleapLabs/unchained/internal/crypto/bls" - "github.com/TimeleapLabs/unchained/internal/utils" - - bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" - - sia "github.com/pouya-eghbali/go-sia/v2/pkg" -) - -type TokenKey struct { - Name string - Pair string - Chain string - Delta int64 - Invert bool - Cross string -} - -func (t *TokenKey) Sia() sia.Sia { - return sia.New(). - AddString8(t.Name). - AddString8(t.Pair). - AddString8(t.Chain). - AddInt64(t.Delta). - AddBool(t.Invert). - AddString8(t.Cross) -} - -func (t *TokenKey) FromSia(sia sia.Sia) *TokenKey { - t.Name = sia.ReadString8() - t.Pair = sia.ReadString8() - t.Chain = sia.ReadString8() - t.Delta = sia.ReadInt64() - t.Invert = sia.ReadBool() - t.Cross = sia.ReadString8() - - return t -} - -type AssetKey struct { - Token TokenKey - Block uint64 -} - -func (a *AssetKey) Sia() sia.Sia { - return sia.New(). - EmbedBytes(a.Token.Sia().Bytes()). - AddUInt64(a.Block) -} - -func (a *AssetKey) FromSia(sia sia.Sia) *AssetKey { - a.Token.FromSia(sia) - a.Block = sia.ReadUInt64() - - return a -} - -type PriceInfo struct { - Asset AssetKey - Price big.Int -} - -func (p *PriceInfo) Sia() sia.Sia { - return sia.New(). - EmbedBytes(p.Asset.Sia().Bytes()). - AddBigInt(&p.Price) -} - -func (p *PriceInfo) FromBytes(payload []byte) *PriceInfo { - siaMessage := sia.NewFromBytes(payload) - return p.FromSia(siaMessage) -} - -func (p *PriceInfo) FromSia(sia sia.Sia) *PriceInfo { - p.Asset.FromSia(sia) - p.Price = *sia.ReadBigInt() - - return p -} - -func (p *PriceInfo) Bls() (bls12381.G1Affine, error) { - hash, err := bls.Hash(p.Sia().Bytes()) - if err != nil { - utils.Logger.With("err", err).Error("Can't hash bls") - return bls12381.G1Affine{}, err - } - - return hash, err -} - -type BroadcastPricePacket struct { - Info PriceInfo - Signature [48]byte - Signer Signer -} - -func (b *BroadcastPricePacket) Sia() sia.Sia { - return sia.New(). - EmbedBytes(b.Info.Sia().Bytes()). - AddByteArray8(b.Signature[:]). - EmbedBytes(b.Signer.Sia().Bytes()) -} - -func (b *BroadcastPricePacket) FromBytes(payload []byte) *BroadcastPricePacket { - siaMessage := sia.NewFromBytes(payload) - b.Info.FromSia(siaMessage) - copy(b.Signature[:], siaMessage.ReadByteArray8()) - b.Signer.FromSia(siaMessage) - - return b -} diff --git a/internal/repository/postgres/assetprice.go b/internal/repository/postgres/assetprice.go index 441a898d..f1570fbc 100644 --- a/internal/repository/postgres/assetprice.go +++ b/internal/repository/postgres/assetprice.go @@ -2,11 +2,11 @@ package postgres import ( "context" + "time" + + "gorm.io/gorm/clause" "github.com/TimeleapLabs/unchained/internal/consts" - "github.com/TimeleapLabs/unchained/internal/ent" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" "github.com/TimeleapLabs/unchained/internal/transport/database" @@ -20,21 +20,17 @@ type AssetPriceRepo struct { func (a AssetPriceRepo) Upsert(ctx context.Context, data model.AssetPrice) error { err := a.client. GetConnection(). - AssetPrice. - Create(). - SetPair(data.Pair). - SetAsset(data.Name). - SetChain(data.Chain). - SetBlock(data.Block). - SetPrice(&helpers.BigInt{Int: data.Price}). - SetSignersCount(data.SignersCount). - SetSignature(data.Signature). - SetConsensus(data.Consensus). - SetVoted(&helpers.BigInt{Int: data.Voted}). - AddSignerIDs(data.SignerIDs...). - OnConflictColumns("block", "chain", "asset", "pair"). - UpdateNewValues(). - Exec(ctx) + WithContext(ctx). + Table("asset_price"). + Clauses(clause.OnConflict{ + Columns: []clause.Column{{Name: "block"}, {Name: "chain"}, {Name: "asset"}, {Name: "pair"}}, + UpdateAll: true, + }). + Create(&model.DataFrame{ + Hash: data.Hash(), + Timestamp: time.Now(), + Data: data, + }) if err != nil { utils.Logger.With("err", err).Error("Cant upsert asset price record in database") @@ -44,19 +40,18 @@ func (a AssetPriceRepo) Upsert(ctx context.Context, data model.AssetPrice) error return nil } -func (a AssetPriceRepo) Find(ctx context.Context, block uint64, chain string, name string, pair string) ([]*ent.AssetPrice, error) { - currentRecords, err := a.client. +func (a AssetPriceRepo) Find(ctx context.Context, block uint64, chain string, name string, pair string) ([]model.AssetPrice, error) { + currentRecords := []model.AssetPrice{} + err := a.client. GetConnection(). - AssetPrice. - Query(). - Where( - assetprice.Block(block), - assetprice.Chain(chain), - assetprice.Asset(name), - assetprice.Pair(pair), - ). - WithSigners(). - All(ctx) + WithContext(ctx). + Table("asset_price"). + Where("block", block). + Where("chain", chain). + Where("name", name). + Where("pair", pair). + Preload("Signer"). + Find(¤tRecords) if err != nil { utils.Logger.With("err", err).Error("Cant fetch asset price records from database") diff --git a/internal/repository/postgres/correctness.go b/internal/repository/postgres/correctness.go index c4095362..48f9d862 100644 --- a/internal/repository/postgres/correctness.go +++ b/internal/repository/postgres/correctness.go @@ -2,32 +2,30 @@ package postgres import ( "context" + "time" "github.com/TimeleapLabs/unchained/internal/consts" - "github.com/TimeleapLabs/unchained/internal/ent" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" "github.com/TimeleapLabs/unchained/internal/transport/database" "github.com/TimeleapLabs/unchained/internal/utils" + "gorm.io/gorm/clause" ) type CorrectnessRepo struct { client database.Database } -func (c CorrectnessRepo) Find(ctx context.Context, hash []byte, topic []byte, timestamp uint64) ([]*ent.CorrectnessReport, error) { - currentRecords, err := c.client. +func (c CorrectnessRepo) Find(ctx context.Context, hash []byte, topic []byte, timestamp uint64) ([]model.Correctness, error) { + currentRecords := []model.Correctness{} + err := c.client. GetConnection(). - CorrectnessReport. - Query(). - Where(correctnessreport.And( - correctnessreport.Hash(hash), - correctnessreport.Topic(topic), - correctnessreport.Timestamp(timestamp), - )). - All(ctx) + WithContext(ctx). + Table("correctness"). + Where("hash", hash). + Where("topic", topic). + Where("timestamp", timestamp). + Find(¤tRecords) if err != nil { utils.Logger.With("err", err).Error("Cant fetch correctness reports from database") @@ -38,22 +36,22 @@ func (c CorrectnessRepo) Find(ctx context.Context, hash []byte, topic []byte, ti } func (c CorrectnessRepo) Upsert(ctx context.Context, data model.Correctness) error { + dataBls := data.Bls() + dataBlsHash := (&dataBls).Marshal() + err := c.client. GetConnection(). - CorrectnessReport. - Create(). - SetCorrect(data.Correct). - SetSignersCount(data.SignersCount). - SetSignature(data.Signature). - SetHash(data.Hash). - SetTimestamp(data.Timestamp). - SetTopic(data.Topic[:]). - SetConsensus(data.Consensus). - SetVoted(&helpers.BigInt{Int: data.Voted}). - AddSignerIDs(data.SignerIDs...). - OnConflictColumns("topic", "hash"). - UpdateNewValues(). - Exec(ctx) + WithContext(ctx). + Table("correctness"). + Clauses(clause.OnConflict{ + Columns: []clause.Column{{Name: "topic"}, {Name: "hash"}}, + UpdateAll: true, + }). + Create(&model.DataFrame{ + Hash: dataBlsHash, + Timestamp: time.Now(), + Data: data, + }) if err != nil { utils.Logger.With("err", err).Error("Cant upsert correctness report in database") diff --git a/internal/repository/postgres/eventlog.go b/internal/repository/postgres/eventlog.go index 74477c91..09aa565e 100644 --- a/internal/repository/postgres/eventlog.go +++ b/internal/repository/postgres/eventlog.go @@ -2,10 +2,11 @@ package postgres import ( "context" + "time" + + "gorm.io/gorm/clause" "github.com/TimeleapLabs/unchained/internal/consts" - "github.com/TimeleapLabs/unchained/internal/ent" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" "github.com/TimeleapLabs/unchained/internal/transport/database" @@ -16,18 +17,17 @@ type EventLogRepo struct { client database.Database } -func (r EventLogRepo) Find(ctx context.Context, block uint64, hash []byte, index uint64) ([]*ent.EventLog, error) { - currentRecords, err := r.client. +func (r EventLogRepo) Find(ctx context.Context, block uint64, hash []byte, index uint64) ([]model.EventLog, error) { + currentRecords := []model.EventLog{} + err := r.client. GetConnection(). - EventLog. - Query(). - Where( - eventlog.Block(block), - eventlog.TransactionEQ(hash), - eventlog.IndexEQ(index), - ). - WithSigners(). - All(ctx) + WithContext(ctx). + Table("event_log"). + Where("block", block). + Where("transaction", hash). + Where("index", index). + Preload("Signers"). + Find(¤tRecords) if err != nil { utils.Logger.With("err", err).Error("Cant fetch event log records from database") @@ -40,23 +40,17 @@ func (r EventLogRepo) Find(ctx context.Context, block uint64, hash []byte, index func (r EventLogRepo) Upsert(ctx context.Context, data model.EventLog) error { err := r.client. GetConnection(). - EventLog. - Create(). - SetBlock(data.Block). - SetChain(data.Chain). - SetAddress(data.Address). - SetEvent(data.Event). - SetIndex(data.LogIndex). - SetTransaction(data.TxHash[:]). - SetSignersCount(data.SignersCount). - SetSignature(data.Signature). - SetArgs(data.Args). - SetConsensus(data.Consensus). - SetVoted(data.Voted). - AddSignerIDs(data.SignerIDs...). - OnConflictColumns("block", "transaction", "index"). - UpdateNewValues(). - Exec(ctx) + WithContext(ctx). + Table("event_log"). + Clauses(clause.OnConflict{ + Columns: []clause.Column{{Name: "block"}, {Name: "transaction"}, {Name: "index"}}, + UpdateAll: true, + }). + Create(&model.DataFrame{ + Hash: nil, + Timestamp: time.Now(), + Data: data, + }) if err != nil { utils.Logger.With("err", err).Error("Cant upsert event log record to database") diff --git a/internal/repository/postgres/signer.go b/internal/repository/postgres/signer.go index 3ba2b270..26eb8a57 100644 --- a/internal/repository/postgres/signer.go +++ b/internal/repository/postgres/signer.go @@ -3,9 +3,10 @@ package postgres import ( "context" + "gorm.io/gorm" + "gorm.io/gorm/clause" + "github.com/TimeleapLabs/unchained/internal/consts" - "github.com/TimeleapLabs/unchained/internal/ent" - "github.com/TimeleapLabs/unchained/internal/ent/signer" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" "github.com/TimeleapLabs/unchained/internal/transport/database" @@ -19,22 +20,22 @@ type signerRepo struct { func (s signerRepo) CreateSigners(ctx context.Context, signers []model.Signer) error { err := s.client. GetConnection(). - Signer.MapCreateBulk(signers, func(sc *ent.SignerCreate, i int) { - signer := signers[i] - sc.SetName(signer.Name). - SetEvm(signer.EvmAddress). - SetKey(signer.PublicKey[:]). - SetShortkey(signer.ShortPublicKey[:]). - SetPoints(0) - }). - OnConflictColumns("shortkey"). - UpdateName(). - UpdateEvm(). - UpdateKey(). - Update(func(su *ent.SignerUpsert) { - su.AddPoints(1) + WithContext(ctx). + Table("signer"). + Clauses(clause.OnConflict{ + Columns: []clause.Column{{Name: "shortkey"}}, + DoUpdates: clause.Assignments(map[string]interface{}{ + "name": "name", + "evm": "evm", + "key": "key", + "point": gorm.Expr("signer.point + 1"), + }), }). - Exec(ctx) + CreateInBatches(&signers, 100) + + // Update(func(su *ent.SignerUpsert) { + // su.AddPoints(1) + // }). if err != nil { utils.Logger.With("err", err).Error("Cant create signers in database") @@ -45,19 +46,22 @@ func (s signerRepo) CreateSigners(ctx context.Context, signers []model.Signer) e } func (s signerRepo) GetSingerIDsByKeys(ctx context.Context, keys [][]byte) ([]int, error) { - signerIDs, err := s.client. + ids := []int{} + + err := s.client. GetConnection(). - Signer. - Query(). - Where(signer.KeyIn(keys...)). - IDs(ctx) + WithContext(ctx). + Table("signer"). + Select("id"). + Where("data.key in ?", keys). + Find(&ids) if err != nil { utils.Logger.With("err", err).Error("Cant fetch signer IDs from database") return []int{}, consts.ErrInternalError } - return signerIDs, nil + return ids, nil } func NewSigner(client database.Database) repository.Signer { diff --git a/internal/repository/repository.go b/internal/repository/repository.go index 0948dc57..732593c9 100644 --- a/internal/repository/repository.go +++ b/internal/repository/repository.go @@ -3,13 +3,12 @@ package repository import ( "context" - "github.com/TimeleapLabs/unchained/internal/ent" "github.com/TimeleapLabs/unchained/internal/model" ) // EvenetLog interface represents the methods that can be used to interact with the EventLog table in the database. type EventLog interface { - Find(ctx context.Context, block uint64, hash []byte, index uint64) ([]*ent.EventLog, error) + Find(ctx context.Context, block uint64, hash []byte, index uint64) ([]model.EventLog, error) Upsert(ctx context.Context, data model.EventLog) error } @@ -21,13 +20,13 @@ type Signer interface { // AssetPrice interface represents the methods that can be used to interact with the AssetPrice table in the database. type AssetPrice interface { - Find(ctx context.Context, block uint64, chain string, name string, pair string) ([]*ent.AssetPrice, error) + Find(ctx context.Context, block uint64, chain string, name string, pair string) ([]model.AssetPrice, error) Upsert(ctx context.Context, data model.AssetPrice) error } // CorrectnessReport interface represents the methods that can be used to interact with the CorrectnessReport table in the database. type CorrectnessReport interface { - Find(ctx context.Context, hash []byte, topic []byte, timestamp uint64) ([]*ent.CorrectnessReport, error) + Find(ctx context.Context, hash []byte, topic []byte, timestamp uint64) ([]model.Correctness, error) Upsert(ctx context.Context, data model.Correctness) error } diff --git a/internal/service/correctness/correctness.go b/internal/service/correctness/correctness.go index b9ad53bd..802337ba 100644 --- a/internal/service/correctness/correctness.go +++ b/internal/service/correctness/correctness.go @@ -14,12 +14,10 @@ import ( "github.com/TimeleapLabs/unchained/internal/service/pos" "github.com/TimeleapLabs/unchained/internal/utils/address" - "github.com/TimeleapLabs/unchained/internal/service/evmlog" "github.com/puzpuzpuz/xsync/v3" "github.com/TimeleapLabs/unchained/internal/config" "github.com/TimeleapLabs/unchained/internal/crypto/bls" - "github.com/TimeleapLabs/unchained/internal/ent" "github.com/TimeleapLabs/unchained/internal/utils" bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" lru "github.com/hashicorp/golang-lru/v2" @@ -37,7 +35,7 @@ type SaveSignatureArgs struct { } type Service interface { - IsNewSigner(signature model.Signature, records []*ent.CorrectnessReport) bool + IsNewSigner(signature Signature, records []model.Correctness) bool RecordSignature( ctx context.Context, signature bls12381.G1Affine, signer model.Signer, hash bls12381.G1Affine, info model.Correctness, debounce bool, ) error @@ -49,7 +47,7 @@ type service struct { signerRepo repository.Signer correctnessRepo repository.CorrectnessReport - signatureCache *lru.Cache[bls12381.G1Affine, []model.Signature] + signatureCache *lru.Cache[bls12381.G1Affine, []Signature] consensus *lru.Cache[Key, xsync.MapOf[bls12381.G1Affine, big.Int]] DebouncedSaveSignatures func(key bls12381.G1Affine, arg SaveSignatureArgs) @@ -58,11 +56,11 @@ type service struct { } // IsNewSigner checks if the signer's pub key is in the records signers or not. -func (s *service) IsNewSigner(signature model.Signature, records []*ent.CorrectnessReport) bool { +func (s *service) IsNewSigner(signature Signature, records []model.Correctness) bool { // TODO: This isn't efficient, we should use a map for _, record := range records { - for _, signer := range record.Edges.Signers { - if signature.Signer.PublicKey == [96]byte(signer.Key) { + for _, signer := range record.Signers { + if signature.Signer.PublicKey == signer.PublicKey { return false } } @@ -88,7 +86,7 @@ func (s *service) RecordSignature( signatures, ok := s.signatureCache.Get(hash) if !ok { - signatures = make([]model.Signature, 0) + signatures = make([]Signature, 0) } // Check for duplicates @@ -98,7 +96,7 @@ func (s *service) RecordSignature( } } - packed := model.Signature{ + packed := Signature{ Signature: signature, Signer: signer, } @@ -178,7 +176,7 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er } currentRecords, err := s.correctnessRepo.Find(ctx, args.Info.Hash, args.Info.Topic[:], args.Info.Timestamp) - if err != nil && !ent.IsNotFound(err) { + if err != nil { return err } @@ -255,7 +253,7 @@ func (s *service) init() { s.DebouncedSaveSignatures = utils.Debounce[bls12381.G1Affine, SaveSignatureArgs](5*time.Second, s.SaveSignatures) s.signatureMutex = new(sync.Mutex) s.supportedTopics = make(map[[64]byte]bool) - s.signatureCache, err = lru.New[bls12381.G1Affine, []model.Signature](LruSize) + s.signatureCache, err = lru.New[bls12381.G1Affine, []Signature](LruSize) if err != nil { panic(err) @@ -279,7 +277,7 @@ func New( } var err error - c.consensus, err = lru.New[Key, xsync.MapOf[bls12381.G1Affine, big.Int]](evmlog.LruSize) + c.consensus, err = lru.New[Key, xsync.MapOf[bls12381.G1Affine, big.Int]](LruSize) if err != nil { utils.Logger. Error("Failed to create correctness consensus cache.") diff --git a/internal/service/correctness/correctness_test.go b/internal/service/correctness/correctness_test.go index ca5462ba..a70024d1 100644 --- a/internal/service/correctness/correctness_test.go +++ b/internal/service/correctness/correctness_test.go @@ -3,7 +3,6 @@ package correctness import ( "testing" - "github.com/TimeleapLabs/unchained/internal/ent" "github.com/TimeleapLabs/unchained/internal/model" postgresRepo "github.com/TimeleapLabs/unchained/internal/repository/postgres" "github.com/TimeleapLabs/unchained/internal/service/pos" @@ -13,12 +12,12 @@ import ( ) var ( - SignerOne = model.Signature{ + SignerOne = Signature{ Signer: model.Signer{ PublicKey: [96]byte{1, 2, 3}, }, } - SignerTwo = model.Signature{ + SignerTwo = Signature{ Signer: model.Signer{ PublicKey: [96]byte{3, 2, 1}, }, @@ -43,7 +42,7 @@ func (s *CorrectnessTestSuite) SetupTest() { func (s *CorrectnessTestSuite) TestIsNewSigner() { s.Run("Check if new signer with empty values", func() { - isSigner := s.service.IsNewSigner(model.Signature{}, []*ent.CorrectnessReport{}) + isSigner := s.service.IsNewSigner(Signature{}, []model.Correctness{}) assert.False(s.T(), isSigner) }) @@ -55,16 +54,16 @@ func (s *CorrectnessTestSuite) TestIsNewSigner() { isSigner := s.service.IsNewSigner( SignerOne, - []*ent.CorrectnessReport{ - { - Edges: ent.CorrectnessReportEdges{ - Signers: []*ent.Signer{ - { - Key: signers, - }, - }, - }, - }, + []model.Correctness{ + //{ + // Edges: ent.CorrectnessReportEdges{ + // Signers: []*ent.Signer{ + // { + // Key: signers, + // }, + // }, + // }, + // }, }, ) assert.True(s.T(), isSigner) @@ -78,15 +77,15 @@ func (s *CorrectnessTestSuite) TestIsNewSigner() { isSigner := s.service.IsNewSigner( SignerTwo, - []*ent.CorrectnessReport{ + []model.Correctness{ { - Edges: ent.CorrectnessReportEdges{ - Signers: []*ent.Signer{ - { - Key: signers, - }, - }, - }, + //Edges: ent.CorrectnessReportEdges{ + // Signers: []*ent.Signer{ + // { + // Key: signers, + // }, + // }, + // }, }, }, ) diff --git a/internal/service/correctness/types.go b/internal/service/correctness/types.go index 1170f6b6..bc73fa07 100644 --- a/internal/service/correctness/types.go +++ b/internal/service/correctness/types.go @@ -1,7 +1,41 @@ package correctness +import ( + "github.com/TimeleapLabs/unchained/internal/model" + bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" + sia "github.com/pouya-eghbali/go-sia/v2/pkg" +) + type Key struct { Hash string Topic string Correct bool } + +type Signature struct { + Signature bls12381.G1Affine + Signer model.Signer +} + +func (s *Signature) Sia() sia.Sia { + return sia.New(). + AddByteArray8(s.Signature.Marshal()). + EmbedBytes(s.Signer.Sia().Bytes()) +} + +func (s *Signature) FromBytes(payload []byte) *Signature { + siaMessage := sia.NewFromBytes(payload) + return s.FromSia(siaMessage) +} + +func (s *Signature) FromSia(sia sia.Sia) *Signature { + err := s.Signature.Unmarshal(sia.ReadByteArray8()) + + if err != nil { + s.Signature = bls12381.G1Affine{} + } + + s.Signer.FromSia(sia) + + return s +} diff --git a/internal/service/evmlog/evmlog.go b/internal/service/evmlog/evmlog.go index b96d1bfb..273a684f 100644 --- a/internal/service/evmlog/evmlog.go +++ b/internal/service/evmlog/evmlog.go @@ -9,6 +9,9 @@ import ( "sync" "time" + "github.com/TimeleapLabs/unchained/internal/service/correctness" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" + "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" @@ -19,8 +22,6 @@ import ( "github.com/TimeleapLabs/unchained/internal/config" "github.com/TimeleapLabs/unchained/internal/crypto/bls" - "github.com/TimeleapLabs/unchained/internal/ent" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" "github.com/TimeleapLabs/unchained/internal/transport/client/conn" "github.com/TimeleapLabs/unchained/internal/utils" bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" @@ -57,7 +58,7 @@ type service struct { persistence *Badger consensus *lru.Cache[EventKey, map[bls12381.G1Affine]big.Int] - signatureCache *lru.Cache[bls12381.G1Affine, []model.Signature] + signatureCache *lru.Cache[bls12381.G1Affine, []correctness.Signature] DebouncedSaveSignatures func(key bls12381.G1Affine, arg SaveSignatureArgs) signatureMutex *sync.Mutex supportedEvents map[SupportKey]bool @@ -87,7 +88,7 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er var keys [][]byte currentRecords, err := s.eventLogRepo.Find(ctx, args.Info.Block, args.Info.TxHash[:], args.Info.LogIndex) - if err != nil && !ent.IsNotFound(err) { + if err != nil { return err } @@ -175,7 +176,7 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er args.Info.SignerIDs = signerIDs args.Info.Consensus = args.Consensus args.Info.Signature = signatureBytes[:] - args.Info.Voted = &helpers.BigInt{Int: *args.Voted} + args.Info.Voted = args.Voted err = s.eventLogRepo.Upsert(ctx, args.Info) if err != nil { @@ -188,7 +189,7 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er func (s *service) SendPriceReport(signature bls12381.G1Affine, event model.EventLog) { compressedSignature := signature.Bytes() - priceReport := model.EventLogReportPacket{ + priceReport := packet.EventLogReportPacket{ EventLog: event, Signature: compressedSignature, } @@ -219,7 +220,7 @@ func New( s.DebouncedSaveSignatures = utils.Debounce[bls12381.G1Affine, SaveSignatureArgs](5*time.Second, s.SaveSignatures) var err error - s.signatureCache, err = lru.New[bls12381.G1Affine, []model.Signature](LruSize) + s.signatureCache, err = lru.New[bls12381.G1Affine, []correctness.Signature](LruSize) if err != nil { panic(err) } diff --git a/internal/service/evmlog/helper.go b/internal/service/evmlog/helper.go index 3d9b18d0..dda1f396 100644 --- a/internal/service/evmlog/helper.go +++ b/internal/service/evmlog/helper.go @@ -1,14 +1,14 @@ package evmlog import ( - "github.com/TimeleapLabs/unchained/internal/ent" "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/service/correctness" ) -func isNewSigner(signature model.Signature, records []*ent.EventLog) bool { +func isNewSigner(signature correctness.Signature, records []model.EventLog) bool { for _, record := range records { - for _, signer := range record.Edges.Signers { - if signature.Signer.PublicKey == [96]byte(signer.Key) { + for _, signer := range record.Signers { + if signature.Signer.PublicKey == signer.PublicKey { return false } } diff --git a/internal/service/evmlog/record.go b/internal/service/evmlog/record.go index 646f1453..01e98741 100644 --- a/internal/service/evmlog/record.go +++ b/internal/service/evmlog/record.go @@ -4,6 +4,8 @@ import ( "context" "math/big" + "github.com/TimeleapLabs/unchained/internal/service/correctness" + "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/utils" @@ -88,7 +90,7 @@ func (s *service) RecordSignature( cached, _ := s.signatureCache.Get(hash) - packed := model.Signature{ + packed := correctness.Signature{ Signature: signature, Signer: signer, } diff --git a/internal/service/uniswap/helper.go b/internal/service/uniswap/helper.go index ce63a731..9688238f 100644 --- a/internal/service/uniswap/helper.go +++ b/internal/service/uniswap/helper.go @@ -1,14 +1,14 @@ package uniswap import ( - "github.com/TimeleapLabs/unchained/internal/ent" "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/service/correctness" ) -func IsNewSigner(signature model.Signature, records []*ent.AssetPrice) bool { +func IsNewSigner(signature correctness.Signature, records []model.AssetPrice) bool { for _, record := range records { - for _, signer := range record.Edges.Signers { - if signature.Signer.PublicKey == [96]byte(signer.Key) { + for _, signer := range record.Signers { + if signature.Signer.PublicKey == signer.PublicKey { return false } } diff --git a/internal/service/uniswap/process.go b/internal/service/uniswap/process.go index 0e2a3af9..c7bac60f 100644 --- a/internal/service/uniswap/process.go +++ b/internal/service/uniswap/process.go @@ -3,8 +3,9 @@ package uniswap import ( "context" + "github.com/TimeleapLabs/unchained/internal/service/uniswap/types" + "github.com/TimeleapLabs/unchained/internal/config" - "github.com/TimeleapLabs/unchained/internal/model" ) func (s *service) ProcessBlocks(ctx context.Context, chain string) error { @@ -14,7 +15,7 @@ func (s *service) ProcessBlocks(ctx context.Context, chain string) error { return err } - for _, token := range model.NewTokensFromCfg(config.App.Plugins.Uniswap.Tokens) { + for _, token := range types.NewTokensFromCfg(config.App.Plugins.Uniswap.Tokens) { if token.Chain != chain { continue } diff --git a/internal/service/uniswap/record.go b/internal/service/uniswap/record.go index 54707062..8d81ecf8 100644 --- a/internal/service/uniswap/record.go +++ b/internal/service/uniswap/record.go @@ -5,6 +5,8 @@ import ( "fmt" "math/big" + "github.com/TimeleapLabs/unchained/internal/service/uniswap/types" + "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/utils" @@ -17,7 +19,7 @@ import ( // TODO: This needs to work with different datasets // TODO: Can we turn this into a library func? func (s *service) RecordSignature( - ctx context.Context, signature bls12381.G1Affine, signer model.Signer, hash bls12381.G1Affine, info model.PriceInfo, debounce bool, historical bool, + ctx context.Context, signature bls12381.G1Affine, signer model.Signer, hash bls12381.G1Affine, info types.PriceInfo, debounce bool, historical bool, ) error { if supported := s.SupportedTokens[info.Asset.Token]; !supported { utils.Logger. diff --git a/internal/service/uniswap/types/assetkey.go b/internal/service/uniswap/types/assetkey.go new file mode 100644 index 00000000..19407873 --- /dev/null +++ b/internal/service/uniswap/types/assetkey.go @@ -0,0 +1,21 @@ +package types + +import sia "github.com/pouya-eghbali/go-sia/v2/pkg" + +type AssetKey struct { + Token TokenKey + Block uint64 +} + +func (a *AssetKey) Sia() sia.Sia { + return sia.New(). + EmbedBytes(a.Token.Sia().Bytes()). + AddUInt64(a.Block) +} + +func (a *AssetKey) FromSia(sia sia.Sia) *AssetKey { + a.Token.FromSia(sia) + a.Block = sia.ReadUInt64() + + return a +} diff --git a/internal/service/uniswap/types/priceinfo.go b/internal/service/uniswap/types/priceinfo.go new file mode 100644 index 00000000..08171803 --- /dev/null +++ b/internal/service/uniswap/types/priceinfo.go @@ -0,0 +1,43 @@ +package types + +import ( + "math/big" + + "github.com/TimeleapLabs/unchained/internal/crypto/bls" + "github.com/TimeleapLabs/unchained/internal/utils" + bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" + sia "github.com/pouya-eghbali/go-sia/v2/pkg" +) + +type PriceInfo struct { + Asset AssetKey + Price big.Int +} + +func (p *PriceInfo) Sia() sia.Sia { + return sia.New(). + EmbedBytes(p.Asset.Sia().Bytes()). + AddBigInt(&p.Price) +} + +func (p *PriceInfo) FromBytes(payload []byte) *PriceInfo { + siaMessage := sia.NewFromBytes(payload) + return p.FromSia(siaMessage) +} + +func (p *PriceInfo) FromSia(sia sia.Sia) *PriceInfo { + p.Asset.FromSia(sia) + p.Price = *sia.ReadBigInt() + + return p +} + +func (p *PriceInfo) Bls() (bls12381.G1Affine, error) { + hash, err := bls.Hash(p.Sia().Bytes()) + if err != nil { + utils.Logger.With("err", err).Error("Can't hash bls") + return bls12381.G1Affine{}, err + } + + return hash, err +} diff --git a/internal/model/token.go b/internal/service/uniswap/types/token.go similarity index 98% rename from internal/model/token.go rename to internal/service/uniswap/types/token.go index d1300119..48ab8e2e 100644 --- a/internal/model/token.go +++ b/internal/service/uniswap/types/token.go @@ -1,4 +1,4 @@ -package model +package types import "github.com/TimeleapLabs/unchained/internal/config" diff --git a/internal/service/uniswap/types/tokenkey.go b/internal/service/uniswap/types/tokenkey.go new file mode 100644 index 00000000..6593bf62 --- /dev/null +++ b/internal/service/uniswap/types/tokenkey.go @@ -0,0 +1,33 @@ +package types + +import sia "github.com/pouya-eghbali/go-sia/v2/pkg" + +type TokenKey struct { + Name string + Pair string + Chain string + Delta int64 + Invert bool + Cross string +} + +func (t *TokenKey) Sia() sia.Sia { + return sia.New(). + AddString8(t.Name). + AddString8(t.Pair). + AddString8(t.Chain). + AddInt64(t.Delta). + AddBool(t.Invert). + AddString8(t.Cross) +} + +func (t *TokenKey) FromSia(sia sia.Sia) *TokenKey { + t.Name = sia.ReadString8() + t.Pair = sia.ReadString8() + t.Chain = sia.ReadString8() + t.Delta = sia.ReadInt64() + t.Invert = sia.ReadBool() + t.Cross = sia.ReadString8() + + return t +} diff --git a/internal/service/uniswap/uniswap.go b/internal/service/uniswap/uniswap.go index 1bbdc6da..ae909411 100644 --- a/internal/service/uniswap/uniswap.go +++ b/internal/service/uniswap/uniswap.go @@ -9,6 +9,10 @@ import ( "sync" "time" + "github.com/TimeleapLabs/unchained/internal/service/correctness" + "github.com/TimeleapLabs/unchained/internal/service/uniswap/types" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" + "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" @@ -19,7 +23,6 @@ import ( "github.com/TimeleapLabs/unchained/internal/crypto" "github.com/TimeleapLabs/unchained/internal/crypto/bls" "github.com/TimeleapLabs/unchained/internal/crypto/ethereum" - "github.com/TimeleapLabs/unchained/internal/ent" "github.com/TimeleapLabs/unchained/internal/service/evmlog" "github.com/TimeleapLabs/unchained/internal/transport/client/conn" "github.com/TimeleapLabs/unchained/internal/utils" @@ -37,7 +40,7 @@ const ( SizeOfPriceCacheLru = 128 ) -var DebouncedSaveSignatures func(key model.AssetKey, arg SaveSignatureArgs) +var DebouncedSaveSignatures func(key types.AssetKey, arg SaveSignatureArgs) type Service interface { checkAndCacheSignature( @@ -47,10 +50,10 @@ type Service interface { saveSignatures(ctx context.Context, args SaveSignatureArgs) error GetBlockNumber(ctx context.Context, network string) (*uint64, error) GetPriceAtBlockFromPair(network string, blockNumber uint64, pairAddr string, decimalDif int64, inverse bool) (*big.Int, error) - SyncBlocks(ctx context.Context, token model.Token, key model.TokenKey, latest uint64) error - TokenKey(token model.Token) *model.TokenKey + SyncBlocks(ctx context.Context, token types.Token, key types.TokenKey, latest uint64) error + TokenKey(token types.Token) *types.TokenKey RecordSignature( - ctx context.Context, signature bls12381.G1Affine, signer model.Signer, hash bls12381.G1Affine, info model.PriceInfo, debounce bool, historical bool, + ctx context.Context, signature bls12381.G1Affine, signer model.Signer, hash bls12381.G1Affine, info types.PriceInfo, debounce bool, historical bool, ) error ProcessBlocks(ctx context.Context, chain string) error } @@ -61,18 +64,18 @@ type service struct { signerRepo repository.Signer assetPriceRepo repository.AssetPrice - consensus *lru.Cache[model.AssetKey, xsync.MapOf[bls12381.G1Affine, big.Int]] - signatureCache *lru.Cache[bls12381.G1Affine, []model.Signature] - SupportedTokens map[model.TokenKey]bool + consensus *lru.Cache[types.AssetKey, xsync.MapOf[bls12381.G1Affine, big.Int]] + signatureCache *lru.Cache[bls12381.G1Affine, []correctness.Signature] + SupportedTokens map[types.TokenKey]bool signatureMutex sync.Mutex twoOneNineTwo big.Int tenEighteen big.Int tenEighteenF big.Float - LastBlock xsync.MapOf[model.TokenKey, uint64] + LastBlock xsync.MapOf[types.TokenKey, uint64] PriceCache map[string]*lru.Cache[uint64, big.Int] crossPrices map[string]big.Int - crossTokens map[string]model.TokenKey + crossTokens map[string]types.TokenKey LastPrice big.Int } @@ -85,7 +88,7 @@ func (s *service) checkAndCacheSignature( cached, _ := s.signatureCache.Get(hash) - packed := model.Signature{ + packed := correctness.Signature{ Signature: signature, Signer: signer, } @@ -107,7 +110,7 @@ func (s *service) checkAndCacheSignature( } type SaveSignatureArgs struct { - Info model.PriceInfo + Info types.PriceInfo Hash bls12381.G1Affine Consensus bool Voted *big.Int @@ -137,7 +140,7 @@ func (s *service) saveSignatures(ctx context.Context, args SaveSignatureArgs) er args.Info.Asset.Block, args.Info.Asset.Token.Chain, args.Info.Asset.Token.Name, args.Info.Asset.Token.Pair, ) - if err != nil && !ent.IsNotFound(err) { + if err != nil { return err } @@ -163,7 +166,6 @@ func (s *service) saveSignatures(ctx context.Context, args SaveSignatureArgs) er } signerIDs, err := s.signerRepo.GetSingerIDsByKeys(ctx, keys) - if err != nil { utils.Logger. With("Block", args.Info.Asset.Block). @@ -177,7 +179,6 @@ func (s *service) saveSignatures(ctx context.Context, args SaveSignatureArgs) er for _, record := range currentRecords { if record.Price.Cmp(&args.Info.Price) == 0 { currentAggregate, err := bls.RecoverSignature([48]byte(record.Signature)) - if err != nil { utils.Logger. With("Block", args.Info.Asset.Block). @@ -290,7 +291,7 @@ func (s *service) priceFromSqrtX96(sqrtPriceX96 *big.Int, decimalDif int64, inve return &price } -func (s *service) syncBlock(ctx context.Context, token model.Token, caser cases.Caser, key *model.TokenKey, blockInx uint64) error { +func (s *service) syncBlock(ctx context.Context, token types.Token, caser cases.Caser, key *types.TokenKey, blockInx uint64) error { lastSynced, ok := s.LastBlock.Load(*key) if ok && blockInx <= lastSynced { @@ -347,9 +348,9 @@ func (s *service) syncBlock(ctx context.Context, token model.Token, caser cases. key = s.TokenKey(token) - priceInfo := model.PriceInfo{ + priceInfo := types.PriceInfo{ Price: *price, - Asset: model.AssetKey{ + Asset: types.AssetKey{ Block: blockInx, Token: *key, }, @@ -359,7 +360,7 @@ func (s *service) syncBlock(ctx context.Context, token model.Token, caser cases. if token.Send && !conn.IsClosed { compressedSignature := signature.Bytes() - priceReport := model.PriceReportPacket{ + priceReport := packet.PriceReportPacket{ PriceInfo: priceInfo, Signature: compressedSignature, } @@ -388,7 +389,7 @@ func (s *service) syncBlock(ctx context.Context, token model.Token, caser cases. return nil } -func (s *service) SyncBlocks(ctx context.Context, token model.Token, key model.TokenKey, latest uint64) error { +func (s *service) SyncBlocks(ctx context.Context, token types.Token, key types.TokenKey, latest uint64) error { block, ok := s.LastBlock.Load(key) if !ok { return consts.ErrCantLoadLastBlock @@ -406,21 +407,21 @@ func (s *service) SyncBlocks(ctx context.Context, token model.Token, key model.T return nil } -func (s *service) TokenKey(token model.Token) *model.TokenKey { - var cross []model.TokenKey +func (s *service) TokenKey(token types.Token) *types.TokenKey { + var cross []types.TokenKey for _, id := range token.Cross { cross = append(cross, s.crossTokens[id]) } - toHash := new(sia.ArraySia[model.TokenKey]). - AddArray8(cross, func(s *sia.ArraySia[model.TokenKey], item model.TokenKey) { + toHash := new(sia.ArraySia[types.TokenKey]). + AddArray8(cross, func(s *sia.ArraySia[types.TokenKey], item types.TokenKey) { s.EmbedBytes(item.Sia().Bytes()) }).Bytes() hash := utils.Shake(toHash) - key := model.TokenKey{ + key := types.TokenKey{ Name: strings.ToLower(token.Name), Pair: strings.ToLower(token.Pair), Chain: strings.ToLower(token.Chain), @@ -446,15 +447,15 @@ func New( consensus: nil, signatureCache: nil, - SupportedTokens: map[model.TokenKey]bool{}, + SupportedTokens: map[types.TokenKey]bool{}, signatureMutex: sync.Mutex{}, - LastBlock: *xsync.NewMapOf[model.TokenKey, uint64](), + LastBlock: *xsync.NewMapOf[types.TokenKey, uint64](), PriceCache: map[string]*lru.Cache[uint64, big.Int]{}, crossPrices: map[string]big.Int{}, - crossTokens: map[string]model.TokenKey{}, + crossTokens: map[string]types.TokenKey{}, } - DebouncedSaveSignatures = utils.Debounce[model.AssetKey, SaveSignatureArgs](5*time.Second, s.saveSignatures) + DebouncedSaveSignatures = utils.Debounce[types.AssetKey, SaveSignatureArgs](5*time.Second, s.saveSignatures) s.twoOneNineTwo.Exp(big.NewInt(2), big.NewInt(192), nil) s.tenEighteen.Exp(big.NewInt(10), big.NewInt(18), nil) @@ -462,7 +463,7 @@ func New( if config.App.Plugins.Uniswap != nil { for _, t := range config.App.Plugins.Uniswap.Tokens { - token := model.NewTokenFromCfg(t) + token := types.NewTokenFromCfg(t) key := s.TokenKey(token) s.SupportedTokens[*key] = true @@ -470,7 +471,7 @@ func New( } for _, t := range config.App.Plugins.Uniswap.Tokens { - token := model.NewTokenFromCfg(t) + token := types.NewTokenFromCfg(t) var err error s.PriceCache[strings.ToLower(token.Pair)], err = lru.New[uint64, big.Int](SizeOfPriceCacheLru) @@ -481,14 +482,14 @@ func New( } var err error - s.signatureCache, err = lru.New[bls12381.G1Affine, []model.Signature](evmlog.LruSize) + s.signatureCache, err = lru.New[bls12381.G1Affine, []correctness.Signature](evmlog.LruSize) if err != nil { utils.Logger.Error("Failed to create token price signature cache.") os.Exit(1) } // TODO: This is vulnerable to flood attacks - s.consensus, err = lru.New[model.AssetKey, xsync.MapOf[bls12381.G1Affine, big.Int]](evmlog.LruSize) + s.consensus, err = lru.New[types.AssetKey, xsync.MapOf[bls12381.G1Affine, big.Int]](evmlog.LruSize) if err != nil { utils.Logger.Error("Failed to create token price consensus cache.") os.Exit(1) diff --git a/internal/transport/client/handler/challenge.go b/internal/transport/client/handler/challenge.go index 88bbbb9a..d42f08e5 100644 --- a/internal/transport/client/handler/challenge.go +++ b/internal/transport/client/handler/challenge.go @@ -2,11 +2,11 @@ package handler import ( "github.com/TimeleapLabs/unchained/internal/crypto" - "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" ) func (h *consumer) Challenge(message []byte) []byte { - challenge := new(model.ChallengePacket).FromBytes(message) + challenge := new(packet.ChallengePacket).FromBytes(message) signature, _ := crypto.Identity.Bls.Sign(challenge.Random[:]) challenge.Signature = signature.Bytes() @@ -15,7 +15,7 @@ func (h *consumer) Challenge(message []byte) []byte { } func (w worker) Challenge(message []byte) []byte { - challenge := new(model.ChallengePacket).FromBytes(message) + challenge := new(packet.ChallengePacket).FromBytes(message) signature, _ := crypto.Identity.Bls.Sign(challenge.Random[:]) challenge.Signature = signature.Bytes() diff --git a/internal/transport/client/handler/correctness.go b/internal/transport/client/handler/correctness.go index 50486e1a..fdd3c0b0 100644 --- a/internal/transport/client/handler/correctness.go +++ b/internal/transport/client/handler/correctness.go @@ -3,18 +3,16 @@ package handler import ( "context" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" + "github.com/TimeleapLabs/unchained/internal/crypto/bls" - "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/utils" ) func (h *consumer) CorrectnessReport(ctx context.Context, message []byte) { - packet := new(model.BroadcastCorrectnessPacket).FromBytes(message) + packet := new(packet.BroadcastCorrectnessPacket).FromBytes(message) - correctnessHash, err := packet.Info.Bls() - if err != nil { - return - } + correctnessHash := packet.Info.Bls() signature, err := bls.RecoverSignature(packet.Signature) if err != nil { diff --git a/internal/transport/client/handler/event.go b/internal/transport/client/handler/event.go index a33f9f16..c8c48417 100644 --- a/internal/transport/client/handler/event.go +++ b/internal/transport/client/handler/event.go @@ -3,13 +3,14 @@ package handler import ( "context" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" + "github.com/TimeleapLabs/unchained/internal/crypto/bls" - "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/utils" ) func (h *consumer) EventLog(ctx context.Context, message []byte) { - packet := new(model.BroadcastEventPacket).FromBytes(message) + packet := new(packet.BroadcastEventPacket).FromBytes(message) eventLogHash, err := packet.Info.Bls() if err != nil { diff --git a/internal/transport/client/handler/price.go b/internal/transport/client/handler/price.go index 09b34a33..10531d8f 100644 --- a/internal/transport/client/handler/price.go +++ b/internal/transport/client/handler/price.go @@ -3,13 +3,14 @@ package handler import ( "context" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" + "github.com/TimeleapLabs/unchained/internal/crypto/bls" - "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/utils" ) func (h *consumer) PriceReport(ctx context.Context, message []byte) { - packet := new(model.BroadcastPricePacket).FromBytes(message) + packet := new(packet.BroadcastPricePacket).FromBytes(message) priceInfoHash, err := packet.Info.Bls() if err != nil { diff --git a/internal/transport/database/database.go b/internal/transport/database/database.go index 39ded2c0..db17af8b 100644 --- a/internal/transport/database/database.go +++ b/internal/transport/database/database.go @@ -3,10 +3,10 @@ package database import ( "context" - "github.com/TimeleapLabs/unchained/internal/ent" + "gorm.io/gorm" ) type Database interface { - GetConnection() *ent.Client + GetConnection() *gorm.DB HealthCheck(ctx context.Context) bool } diff --git a/internal/transport/database/mock/postgres_mock.go b/internal/transport/database/mock/postgres_mock.go index 367bf0ef..5827cd5b 100644 --- a/internal/transport/database/mock/postgres_mock.go +++ b/internal/transport/database/mock/postgres_mock.go @@ -4,7 +4,10 @@ import ( "context" "testing" - "github.com/TimeleapLabs/unchained/internal/ent" + "gorm.io/driver/postgres" + "gorm.io/gorm" + "gorm.io/gorm/logger" + "github.com/TimeleapLabs/unchained/internal/transport/database" "github.com/peterldowns/pgtestdb" @@ -12,10 +15,10 @@ import ( type mockConnection struct { t *testing.T - db *ent.Client + db *gorm.DB } -func (m *mockConnection) GetConnection() *ent.Client { +func (m *mockConnection) GetConnection() *gorm.DB { if m.db != nil { return m.db } @@ -34,7 +37,13 @@ func (m *mockConnection) GetConnection() *ent.Client { ) var err error - m.db, err = ent.Open("postgres", "postgresql://postgres:password@127.0.0.1:5433/unchained?sslmode=disable") + m.db, err = gorm.Open( + postgres.Open("postgresql://postgres:password@127.0.0.1:5433/unchained?sslmode=disable"), + &gorm.Config{ + Logger: logger.Default.LogMode(logger.Warn), + TranslateError: true, + }, + ) if err != nil { panic(err) } diff --git a/internal/transport/database/postgres/postgres.go b/internal/transport/database/postgres/postgres.go index 40784bd2..b641b326 100644 --- a/internal/transport/database/postgres/postgres.go +++ b/internal/transport/database/postgres/postgres.go @@ -4,24 +4,38 @@ import ( "context" "github.com/TimeleapLabs/unchained/internal/config" - "github.com/TimeleapLabs/unchained/internal/ent" "github.com/TimeleapLabs/unchained/internal/transport/database" "github.com/TimeleapLabs/unchained/internal/utils" - // these imports are required for ent to work with postgres. - _ "github.com/jackc/pgx/v5/stdlib" - _ "github.com/lib/pq" + "gorm.io/driver/postgres" + "gorm.io/gorm" + "gorm.io/gorm/logger" ) type connection struct { - db *ent.Client + db *gorm.DB } func (c *connection) HealthCheck(_ context.Context) bool { + if c.db != nil { + return false + } + conn, err := c.db.DB() + if err != nil { + utils.Logger.With("Error", err).Error("Failed to get DB connection") + return false + } + + err = conn.Ping() + if err != nil { + utils.Logger.With("Error", err).Error("Failed to ping DB") + return false + } + return true } -func (c *connection) GetConnection() *ent.Client { +func (c *connection) GetConnection() *gorm.DB { if c.db != nil { return c.db } @@ -34,17 +48,30 @@ func (c *connection) GetConnection() *ent.Client { utils.Logger.Info("Connecting to DB") - c.db, err = ent.Open("postgres", config.App.Postgres.URL) - + c.db, err = gorm.Open( + postgres.Open(config.App.Postgres.URL), + &gorm.Config{ + Logger: logger.Default.LogMode(logger.Warn), + TranslateError: true, + }, + ) if err != nil { - utils.Logger.With("err", err).Error("failed opening connection to postgres") + panic(err) } - if err = c.db.Schema.Create(context.Background()); err != nil { - utils.Logger.With("err", err).Error("failed creating schema resources") + return c.db +} + +func (c *connection) Migrate() { + if c.db == nil { + c.GetConnection() } - return c.db + err := c.db.AutoMigrate() + + if err != nil { + utils.Logger.With("Error", err).Error("Failed to migrate DB") + } } func New() database.Database { diff --git a/internal/transport/server/gql/args.graphql b/internal/transport/server/gql/args.graphql deleted file mode 100644 index b38a3c14..00000000 --- a/internal/transport/server/gql/args.graphql +++ /dev/null @@ -1,7 +0,0 @@ -scalar BigInt -scalar Bytes - -type EventLogArg { - name: String! - value: String! -} diff --git a/internal/transport/server/gql/args.resolvers.go b/internal/transport/server/gql/args.resolvers.go deleted file mode 100644 index 014d802d..00000000 --- a/internal/transport/server/gql/args.resolvers.go +++ /dev/null @@ -1,39 +0,0 @@ -package gql - -// This file will be automatically regenerated based on the schema, any resolver implementations -// will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.45 - -import ( - "context" - "fmt" - "github.com/TimeleapLabs/unchained/internal/model" - "strings" - - "github.com/TimeleapLabs/unchained/internal/transport/server/gql/generated" -) - -// Value is the resolver for the value field. -func (r *eventLogArgResolver) Value(ctx context.Context, obj *model.EventLogArg) (string, error) { - switch { - case strings.HasPrefix(obj.Type, "uint"), strings.HasPrefix(obj.Type, "int"): - return obj.Value.(string), nil - - case obj.Type == "bool": - return fmt.Sprintf("%t", obj.Value), nil - - case obj.Type == "string": - return obj.Value.(string), nil - - case obj.Type == "address": - return obj.Value.(string), nil - - default: - return "", fmt.Errorf("unsupported type: %s", obj.Type) - } -} - -// EventLogArg returns generated.EventLogArgResolver implementation. -func (r *Resolver) EventLogArg() generated.EventLogArgResolver { return &eventLogArgResolver{r} } - -type eventLogArgResolver struct{ *Resolver } diff --git a/internal/transport/server/gql/extensions.graphql b/internal/transport/server/gql/extensions.graphql deleted file mode 100644 index ac87aa64..00000000 --- a/internal/transport/server/gql/extensions.graphql +++ /dev/null @@ -1,8 +0,0 @@ -extend input SignerWhereInput { - key: String -} - -extend input CorrectnessReportWhereInput { - topic: String - hash: String -} diff --git a/internal/transport/server/gql/extensions.resolvers.go b/internal/transport/server/gql/extensions.resolvers.go deleted file mode 100644 index 4ef548d2..00000000 --- a/internal/transport/server/gql/extensions.resolvers.go +++ /dev/null @@ -1,65 +0,0 @@ -package gql - -// This file will be automatically regenerated based on the schema, any resolver implementations -// will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.45 - -import ( - "context" - "encoding/hex" - - "github.com/TimeleapLabs/unchained/internal/ent" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// Topic is the resolver for the topic field. -func (r *correctnessReportWhereInputResolver) Topic(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *string) error { - if obj == nil || data == nil { - return nil - } - - bytes, err := hex.DecodeString(*data) - - if err != nil { - return err - } - - obj.AddPredicates(correctnessreport.TopicEQ(bytes)) - - return nil -} - -// Hash is the resolver for the hash field. -func (r *correctnessReportWhereInputResolver) Hash(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *string) error { - if obj == nil || data == nil { - return nil - } - - bytes, err := hex.DecodeString(*data) - - if err != nil { - return err - } - - obj.AddPredicates(correctnessreport.HashEQ(bytes)) - - return nil -} - -// Key is the resolver for the key field. -func (r *signerWhereInputResolver) Key(ctx context.Context, obj *ent.SignerWhereInput, data *string) error { - if obj == nil || data == nil { - return nil - } - - bytes, err := hex.DecodeString(*data) - - if err != nil { - return err - } - - obj.AddPredicates(signer.KeyEQ(bytes)) - - return nil -} diff --git a/internal/transport/server/gql/generated/args.generated.go b/internal/transport/server/gql/generated/args.generated.go deleted file mode 100644 index 62e0fe21..00000000 --- a/internal/transport/server/gql/generated/args.generated.go +++ /dev/null @@ -1,279 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package generated - -import ( - "context" - "errors" - "github.com/TimeleapLabs/unchained/internal/model" - "strconv" - "sync" - "sync/atomic" - - "github.com/99designs/gqlgen/graphql" - "github.com/TimeleapLabs/unchained/internal/transport/server/gql/types" - "github.com/vektah/gqlparser/v2/ast" -) - -// region ************************** generated!.gotpl ************************** - -type EventLogArgResolver interface { - Value(ctx context.Context, obj *model.EventLogArg) (string, error) -} - -// endregion ************************** generated!.gotpl ************************** - -// region ***************************** args.gotpl ***************************** - -// endregion ***************************** args.gotpl ***************************** - -// region ************************** directives.gotpl ************************** - -// endregion ************************** directives.gotpl ************************** - -// region **************************** field.gotpl ***************************** - -func (ec *executionContext) _EventLogArg_name(ctx context.Context, field graphql.CollectedField, obj *model.EventLogArg) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLogArg_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLogArg_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLogArg", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLogArg_value(ctx context.Context, field graphql.CollectedField, obj *model.EventLogArg) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLogArg_value(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.EventLogArg().Value(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLogArg_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLogArg", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** - -// endregion **************************** input.gotpl ***************************** - -// region ************************** interface.gotpl *************************** - -// endregion ************************** interface.gotpl *************************** - -// region **************************** object.gotpl **************************** - -var eventLogArgImplementors = []string{"EventLogArg"} - -func (ec *executionContext) _EventLogArg(ctx context.Context, sel ast.SelectionSet, obj *model.EventLogArg) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, eventLogArgImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("EventLogArg") - case "name": - out.Values[i] = ec._EventLogArg_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "value": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._EventLogArg_value(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -// endregion **************************** object.gotpl **************************** - -// region ***************************** type.gotpl ***************************** - -func (ec *executionContext) unmarshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx context.Context, v interface{}) (types.Bytes, error) { - var res types.Bytes - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx context.Context, sel ast.SelectionSet, v types.Bytes) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return v -} - -func (ec *executionContext) marshalNEventLogArg2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋdatasetsᚐEventLogArg(ctx context.Context, sel ast.SelectionSet, v model.EventLogArg) graphql.Marshaler { - return ec._EventLogArg(ctx, sel, &v) -} - -func (ec *executionContext) marshalNEventLogArg2ᚕgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋdatasetsᚐEventLogArgᚄ(ctx context.Context, sel ast.SelectionSet, v []model.EventLogArg) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNEventLogArg2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋdatasetsᚐEventLogArg(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -// endregion ***************************** type.gotpl ***************************** diff --git a/internal/transport/server/gql/generated/prelude.generated.go b/internal/transport/server/gql/generated/prelude.generated.go deleted file mode 100644 index 4ed6110b..00000000 --- a/internal/transport/server/gql/generated/prelude.generated.go +++ /dev/null @@ -1,2969 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package generated - -import ( - "context" - "errors" - "fmt" - "strconv" - "sync" - "sync/atomic" - - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/introspection" - "github.com/vektah/gqlparser/v2/ast" -) - -// region ************************** generated!.gotpl ************************** - -// endregion ************************** generated!.gotpl ************************** - -// region ***************************** args.gotpl ***************************** - -func (ec *executionContext) dir_defer_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 *bool - if tmp, ok := rawArgs["if"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("if")) - arg0, err = ec.unmarshalOBoolean2ᚖbool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["if"] = arg0 - var arg1 *string - if tmp, ok := rawArgs["label"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("label")) - arg1, err = ec.unmarshalOString2ᚖstring(ctx, tmp) - if err != nil { - return nil, err - } - } - args["label"] = arg1 - return args, nil -} - -func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) - arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil -} - -func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) - arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil -} - -// endregion ***************************** args.gotpl ***************************** - -// region ************************** directives.gotpl ************************** - -// endregion ************************** directives.gotpl ************************** - -// region **************************** field.gotpl ***************************** - -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_locations(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Locations, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]string) - fc.Result = res - return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type __DirectiveLocation does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_args(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsRepeatable, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_args(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_type(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_type(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_types(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Types(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_queryType(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_mutationType(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_directives(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.Directive) - fc.Result = res - return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___Directive_name(ctx, field) - case "description": - return ec.fieldContext___Directive_description(ctx, field) - case "locations": - return ec.fieldContext___Directive_locations(ctx, field) - case "args": - return ec.fieldContext___Directive_args(ctx, field) - case "isRepeatable": - return ec.fieldContext___Directive_isRepeatable(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_kind(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalN__TypeKind2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type __TypeKind does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_fields(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Field) - fc.Result = res - return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___Field_name(ctx, field) - case "description": - return ec.fieldContext___Field_description(ctx, field) - case "args": - return ec.fieldContext___Field_args(ctx, field) - case "type": - return ec.fieldContext___Field_type(ctx, field) - case "isDeprecated": - return ec.fieldContext___Field_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___Field_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_interfaces(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_enumValues(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.EnumValue) - fc.Result = res - return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___EnumValue_name(ctx, field) - case "description": - return ec.fieldContext___EnumValue_description(ctx, field) - case "isDeprecated": - return ec.fieldContext___EnumValue_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___EnumValue_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_inputFields(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - fc.Result = res - return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_ofType(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SpecifiedByURL(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** - -// endregion **************************** input.gotpl ***************************** - -// region ************************** interface.gotpl *************************** - -// endregion ************************** interface.gotpl *************************** - -// region **************************** object.gotpl **************************** - -var __DirectiveImplementors = []string{"__Directive"} - -func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Directive") - case "name": - out.Values[i] = ec.___Directive_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "description": - out.Values[i] = ec.___Directive_description(ctx, field, obj) - case "locations": - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "isRepeatable": - out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var __EnumValueImplementors = []string{"__EnumValue"} - -func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__EnumValue") - case "name": - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "description": - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - case "isDeprecated": - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var __FieldImplementors = []string{"__Field"} - -func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Field") - case "name": - out.Values[i] = ec.___Field_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "description": - out.Values[i] = ec.___Field_description(ctx, field, obj) - case "args": - out.Values[i] = ec.___Field_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var __InputValueImplementors = []string{"__InputValue"} - -func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__InputValue") - case "name": - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "description": - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - case "type": - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var __SchemaImplementors = []string{"__Schema"} - -func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Schema") - case "description": - out.Values[i] = ec.___Schema_description(ctx, field, obj) - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "mutationType": - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - case "subscriptionType": - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - case "directives": - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var __TypeImplementors = []string{"__Type"} - -func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Type") - case "kind": - out.Values[i] = ec.___Type_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "name": - out.Values[i] = ec.___Type_name(ctx, field, obj) - case "description": - out.Values[i] = ec.___Type_description(ctx, field, obj) - case "fields": - out.Values[i] = ec.___Type_fields(ctx, field, obj) - case "interfaces": - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - case "possibleTypes": - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - case "enumValues": - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - case "inputFields": - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - case "ofType": - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - case "specifiedByURL": - out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -// endregion **************************** object.gotpl **************************** - -// region ***************************** type.gotpl ***************************** - -func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { - res, err := graphql.UnmarshalBoolean(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) (int, error) { - res, err := graphql.UnmarshalIntID(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - res := graphql.MarshalIntID(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalNID2ᚕintᚄ(ctx context.Context, v interface{}) ([]int, error) { - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]int, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNID2int(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalNID2ᚕintᚄ(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalNID2int(ctx, sel, v[i]) - } - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { - res, err := graphql.UnmarshalInt(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - res := graphql.MarshalInt(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalNInt2int64(ctx context.Context, v interface{}) (int64, error) { - res, err := graphql.UnmarshalInt64(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNInt2int64(ctx context.Context, sel ast.SelectionSet, v int64) graphql.Marshaler { - res := graphql.MarshalInt64(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec.___Type(ctx, sel, v) -} - -func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { - res, err := graphql.UnmarshalBoolean(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) - return res -} - -func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalBoolean(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalBoolean(*v) - return res -} - -func (ec *executionContext) unmarshalOID2ᚕintᚄ(ctx context.Context, v interface{}) ([]int, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]int, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNID2int(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalOID2ᚕintᚄ(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalNID2int(ctx, sel, v[i]) - } - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalOID2ᚖint(ctx context.Context, v interface{}) (*int, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalIntID(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOID2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalIntID(*v) - return res -} - -func (ec *executionContext) unmarshalOInt2ᚕint64ᚄ(ctx context.Context, v interface{}) ([]int64, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]int64, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNInt2int64(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalOInt2ᚕint64ᚄ(ctx context.Context, sel ast.SelectionSet, v []int64) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalNInt2int64(ctx, sel, v[i]) - } - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalInt(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalInt(*v) - return res -} - -func (ec *executionContext) unmarshalOInt2ᚖint64(ctx context.Context, v interface{}) (*int64, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalInt64(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOInt2ᚖint64(ctx context.Context, sel ast.SelectionSet, v *int64) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalInt64(*v) - return res -} - -func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - return res -} - -func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNString2string(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalOString2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalNString2string(ctx, sel, v[i]) - } - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalString(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalString(*v) - return res -} - -func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Schema(ctx, sel, v) -} - -func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Type(ctx, sel, v) -} - -// endregion ***************************** type.gotpl ***************************** diff --git a/internal/transport/server/gql/generated/root_.generated.go b/internal/transport/server/gql/generated/root_.generated.go deleted file mode 100644 index 7a6e02ff..00000000 --- a/internal/transport/server/gql/generated/root_.generated.go +++ /dev/null @@ -1,1712 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package generated - -import ( - "bytes" - "context" - "errors" - "sync/atomic" - - "entgo.io/contrib/entgql" - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/introspection" - "github.com/TimeleapLabs/unchained/internal/ent" - gqlparser "github.com/vektah/gqlparser/v2" - "github.com/vektah/gqlparser/v2/ast" -) - -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - schema: cfg.Schema, - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Schema *ast.Schema - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - AssetPrice() AssetPriceResolver - CorrectnessReport() CorrectnessReportResolver - EventLog() EventLogResolver - EventLogArg() EventLogArgResolver - Query() QueryResolver - Signer() SignerResolver - AssetPriceWhereInput() AssetPriceWhereInputResolver - CorrectnessReportWhereInput() CorrectnessReportWhereInputResolver - EventLogWhereInput() EventLogWhereInputResolver - SignerWhereInput() SignerWhereInputResolver -} - -type DirectiveRoot struct { -} - -type ComplexityRoot struct { - AssetPrice struct { - Asset func(childComplexity int) int - Block func(childComplexity int) int - Chain func(childComplexity int) int - Consensus func(childComplexity int) int - ID func(childComplexity int) int - Pair func(childComplexity int) int - Price func(childComplexity int) int - Signature func(childComplexity int) int - Signers func(childComplexity int) int - SignersCount func(childComplexity int) int - Voted func(childComplexity int) int - } - - AssetPriceConnection struct { - Edges func(childComplexity int) int - PageInfo func(childComplexity int) int - TotalCount func(childComplexity int) int - } - - AssetPriceEdge struct { - Cursor func(childComplexity int) int - Node func(childComplexity int) int - } - - CorrectnessReport struct { - Consensus func(childComplexity int) int - Correct func(childComplexity int) int - Hash func(childComplexity int) int - ID func(childComplexity int) int - Signature func(childComplexity int) int - Signers func(childComplexity int) int - SignersCount func(childComplexity int) int - Timestamp func(childComplexity int) int - Topic func(childComplexity int) int - Voted func(childComplexity int) int - } - - CorrectnessReportConnection struct { - Edges func(childComplexity int) int - PageInfo func(childComplexity int) int - TotalCount func(childComplexity int) int - } - - CorrectnessReportEdge struct { - Cursor func(childComplexity int) int - Node func(childComplexity int) int - } - - EventLog struct { - Address func(childComplexity int) int - Args func(childComplexity int) int - Block func(childComplexity int) int - Chain func(childComplexity int) int - Consensus func(childComplexity int) int - Event func(childComplexity int) int - ID func(childComplexity int) int - Index func(childComplexity int) int - Signature func(childComplexity int) int - Signers func(childComplexity int) int - SignersCount func(childComplexity int) int - Transaction func(childComplexity int) int - Voted func(childComplexity int) int - } - - EventLogArg struct { - Name func(childComplexity int) int - Value func(childComplexity int) int - } - - EventLogConnection struct { - Edges func(childComplexity int) int - PageInfo func(childComplexity int) int - TotalCount func(childComplexity int) int - } - - EventLogEdge struct { - Cursor func(childComplexity int) int - Node func(childComplexity int) int - } - - PageInfo struct { - EndCursor func(childComplexity int) int - HasNextPage func(childComplexity int) int - HasPreviousPage func(childComplexity int) int - StartCursor func(childComplexity int) int - } - - Query struct { - AssetPrices func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.AssetPriceOrder, where *ent.AssetPriceWhereInput) int - CorrectnessReports func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.CorrectnessReportOrder, where *ent.CorrectnessReportWhereInput) int - EventLogs func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.EventLogOrder, where *ent.EventLogWhereInput) int - Node func(childComplexity int, id int) int - Nodes func(childComplexity int, ids []int) int - Signers func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.SignerOrder, where *ent.SignerWhereInput) int - } - - Signer struct { - AssetPrice func(childComplexity int) int - CorrectnessReport func(childComplexity int) int - EventLogs func(childComplexity int) int - Evm func(childComplexity int) int - ID func(childComplexity int) int - Key func(childComplexity int) int - Name func(childComplexity int) int - Points func(childComplexity int) int - Shortkey func(childComplexity int) int - } - - SignerConnection struct { - Edges func(childComplexity int) int - PageInfo func(childComplexity int) int - TotalCount func(childComplexity int) int - } - - SignerEdge struct { - Cursor func(childComplexity int) int - Node func(childComplexity int) int - } -} - -type executableSchema struct { - schema *ast.Schema - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} - -func (e *executableSchema) Schema() *ast.Schema { - if e.schema != nil { - return e.schema - } - return parsedSchema -} - -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - ec := executionContext{nil, e, 0, 0, nil} - _ = ec - switch typeName + "." + field { - - case "AssetPrice.asset": - if e.complexity.AssetPrice.Asset == nil { - break - } - - return e.complexity.AssetPrice.Asset(childComplexity), true - - case "AssetPrice.block": - if e.complexity.AssetPrice.Block == nil { - break - } - - return e.complexity.AssetPrice.Block(childComplexity), true - - case "AssetPrice.chain": - if e.complexity.AssetPrice.Chain == nil { - break - } - - return e.complexity.AssetPrice.Chain(childComplexity), true - - case "AssetPrice.consensus": - if e.complexity.AssetPrice.Consensus == nil { - break - } - - return e.complexity.AssetPrice.Consensus(childComplexity), true - - case "AssetPrice.id": - if e.complexity.AssetPrice.ID == nil { - break - } - - return e.complexity.AssetPrice.ID(childComplexity), true - - case "AssetPrice.pair": - if e.complexity.AssetPrice.Pair == nil { - break - } - - return e.complexity.AssetPrice.Pair(childComplexity), true - - case "AssetPrice.price": - if e.complexity.AssetPrice.Price == nil { - break - } - - return e.complexity.AssetPrice.Price(childComplexity), true - - case "AssetPrice.signature": - if e.complexity.AssetPrice.Signature == nil { - break - } - - return e.complexity.AssetPrice.Signature(childComplexity), true - - case "AssetPrice.signers": - if e.complexity.AssetPrice.Signers == nil { - break - } - - return e.complexity.AssetPrice.Signers(childComplexity), true - - case "AssetPrice.signerscount": - if e.complexity.AssetPrice.SignersCount == nil { - break - } - - return e.complexity.AssetPrice.SignersCount(childComplexity), true - - case "AssetPrice.voted": - if e.complexity.AssetPrice.Voted == nil { - break - } - - return e.complexity.AssetPrice.Voted(childComplexity), true - - case "AssetPriceConnection.edges": - if e.complexity.AssetPriceConnection.Edges == nil { - break - } - - return e.complexity.AssetPriceConnection.Edges(childComplexity), true - - case "AssetPriceConnection.pageInfo": - if e.complexity.AssetPriceConnection.PageInfo == nil { - break - } - - return e.complexity.AssetPriceConnection.PageInfo(childComplexity), true - - case "AssetPriceConnection.totalCount": - if e.complexity.AssetPriceConnection.TotalCount == nil { - break - } - - return e.complexity.AssetPriceConnection.TotalCount(childComplexity), true - - case "AssetPriceEdge.cursor": - if e.complexity.AssetPriceEdge.Cursor == nil { - break - } - - return e.complexity.AssetPriceEdge.Cursor(childComplexity), true - - case "AssetPriceEdge.node": - if e.complexity.AssetPriceEdge.Node == nil { - break - } - - return e.complexity.AssetPriceEdge.Node(childComplexity), true - - case "CorrectnessReport.consensus": - if e.complexity.CorrectnessReport.Consensus == nil { - break - } - - return e.complexity.CorrectnessReport.Consensus(childComplexity), true - - case "CorrectnessReport.correct": - if e.complexity.CorrectnessReport.Correct == nil { - break - } - - return e.complexity.CorrectnessReport.Correct(childComplexity), true - - case "CorrectnessReport.hash": - if e.complexity.CorrectnessReport.Hash == nil { - break - } - - return e.complexity.CorrectnessReport.Hash(childComplexity), true - - case "CorrectnessReport.id": - if e.complexity.CorrectnessReport.ID == nil { - break - } - - return e.complexity.CorrectnessReport.ID(childComplexity), true - - case "CorrectnessReport.signature": - if e.complexity.CorrectnessReport.Signature == nil { - break - } - - return e.complexity.CorrectnessReport.Signature(childComplexity), true - - case "CorrectnessReport.signers": - if e.complexity.CorrectnessReport.Signers == nil { - break - } - - return e.complexity.CorrectnessReport.Signers(childComplexity), true - - case "CorrectnessReport.signerscount": - if e.complexity.CorrectnessReport.SignersCount == nil { - break - } - - return e.complexity.CorrectnessReport.SignersCount(childComplexity), true - - case "CorrectnessReport.timestamp": - if e.complexity.CorrectnessReport.Timestamp == nil { - break - } - - return e.complexity.CorrectnessReport.Timestamp(childComplexity), true - - case "CorrectnessReport.topic": - if e.complexity.CorrectnessReport.Topic == nil { - break - } - - return e.complexity.CorrectnessReport.Topic(childComplexity), true - - case "CorrectnessReport.voted": - if e.complexity.CorrectnessReport.Voted == nil { - break - } - - return e.complexity.CorrectnessReport.Voted(childComplexity), true - - case "CorrectnessReportConnection.edges": - if e.complexity.CorrectnessReportConnection.Edges == nil { - break - } - - return e.complexity.CorrectnessReportConnection.Edges(childComplexity), true - - case "CorrectnessReportConnection.pageInfo": - if e.complexity.CorrectnessReportConnection.PageInfo == nil { - break - } - - return e.complexity.CorrectnessReportConnection.PageInfo(childComplexity), true - - case "CorrectnessReportConnection.totalCount": - if e.complexity.CorrectnessReportConnection.TotalCount == nil { - break - } - - return e.complexity.CorrectnessReportConnection.TotalCount(childComplexity), true - - case "CorrectnessReportEdge.cursor": - if e.complexity.CorrectnessReportEdge.Cursor == nil { - break - } - - return e.complexity.CorrectnessReportEdge.Cursor(childComplexity), true - - case "CorrectnessReportEdge.node": - if e.complexity.CorrectnessReportEdge.Node == nil { - break - } - - return e.complexity.CorrectnessReportEdge.Node(childComplexity), true - - case "EventLog.address": - if e.complexity.EventLog.Address == nil { - break - } - - return e.complexity.EventLog.Address(childComplexity), true - - case "EventLog.args": - if e.complexity.EventLog.Args == nil { - break - } - - return e.complexity.EventLog.Args(childComplexity), true - - case "EventLog.block": - if e.complexity.EventLog.Block == nil { - break - } - - return e.complexity.EventLog.Block(childComplexity), true - - case "EventLog.chain": - if e.complexity.EventLog.Chain == nil { - break - } - - return e.complexity.EventLog.Chain(childComplexity), true - - case "EventLog.consensus": - if e.complexity.EventLog.Consensus == nil { - break - } - - return e.complexity.EventLog.Consensus(childComplexity), true - - case "EventLog.event": - if e.complexity.EventLog.Event == nil { - break - } - - return e.complexity.EventLog.Event(childComplexity), true - - case "EventLog.id": - if e.complexity.EventLog.ID == nil { - break - } - - return e.complexity.EventLog.ID(childComplexity), true - - case "EventLog.index": - if e.complexity.EventLog.Index == nil { - break - } - - return e.complexity.EventLog.Index(childComplexity), true - - case "EventLog.signature": - if e.complexity.EventLog.Signature == nil { - break - } - - return e.complexity.EventLog.Signature(childComplexity), true - - case "EventLog.signers": - if e.complexity.EventLog.Signers == nil { - break - } - - return e.complexity.EventLog.Signers(childComplexity), true - - case "EventLog.signerscount": - if e.complexity.EventLog.SignersCount == nil { - break - } - - return e.complexity.EventLog.SignersCount(childComplexity), true - - case "EventLog.transaction": - if e.complexity.EventLog.Transaction == nil { - break - } - - return e.complexity.EventLog.Transaction(childComplexity), true - - case "EventLog.voted": - if e.complexity.EventLog.Voted == nil { - break - } - - return e.complexity.EventLog.Voted(childComplexity), true - - case "EventLogArg.name": - if e.complexity.EventLogArg.Name == nil { - break - } - - return e.complexity.EventLogArg.Name(childComplexity), true - - case "EventLogArg.value": - if e.complexity.EventLogArg.Value == nil { - break - } - - return e.complexity.EventLogArg.Value(childComplexity), true - - case "EventLogConnection.edges": - if e.complexity.EventLogConnection.Edges == nil { - break - } - - return e.complexity.EventLogConnection.Edges(childComplexity), true - - case "EventLogConnection.pageInfo": - if e.complexity.EventLogConnection.PageInfo == nil { - break - } - - return e.complexity.EventLogConnection.PageInfo(childComplexity), true - - case "EventLogConnection.totalCount": - if e.complexity.EventLogConnection.TotalCount == nil { - break - } - - return e.complexity.EventLogConnection.TotalCount(childComplexity), true - - case "EventLogEdge.cursor": - if e.complexity.EventLogEdge.Cursor == nil { - break - } - - return e.complexity.EventLogEdge.Cursor(childComplexity), true - - case "EventLogEdge.node": - if e.complexity.EventLogEdge.Node == nil { - break - } - - return e.complexity.EventLogEdge.Node(childComplexity), true - - case "PageInfo.endCursor": - if e.complexity.PageInfo.EndCursor == nil { - break - } - - return e.complexity.PageInfo.EndCursor(childComplexity), true - - case "PageInfo.hasNextPage": - if e.complexity.PageInfo.HasNextPage == nil { - break - } - - return e.complexity.PageInfo.HasNextPage(childComplexity), true - - case "PageInfo.hasPreviousPage": - if e.complexity.PageInfo.HasPreviousPage == nil { - break - } - - return e.complexity.PageInfo.HasPreviousPage(childComplexity), true - - case "PageInfo.startCursor": - if e.complexity.PageInfo.StartCursor == nil { - break - } - - return e.complexity.PageInfo.StartCursor(childComplexity), true - - case "Query.assetPrices": - if e.complexity.Query.AssetPrices == nil { - break - } - - args, err := ec.field_Query_assetPrices_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.AssetPrices(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["orderBy"].(*ent.AssetPriceOrder), args["where"].(*ent.AssetPriceWhereInput)), true - - case "Query.correctnessReports": - if e.complexity.Query.CorrectnessReports == nil { - break - } - - args, err := ec.field_Query_correctnessReports_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.CorrectnessReports(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["orderBy"].(*ent.CorrectnessReportOrder), args["where"].(*ent.CorrectnessReportWhereInput)), true - - case "Query.eventLogs": - if e.complexity.Query.EventLogs == nil { - break - } - - args, err := ec.field_Query_eventLogs_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.EventLogs(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["orderBy"].(*ent.EventLogOrder), args["where"].(*ent.EventLogWhereInput)), true - - case "Query.node": - if e.complexity.Query.Node == nil { - break - } - - args, err := ec.field_Query_node_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Node(childComplexity, args["id"].(int)), true - - case "Query.nodes": - if e.complexity.Query.Nodes == nil { - break - } - - args, err := ec.field_Query_nodes_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Nodes(childComplexity, args["ids"].([]int)), true - - case "Query.signers": - if e.complexity.Query.Signers == nil { - break - } - - args, err := ec.field_Query_signers_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Signers(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["orderBy"].(*ent.SignerOrder), args["where"].(*ent.SignerWhereInput)), true - - case "Signer.assetprice": - if e.complexity.Signer.AssetPrice == nil { - break - } - - return e.complexity.Signer.AssetPrice(childComplexity), true - - case "Signer.correctnessreport": - if e.complexity.Signer.CorrectnessReport == nil { - break - } - - return e.complexity.Signer.CorrectnessReport(childComplexity), true - - case "Signer.eventlogs": - if e.complexity.Signer.EventLogs == nil { - break - } - - return e.complexity.Signer.EventLogs(childComplexity), true - - case "Signer.evm": - if e.complexity.Signer.Evm == nil { - break - } - - return e.complexity.Signer.Evm(childComplexity), true - - case "Signer.id": - if e.complexity.Signer.ID == nil { - break - } - - return e.complexity.Signer.ID(childComplexity), true - - case "Signer.key": - if e.complexity.Signer.Key == nil { - break - } - - return e.complexity.Signer.Key(childComplexity), true - - case "Signer.name": - if e.complexity.Signer.Name == nil { - break - } - - return e.complexity.Signer.Name(childComplexity), true - - case "Signer.points": - if e.complexity.Signer.Points == nil { - break - } - - return e.complexity.Signer.Points(childComplexity), true - - case "Signer.shortkey": - if e.complexity.Signer.Shortkey == nil { - break - } - - return e.complexity.Signer.Shortkey(childComplexity), true - - case "SignerConnection.edges": - if e.complexity.SignerConnection.Edges == nil { - break - } - - return e.complexity.SignerConnection.Edges(childComplexity), true - - case "SignerConnection.pageInfo": - if e.complexity.SignerConnection.PageInfo == nil { - break - } - - return e.complexity.SignerConnection.PageInfo(childComplexity), true - - case "SignerConnection.totalCount": - if e.complexity.SignerConnection.TotalCount == nil { - break - } - - return e.complexity.SignerConnection.TotalCount(childComplexity), true - - case "SignerEdge.cursor": - if e.complexity.SignerEdge.Cursor == nil { - break - } - - return e.complexity.SignerEdge.Cursor(childComplexity), true - - case "SignerEdge.node": - if e.complexity.SignerEdge.Node == nil { - break - } - - return e.complexity.SignerEdge.Node(childComplexity), true - - } - return 0, false -} - -func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { - rc := graphql.GetOperationContext(ctx) - ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} - inputUnmarshalMap := graphql.BuildUnmarshalerMap( - ec.unmarshalInputAssetPriceOrder, - ec.unmarshalInputAssetPriceWhereInput, - ec.unmarshalInputCorrectnessReportOrder, - ec.unmarshalInputCorrectnessReportWhereInput, - ec.unmarshalInputEventLogOrder, - ec.unmarshalInputEventLogWhereInput, - ec.unmarshalInputSignerOrder, - ec.unmarshalInputSignerWhereInput, - ) - first := true - - switch rc.Operation.Operation { - case ast.Query: - return func(ctx context.Context) *graphql.Response { - var response graphql.Response - var data graphql.Marshaler - if first { - first = false - ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) - data = ec._Query(ctx, rc.Operation.SelectionSet) - } else { - if atomic.LoadInt32(&ec.pendingDeferred) > 0 { - result := <-ec.deferredResults - atomic.AddInt32(&ec.pendingDeferred, -1) - data = result.Result - response.Path = result.Path - response.Label = result.Label - response.Errors = result.Errors - } else { - return nil - } - } - var buf bytes.Buffer - data.MarshalGQL(&buf) - response.Data = buf.Bytes() - if atomic.LoadInt32(&ec.deferred) > 0 { - hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 - response.HasNext = &hasNext - } - - return &response - } - - default: - return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) - } -} - -type executionContext struct { - *graphql.OperationContext - *executableSchema - deferred int32 - pendingDeferred int32 - deferredResults chan graphql.DeferredResult -} - -func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { - atomic.AddInt32(&ec.pendingDeferred, 1) - go func() { - ctx := graphql.WithFreshResponseContext(dg.Context) - dg.FieldSet.Dispatch(ctx) - ds := graphql.DeferredResult{ - Path: dg.Path, - Label: dg.Label, - Result: dg.FieldSet, - Errors: graphql.GetErrors(ctx), - } - // null fields should bubble up - if dg.FieldSet.Invalids > 0 { - ds.Result = graphql.Null - } - ec.deferredResults <- ds - }() -} - -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapSchema(ec.Schema()), nil -} - -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil -} - -var sources = []*ast.Source{ - {Name: "../args.graphql", Input: `scalar BigInt -scalar Bytes - -type EventLogArg { - name: String! - value: String! -} -`, BuiltIn: false}, - {Name: "../extensions.graphql", Input: `extend input SignerWhereInput { - key: String -} - -extend input CorrectnessReportWhereInput { - topic: String - hash: String -} -`, BuiltIn: false}, - {Name: "../unchained.graphql", Input: `directive @goField(forceResolver: Boolean, name: String) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION -directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION -type AssetPrice implements Node { - id: ID! - block: Uint! - signerscount: Uint @goField(name: "SignersCount", forceResolver: false) - price: Uint! - signature: Bytes! - asset: String - chain: String - pair: String - consensus: Boolean! - voted: Uint! - signers: [Signer!]! -} -""" -A connection to a list of items. -""" -type AssetPriceConnection { - """ - A list of edges. - """ - edges: [AssetPriceEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} -""" -An edge in a connection. -""" -type AssetPriceEdge { - """ - The item at the end of the edge. - """ - node: AssetPrice - """ - A cursor for use in pagination. - """ - cursor: Cursor! -} -""" -Ordering options for AssetPrice connections -""" -input AssetPriceOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order AssetPrices. - """ - field: AssetPriceOrderField! -} -""" -Properties by which AssetPrice connections can be ordered. -""" -enum AssetPriceOrderField { - BLOCK -} -""" -AssetPriceWhereInput is used for filtering AssetPrice objects. -Input was generated by ent. -""" -input AssetPriceWhereInput { - not: AssetPriceWhereInput - and: [AssetPriceWhereInput!] - or: [AssetPriceWhereInput!] - """ - id field predicates - """ - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """ - block field predicates - """ - block: Uint - blockNEQ: Uint - blockIn: [Uint!] - blockNotIn: [Uint!] - blockGT: Uint - blockGTE: Uint - blockLT: Uint - blockLTE: Uint - """ - signersCount field predicates - """ - signerscount: Uint - signerscountNEQ: Uint - signerscountIn: [Uint!] - signerscountNotIn: [Uint!] - signerscountGT: Uint - signerscountGTE: Uint - signerscountLT: Uint - signerscountLTE: Uint - signerscountIsNil: Boolean - signerscountNotNil: Boolean - """ - price field predicates - """ - price: Uint - priceNEQ: Uint - priceIn: [Uint!] - priceNotIn: [Uint!] - priceGT: Uint - priceGTE: Uint - priceLT: Uint - priceLTE: Uint - """ - asset field predicates - """ - asset: String - assetNEQ: String - assetIn: [String!] - assetNotIn: [String!] - assetGT: String - assetGTE: String - assetLT: String - assetLTE: String - assetContains: String - assetHasPrefix: String - assetHasSuffix: String - assetIsNil: Boolean - assetNotNil: Boolean - assetEqualFold: String - assetContainsFold: String - """ - chain field predicates - """ - chain: String - chainNEQ: String - chainIn: [String!] - chainNotIn: [String!] - chainGT: String - chainGTE: String - chainLT: String - chainLTE: String - chainContains: String - chainHasPrefix: String - chainHasSuffix: String - chainIsNil: Boolean - chainNotNil: Boolean - chainEqualFold: String - chainContainsFold: String - """ - pair field predicates - """ - pair: String - pairNEQ: String - pairIn: [String!] - pairNotIn: [String!] - pairGT: String - pairGTE: String - pairLT: String - pairLTE: String - pairContains: String - pairHasPrefix: String - pairHasSuffix: String - pairIsNil: Boolean - pairNotNil: Boolean - pairEqualFold: String - pairContainsFold: String - """ - consensus field predicates - """ - consensus: Boolean - consensusNEQ: Boolean - """ - voted field predicates - """ - voted: Uint - votedNEQ: Uint - votedIn: [Uint!] - votedNotIn: [Uint!] - votedGT: Uint - votedGTE: Uint - votedLT: Uint - votedLTE: Uint - """ - signers edge predicates - """ - hasSigners: Boolean - hasSignersWith: [SignerWhereInput!] -} -type CorrectnessReport implements Node { - id: ID! - signerscount: Uint! @goField(name: "SignersCount", forceResolver: false) - timestamp: Uint! - signature: Bytes! - hash: Bytes! - topic: Bytes! - correct: Boolean! - consensus: Boolean! - voted: Uint! - signers: [Signer!]! -} -""" -A connection to a list of items. -""" -type CorrectnessReportConnection { - """ - A list of edges. - """ - edges: [CorrectnessReportEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} -""" -An edge in a connection. -""" -type CorrectnessReportEdge { - """ - The item at the end of the edge. - """ - node: CorrectnessReport - """ - A cursor for use in pagination. - """ - cursor: Cursor! -} -""" -Ordering options for CorrectnessReport connections -""" -input CorrectnessReportOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order CorrectnessReports. - """ - field: CorrectnessReportOrderField! -} -""" -Properties by which CorrectnessReport connections can be ordered. -""" -enum CorrectnessReportOrderField { - TIMESTAMP -} -""" -CorrectnessReportWhereInput is used for filtering CorrectnessReport objects. -Input was generated by ent. -""" -input CorrectnessReportWhereInput { - not: CorrectnessReportWhereInput - and: [CorrectnessReportWhereInput!] - or: [CorrectnessReportWhereInput!] - """ - id field predicates - """ - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """ - signersCount field predicates - """ - signerscount: Uint - signerscountNEQ: Uint - signerscountIn: [Uint!] - signerscountNotIn: [Uint!] - signerscountGT: Uint - signerscountGTE: Uint - signerscountLT: Uint - signerscountLTE: Uint - """ - timestamp field predicates - """ - timestamp: Uint - timestampNEQ: Uint - timestampIn: [Uint!] - timestampNotIn: [Uint!] - timestampGT: Uint - timestampGTE: Uint - timestampLT: Uint - timestampLTE: Uint - """ - correct field predicates - """ - correct: Boolean - correctNEQ: Boolean - """ - consensus field predicates - """ - consensus: Boolean - consensusNEQ: Boolean - """ - voted field predicates - """ - voted: Uint - votedNEQ: Uint - votedIn: [Uint!] - votedNotIn: [Uint!] - votedGT: Uint - votedGTE: Uint - votedLT: Uint - votedLTE: Uint - """ - signers edge predicates - """ - hasSigners: Boolean - hasSignersWith: [SignerWhereInput!] -} -""" -Define a Relay Cursor type: -https://relay.dev/graphql/connections.htm#sec-Cursor -""" -scalar Cursor -type EventLog implements Node { - id: ID! - block: Uint! - signerscount: Uint! @goField(name: "SignersCount", forceResolver: false) - signature: Bytes! - address: String! - chain: String! - index: Uint! - event: String! - transaction: Bytes! - args: [EventLogArg!]! - consensus: Boolean! - voted: Uint! - signers: [Signer!]! -} -""" -A connection to a list of items. -""" -type EventLogConnection { - """ - A list of edges. - """ - edges: [EventLogEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} -""" -An edge in a connection. -""" -type EventLogEdge { - """ - The item at the end of the edge. - """ - node: EventLog - """ - A cursor for use in pagination. - """ - cursor: Cursor! -} -""" -Ordering options for EventLog connections -""" -input EventLogOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order EventLogs. - """ - field: EventLogOrderField! -} -""" -Properties by which EventLog connections can be ordered. -""" -enum EventLogOrderField { - BLOCK -} -""" -EventLogWhereInput is used for filtering EventLog objects. -Input was generated by ent. -""" -input EventLogWhereInput { - not: EventLogWhereInput - and: [EventLogWhereInput!] - or: [EventLogWhereInput!] - """ - id field predicates - """ - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """ - block field predicates - """ - block: Uint - blockNEQ: Uint - blockIn: [Uint!] - blockNotIn: [Uint!] - blockGT: Uint - blockGTE: Uint - blockLT: Uint - blockLTE: Uint - """ - signersCount field predicates - """ - signerscount: Uint - signerscountNEQ: Uint - signerscountIn: [Uint!] - signerscountNotIn: [Uint!] - signerscountGT: Uint - signerscountGTE: Uint - signerscountLT: Uint - signerscountLTE: Uint - """ - address field predicates - """ - address: String - addressNEQ: String - addressIn: [String!] - addressNotIn: [String!] - addressGT: String - addressGTE: String - addressLT: String - addressLTE: String - addressContains: String - addressHasPrefix: String - addressHasSuffix: String - addressEqualFold: String - addressContainsFold: String - """ - chain field predicates - """ - chain: String - chainNEQ: String - chainIn: [String!] - chainNotIn: [String!] - chainGT: String - chainGTE: String - chainLT: String - chainLTE: String - chainContains: String - chainHasPrefix: String - chainHasSuffix: String - chainEqualFold: String - chainContainsFold: String - """ - index field predicates - """ - index: Uint - indexNEQ: Uint - indexIn: [Uint!] - indexNotIn: [Uint!] - indexGT: Uint - indexGTE: Uint - indexLT: Uint - indexLTE: Uint - """ - event field predicates - """ - event: String - eventNEQ: String - eventIn: [String!] - eventNotIn: [String!] - eventGT: String - eventGTE: String - eventLT: String - eventLTE: String - eventContains: String - eventHasPrefix: String - eventHasSuffix: String - eventEqualFold: String - eventContainsFold: String - """ - consensus field predicates - """ - consensus: Boolean - consensusNEQ: Boolean - """ - voted field predicates - """ - voted: Uint - votedNEQ: Uint - votedIn: [Uint!] - votedNotIn: [Uint!] - votedGT: Uint - votedGTE: Uint - votedLT: Uint - votedLTE: Uint - """ - signers edge predicates - """ - hasSigners: Boolean - hasSignersWith: [SignerWhereInput!] -} -""" -An object with an ID. -Follows the [Relay Global Object Identification Specification](https://relay.dev/graphql/objectidentification.htm) -""" -interface Node @goModel(model: "github.com/TimeleapLabs/unchained/internal/ent.Noder") { - """ - The id of the object. - """ - id: ID! -} -""" -Possible directions in which to order a list of items when provided an ` + "`" + `orderBy` + "`" + ` argument. -""" -enum OrderDirection { - """ - Specifies an ascending order for a given ` + "`" + `orderBy` + "`" + ` argument. - """ - ASC - """ - Specifies a descending order for a given ` + "`" + `orderBy` + "`" + ` argument. - """ - DESC -} -""" -Information about pagination in a connection. -https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo -""" -type PageInfo { - """ - When paginating forwards, are there more items? - """ - hasNextPage: Boolean! - """ - When paginating backwards, are there more items? - """ - hasPreviousPage: Boolean! - """ - When paginating backwards, the cursor to continue. - """ - startCursor: Cursor - """ - When paginating forwards, the cursor to continue. - """ - endCursor: Cursor -} -type Query { - """ - Fetches an object given its ID. - """ - node( - """ - ID of the object. - """ - id: ID! - ): Node - """ - Lookup nodes by a list of IDs. - """ - nodes( - """ - The list of node IDs. - """ - ids: [ID!]! - ): [Node]! - assetPrices( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for AssetPrices returned from the connection. - """ - orderBy: AssetPriceOrder - - """ - Filtering options for AssetPrices returned from the connection. - """ - where: AssetPriceWhereInput - ): AssetPriceConnection! - correctnessReports( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for CorrectnessReports returned from the connection. - """ - orderBy: CorrectnessReportOrder - - """ - Filtering options for CorrectnessReports returned from the connection. - """ - where: CorrectnessReportWhereInput - ): CorrectnessReportConnection! - eventLogs( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for EventLogs returned from the connection. - """ - orderBy: EventLogOrder - - """ - Filtering options for EventLogs returned from the connection. - """ - where: EventLogWhereInput - ): EventLogConnection! - signers( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for Signers returned from the connection. - """ - orderBy: SignerOrder - - """ - Filtering options for Signers returned from the connection. - """ - where: SignerWhereInput - ): SignerConnection! -} -type Signer implements Node { - id: ID! - name: String! - evm: String - key: Bytes! - shortkey: Bytes! - points: Int! - assetprice: [AssetPrice!] @goField(name: "AssetPrice", forceResolver: false) - eventlogs: [EventLog!] @goField(name: "EventLogs", forceResolver: false) - correctnessreport: [CorrectnessReport!] @goField(name: "CorrectnessReport", forceResolver: false) -} -""" -A connection to a list of items. -""" -type SignerConnection { - """ - A list of edges. - """ - edges: [SignerEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} -""" -An edge in a connection. -""" -type SignerEdge { - """ - The item at the end of the edge. - """ - node: Signer - """ - A cursor for use in pagination. - """ - cursor: Cursor! -} -""" -Ordering options for Signer connections -""" -input SignerOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order Signers. - """ - field: SignerOrderField! -} -""" -Properties by which Signer connections can be ordered. -""" -enum SignerOrderField { - POINTS -} -""" -SignerWhereInput is used for filtering Signer objects. -Input was generated by ent. -""" -input SignerWhereInput { - not: SignerWhereInput - and: [SignerWhereInput!] - or: [SignerWhereInput!] - """ - id field predicates - """ - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """ - name field predicates - """ - name: String - nameNEQ: String - nameIn: [String!] - nameNotIn: [String!] - nameGT: String - nameGTE: String - nameLT: String - nameLTE: String - nameContains: String - nameHasPrefix: String - nameHasSuffix: String - nameEqualFold: String - nameContainsFold: String - """ - evm field predicates - """ - evm: String - evmNEQ: String - evmIn: [String!] - evmNotIn: [String!] - evmGT: String - evmGTE: String - evmLT: String - evmLTE: String - evmContains: String - evmHasPrefix: String - evmHasSuffix: String - evmIsNil: Boolean - evmNotNil: Boolean - evmEqualFold: String - evmContainsFold: String - """ - points field predicates - """ - points: Int - pointsNEQ: Int - pointsIn: [Int!] - pointsNotIn: [Int!] - pointsGT: Int - pointsGTE: Int - pointsLT: Int - pointsLTE: Int - """ - assetPrice edge predicates - """ - hasAssetPrice: Boolean - hasAssetPriceWith: [AssetPriceWhereInput!] - """ - eventLogs edge predicates - """ - hasEventLogs: Boolean - hasEventLogsWith: [EventLogWhereInput!] - """ - correctnessReport edge predicates - """ - hasCorrectnessReport: Boolean - hasCorrectnessReportWith: [CorrectnessReportWhereInput!] -} -""" -The builtin Uint type -""" -scalar Uint -`, BuiltIn: false}, -} -var parsedSchema = gqlparser.MustLoadSchema(sources...) diff --git a/internal/transport/server/gql/generated/unchained.generated.go b/internal/transport/server/gql/generated/unchained.generated.go deleted file mode 100644 index a68d855a..00000000 --- a/internal/transport/server/gql/generated/unchained.generated.go +++ /dev/null @@ -1,8709 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package generated - -import ( - "context" - "errors" - "fmt" - "github.com/TimeleapLabs/unchained/internal/model" - "strconv" - "sync" - "sync/atomic" - - "entgo.io/contrib/entgql" - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/introspection" - "github.com/TimeleapLabs/unchained/internal/ent" - "github.com/TimeleapLabs/unchained/internal/transport/server/gql/types" - "github.com/vektah/gqlparser/v2/ast" -) - -// region ************************** generated!.gotpl ************************** - -type AssetPriceResolver interface { - Price(ctx context.Context, obj *ent.AssetPrice) (uint64, error) - Signature(ctx context.Context, obj *ent.AssetPrice) (types.Bytes, error) - - Voted(ctx context.Context, obj *ent.AssetPrice) (uint64, error) -} -type CorrectnessReportResolver interface { - Signature(ctx context.Context, obj *ent.CorrectnessReport) (types.Bytes, error) - Hash(ctx context.Context, obj *ent.CorrectnessReport) (types.Bytes, error) - Topic(ctx context.Context, obj *ent.CorrectnessReport) (types.Bytes, error) - - Voted(ctx context.Context, obj *ent.CorrectnessReport) (uint64, error) -} -type EventLogResolver interface { - Signature(ctx context.Context, obj *ent.EventLog) (types.Bytes, error) - - Transaction(ctx context.Context, obj *ent.EventLog) (types.Bytes, error) - - Voted(ctx context.Context, obj *ent.EventLog) (uint64, error) -} -type QueryResolver interface { - Node(ctx context.Context, id int) (ent.Noder, error) - Nodes(ctx context.Context, ids []int) ([]ent.Noder, error) - AssetPrices(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.AssetPriceOrder, where *ent.AssetPriceWhereInput) (*ent.AssetPriceConnection, error) - CorrectnessReports(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.CorrectnessReportOrder, where *ent.CorrectnessReportWhereInput) (*ent.CorrectnessReportConnection, error) - EventLogs(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.EventLogOrder, where *ent.EventLogWhereInput) (*ent.EventLogConnection, error) - Signers(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.SignerOrder, where *ent.SignerWhereInput) (*ent.SignerConnection, error) -} -type SignerResolver interface { - Key(ctx context.Context, obj *ent.Signer) (types.Bytes, error) - Shortkey(ctx context.Context, obj *ent.Signer) (types.Bytes, error) -} - -type AssetPriceWhereInputResolver interface { - Price(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - PriceNeq(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - PriceIn(ctx context.Context, obj *ent.AssetPriceWhereInput, data []uint64) error - PriceNotIn(ctx context.Context, obj *ent.AssetPriceWhereInput, data []uint64) error - PriceGt(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - PriceGte(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - PriceLt(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - PriceLte(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - - Voted(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - VotedNeq(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - VotedIn(ctx context.Context, obj *ent.AssetPriceWhereInput, data []uint64) error - VotedNotIn(ctx context.Context, obj *ent.AssetPriceWhereInput, data []uint64) error - VotedGt(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - VotedGte(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - VotedLt(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - VotedLte(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error -} -type CorrectnessReportWhereInputResolver interface { - Voted(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error - VotedNeq(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error - VotedIn(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data []uint64) error - VotedNotIn(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data []uint64) error - VotedGt(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error - VotedGte(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error - VotedLt(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error - VotedLte(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error - - Topic(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *string) error - Hash(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *string) error -} -type EventLogWhereInputResolver interface { - Voted(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error - VotedNeq(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error - VotedIn(ctx context.Context, obj *ent.EventLogWhereInput, data []uint64) error - VotedNotIn(ctx context.Context, obj *ent.EventLogWhereInput, data []uint64) error - VotedGt(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error - VotedGte(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error - VotedLt(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error - VotedLte(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error -} -type SignerWhereInputResolver interface { - Key(ctx context.Context, obj *ent.SignerWhereInput, data *string) error -} - -// endregion ************************** generated!.gotpl ************************** - -// region ***************************** args.gotpl ***************************** - -func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_assetPrices_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 *entgql.Cursor[int] - if tmp, ok := rawArgs["after"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) - arg0, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) - if err != nil { - return nil, err - } - } - args["after"] = arg0 - var arg1 *int - if tmp, ok := rawArgs["first"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) - arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) - if err != nil { - return nil, err - } - } - args["first"] = arg1 - var arg2 *entgql.Cursor[int] - if tmp, ok := rawArgs["before"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) - arg2, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) - if err != nil { - return nil, err - } - } - args["before"] = arg2 - var arg3 *int - if tmp, ok := rawArgs["last"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("last")) - arg3, err = ec.unmarshalOInt2ᚖint(ctx, tmp) - if err != nil { - return nil, err - } - } - args["last"] = arg3 - var arg4 *ent.AssetPriceOrder - if tmp, ok := rawArgs["orderBy"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg4, err = ec.unmarshalOAssetPriceOrder2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceOrder(ctx, tmp) - if err != nil { - return nil, err - } - } - args["orderBy"] = arg4 - var arg5 *ent.AssetPriceWhereInput - if tmp, ok := rawArgs["where"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("where")) - arg5, err = ec.unmarshalOAssetPriceWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceWhereInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["where"] = arg5 - return args, nil -} - -func (ec *executionContext) field_Query_correctnessReports_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 *entgql.Cursor[int] - if tmp, ok := rawArgs["after"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) - arg0, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) - if err != nil { - return nil, err - } - } - args["after"] = arg0 - var arg1 *int - if tmp, ok := rawArgs["first"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) - arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) - if err != nil { - return nil, err - } - } - args["first"] = arg1 - var arg2 *entgql.Cursor[int] - if tmp, ok := rawArgs["before"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) - arg2, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) - if err != nil { - return nil, err - } - } - args["before"] = arg2 - var arg3 *int - if tmp, ok := rawArgs["last"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("last")) - arg3, err = ec.unmarshalOInt2ᚖint(ctx, tmp) - if err != nil { - return nil, err - } - } - args["last"] = arg3 - var arg4 *ent.CorrectnessReportOrder - if tmp, ok := rawArgs["orderBy"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg4, err = ec.unmarshalOCorrectnessReportOrder2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportOrder(ctx, tmp) - if err != nil { - return nil, err - } - } - args["orderBy"] = arg4 - var arg5 *ent.CorrectnessReportWhereInput - if tmp, ok := rawArgs["where"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("where")) - arg5, err = ec.unmarshalOCorrectnessReportWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportWhereInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["where"] = arg5 - return args, nil -} - -func (ec *executionContext) field_Query_eventLogs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 *entgql.Cursor[int] - if tmp, ok := rawArgs["after"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) - arg0, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) - if err != nil { - return nil, err - } - } - args["after"] = arg0 - var arg1 *int - if tmp, ok := rawArgs["first"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) - arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) - if err != nil { - return nil, err - } - } - args["first"] = arg1 - var arg2 *entgql.Cursor[int] - if tmp, ok := rawArgs["before"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) - arg2, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) - if err != nil { - return nil, err - } - } - args["before"] = arg2 - var arg3 *int - if tmp, ok := rawArgs["last"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("last")) - arg3, err = ec.unmarshalOInt2ᚖint(ctx, tmp) - if err != nil { - return nil, err - } - } - args["last"] = arg3 - var arg4 *ent.EventLogOrder - if tmp, ok := rawArgs["orderBy"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg4, err = ec.unmarshalOEventLogOrder2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogOrder(ctx, tmp) - if err != nil { - return nil, err - } - } - args["orderBy"] = arg4 - var arg5 *ent.EventLogWhereInput - if tmp, ok := rawArgs["where"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("where")) - arg5, err = ec.unmarshalOEventLogWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogWhereInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["where"] = arg5 - return args, nil -} - -func (ec *executionContext) field_Query_node_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 int - if tmp, ok := rawArgs["id"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - arg0, err = ec.unmarshalNID2int(ctx, tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_nodes_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 []int - if tmp, ok := rawArgs["ids"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ids")) - arg0, err = ec.unmarshalNID2ᚕintᚄ(ctx, tmp) - if err != nil { - return nil, err - } - } - args["ids"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_signers_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 *entgql.Cursor[int] - if tmp, ok := rawArgs["after"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) - arg0, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) - if err != nil { - return nil, err - } - } - args["after"] = arg0 - var arg1 *int - if tmp, ok := rawArgs["first"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) - arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) - if err != nil { - return nil, err - } - } - args["first"] = arg1 - var arg2 *entgql.Cursor[int] - if tmp, ok := rawArgs["before"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) - arg2, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) - if err != nil { - return nil, err - } - } - args["before"] = arg2 - var arg3 *int - if tmp, ok := rawArgs["last"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("last")) - arg3, err = ec.unmarshalOInt2ᚖint(ctx, tmp) - if err != nil { - return nil, err - } - } - args["last"] = arg3 - var arg4 *ent.SignerOrder - if tmp, ok := rawArgs["orderBy"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg4, err = ec.unmarshalOSignerOrder2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerOrder(ctx, tmp) - if err != nil { - return nil, err - } - } - args["orderBy"] = arg4 - var arg5 *ent.SignerWhereInput - if tmp, ok := rawArgs["where"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("where")) - arg5, err = ec.unmarshalOSignerWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["where"] = arg5 - return args, nil -} - -// endregion ***************************** args.gotpl ***************************** - -// region ************************** directives.gotpl ************************** - -// endregion ************************** directives.gotpl ************************** - -// region **************************** field.gotpl ***************************** - -func (ec *executionContext) _AssetPrice_id(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_id(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_block(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_block(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Block, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_block(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_signerscount(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_signerscount(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SignersCount, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*uint64) - fc.Result = res - return ec.marshalOUint2ᚖuint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_signerscount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_price(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_price(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.AssetPrice().Price(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_price(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_signature(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_signature(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.AssetPrice().Signature(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(types.Bytes) - fc.Result = res - return ec.marshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_signature(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Bytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_asset(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_asset(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Asset, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_asset(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_chain(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_chain(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Chain, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_chain(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_pair(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_pair(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Pair, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_pair(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_consensus(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_consensus(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Consensus, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_consensus(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_voted(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_voted(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.AssetPrice().Voted(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_voted(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_signers(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_signers(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Signers(ctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]*ent.Signer) - fc.Result = res - return ec.marshalNSigner2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_signers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Signer_id(ctx, field) - case "name": - return ec.fieldContext_Signer_name(ctx, field) - case "evm": - return ec.fieldContext_Signer_evm(ctx, field) - case "key": - return ec.fieldContext_Signer_key(ctx, field) - case "shortkey": - return ec.fieldContext_Signer_shortkey(ctx, field) - case "points": - return ec.fieldContext_Signer_points(ctx, field) - case "assetprice": - return ec.fieldContext_Signer_assetprice(ctx, field) - case "eventlogs": - return ec.fieldContext_Signer_eventlogs(ctx, field) - case "correctnessreport": - return ec.fieldContext_Signer_correctnessreport(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Signer", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPriceConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPriceConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPriceConnection_edges(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Edges, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*ent.AssetPriceEdge) - fc.Result = res - return ec.marshalOAssetPriceEdge2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceEdge(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPriceConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPriceConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_AssetPriceEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_AssetPriceEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AssetPriceEdge", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPriceConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPriceConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPriceConnection_pageInfo(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PageInfo, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(entgql.PageInfo[int]) - fc.Result = res - return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPriceConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPriceConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPriceConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPriceConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPriceConnection_totalCount(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.TotalCount, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPriceConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPriceConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPriceEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPriceEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPriceEdge_node(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Node, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*ent.AssetPrice) - fc.Result = res - return ec.marshalOAssetPrice2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPrice(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPriceEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPriceEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_AssetPrice_id(ctx, field) - case "block": - return ec.fieldContext_AssetPrice_block(ctx, field) - case "signerscount": - return ec.fieldContext_AssetPrice_signerscount(ctx, field) - case "price": - return ec.fieldContext_AssetPrice_price(ctx, field) - case "signature": - return ec.fieldContext_AssetPrice_signature(ctx, field) - case "asset": - return ec.fieldContext_AssetPrice_asset(ctx, field) - case "chain": - return ec.fieldContext_AssetPrice_chain(ctx, field) - case "pair": - return ec.fieldContext_AssetPrice_pair(ctx, field) - case "consensus": - return ec.fieldContext_AssetPrice_consensus(ctx, field) - case "voted": - return ec.fieldContext_AssetPrice_voted(ctx, field) - case "signers": - return ec.fieldContext_AssetPrice_signers(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AssetPrice", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPriceEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPriceEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPriceEdge_cursor(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(entgql.Cursor[int]) - fc.Result = res - return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPriceEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPriceEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_id(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_id(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_signerscount(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_signerscount(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SignersCount, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_signerscount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_timestamp(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_timestamp(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Timestamp, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_timestamp(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_signature(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_signature(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.CorrectnessReport().Signature(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(types.Bytes) - fc.Result = res - return ec.marshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_signature(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Bytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_hash(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_hash(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.CorrectnessReport().Hash(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(types.Bytes) - fc.Result = res - return ec.marshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_hash(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Bytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_topic(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_topic(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.CorrectnessReport().Topic(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(types.Bytes) - fc.Result = res - return ec.marshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_topic(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Bytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_correct(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_correct(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Correct, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_correct(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_consensus(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_consensus(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Consensus, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_consensus(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_voted(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_voted(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.CorrectnessReport().Voted(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_voted(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_signers(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_signers(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Signers(ctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]*ent.Signer) - fc.Result = res - return ec.marshalNSigner2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_signers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Signer_id(ctx, field) - case "name": - return ec.fieldContext_Signer_name(ctx, field) - case "evm": - return ec.fieldContext_Signer_evm(ctx, field) - case "key": - return ec.fieldContext_Signer_key(ctx, field) - case "shortkey": - return ec.fieldContext_Signer_shortkey(ctx, field) - case "points": - return ec.fieldContext_Signer_points(ctx, field) - case "assetprice": - return ec.fieldContext_Signer_assetprice(ctx, field) - case "eventlogs": - return ec.fieldContext_Signer_eventlogs(ctx, field) - case "correctnessreport": - return ec.fieldContext_Signer_correctnessreport(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Signer", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReportConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReportConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReportConnection_edges(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Edges, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*ent.CorrectnessReportEdge) - fc.Result = res - return ec.marshalOCorrectnessReportEdge2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportEdge(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReportConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReportConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_CorrectnessReportEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_CorrectnessReportEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type CorrectnessReportEdge", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReportConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReportConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReportConnection_pageInfo(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PageInfo, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(entgql.PageInfo[int]) - fc.Result = res - return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReportConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReportConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReportConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReportConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReportConnection_totalCount(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.TotalCount, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReportConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReportConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReportEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReportEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReportEdge_node(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Node, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*ent.CorrectnessReport) - fc.Result = res - return ec.marshalOCorrectnessReport2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReport(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReportEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReportEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_CorrectnessReport_id(ctx, field) - case "signerscount": - return ec.fieldContext_CorrectnessReport_signerscount(ctx, field) - case "timestamp": - return ec.fieldContext_CorrectnessReport_timestamp(ctx, field) - case "signature": - return ec.fieldContext_CorrectnessReport_signature(ctx, field) - case "hash": - return ec.fieldContext_CorrectnessReport_hash(ctx, field) - case "topic": - return ec.fieldContext_CorrectnessReport_topic(ctx, field) - case "correct": - return ec.fieldContext_CorrectnessReport_correct(ctx, field) - case "consensus": - return ec.fieldContext_CorrectnessReport_consensus(ctx, field) - case "voted": - return ec.fieldContext_CorrectnessReport_voted(ctx, field) - case "signers": - return ec.fieldContext_CorrectnessReport_signers(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type CorrectnessReport", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReportEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReportEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReportEdge_cursor(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(entgql.Cursor[int]) - fc.Result = res - return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReportEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReportEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_id(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_id(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_block(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_block(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Block, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_block(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_signerscount(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_signerscount(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SignersCount, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_signerscount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_signature(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_signature(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.EventLog().Signature(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(types.Bytes) - fc.Result = res - return ec.marshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_signature(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Bytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_address(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_address(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Address, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_address(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_chain(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_chain(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Chain, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_chain(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_index(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_index(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Index, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_index(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_event(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_event(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Event, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_event(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_transaction(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_transaction(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.EventLog().Transaction(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(types.Bytes) - fc.Result = res - return ec.marshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_transaction(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Bytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_args(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_args(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]model.EventLogArg) - fc.Result = res - return ec.marshalNEventLogArg2ᚕgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋdatasetsᚐEventLogArgᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext_EventLogArg_name(ctx, field) - case "value": - return ec.fieldContext_EventLogArg_value(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type EventLogArg", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_consensus(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_consensus(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Consensus, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_consensus(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_voted(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_voted(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.EventLog().Voted(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_voted(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_signers(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_signers(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Signers(ctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]*ent.Signer) - fc.Result = res - return ec.marshalNSigner2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_signers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Signer_id(ctx, field) - case "name": - return ec.fieldContext_Signer_name(ctx, field) - case "evm": - return ec.fieldContext_Signer_evm(ctx, field) - case "key": - return ec.fieldContext_Signer_key(ctx, field) - case "shortkey": - return ec.fieldContext_Signer_shortkey(ctx, field) - case "points": - return ec.fieldContext_Signer_points(ctx, field) - case "assetprice": - return ec.fieldContext_Signer_assetprice(ctx, field) - case "eventlogs": - return ec.fieldContext_Signer_eventlogs(ctx, field) - case "correctnessreport": - return ec.fieldContext_Signer_correctnessreport(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Signer", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLogConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.EventLogConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLogConnection_edges(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Edges, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*ent.EventLogEdge) - fc.Result = res - return ec.marshalOEventLogEdge2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogEdge(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLogConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLogConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_EventLogEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_EventLogEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type EventLogEdge", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLogConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.EventLogConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLogConnection_pageInfo(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PageInfo, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(entgql.PageInfo[int]) - fc.Result = res - return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLogConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLogConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLogConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.EventLogConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLogConnection_totalCount(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.TotalCount, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLogConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLogConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLogEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.EventLogEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLogEdge_node(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Node, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*ent.EventLog) - fc.Result = res - return ec.marshalOEventLog2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLog(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLogEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLogEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_EventLog_id(ctx, field) - case "block": - return ec.fieldContext_EventLog_block(ctx, field) - case "signerscount": - return ec.fieldContext_EventLog_signerscount(ctx, field) - case "signature": - return ec.fieldContext_EventLog_signature(ctx, field) - case "address": - return ec.fieldContext_EventLog_address(ctx, field) - case "chain": - return ec.fieldContext_EventLog_chain(ctx, field) - case "index": - return ec.fieldContext_EventLog_index(ctx, field) - case "event": - return ec.fieldContext_EventLog_event(ctx, field) - case "transaction": - return ec.fieldContext_EventLog_transaction(ctx, field) - case "args": - return ec.fieldContext_EventLog_args(ctx, field) - case "consensus": - return ec.fieldContext_EventLog_consensus(ctx, field) - case "voted": - return ec.fieldContext_EventLog_voted(ctx, field) - case "signers": - return ec.fieldContext_EventLog_signers(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type EventLog", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLogEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.EventLogEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLogEdge_cursor(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(entgql.Cursor[int]) - fc.Result = res - return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLogEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLogEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.HasNextPage, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "PageInfo", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.HasPreviousPage, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "PageInfo", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_startCursor(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.StartCursor, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*entgql.Cursor[int]) - fc.Result = res - return ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_PageInfo_startCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "PageInfo", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_endCursor(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EndCursor, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*entgql.Cursor[int]) - fc.Result = res - return ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_PageInfo_endCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "PageInfo", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_node(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Node(rctx, fc.Args["id"].(int)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(ent.Noder) - fc.Result = res - return ec.marshalONode2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐNoder(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_nodes(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Nodes(rctx, fc.Args["ids"].([]int)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]ent.Noder) - fc.Result = res - return ec.marshalNNode2ᚕgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐNoder(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query_assetPrices(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_assetPrices(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().AssetPrices(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].(*ent.AssetPriceOrder), fc.Args["where"].(*ent.AssetPriceWhereInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*ent.AssetPriceConnection) - fc.Result = res - return ec.marshalNAssetPriceConnection2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceConnection(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_assetPrices(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_AssetPriceConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_AssetPriceConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_AssetPriceConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AssetPriceConnection", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_assetPrices_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query_correctnessReports(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_correctnessReports(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().CorrectnessReports(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].(*ent.CorrectnessReportOrder), fc.Args["where"].(*ent.CorrectnessReportWhereInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*ent.CorrectnessReportConnection) - fc.Result = res - return ec.marshalNCorrectnessReportConnection2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportConnection(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_correctnessReports(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_CorrectnessReportConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_CorrectnessReportConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_CorrectnessReportConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type CorrectnessReportConnection", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_correctnessReports_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query_eventLogs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_eventLogs(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().EventLogs(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].(*ent.EventLogOrder), fc.Args["where"].(*ent.EventLogWhereInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*ent.EventLogConnection) - fc.Result = res - return ec.marshalNEventLogConnection2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogConnection(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_eventLogs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_EventLogConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_EventLogConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_EventLogConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type EventLogConnection", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_eventLogs_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query_signers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_signers(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Signers(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].(*ent.SignerOrder), fc.Args["where"].(*ent.SignerWhereInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*ent.SignerConnection) - fc.Result = res - return ec.marshalNSignerConnection2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerConnection(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_signers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_SignerConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_SignerConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_SignerConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type SignerConnection", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_signers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___type(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectType(fc.Args["name"].(string)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___schema(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Schema) - fc.Result = res - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "description": - return ec.fieldContext___Schema_description(ctx, field) - case "types": - return ec.fieldContext___Schema_types(ctx, field) - case "queryType": - return ec.fieldContext___Schema_queryType(ctx, field) - case "mutationType": - return ec.fieldContext___Schema_mutationType(ctx, field) - case "subscriptionType": - return ec.fieldContext___Schema_subscriptionType(ctx, field) - case "directives": - return ec.fieldContext___Schema_directives(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Signer_id(ctx context.Context, field graphql.CollectedField, obj *ent.Signer) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signer_id(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Signer_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Signer", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Signer_name(ctx context.Context, field graphql.CollectedField, obj *ent.Signer) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signer_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Signer_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Signer", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Signer_evm(ctx context.Context, field graphql.CollectedField, obj *ent.Signer) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signer_evm(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Evm, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Signer_evm(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Signer", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Signer_key(ctx context.Context, field graphql.CollectedField, obj *ent.Signer) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signer_key(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Signer().Key(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(types.Bytes) - fc.Result = res - return ec.marshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Signer_key(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Signer", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Bytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Signer_shortkey(ctx context.Context, field graphql.CollectedField, obj *ent.Signer) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signer_shortkey(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Signer().Shortkey(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(types.Bytes) - fc.Result = res - return ec.marshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Signer_shortkey(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Signer", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Bytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Signer_points(ctx context.Context, field graphql.CollectedField, obj *ent.Signer) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signer_points(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Points, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int64) - fc.Result = res - return ec.marshalNInt2int64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Signer_points(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Signer", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Signer_assetprice(ctx context.Context, field graphql.CollectedField, obj *ent.Signer) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signer_assetprice(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.AssetPrice(ctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*ent.AssetPrice) - fc.Result = res - return ec.marshalOAssetPrice2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Signer_assetprice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Signer", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_AssetPrice_id(ctx, field) - case "block": - return ec.fieldContext_AssetPrice_block(ctx, field) - case "signerscount": - return ec.fieldContext_AssetPrice_signerscount(ctx, field) - case "price": - return ec.fieldContext_AssetPrice_price(ctx, field) - case "signature": - return ec.fieldContext_AssetPrice_signature(ctx, field) - case "asset": - return ec.fieldContext_AssetPrice_asset(ctx, field) - case "chain": - return ec.fieldContext_AssetPrice_chain(ctx, field) - case "pair": - return ec.fieldContext_AssetPrice_pair(ctx, field) - case "consensus": - return ec.fieldContext_AssetPrice_consensus(ctx, field) - case "voted": - return ec.fieldContext_AssetPrice_voted(ctx, field) - case "signers": - return ec.fieldContext_AssetPrice_signers(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AssetPrice", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Signer_eventlogs(ctx context.Context, field graphql.CollectedField, obj *ent.Signer) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signer_eventlogs(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EventLogs(ctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*ent.EventLog) - fc.Result = res - return ec.marshalOEventLog2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Signer_eventlogs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Signer", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_EventLog_id(ctx, field) - case "block": - return ec.fieldContext_EventLog_block(ctx, field) - case "signerscount": - return ec.fieldContext_EventLog_signerscount(ctx, field) - case "signature": - return ec.fieldContext_EventLog_signature(ctx, field) - case "address": - return ec.fieldContext_EventLog_address(ctx, field) - case "chain": - return ec.fieldContext_EventLog_chain(ctx, field) - case "index": - return ec.fieldContext_EventLog_index(ctx, field) - case "event": - return ec.fieldContext_EventLog_event(ctx, field) - case "transaction": - return ec.fieldContext_EventLog_transaction(ctx, field) - case "args": - return ec.fieldContext_EventLog_args(ctx, field) - case "consensus": - return ec.fieldContext_EventLog_consensus(ctx, field) - case "voted": - return ec.fieldContext_EventLog_voted(ctx, field) - case "signers": - return ec.fieldContext_EventLog_signers(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type EventLog", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Signer_correctnessreport(ctx context.Context, field graphql.CollectedField, obj *ent.Signer) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signer_correctnessreport(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.CorrectnessReport(ctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*ent.CorrectnessReport) - fc.Result = res - return ec.marshalOCorrectnessReport2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Signer_correctnessreport(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Signer", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_CorrectnessReport_id(ctx, field) - case "signerscount": - return ec.fieldContext_CorrectnessReport_signerscount(ctx, field) - case "timestamp": - return ec.fieldContext_CorrectnessReport_timestamp(ctx, field) - case "signature": - return ec.fieldContext_CorrectnessReport_signature(ctx, field) - case "hash": - return ec.fieldContext_CorrectnessReport_hash(ctx, field) - case "topic": - return ec.fieldContext_CorrectnessReport_topic(ctx, field) - case "correct": - return ec.fieldContext_CorrectnessReport_correct(ctx, field) - case "consensus": - return ec.fieldContext_CorrectnessReport_consensus(ctx, field) - case "voted": - return ec.fieldContext_CorrectnessReport_voted(ctx, field) - case "signers": - return ec.fieldContext_CorrectnessReport_signers(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type CorrectnessReport", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _SignerConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.SignerConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SignerConnection_edges(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Edges, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*ent.SignerEdge) - fc.Result = res - return ec.marshalOSignerEdge2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerEdge(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_SignerConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "SignerConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_SignerEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_SignerEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type SignerEdge", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _SignerConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.SignerConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SignerConnection_pageInfo(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PageInfo, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(entgql.PageInfo[int]) - fc.Result = res - return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_SignerConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "SignerConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _SignerConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.SignerConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SignerConnection_totalCount(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.TotalCount, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_SignerConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "SignerConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _SignerEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.SignerEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SignerEdge_node(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Node, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*ent.Signer) - fc.Result = res - return ec.marshalOSigner2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSigner(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_SignerEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "SignerEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Signer_id(ctx, field) - case "name": - return ec.fieldContext_Signer_name(ctx, field) - case "evm": - return ec.fieldContext_Signer_evm(ctx, field) - case "key": - return ec.fieldContext_Signer_key(ctx, field) - case "shortkey": - return ec.fieldContext_Signer_shortkey(ctx, field) - case "points": - return ec.fieldContext_Signer_points(ctx, field) - case "assetprice": - return ec.fieldContext_Signer_assetprice(ctx, field) - case "eventlogs": - return ec.fieldContext_Signer_eventlogs(ctx, field) - case "correctnessreport": - return ec.fieldContext_Signer_correctnessreport(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Signer", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _SignerEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.SignerEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SignerEdge_cursor(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(entgql.Cursor[int]) - fc.Result = res - return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_SignerEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "SignerEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") - }, - } - return fc, nil -} - -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** - -func (ec *executionContext) unmarshalInputAssetPriceOrder(ctx context.Context, obj interface{}) (ent.AssetPriceOrder, error) { - var it ent.AssetPriceOrder - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" - } - - fieldsInOrder := [...]string{"direction", "field"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "direction": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) - if err != nil { - return it, err - } - it.Direction = data - case "field": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNAssetPriceOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceOrderField(ctx, v) - if err != nil { - return it, err - } - it.Field = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputAssetPriceWhereInput(ctx context.Context, obj interface{}) (ent.AssetPriceWhereInput, error) { - var it ent.AssetPriceWhereInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "block", "blockNEQ", "blockIn", "blockNotIn", "blockGT", "blockGTE", "blockLT", "blockLTE", "signerscount", "signerscountNEQ", "signerscountIn", "signerscountNotIn", "signerscountGT", "signerscountGTE", "signerscountLT", "signerscountLTE", "signerscountIsNil", "signerscountNotNil", "price", "priceNEQ", "priceIn", "priceNotIn", "priceGT", "priceGTE", "priceLT", "priceLTE", "asset", "assetNEQ", "assetIn", "assetNotIn", "assetGT", "assetGTE", "assetLT", "assetLTE", "assetContains", "assetHasPrefix", "assetHasSuffix", "assetIsNil", "assetNotNil", "assetEqualFold", "assetContainsFold", "chain", "chainNEQ", "chainIn", "chainNotIn", "chainGT", "chainGTE", "chainLT", "chainLTE", "chainContains", "chainHasPrefix", "chainHasSuffix", "chainIsNil", "chainNotNil", "chainEqualFold", "chainContainsFold", "pair", "pairNEQ", "pairIn", "pairNotIn", "pairGT", "pairGTE", "pairLT", "pairLTE", "pairContains", "pairHasPrefix", "pairHasSuffix", "pairIsNil", "pairNotNil", "pairEqualFold", "pairContainsFold", "consensus", "consensusNEQ", "voted", "votedNEQ", "votedIn", "votedNotIn", "votedGT", "votedGTE", "votedLT", "votedLTE", "hasSigners", "hasSignersWith"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOAssetPriceWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceWhereInput(ctx, v) - if err != nil { - return it, err - } - it.Not = data - case "and": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOAssetPriceWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.And = data - case "or": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOAssetPriceWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.Or = data - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.ID = data - case "idNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDNEQ = data - case "idIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.IDIn = data - case "idNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDLTE = data - case "block": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("block")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.Block = data - case "blockNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockNEQ = data - case "blockIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.BlockIn = data - case "blockNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.BlockNotIn = data - case "blockGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockGT = data - case "blockGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockGTE = data - case "blockLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockLT = data - case "blockLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockLTE = data - case "signerscount": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscount")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCount = data - case "signerscountNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountNEQ = data - case "signerscountIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.SignersCountIn = data - case "signerscountNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.SignersCountNotIn = data - case "signerscountGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountGT = data - case "signerscountGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountGTE = data - case "signerscountLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountLT = data - case "signerscountLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountLTE = data - case "signerscountIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.SignersCountIsNil = data - case "signerscountNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.SignersCountNotNil = data - case "price": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("price")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().Price(ctx, &it, data); err != nil { - return it, err - } - case "priceNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priceNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().PriceNeq(ctx, &it, data); err != nil { - return it, err - } - case "priceIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priceIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().PriceIn(ctx, &it, data); err != nil { - return it, err - } - case "priceNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priceNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().PriceNotIn(ctx, &it, data); err != nil { - return it, err - } - case "priceGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priceGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().PriceGt(ctx, &it, data); err != nil { - return it, err - } - case "priceGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priceGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().PriceGte(ctx, &it, data); err != nil { - return it, err - } - case "priceLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priceLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().PriceLt(ctx, &it, data); err != nil { - return it, err - } - case "priceLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priceLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().PriceLte(ctx, &it, data); err != nil { - return it, err - } - case "asset": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("asset")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Asset = data - case "assetNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetNEQ = data - case "assetIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.AssetIn = data - case "assetNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.AssetNotIn = data - case "assetGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetGT = data - case "assetGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetGTE = data - case "assetLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetLT = data - case "assetLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetLTE = data - case "assetContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetContains = data - case "assetHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetHasPrefix = data - case "assetHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetHasSuffix = data - case "assetIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.AssetIsNil = data - case "assetNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.AssetNotNil = data - case "assetEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetEqualFold = data - case "assetContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetContainsFold = data - case "chain": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chain")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Chain = data - case "chainNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainNEQ = data - case "chainIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.ChainIn = data - case "chainNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.ChainNotIn = data - case "chainGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainGT = data - case "chainGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainGTE = data - case "chainLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainLT = data - case "chainLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainLTE = data - case "chainContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainContains = data - case "chainHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainHasPrefix = data - case "chainHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainHasSuffix = data - case "chainIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ChainIsNil = data - case "chainNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ChainNotNil = data - case "chainEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainEqualFold = data - case "chainContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainContainsFold = data - case "pair": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pair")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Pair = data - case "pairNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairNEQ = data - case "pairIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.PairIn = data - case "pairNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.PairNotIn = data - case "pairGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairGT = data - case "pairGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairGTE = data - case "pairLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairLT = data - case "pairLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairLTE = data - case "pairContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairContains = data - case "pairHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairHasPrefix = data - case "pairHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairHasSuffix = data - case "pairIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.PairIsNil = data - case "pairNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.PairNotNil = data - case "pairEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairEqualFold = data - case "pairContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairContainsFold = data - case "consensus": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("consensus")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.Consensus = data - case "consensusNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("consensusNEQ")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.ConsensusNEQ = data - case "voted": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("voted")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().Voted(ctx, &it, data); err != nil { - return it, err - } - case "votedNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().VotedNeq(ctx, &it, data); err != nil { - return it, err - } - case "votedIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().VotedIn(ctx, &it, data); err != nil { - return it, err - } - case "votedNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().VotedNotIn(ctx, &it, data); err != nil { - return it, err - } - case "votedGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().VotedGt(ctx, &it, data); err != nil { - return it, err - } - case "votedGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().VotedGte(ctx, &it, data); err != nil { - return it, err - } - case "votedLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().VotedLt(ctx, &it, data); err != nil { - return it, err - } - case "votedLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().VotedLte(ctx, &it, data); err != nil { - return it, err - } - case "hasSigners": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSigners")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasSigners = data - case "hasSignersWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSignersWith")) - data, err := ec.unmarshalOSignerWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasSignersWith = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputCorrectnessReportOrder(ctx context.Context, obj interface{}) (ent.CorrectnessReportOrder, error) { - var it ent.CorrectnessReportOrder - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" - } - - fieldsInOrder := [...]string{"direction", "field"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "direction": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) - if err != nil { - return it, err - } - it.Direction = data - case "field": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNCorrectnessReportOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportOrderField(ctx, v) - if err != nil { - return it, err - } - it.Field = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputCorrectnessReportWhereInput(ctx context.Context, obj interface{}) (ent.CorrectnessReportWhereInput, error) { - var it ent.CorrectnessReportWhereInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "signerscount", "signerscountNEQ", "signerscountIn", "signerscountNotIn", "signerscountGT", "signerscountGTE", "signerscountLT", "signerscountLTE", "timestamp", "timestampNEQ", "timestampIn", "timestampNotIn", "timestampGT", "timestampGTE", "timestampLT", "timestampLTE", "correct", "correctNEQ", "consensus", "consensusNEQ", "voted", "votedNEQ", "votedIn", "votedNotIn", "votedGT", "votedGTE", "votedLT", "votedLTE", "hasSigners", "hasSignersWith", "topic", "hash"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOCorrectnessReportWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportWhereInput(ctx, v) - if err != nil { - return it, err - } - it.Not = data - case "and": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOCorrectnessReportWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.And = data - case "or": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOCorrectnessReportWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.Or = data - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.ID = data - case "idNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDNEQ = data - case "idIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.IDIn = data - case "idNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDLTE = data - case "signerscount": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscount")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCount = data - case "signerscountNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountNEQ = data - case "signerscountIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.SignersCountIn = data - case "signerscountNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.SignersCountNotIn = data - case "signerscountGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountGT = data - case "signerscountGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountGTE = data - case "signerscountLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountLT = data - case "signerscountLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountLTE = data - case "timestamp": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("timestamp")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.Timestamp = data - case "timestampNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("timestampNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.TimestampNEQ = data - case "timestampIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("timestampIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.TimestampIn = data - case "timestampNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("timestampNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.TimestampNotIn = data - case "timestampGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("timestampGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.TimestampGT = data - case "timestampGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("timestampGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.TimestampGTE = data - case "timestampLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("timestampLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.TimestampLT = data - case "timestampLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("timestampLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.TimestampLTE = data - case "correct": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("correct")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.Correct = data - case "correctNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("correctNEQ")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.CorrectNEQ = data - case "consensus": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("consensus")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.Consensus = data - case "consensusNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("consensusNEQ")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.ConsensusNEQ = data - case "voted": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("voted")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().Voted(ctx, &it, data); err != nil { - return it, err - } - case "votedNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().VotedNeq(ctx, &it, data); err != nil { - return it, err - } - case "votedIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().VotedIn(ctx, &it, data); err != nil { - return it, err - } - case "votedNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().VotedNotIn(ctx, &it, data); err != nil { - return it, err - } - case "votedGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().VotedGt(ctx, &it, data); err != nil { - return it, err - } - case "votedGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().VotedGte(ctx, &it, data); err != nil { - return it, err - } - case "votedLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().VotedLt(ctx, &it, data); err != nil { - return it, err - } - case "votedLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().VotedLte(ctx, &it, data); err != nil { - return it, err - } - case "hasSigners": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSigners")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasSigners = data - case "hasSignersWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSignersWith")) - data, err := ec.unmarshalOSignerWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasSignersWith = data - case "topic": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("topic")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().Topic(ctx, &it, data); err != nil { - return it, err - } - case "hash": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().Hash(ctx, &it, data); err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputEventLogOrder(ctx context.Context, obj interface{}) (ent.EventLogOrder, error) { - var it ent.EventLogOrder - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" - } - - fieldsInOrder := [...]string{"direction", "field"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "direction": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) - if err != nil { - return it, err - } - it.Direction = data - case "field": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNEventLogOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogOrderField(ctx, v) - if err != nil { - return it, err - } - it.Field = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputEventLogWhereInput(ctx context.Context, obj interface{}) (ent.EventLogWhereInput, error) { - var it ent.EventLogWhereInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "block", "blockNEQ", "blockIn", "blockNotIn", "blockGT", "blockGTE", "blockLT", "blockLTE", "signerscount", "signerscountNEQ", "signerscountIn", "signerscountNotIn", "signerscountGT", "signerscountGTE", "signerscountLT", "signerscountLTE", "address", "addressNEQ", "addressIn", "addressNotIn", "addressGT", "addressGTE", "addressLT", "addressLTE", "addressContains", "addressHasPrefix", "addressHasSuffix", "addressEqualFold", "addressContainsFold", "chain", "chainNEQ", "chainIn", "chainNotIn", "chainGT", "chainGTE", "chainLT", "chainLTE", "chainContains", "chainHasPrefix", "chainHasSuffix", "chainEqualFold", "chainContainsFold", "index", "indexNEQ", "indexIn", "indexNotIn", "indexGT", "indexGTE", "indexLT", "indexLTE", "event", "eventNEQ", "eventIn", "eventNotIn", "eventGT", "eventGTE", "eventLT", "eventLTE", "eventContains", "eventHasPrefix", "eventHasSuffix", "eventEqualFold", "eventContainsFold", "consensus", "consensusNEQ", "voted", "votedNEQ", "votedIn", "votedNotIn", "votedGT", "votedGTE", "votedLT", "votedLTE", "hasSigners", "hasSignersWith"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOEventLogWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogWhereInput(ctx, v) - if err != nil { - return it, err - } - it.Not = data - case "and": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOEventLogWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.And = data - case "or": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOEventLogWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.Or = data - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.ID = data - case "idNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDNEQ = data - case "idIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.IDIn = data - case "idNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDLTE = data - case "block": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("block")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.Block = data - case "blockNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockNEQ = data - case "blockIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.BlockIn = data - case "blockNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.BlockNotIn = data - case "blockGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockGT = data - case "blockGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockGTE = data - case "blockLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockLT = data - case "blockLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockLTE = data - case "signerscount": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscount")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCount = data - case "signerscountNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountNEQ = data - case "signerscountIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.SignersCountIn = data - case "signerscountNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.SignersCountNotIn = data - case "signerscountGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountGT = data - case "signerscountGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountGTE = data - case "signerscountLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountLT = data - case "signerscountLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountLTE = data - case "address": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("address")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Address = data - case "addressNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressNEQ = data - case "addressIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.AddressIn = data - case "addressNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.AddressNotIn = data - case "addressGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressGT = data - case "addressGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressGTE = data - case "addressLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressLT = data - case "addressLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressLTE = data - case "addressContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressContains = data - case "addressHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressHasPrefix = data - case "addressHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressHasSuffix = data - case "addressEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressEqualFold = data - case "addressContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressContainsFold = data - case "chain": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chain")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Chain = data - case "chainNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainNEQ = data - case "chainIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.ChainIn = data - case "chainNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.ChainNotIn = data - case "chainGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainGT = data - case "chainGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainGTE = data - case "chainLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainLT = data - case "chainLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainLTE = data - case "chainContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainContains = data - case "chainHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainHasPrefix = data - case "chainHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainHasSuffix = data - case "chainEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainEqualFold = data - case "chainContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainContainsFold = data - case "index": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("index")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.Index = data - case "indexNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("indexNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.IndexNEQ = data - case "indexIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("indexIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.IndexIn = data - case "indexNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("indexNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.IndexNotIn = data - case "indexGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("indexGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.IndexGT = data - case "indexGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("indexGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.IndexGTE = data - case "indexLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("indexLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.IndexLT = data - case "indexLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("indexLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.IndexLTE = data - case "event": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("event")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Event = data - case "eventNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventNEQ = data - case "eventIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.EventIn = data - case "eventNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.EventNotIn = data - case "eventGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventGT = data - case "eventGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventGTE = data - case "eventLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventLT = data - case "eventLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventLTE = data - case "eventContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventContains = data - case "eventHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventHasPrefix = data - case "eventHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventHasSuffix = data - case "eventEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventEqualFold = data - case "eventContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventContainsFold = data - case "consensus": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("consensus")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.Consensus = data - case "consensusNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("consensusNEQ")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.ConsensusNEQ = data - case "voted": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("voted")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.EventLogWhereInput().Voted(ctx, &it, data); err != nil { - return it, err - } - case "votedNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.EventLogWhereInput().VotedNeq(ctx, &it, data); err != nil { - return it, err - } - case "votedIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.EventLogWhereInput().VotedIn(ctx, &it, data); err != nil { - return it, err - } - case "votedNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.EventLogWhereInput().VotedNotIn(ctx, &it, data); err != nil { - return it, err - } - case "votedGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.EventLogWhereInput().VotedGt(ctx, &it, data); err != nil { - return it, err - } - case "votedGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.EventLogWhereInput().VotedGte(ctx, &it, data); err != nil { - return it, err - } - case "votedLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.EventLogWhereInput().VotedLt(ctx, &it, data); err != nil { - return it, err - } - case "votedLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.EventLogWhereInput().VotedLte(ctx, &it, data); err != nil { - return it, err - } - case "hasSigners": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSigners")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasSigners = data - case "hasSignersWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSignersWith")) - data, err := ec.unmarshalOSignerWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasSignersWith = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputSignerOrder(ctx context.Context, obj interface{}) (ent.SignerOrder, error) { - var it ent.SignerOrder - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" - } - - fieldsInOrder := [...]string{"direction", "field"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "direction": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) - if err != nil { - return it, err - } - it.Direction = data - case "field": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNSignerOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerOrderField(ctx, v) - if err != nil { - return it, err - } - it.Field = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputSignerWhereInput(ctx context.Context, obj interface{}) (ent.SignerWhereInput, error) { - var it ent.SignerWhereInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "evm", "evmNEQ", "evmIn", "evmNotIn", "evmGT", "evmGTE", "evmLT", "evmLTE", "evmContains", "evmHasPrefix", "evmHasSuffix", "evmIsNil", "evmNotNil", "evmEqualFold", "evmContainsFold", "points", "pointsNEQ", "pointsIn", "pointsNotIn", "pointsGT", "pointsGTE", "pointsLT", "pointsLTE", "hasAssetPrice", "hasAssetPriceWith", "hasEventLogs", "hasEventLogsWith", "hasCorrectnessReport", "hasCorrectnessReportWith", "key"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOSignerWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInput(ctx, v) - if err != nil { - return it, err - } - it.Not = data - case "and": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOSignerWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.And = data - case "or": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOSignerWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.Or = data - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.ID = data - case "idNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDNEQ = data - case "idIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.IDIn = data - case "idNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDLTE = data - case "name": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Name = data - case "nameNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameNEQ = data - case "nameIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.NameIn = data - case "nameNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.NameNotIn = data - case "nameGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameGT = data - case "nameGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameGTE = data - case "nameLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameLT = data - case "nameLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameLTE = data - case "nameContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameContains = data - case "nameHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameHasPrefix = data - case "nameHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameHasSuffix = data - case "nameEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameEqualFold = data - case "nameContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameContainsFold = data - case "evm": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evm")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Evm = data - case "evmNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmNEQ = data - case "evmIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.EvmIn = data - case "evmNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.EvmNotIn = data - case "evmGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmGT = data - case "evmGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmGTE = data - case "evmLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmLT = data - case "evmLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmLTE = data - case "evmContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmContains = data - case "evmHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmHasPrefix = data - case "evmHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmHasSuffix = data - case "evmIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.EvmIsNil = data - case "evmNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.EvmNotNil = data - case "evmEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmEqualFold = data - case "evmContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmContainsFold = data - case "points": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("points")) - data, err := ec.unmarshalOInt2ᚖint64(ctx, v) - if err != nil { - return it, err - } - it.Points = data - case "pointsNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pointsNEQ")) - data, err := ec.unmarshalOInt2ᚖint64(ctx, v) - if err != nil { - return it, err - } - it.PointsNEQ = data - case "pointsIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pointsIn")) - data, err := ec.unmarshalOInt2ᚕint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.PointsIn = data - case "pointsNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pointsNotIn")) - data, err := ec.unmarshalOInt2ᚕint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.PointsNotIn = data - case "pointsGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pointsGT")) - data, err := ec.unmarshalOInt2ᚖint64(ctx, v) - if err != nil { - return it, err - } - it.PointsGT = data - case "pointsGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pointsGTE")) - data, err := ec.unmarshalOInt2ᚖint64(ctx, v) - if err != nil { - return it, err - } - it.PointsGTE = data - case "pointsLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pointsLT")) - data, err := ec.unmarshalOInt2ᚖint64(ctx, v) - if err != nil { - return it, err - } - it.PointsLT = data - case "pointsLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pointsLTE")) - data, err := ec.unmarshalOInt2ᚖint64(ctx, v) - if err != nil { - return it, err - } - it.PointsLTE = data - case "hasAssetPrice": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasAssetPrice")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasAssetPrice = data - case "hasAssetPriceWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasAssetPriceWith")) - data, err := ec.unmarshalOAssetPriceWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasAssetPriceWith = data - case "hasEventLogs": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasEventLogs")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasEventLogs = data - case "hasEventLogsWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasEventLogsWith")) - data, err := ec.unmarshalOEventLogWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasEventLogsWith = data - case "hasCorrectnessReport": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCorrectnessReport")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasCorrectnessReport = data - case "hasCorrectnessReportWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCorrectnessReportWith")) - data, err := ec.unmarshalOCorrectnessReportWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasCorrectnessReportWith = data - case "key": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("key")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.SignerWhereInput().Key(ctx, &it, data); err != nil { - return it, err - } - } - } - - return it, nil -} - -// endregion **************************** input.gotpl ***************************** - -// region ************************** interface.gotpl *************************** - -func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj ent.Noder) graphql.Marshaler { - switch obj := (obj).(type) { - case nil: - return graphql.Null - case *ent.AssetPrice: - if obj == nil { - return graphql.Null - } - return ec._AssetPrice(ctx, sel, obj) - case *ent.CorrectnessReport: - if obj == nil { - return graphql.Null - } - return ec._CorrectnessReport(ctx, sel, obj) - case *ent.EventLog: - if obj == nil { - return graphql.Null - } - return ec._EventLog(ctx, sel, obj) - case *ent.Signer: - if obj == nil { - return graphql.Null - } - return ec._Signer(ctx, sel, obj) - default: - panic(fmt.Errorf("unexpected type %T", obj)) - } -} - -// endregion ************************** interface.gotpl *************************** - -// region **************************** object.gotpl **************************** - -var assetPriceImplementors = []string{"AssetPrice", "Node"} - -func (ec *executionContext) _AssetPrice(ctx context.Context, sel ast.SelectionSet, obj *ent.AssetPrice) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, assetPriceImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("AssetPrice") - case "id": - out.Values[i] = ec._AssetPrice_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "block": - out.Values[i] = ec._AssetPrice_block(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "signerscount": - out.Values[i] = ec._AssetPrice_signerscount(ctx, field, obj) - case "price": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._AssetPrice_price(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "signature": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._AssetPrice_signature(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "asset": - out.Values[i] = ec._AssetPrice_asset(ctx, field, obj) - case "chain": - out.Values[i] = ec._AssetPrice_chain(ctx, field, obj) - case "pair": - out.Values[i] = ec._AssetPrice_pair(ctx, field, obj) - case "consensus": - out.Values[i] = ec._AssetPrice_consensus(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "voted": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._AssetPrice_voted(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "signers": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._AssetPrice_signers(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var assetPriceConnectionImplementors = []string{"AssetPriceConnection"} - -func (ec *executionContext) _AssetPriceConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.AssetPriceConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, assetPriceConnectionImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("AssetPriceConnection") - case "edges": - out.Values[i] = ec._AssetPriceConnection_edges(ctx, field, obj) - case "pageInfo": - out.Values[i] = ec._AssetPriceConnection_pageInfo(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "totalCount": - out.Values[i] = ec._AssetPriceConnection_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var assetPriceEdgeImplementors = []string{"AssetPriceEdge"} - -func (ec *executionContext) _AssetPriceEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.AssetPriceEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, assetPriceEdgeImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("AssetPriceEdge") - case "node": - out.Values[i] = ec._AssetPriceEdge_node(ctx, field, obj) - case "cursor": - out.Values[i] = ec._AssetPriceEdge_cursor(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var correctnessReportImplementors = []string{"CorrectnessReport", "Node"} - -func (ec *executionContext) _CorrectnessReport(ctx context.Context, sel ast.SelectionSet, obj *ent.CorrectnessReport) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, correctnessReportImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("CorrectnessReport") - case "id": - out.Values[i] = ec._CorrectnessReport_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "signerscount": - out.Values[i] = ec._CorrectnessReport_signerscount(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "timestamp": - out.Values[i] = ec._CorrectnessReport_timestamp(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "signature": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._CorrectnessReport_signature(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "hash": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._CorrectnessReport_hash(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "topic": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._CorrectnessReport_topic(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "correct": - out.Values[i] = ec._CorrectnessReport_correct(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "consensus": - out.Values[i] = ec._CorrectnessReport_consensus(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "voted": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._CorrectnessReport_voted(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "signers": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._CorrectnessReport_signers(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var correctnessReportConnectionImplementors = []string{"CorrectnessReportConnection"} - -func (ec *executionContext) _CorrectnessReportConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.CorrectnessReportConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, correctnessReportConnectionImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("CorrectnessReportConnection") - case "edges": - out.Values[i] = ec._CorrectnessReportConnection_edges(ctx, field, obj) - case "pageInfo": - out.Values[i] = ec._CorrectnessReportConnection_pageInfo(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "totalCount": - out.Values[i] = ec._CorrectnessReportConnection_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var correctnessReportEdgeImplementors = []string{"CorrectnessReportEdge"} - -func (ec *executionContext) _CorrectnessReportEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.CorrectnessReportEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, correctnessReportEdgeImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("CorrectnessReportEdge") - case "node": - out.Values[i] = ec._CorrectnessReportEdge_node(ctx, field, obj) - case "cursor": - out.Values[i] = ec._CorrectnessReportEdge_cursor(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var eventLogImplementors = []string{"EventLog", "Node"} - -func (ec *executionContext) _EventLog(ctx context.Context, sel ast.SelectionSet, obj *ent.EventLog) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, eventLogImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("EventLog") - case "id": - out.Values[i] = ec._EventLog_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "block": - out.Values[i] = ec._EventLog_block(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "signerscount": - out.Values[i] = ec._EventLog_signerscount(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "signature": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._EventLog_signature(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "address": - out.Values[i] = ec._EventLog_address(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "chain": - out.Values[i] = ec._EventLog_chain(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "index": - out.Values[i] = ec._EventLog_index(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "event": - out.Values[i] = ec._EventLog_event(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "transaction": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._EventLog_transaction(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "args": - out.Values[i] = ec._EventLog_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "consensus": - out.Values[i] = ec._EventLog_consensus(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "voted": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._EventLog_voted(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "signers": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._EventLog_signers(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var eventLogConnectionImplementors = []string{"EventLogConnection"} - -func (ec *executionContext) _EventLogConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.EventLogConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, eventLogConnectionImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("EventLogConnection") - case "edges": - out.Values[i] = ec._EventLogConnection_edges(ctx, field, obj) - case "pageInfo": - out.Values[i] = ec._EventLogConnection_pageInfo(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "totalCount": - out.Values[i] = ec._EventLogConnection_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var eventLogEdgeImplementors = []string{"EventLogEdge"} - -func (ec *executionContext) _EventLogEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.EventLogEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, eventLogEdgeImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("EventLogEdge") - case "node": - out.Values[i] = ec._EventLogEdge_node(ctx, field, obj) - case "cursor": - out.Values[i] = ec._EventLogEdge_cursor(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var pageInfoImplementors = []string{"PageInfo"} - -func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *entgql.PageInfo[int]) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, pageInfoImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("PageInfo") - case "hasNextPage": - out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "hasPreviousPage": - out.Values[i] = ec._PageInfo_hasPreviousPage(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "startCursor": - out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj) - case "endCursor": - out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var queryImplementors = []string{"Query"} - -func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) - ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ - Object: "Query", - }) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ - Object: field.Name, - Field: field, - }) - - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "node": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_node(ctx, field) - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "nodes": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_nodes(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "assetPrices": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_assetPrices(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "correctnessReports": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_correctnessReports(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "eventLogs": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_eventLogs(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "signers": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_signers(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "__type": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Query___type(ctx, field) - }) - case "__schema": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Query___schema(ctx, field) - }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var signerImplementors = []string{"Signer", "Node"} - -func (ec *executionContext) _Signer(ctx context.Context, sel ast.SelectionSet, obj *ent.Signer) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, signerImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Signer") - case "id": - out.Values[i] = ec._Signer_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "name": - out.Values[i] = ec._Signer_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "evm": - out.Values[i] = ec._Signer_evm(ctx, field, obj) - case "key": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Signer_key(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "shortkey": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Signer_shortkey(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "points": - out.Values[i] = ec._Signer_points(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "assetprice": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Signer_assetprice(ctx, field, obj) - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "eventlogs": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Signer_eventlogs(ctx, field, obj) - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "correctnessreport": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Signer_correctnessreport(ctx, field, obj) - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var signerConnectionImplementors = []string{"SignerConnection"} - -func (ec *executionContext) _SignerConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.SignerConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, signerConnectionImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("SignerConnection") - case "edges": - out.Values[i] = ec._SignerConnection_edges(ctx, field, obj) - case "pageInfo": - out.Values[i] = ec._SignerConnection_pageInfo(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "totalCount": - out.Values[i] = ec._SignerConnection_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var signerEdgeImplementors = []string{"SignerEdge"} - -func (ec *executionContext) _SignerEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.SignerEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, signerEdgeImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("SignerEdge") - case "node": - out.Values[i] = ec._SignerEdge_node(ctx, field, obj) - case "cursor": - out.Values[i] = ec._SignerEdge_cursor(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -// endregion **************************** object.gotpl **************************** - -// region ***************************** type.gotpl ***************************** - -func (ec *executionContext) marshalNAssetPrice2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPrice(ctx context.Context, sel ast.SelectionSet, v *ent.AssetPrice) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._AssetPrice(ctx, sel, v) -} - -func (ec *executionContext) marshalNAssetPriceConnection2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceConnection(ctx context.Context, sel ast.SelectionSet, v ent.AssetPriceConnection) graphql.Marshaler { - return ec._AssetPriceConnection(ctx, sel, &v) -} - -func (ec *executionContext) marshalNAssetPriceConnection2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceConnection(ctx context.Context, sel ast.SelectionSet, v *ent.AssetPriceConnection) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._AssetPriceConnection(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNAssetPriceOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceOrderField(ctx context.Context, v interface{}) (*ent.AssetPriceOrderField, error) { - var res = new(ent.AssetPriceOrderField) - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNAssetPriceOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.AssetPriceOrderField) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return v -} - -func (ec *executionContext) unmarshalNAssetPriceWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceWhereInput(ctx context.Context, v interface{}) (*ent.AssetPriceWhereInput, error) { - res, err := ec.unmarshalInputAssetPriceWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNCorrectnessReport2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReport(ctx context.Context, sel ast.SelectionSet, v *ent.CorrectnessReport) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._CorrectnessReport(ctx, sel, v) -} - -func (ec *executionContext) marshalNCorrectnessReportConnection2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportConnection(ctx context.Context, sel ast.SelectionSet, v ent.CorrectnessReportConnection) graphql.Marshaler { - return ec._CorrectnessReportConnection(ctx, sel, &v) -} - -func (ec *executionContext) marshalNCorrectnessReportConnection2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportConnection(ctx context.Context, sel ast.SelectionSet, v *ent.CorrectnessReportConnection) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._CorrectnessReportConnection(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNCorrectnessReportOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportOrderField(ctx context.Context, v interface{}) (*ent.CorrectnessReportOrderField, error) { - var res = new(ent.CorrectnessReportOrderField) - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNCorrectnessReportOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.CorrectnessReportOrderField) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return v -} - -func (ec *executionContext) unmarshalNCorrectnessReportWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportWhereInput(ctx context.Context, v interface{}) (*ent.CorrectnessReportWhereInput, error) { - res, err := ec.unmarshalInputCorrectnessReportWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx context.Context, v interface{}) (entgql.Cursor[int], error) { - var res entgql.Cursor[int] - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx context.Context, sel ast.SelectionSet, v entgql.Cursor[int]) graphql.Marshaler { - return v -} - -func (ec *executionContext) marshalNEventLog2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLog(ctx context.Context, sel ast.SelectionSet, v *ent.EventLog) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._EventLog(ctx, sel, v) -} - -func (ec *executionContext) marshalNEventLogConnection2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogConnection(ctx context.Context, sel ast.SelectionSet, v ent.EventLogConnection) graphql.Marshaler { - return ec._EventLogConnection(ctx, sel, &v) -} - -func (ec *executionContext) marshalNEventLogConnection2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogConnection(ctx context.Context, sel ast.SelectionSet, v *ent.EventLogConnection) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._EventLogConnection(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNEventLogOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogOrderField(ctx context.Context, v interface{}) (*ent.EventLogOrderField, error) { - var res = new(ent.EventLogOrderField) - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNEventLogOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.EventLogOrderField) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return v -} - -func (ec *executionContext) unmarshalNEventLogWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogWhereInput(ctx context.Context, v interface{}) (*ent.EventLogWhereInput, error) { - res, err := ec.unmarshalInputEventLogWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNNode2ᚕgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐNoder(ctx context.Context, sel ast.SelectionSet, v []ent.Noder) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalONode2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐNoder(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - -func (ec *executionContext) unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx context.Context, v interface{}) (entgql.OrderDirection, error) { - var res entgql.OrderDirection - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx context.Context, sel ast.SelectionSet, v entgql.OrderDirection) graphql.Marshaler { - return v -} - -func (ec *executionContext) marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx context.Context, sel ast.SelectionSet, v entgql.PageInfo[int]) graphql.Marshaler { - return ec._PageInfo(ctx, sel, &v) -} - -func (ec *executionContext) marshalNSigner2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.Signer) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNSigner2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSigner(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalNSigner2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSigner(ctx context.Context, sel ast.SelectionSet, v *ent.Signer) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._Signer(ctx, sel, v) -} - -func (ec *executionContext) marshalNSignerConnection2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerConnection(ctx context.Context, sel ast.SelectionSet, v ent.SignerConnection) graphql.Marshaler { - return ec._SignerConnection(ctx, sel, &v) -} - -func (ec *executionContext) marshalNSignerConnection2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerConnection(ctx context.Context, sel ast.SelectionSet, v *ent.SignerConnection) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._SignerConnection(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNSignerOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerOrderField(ctx context.Context, v interface{}) (*ent.SignerOrderField, error) { - var res = new(ent.SignerOrderField) - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNSignerOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.SignerOrderField) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return v -} - -func (ec *executionContext) unmarshalNSignerWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInput(ctx context.Context, v interface{}) (*ent.SignerWhereInput, error) { - res, err := ec.unmarshalInputSignerWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNUint2uint64(ctx context.Context, v interface{}) (uint64, error) { - res, err := graphql.UnmarshalUint64(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNUint2uint64(ctx context.Context, sel ast.SelectionSet, v uint64) graphql.Marshaler { - res := graphql.MarshalUint64(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) marshalOAssetPrice2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.AssetPrice) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNAssetPrice2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPrice(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalOAssetPrice2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPrice(ctx context.Context, sel ast.SelectionSet, v *ent.AssetPrice) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._AssetPrice(ctx, sel, v) -} - -func (ec *executionContext) marshalOAssetPriceEdge2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceEdge(ctx context.Context, sel ast.SelectionSet, v []*ent.AssetPriceEdge) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOAssetPriceEdge2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - -func (ec *executionContext) marshalOAssetPriceEdge2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceEdge(ctx context.Context, sel ast.SelectionSet, v *ent.AssetPriceEdge) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._AssetPriceEdge(ctx, sel, v) -} - -func (ec *executionContext) unmarshalOAssetPriceOrder2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceOrder(ctx context.Context, v interface{}) (*ent.AssetPriceOrder, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputAssetPriceOrder(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalOAssetPriceWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.AssetPriceWhereInput, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]*ent.AssetPriceWhereInput, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNAssetPriceWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceWhereInput(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) unmarshalOAssetPriceWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceWhereInput(ctx context.Context, v interface{}) (*ent.AssetPriceWhereInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputAssetPriceWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOCorrectnessReport2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.CorrectnessReport) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNCorrectnessReport2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReport(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalOCorrectnessReport2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReport(ctx context.Context, sel ast.SelectionSet, v *ent.CorrectnessReport) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._CorrectnessReport(ctx, sel, v) -} - -func (ec *executionContext) marshalOCorrectnessReportEdge2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportEdge(ctx context.Context, sel ast.SelectionSet, v []*ent.CorrectnessReportEdge) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOCorrectnessReportEdge2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - -func (ec *executionContext) marshalOCorrectnessReportEdge2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportEdge(ctx context.Context, sel ast.SelectionSet, v *ent.CorrectnessReportEdge) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._CorrectnessReportEdge(ctx, sel, v) -} - -func (ec *executionContext) unmarshalOCorrectnessReportOrder2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportOrder(ctx context.Context, v interface{}) (*ent.CorrectnessReportOrder, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputCorrectnessReportOrder(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalOCorrectnessReportWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.CorrectnessReportWhereInput, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]*ent.CorrectnessReportWhereInput, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNCorrectnessReportWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportWhereInput(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) unmarshalOCorrectnessReportWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportWhereInput(ctx context.Context, v interface{}) (*ent.CorrectnessReportWhereInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputCorrectnessReportWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx context.Context, v interface{}) (*entgql.Cursor[int], error) { - if v == nil { - return nil, nil - } - var res = new(entgql.Cursor[int]) - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx context.Context, sel ast.SelectionSet, v *entgql.Cursor[int]) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return v -} - -func (ec *executionContext) marshalOEventLog2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.EventLog) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNEventLog2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLog(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalOEventLog2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLog(ctx context.Context, sel ast.SelectionSet, v *ent.EventLog) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._EventLog(ctx, sel, v) -} - -func (ec *executionContext) marshalOEventLogEdge2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogEdge(ctx context.Context, sel ast.SelectionSet, v []*ent.EventLogEdge) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOEventLogEdge2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - -func (ec *executionContext) marshalOEventLogEdge2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogEdge(ctx context.Context, sel ast.SelectionSet, v *ent.EventLogEdge) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._EventLogEdge(ctx, sel, v) -} - -func (ec *executionContext) unmarshalOEventLogOrder2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogOrder(ctx context.Context, v interface{}) (*ent.EventLogOrder, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputEventLogOrder(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalOEventLogWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.EventLogWhereInput, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]*ent.EventLogWhereInput, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNEventLogWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogWhereInput(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) unmarshalOEventLogWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogWhereInput(ctx context.Context, v interface{}) (*ent.EventLogWhereInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputEventLogWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalONode2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐNoder(ctx context.Context, sel ast.SelectionSet, v ent.Noder) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Node(ctx, sel, v) -} - -func (ec *executionContext) marshalOSigner2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSigner(ctx context.Context, sel ast.SelectionSet, v *ent.Signer) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Signer(ctx, sel, v) -} - -func (ec *executionContext) marshalOSignerEdge2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerEdge(ctx context.Context, sel ast.SelectionSet, v []*ent.SignerEdge) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOSignerEdge2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - -func (ec *executionContext) marshalOSignerEdge2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerEdge(ctx context.Context, sel ast.SelectionSet, v *ent.SignerEdge) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._SignerEdge(ctx, sel, v) -} - -func (ec *executionContext) unmarshalOSignerOrder2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerOrder(ctx context.Context, v interface{}) (*ent.SignerOrder, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputSignerOrder(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalOSignerWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.SignerWhereInput, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]*ent.SignerWhereInput, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNSignerWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInput(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) unmarshalOSignerWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInput(ctx context.Context, v interface{}) (*ent.SignerWhereInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputSignerWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalOUint2ᚕuint64ᚄ(ctx context.Context, v interface{}) ([]uint64, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]uint64, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNUint2uint64(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalOUint2ᚕuint64ᚄ(ctx context.Context, sel ast.SelectionSet, v []uint64) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalNUint2uint64(ctx, sel, v[i]) - } - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalOUint2ᚖuint64(ctx context.Context, v interface{}) (*uint64, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalUint64(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOUint2ᚖuint64(ctx context.Context, sel ast.SelectionSet, v *uint64) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalUint64(*v) - return res -} - -// endregion ***************************** type.gotpl ***************************** diff --git a/internal/transport/server/gql/resolver.go b/internal/transport/server/gql/resolver.go deleted file mode 100644 index 38458038..00000000 --- a/internal/transport/server/gql/resolver.go +++ /dev/null @@ -1,18 +0,0 @@ -package gql - -import ( - "github.com/TimeleapLabs/unchained/internal/ent" - "github.com/TimeleapLabs/unchained/internal/transport/server/gql/generated" - - "github.com/99designs/gqlgen/graphql" -) - -// Resolver is the resolver root. -type Resolver struct{ client *ent.Client } - -// NewSchema creates a graphql executable schema. -func NewSchema(client *ent.Client) graphql.ExecutableSchema { - return generated.NewExecutableSchema(generated.Config{ - Resolvers: &Resolver{client}, - }) -} diff --git a/internal/transport/server/gql/server.go b/internal/transport/server/gql/server.go deleted file mode 100644 index 96c2e394..00000000 --- a/internal/transport/server/gql/server.go +++ /dev/null @@ -1,21 +0,0 @@ -package gql - -import ( - "net/http" - - "github.com/TimeleapLabs/unchained/internal/transport/database" - "github.com/TimeleapLabs/unchained/internal/utils" - - "github.com/99designs/gqlgen/graphql/handler" - "github.com/99designs/gqlgen/graphql/playground" -) - -func WithGraphQL(db database.Database) func() { - return func() { - utils.Logger.Info("GraphQL service is activated") - - srv := handler.NewDefaultServer(NewSchema(db.GetConnection())) - http.Handle("/gql", playground.Handler("Unchained Playground", "/gql/query")) - http.Handle("/gql/query", srv) - } -} diff --git a/internal/transport/server/gql/types/bytes.go b/internal/transport/server/gql/types/bytes.go deleted file mode 100644 index 91822bc5..00000000 --- a/internal/transport/server/gql/types/bytes.go +++ /dev/null @@ -1,34 +0,0 @@ -package types - -import ( - "encoding/hex" - "fmt" - "io" - - "github.com/TimeleapLabs/unchained/internal/utils" -) - -type Bytes []byte - -// UnmarshalGQL implements the graphql.Unmarshaler interface. -func (bytes *Bytes) UnmarshalGQL(v interface{}) error { - str, ok := v.(string) - if !ok { - return fmt.Errorf("Bytes must be a string") - } - decoded, err := hex.DecodeString(str) - if err != nil { - return fmt.Errorf("Bytes must be a hex string") - } - *bytes = decoded - return nil -} - -// MarshalGQL implements the graphql.Marshaler interface. -func (bytes Bytes) MarshalGQL(w io.Writer) { - hexValue := fmt.Sprintf(`"%x"`, bytes) - _, err := w.Write([]byte(hexValue)) - if err != nil { - utils.Logger.Error(err.Error()) - } -} diff --git a/internal/transport/server/gql/unchained.graphql b/internal/transport/server/gql/unchained.graphql deleted file mode 100644 index e724f15d..00000000 --- a/internal/transport/server/gql/unchained.graphql +++ /dev/null @@ -1,847 +0,0 @@ -directive @goField(forceResolver: Boolean, name: String) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION -directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION -type AssetPrice implements Node { - id: ID! - block: Uint! - signerscount: Uint @goField(name: "SignersCount", forceResolver: false) - price: Uint! - signature: Bytes! - asset: String - chain: String - pair: String - consensus: Boolean! - voted: Uint! - signers: [Signer!]! -} -""" -A connection to a list of items. -""" -type AssetPriceConnection { - """ - A list of edges. - """ - edges: [AssetPriceEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} -""" -An edge in a connection. -""" -type AssetPriceEdge { - """ - The item at the end of the edge. - """ - node: AssetPrice - """ - A cursor for use in pagination. - """ - cursor: Cursor! -} -""" -Ordering options for AssetPrice connections -""" -input AssetPriceOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order AssetPrices. - """ - field: AssetPriceOrderField! -} -""" -Properties by which AssetPrice connections can be ordered. -""" -enum AssetPriceOrderField { - BLOCK -} -""" -AssetPriceWhereInput is used for filtering AssetPrice objects. -Input was generated by ent. -""" -input AssetPriceWhereInput { - not: AssetPriceWhereInput - and: [AssetPriceWhereInput!] - or: [AssetPriceWhereInput!] - """ - id field predicates - """ - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """ - block field predicates - """ - block: Uint - blockNEQ: Uint - blockIn: [Uint!] - blockNotIn: [Uint!] - blockGT: Uint - blockGTE: Uint - blockLT: Uint - blockLTE: Uint - """ - signersCount field predicates - """ - signerscount: Uint - signerscountNEQ: Uint - signerscountIn: [Uint!] - signerscountNotIn: [Uint!] - signerscountGT: Uint - signerscountGTE: Uint - signerscountLT: Uint - signerscountLTE: Uint - signerscountIsNil: Boolean - signerscountNotNil: Boolean - """ - price field predicates - """ - price: Uint - priceNEQ: Uint - priceIn: [Uint!] - priceNotIn: [Uint!] - priceGT: Uint - priceGTE: Uint - priceLT: Uint - priceLTE: Uint - """ - asset field predicates - """ - asset: String - assetNEQ: String - assetIn: [String!] - assetNotIn: [String!] - assetGT: String - assetGTE: String - assetLT: String - assetLTE: String - assetContains: String - assetHasPrefix: String - assetHasSuffix: String - assetIsNil: Boolean - assetNotNil: Boolean - assetEqualFold: String - assetContainsFold: String - """ - chain field predicates - """ - chain: String - chainNEQ: String - chainIn: [String!] - chainNotIn: [String!] - chainGT: String - chainGTE: String - chainLT: String - chainLTE: String - chainContains: String - chainHasPrefix: String - chainHasSuffix: String - chainIsNil: Boolean - chainNotNil: Boolean - chainEqualFold: String - chainContainsFold: String - """ - pair field predicates - """ - pair: String - pairNEQ: String - pairIn: [String!] - pairNotIn: [String!] - pairGT: String - pairGTE: String - pairLT: String - pairLTE: String - pairContains: String - pairHasPrefix: String - pairHasSuffix: String - pairIsNil: Boolean - pairNotNil: Boolean - pairEqualFold: String - pairContainsFold: String - """ - consensus field predicates - """ - consensus: Boolean - consensusNEQ: Boolean - """ - voted field predicates - """ - voted: Uint - votedNEQ: Uint - votedIn: [Uint!] - votedNotIn: [Uint!] - votedGT: Uint - votedGTE: Uint - votedLT: Uint - votedLTE: Uint - """ - signers edge predicates - """ - hasSigners: Boolean - hasSignersWith: [SignerWhereInput!] -} -type CorrectnessReport implements Node { - id: ID! - signerscount: Uint! @goField(name: "SignersCount", forceResolver: false) - timestamp: Uint! - signature: Bytes! - hash: Bytes! - topic: Bytes! - correct: Boolean! - consensus: Boolean! - voted: Uint! - signers: [Signer!]! -} -""" -A connection to a list of items. -""" -type CorrectnessReportConnection { - """ - A list of edges. - """ - edges: [CorrectnessReportEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} -""" -An edge in a connection. -""" -type CorrectnessReportEdge { - """ - The item at the end of the edge. - """ - node: CorrectnessReport - """ - A cursor for use in pagination. - """ - cursor: Cursor! -} -""" -Ordering options for CorrectnessReport connections -""" -input CorrectnessReportOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order CorrectnessReports. - """ - field: CorrectnessReportOrderField! -} -""" -Properties by which CorrectnessReport connections can be ordered. -""" -enum CorrectnessReportOrderField { - TIMESTAMP -} -""" -CorrectnessReportWhereInput is used for filtering CorrectnessReport objects. -Input was generated by ent. -""" -input CorrectnessReportWhereInput { - not: CorrectnessReportWhereInput - and: [CorrectnessReportWhereInput!] - or: [CorrectnessReportWhereInput!] - """ - id field predicates - """ - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """ - signersCount field predicates - """ - signerscount: Uint - signerscountNEQ: Uint - signerscountIn: [Uint!] - signerscountNotIn: [Uint!] - signerscountGT: Uint - signerscountGTE: Uint - signerscountLT: Uint - signerscountLTE: Uint - """ - timestamp field predicates - """ - timestamp: Uint - timestampNEQ: Uint - timestampIn: [Uint!] - timestampNotIn: [Uint!] - timestampGT: Uint - timestampGTE: Uint - timestampLT: Uint - timestampLTE: Uint - """ - correct field predicates - """ - correct: Boolean - correctNEQ: Boolean - """ - consensus field predicates - """ - consensus: Boolean - consensusNEQ: Boolean - """ - voted field predicates - """ - voted: Uint - votedNEQ: Uint - votedIn: [Uint!] - votedNotIn: [Uint!] - votedGT: Uint - votedGTE: Uint - votedLT: Uint - votedLTE: Uint - """ - signers edge predicates - """ - hasSigners: Boolean - hasSignersWith: [SignerWhereInput!] -} -""" -Define a Relay Cursor type: -https://relay.dev/graphql/connections.htm#sec-Cursor -""" -scalar Cursor -type EventLog implements Node { - id: ID! - block: Uint! - signerscount: Uint! @goField(name: "SignersCount", forceResolver: false) - signature: Bytes! - address: String! - chain: String! - index: Uint! - event: String! - transaction: Bytes! - args: [EventLogArg!]! - consensus: Boolean! - voted: Uint! - signers: [Signer!]! -} -""" -A connection to a list of items. -""" -type EventLogConnection { - """ - A list of edges. - """ - edges: [EventLogEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} -""" -An edge in a connection. -""" -type EventLogEdge { - """ - The item at the end of the edge. - """ - node: EventLog - """ - A cursor for use in pagination. - """ - cursor: Cursor! -} -""" -Ordering options for EventLog connections -""" -input EventLogOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order EventLogs. - """ - field: EventLogOrderField! -} -""" -Properties by which EventLog connections can be ordered. -""" -enum EventLogOrderField { - BLOCK -} -""" -EventLogWhereInput is used for filtering EventLog objects. -Input was generated by ent. -""" -input EventLogWhereInput { - not: EventLogWhereInput - and: [EventLogWhereInput!] - or: [EventLogWhereInput!] - """ - id field predicates - """ - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """ - block field predicates - """ - block: Uint - blockNEQ: Uint - blockIn: [Uint!] - blockNotIn: [Uint!] - blockGT: Uint - blockGTE: Uint - blockLT: Uint - blockLTE: Uint - """ - signersCount field predicates - """ - signerscount: Uint - signerscountNEQ: Uint - signerscountIn: [Uint!] - signerscountNotIn: [Uint!] - signerscountGT: Uint - signerscountGTE: Uint - signerscountLT: Uint - signerscountLTE: Uint - """ - address field predicates - """ - address: String - addressNEQ: String - addressIn: [String!] - addressNotIn: [String!] - addressGT: String - addressGTE: String - addressLT: String - addressLTE: String - addressContains: String - addressHasPrefix: String - addressHasSuffix: String - addressEqualFold: String - addressContainsFold: String - """ - chain field predicates - """ - chain: String - chainNEQ: String - chainIn: [String!] - chainNotIn: [String!] - chainGT: String - chainGTE: String - chainLT: String - chainLTE: String - chainContains: String - chainHasPrefix: String - chainHasSuffix: String - chainEqualFold: String - chainContainsFold: String - """ - index field predicates - """ - index: Uint - indexNEQ: Uint - indexIn: [Uint!] - indexNotIn: [Uint!] - indexGT: Uint - indexGTE: Uint - indexLT: Uint - indexLTE: Uint - """ - event field predicates - """ - event: String - eventNEQ: String - eventIn: [String!] - eventNotIn: [String!] - eventGT: String - eventGTE: String - eventLT: String - eventLTE: String - eventContains: String - eventHasPrefix: String - eventHasSuffix: String - eventEqualFold: String - eventContainsFold: String - """ - consensus field predicates - """ - consensus: Boolean - consensusNEQ: Boolean - """ - voted field predicates - """ - voted: Uint - votedNEQ: Uint - votedIn: [Uint!] - votedNotIn: [Uint!] - votedGT: Uint - votedGTE: Uint - votedLT: Uint - votedLTE: Uint - """ - signers edge predicates - """ - hasSigners: Boolean - hasSignersWith: [SignerWhereInput!] -} -""" -An object with an ID. -Follows the [Relay Global Object Identification Specification](https://relay.dev/graphql/objectidentification.htm) -""" -interface Node @goModel(model: "github.com/TimeleapLabs/unchained/internal/ent.Noder") { - """ - The id of the object. - """ - id: ID! -} -""" -Possible directions in which to order a list of items when provided an `orderBy` argument. -""" -enum OrderDirection { - """ - Specifies an ascending order for a given `orderBy` argument. - """ - ASC - """ - Specifies a descending order for a given `orderBy` argument. - """ - DESC -} -""" -Information about pagination in a connection. -https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo -""" -type PageInfo { - """ - When paginating forwards, are there more items? - """ - hasNextPage: Boolean! - """ - When paginating backwards, are there more items? - """ - hasPreviousPage: Boolean! - """ - When paginating backwards, the cursor to continue. - """ - startCursor: Cursor - """ - When paginating forwards, the cursor to continue. - """ - endCursor: Cursor -} -type Query { - """ - Fetches an object given its ID. - """ - node( - """ - ID of the object. - """ - id: ID! - ): Node - """ - Lookup nodes by a list of IDs. - """ - nodes( - """ - The list of node IDs. - """ - ids: [ID!]! - ): [Node]! - assetPrices( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for AssetPrices returned from the connection. - """ - orderBy: AssetPriceOrder - - """ - Filtering options for AssetPrices returned from the connection. - """ - where: AssetPriceWhereInput - ): AssetPriceConnection! - correctnessReports( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for CorrectnessReports returned from the connection. - """ - orderBy: CorrectnessReportOrder - - """ - Filtering options for CorrectnessReports returned from the connection. - """ - where: CorrectnessReportWhereInput - ): CorrectnessReportConnection! - eventLogs( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for EventLogs returned from the connection. - """ - orderBy: EventLogOrder - - """ - Filtering options for EventLogs returned from the connection. - """ - where: EventLogWhereInput - ): EventLogConnection! - signers( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for Signers returned from the connection. - """ - orderBy: SignerOrder - - """ - Filtering options for Signers returned from the connection. - """ - where: SignerWhereInput - ): SignerConnection! -} -type Signer implements Node { - id: ID! - name: String! - evm: String - key: Bytes! - shortkey: Bytes! - points: Int! - assetprice: [AssetPrice!] @goField(name: "AssetPrice", forceResolver: false) - eventlogs: [EventLog!] @goField(name: "EventLogs", forceResolver: false) - correctnessreport: [CorrectnessReport!] @goField(name: "CorrectnessReport", forceResolver: false) -} -""" -A connection to a list of items. -""" -type SignerConnection { - """ - A list of edges. - """ - edges: [SignerEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} -""" -An edge in a connection. -""" -type SignerEdge { - """ - The item at the end of the edge. - """ - node: Signer - """ - A cursor for use in pagination. - """ - cursor: Cursor! -} -""" -Ordering options for Signer connections -""" -input SignerOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order Signers. - """ - field: SignerOrderField! -} -""" -Properties by which Signer connections can be ordered. -""" -enum SignerOrderField { - POINTS -} -""" -SignerWhereInput is used for filtering Signer objects. -Input was generated by ent. -""" -input SignerWhereInput { - not: SignerWhereInput - and: [SignerWhereInput!] - or: [SignerWhereInput!] - """ - id field predicates - """ - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """ - name field predicates - """ - name: String - nameNEQ: String - nameIn: [String!] - nameNotIn: [String!] - nameGT: String - nameGTE: String - nameLT: String - nameLTE: String - nameContains: String - nameHasPrefix: String - nameHasSuffix: String - nameEqualFold: String - nameContainsFold: String - """ - evm field predicates - """ - evm: String - evmNEQ: String - evmIn: [String!] - evmNotIn: [String!] - evmGT: String - evmGTE: String - evmLT: String - evmLTE: String - evmContains: String - evmHasPrefix: String - evmHasSuffix: String - evmIsNil: Boolean - evmNotNil: Boolean - evmEqualFold: String - evmContainsFold: String - """ - points field predicates - """ - points: Int - pointsNEQ: Int - pointsIn: [Int!] - pointsNotIn: [Int!] - pointsGT: Int - pointsGTE: Int - pointsLT: Int - pointsLTE: Int - """ - assetPrice edge predicates - """ - hasAssetPrice: Boolean - hasAssetPriceWith: [AssetPriceWhereInput!] - """ - eventLogs edge predicates - """ - hasEventLogs: Boolean - hasEventLogsWith: [EventLogWhereInput!] - """ - correctnessReport edge predicates - """ - hasCorrectnessReport: Boolean - hasCorrectnessReportWith: [CorrectnessReportWhereInput!] -} -""" -The builtin Uint type -""" -scalar Uint diff --git a/internal/transport/server/gql/unchained.resolvers.go b/internal/transport/server/gql/unchained.resolvers.go deleted file mode 100644 index 0c847bea..00000000 --- a/internal/transport/server/gql/unchained.resolvers.go +++ /dev/null @@ -1,342 +0,0 @@ -package gql - -// This file will be automatically regenerated based on the schema, any resolver implementations -// will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.45 - -import ( - "context" - "fmt" - "math/big" - - "entgo.io/contrib/entgql" - "github.com/TimeleapLabs/unchained/internal/ent" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/transport/server/gql/generated" - "github.com/TimeleapLabs/unchained/internal/transport/server/gql/types" -) - -// Price is the resolver for the price field. -func (r *assetPriceResolver) Price(ctx context.Context, obj *ent.AssetPrice) (uint64, error) { - return obj.Price.Uint64(), nil -} - -// Signature is the resolver for the signature field. -func (r *assetPriceResolver) Signature(ctx context.Context, obj *ent.AssetPrice) (types.Bytes, error) { - return obj.Signature, nil -} - -// Voted is the resolver for the voted field. -func (r *assetPriceResolver) Voted(ctx context.Context, obj *ent.AssetPrice) (uint64, error) { - panic(fmt.Errorf("not implemented: Voted - voted")) -} - -// Signature is the resolver for the signature field. -func (r *correctnessReportResolver) Signature(ctx context.Context, obj *ent.CorrectnessReport) (types.Bytes, error) { - return obj.Signature, nil -} - -// Hash is the resolver for the hash field. -func (r *correctnessReportResolver) Hash(ctx context.Context, obj *ent.CorrectnessReport) (types.Bytes, error) { - return obj.Hash, nil -} - -// Topic is the resolver for the topic field. -func (r *correctnessReportResolver) Topic(ctx context.Context, obj *ent.CorrectnessReport) (types.Bytes, error) { - return obj.Topic, nil -} - -// Voted is the resolver for the voted field. -func (r *correctnessReportResolver) Voted(ctx context.Context, obj *ent.CorrectnessReport) (uint64, error) { - panic(fmt.Errorf("not implemented: Voted - voted")) -} - -// Signature is the resolver for the signature field. -func (r *eventLogResolver) Signature(ctx context.Context, obj *ent.EventLog) (types.Bytes, error) { - return obj.Signature, nil -} - -// Transaction is the resolver for the transaction field. -func (r *eventLogResolver) Transaction(ctx context.Context, obj *ent.EventLog) (types.Bytes, error) { - return obj.Transaction, nil -} - -// Voted is the resolver for the voted field. -func (r *eventLogResolver) Voted(ctx context.Context, obj *ent.EventLog) (uint64, error) { - panic(fmt.Errorf("not implemented: Voted - voted")) -} - -// Node is the resolver for the node field. -func (r *queryResolver) Node(ctx context.Context, id int) (ent.Noder, error) { - return r.client.Noder(ctx, id) -} - -// Nodes is the resolver for the nodes field. -func (r *queryResolver) Nodes(ctx context.Context, ids []int) ([]ent.Noder, error) { - return r.client.Noders(ctx, ids) -} - -// AssetPrices is the resolver for the assetPrices field. -func (r *queryResolver) AssetPrices(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.AssetPriceOrder, where *ent.AssetPriceWhereInput) (*ent.AssetPriceConnection, error) { - return r.client.AssetPrice.Query(). - Paginate(ctx, after, first, before, last, - ent.WithAssetPriceOrder(orderBy), - ent.WithAssetPriceFilter(where.Filter), - ) -} - -// CorrectnessReports is the resolver for the correctnessReports field. -func (r *queryResolver) CorrectnessReports(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.CorrectnessReportOrder, where *ent.CorrectnessReportWhereInput) (*ent.CorrectnessReportConnection, error) { - return r.client.CorrectnessReport.Query(). - Paginate(ctx, after, first, before, last, - ent.WithCorrectnessReportOrder(orderBy), - ent.WithCorrectnessReportFilter(where.Filter), - ) -} - -// EventLogs is the resolver for the eventLogs field. -func (r *queryResolver) EventLogs(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.EventLogOrder, where *ent.EventLogWhereInput) (*ent.EventLogConnection, error) { - return r.client.EventLog.Query(). - Paginate(ctx, after, first, before, last, - ent.WithEventLogOrder(orderBy), - ent.WithEventLogFilter(where.Filter), - ) -} - -// Signers is the resolver for the signers field. -func (r *queryResolver) Signers(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.SignerOrder, where *ent.SignerWhereInput) (*ent.SignerConnection, error) { - return r.client.Signer.Query(). - Paginate(ctx, after, first, before, last, - ent.WithSignerOrder(orderBy), - ent.WithSignerFilter(where.Filter), - ) -} - -// Key is the resolver for the key field. -func (r *signerResolver) Key(ctx context.Context, obj *ent.Signer) (types.Bytes, error) { - return obj.Key, nil -} - -// Shortkey is the resolver for the shortkey field. -func (r *signerResolver) Shortkey(ctx context.Context, obj *ent.Signer) (types.Bytes, error) { - return obj.Shortkey, nil -} - -// Price is the resolver for the price field. -func (r *assetPriceWhereInputResolver) Price(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - obj.Price = &helpers.BigInt{Int: *big.NewInt(int64(*data))} - return nil -} - -// PriceNeq is the resolver for the priceNEQ field. -func (r *assetPriceWhereInputResolver) PriceNeq(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - obj.PriceNEQ = &helpers.BigInt{Int: *big.NewInt(int64(*data))} - return nil -} - -// PriceIn is the resolver for the priceIn field. -func (r *assetPriceWhereInputResolver) PriceIn(ctx context.Context, obj *ent.AssetPriceWhereInput, data []uint64) error { - for _, value := range data { - obj.PriceIn = append(obj.PriceIn, &helpers.BigInt{Int: *big.NewInt(int64(value))}) - } - return nil -} - -// PriceNotIn is the resolver for the priceNotIn field. -func (r *assetPriceWhereInputResolver) PriceNotIn(ctx context.Context, obj *ent.AssetPriceWhereInput, data []uint64) error { - for _, value := range data { - obj.PriceNotIn = append(obj.PriceNotIn, &helpers.BigInt{Int: *big.NewInt(int64(value))}) - } - return nil -} - -// PriceGt is the resolver for the priceGT field. -func (r *assetPriceWhereInputResolver) PriceGt(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - obj.PriceGT = &helpers.BigInt{Int: *big.NewInt(int64(*data))} - return nil -} - -// PriceGte is the resolver for the priceGTE field. -func (r *assetPriceWhereInputResolver) PriceGte(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - obj.PriceGTE = &helpers.BigInt{Int: *big.NewInt(int64(*data))} - return nil -} - -// PriceLt is the resolver for the priceLT field. -func (r *assetPriceWhereInputResolver) PriceLt(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - obj.PriceLT = &helpers.BigInt{Int: *big.NewInt(int64(*data))} - return nil -} - -// PriceLte is the resolver for the priceLTE field. -func (r *assetPriceWhereInputResolver) PriceLte(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - obj.PriceLTE = &helpers.BigInt{Int: *big.NewInt(int64(*data))} - return nil -} - -// Voted is the resolver for the voted field. -func (r *assetPriceWhereInputResolver) Voted(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: Voted - voted")) -} - -// VotedNeq is the resolver for the votedNEQ field. -func (r *assetPriceWhereInputResolver) VotedNeq(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedNeq - votedNEQ")) -} - -// VotedIn is the resolver for the votedIn field. -func (r *assetPriceWhereInputResolver) VotedIn(ctx context.Context, obj *ent.AssetPriceWhereInput, data []uint64) error { - panic(fmt.Errorf("not implemented: VotedIn - votedIn")) -} - -// VotedNotIn is the resolver for the votedNotIn field. -func (r *assetPriceWhereInputResolver) VotedNotIn(ctx context.Context, obj *ent.AssetPriceWhereInput, data []uint64) error { - panic(fmt.Errorf("not implemented: VotedNotIn - votedNotIn")) -} - -// VotedGt is the resolver for the votedGT field. -func (r *assetPriceWhereInputResolver) VotedGt(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedGt - votedGT")) -} - -// VotedGte is the resolver for the votedGTE field. -func (r *assetPriceWhereInputResolver) VotedGte(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedGte - votedGTE")) -} - -// VotedLt is the resolver for the votedLT field. -func (r *assetPriceWhereInputResolver) VotedLt(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedLt - votedLT")) -} - -// VotedLte is the resolver for the votedLTE field. -func (r *assetPriceWhereInputResolver) VotedLte(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedLte - votedLTE")) -} - -// Voted is the resolver for the voted field. -func (r *correctnessReportWhereInputResolver) Voted(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: Voted - voted")) -} - -// VotedNeq is the resolver for the votedNEQ field. -func (r *correctnessReportWhereInputResolver) VotedNeq(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedNeq - votedNEQ")) -} - -// VotedIn is the resolver for the votedIn field. -func (r *correctnessReportWhereInputResolver) VotedIn(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data []uint64) error { - panic(fmt.Errorf("not implemented: VotedIn - votedIn")) -} - -// VotedNotIn is the resolver for the votedNotIn field. -func (r *correctnessReportWhereInputResolver) VotedNotIn(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data []uint64) error { - panic(fmt.Errorf("not implemented: VotedNotIn - votedNotIn")) -} - -// VotedGt is the resolver for the votedGT field. -func (r *correctnessReportWhereInputResolver) VotedGt(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedGt - votedGT")) -} - -// VotedGte is the resolver for the votedGTE field. -func (r *correctnessReportWhereInputResolver) VotedGte(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedGte - votedGTE")) -} - -// VotedLt is the resolver for the votedLT field. -func (r *correctnessReportWhereInputResolver) VotedLt(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedLt - votedLT")) -} - -// VotedLte is the resolver for the votedLTE field. -func (r *correctnessReportWhereInputResolver) VotedLte(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedLte - votedLTE")) -} - -// Voted is the resolver for the voted field. -func (r *eventLogWhereInputResolver) Voted(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: Voted - voted")) -} - -// VotedNeq is the resolver for the votedNEQ field. -func (r *eventLogWhereInputResolver) VotedNeq(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedNeq - votedNEQ")) -} - -// VotedIn is the resolver for the votedIn field. -func (r *eventLogWhereInputResolver) VotedIn(ctx context.Context, obj *ent.EventLogWhereInput, data []uint64) error { - panic(fmt.Errorf("not implemented: VotedIn - votedIn")) -} - -// VotedNotIn is the resolver for the votedNotIn field. -func (r *eventLogWhereInputResolver) VotedNotIn(ctx context.Context, obj *ent.EventLogWhereInput, data []uint64) error { - panic(fmt.Errorf("not implemented: VotedNotIn - votedNotIn")) -} - -// VotedGt is the resolver for the votedGT field. -func (r *eventLogWhereInputResolver) VotedGt(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedGt - votedGT")) -} - -// VotedGte is the resolver for the votedGTE field. -func (r *eventLogWhereInputResolver) VotedGte(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedGte - votedGTE")) -} - -// VotedLt is the resolver for the votedLT field. -func (r *eventLogWhereInputResolver) VotedLt(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedLt - votedLT")) -} - -// VotedLte is the resolver for the votedLTE field. -func (r *eventLogWhereInputResolver) VotedLte(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedLte - votedLTE")) -} - -// AssetPrice returns generated.AssetPriceResolver implementation. -func (r *Resolver) AssetPrice() generated.AssetPriceResolver { return &assetPriceResolver{r} } - -// CorrectnessReport returns generated.CorrectnessReportResolver implementation. -func (r *Resolver) CorrectnessReport() generated.CorrectnessReportResolver { - return &correctnessReportResolver{r} -} - -// EventLog returns generated.EventLogResolver implementation. -func (r *Resolver) EventLog() generated.EventLogResolver { return &eventLogResolver{r} } - -// Query returns generated.QueryResolver implementation. -func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } - -// Signer returns generated.SignerResolver implementation. -func (r *Resolver) Signer() generated.SignerResolver { return &signerResolver{r} } - -// AssetPriceWhereInput returns generated.AssetPriceWhereInputResolver implementation. -func (r *Resolver) AssetPriceWhereInput() generated.AssetPriceWhereInputResolver { - return &assetPriceWhereInputResolver{r} -} - -// CorrectnessReportWhereInput returns generated.CorrectnessReportWhereInputResolver implementation. -func (r *Resolver) CorrectnessReportWhereInput() generated.CorrectnessReportWhereInputResolver { - return &correctnessReportWhereInputResolver{r} -} - -// EventLogWhereInput returns generated.EventLogWhereInputResolver implementation. -func (r *Resolver) EventLogWhereInput() generated.EventLogWhereInputResolver { - return &eventLogWhereInputResolver{r} -} - -// SignerWhereInput returns generated.SignerWhereInputResolver implementation. -func (r *Resolver) SignerWhereInput() generated.SignerWhereInputResolver { - return &signerWhereInputResolver{r} -} - -type assetPriceResolver struct{ *Resolver } -type correctnessReportResolver struct{ *Resolver } -type eventLogResolver struct{ *Resolver } -type queryResolver struct{ *Resolver } -type signerResolver struct{ *Resolver } -type assetPriceWhereInputResolver struct{ *Resolver } -type correctnessReportWhereInputResolver struct{ *Resolver } -type eventLogWhereInputResolver struct{ *Resolver } -type signerWhereInputResolver struct{ *Resolver } diff --git a/internal/model/kosk.go b/internal/transport/server/packet/challenge.go similarity index 97% rename from internal/model/kosk.go rename to internal/transport/server/packet/challenge.go index 0a9fe4c6..2b498fb9 100644 --- a/internal/model/kosk.go +++ b/internal/transport/server/packet/challenge.go @@ -1,4 +1,4 @@ -package model +package packet import sia "github.com/pouya-eghbali/go-sia/v2/pkg" diff --git a/internal/transport/server/packet/correctness.go b/internal/transport/server/packet/correctness.go new file mode 100644 index 00000000..c91c330d --- /dev/null +++ b/internal/transport/server/packet/correctness.go @@ -0,0 +1,49 @@ +package packet + +import ( + "github.com/TimeleapLabs/unchained/internal/model" + sia "github.com/pouya-eghbali/go-sia/v2/pkg" +) + +type CorrectnessReportPacket struct { + model.Correctness + Signature [48]byte +} + +func (c *CorrectnessReportPacket) Sia() sia.Sia { + return sia.New(). + EmbedBytes(c.Correctness.Sia().Bytes()). + AddByteArray8(c.Signature[:]) +} + +func (c *CorrectnessReportPacket) FromBytes(payload []byte) *CorrectnessReportPacket { + siaMessage := sia.NewFromBytes(payload) + + c.Correctness.FromSia(siaMessage) + copy(c.Signature[:], siaMessage.ReadByteArray8()) + + return c +} + +type BroadcastCorrectnessPacket struct { + Info model.Correctness + Signature [48]byte + Signer model.Signer +} + +func (b *BroadcastCorrectnessPacket) Sia() sia.Sia { + return sia.New(). + EmbedBytes(b.Info.Sia().Bytes()). + AddByteArray8(b.Signature[:]). + EmbedBytes(b.Signer.Sia().Bytes()) +} + +func (b *BroadcastCorrectnessPacket) FromBytes(payload []byte) *BroadcastCorrectnessPacket { + siaMessage := sia.NewFromBytes(payload) + + b.Info.FromSia(siaMessage) + copy(b.Signature[:], siaMessage.ReadByteArray8()) + b.Signer.FromSia(siaMessage) + + return b +} diff --git a/internal/transport/server/packet/eventlog.go b/internal/transport/server/packet/eventlog.go new file mode 100644 index 00000000..8a753a87 --- /dev/null +++ b/internal/transport/server/packet/eventlog.go @@ -0,0 +1,48 @@ +package packet + +import ( + "github.com/TimeleapLabs/unchained/internal/model" + sia "github.com/pouya-eghbali/go-sia/v2/pkg" +) + +type EventLogReportPacket struct { + model.EventLog + Signature [48]byte +} + +func (e *EventLogReportPacket) Sia() sia.Sia { + return sia.New(). + EmbedBytes(e.EventLog.Sia().Bytes()). + AddByteArray8(e.Signature[:]) +} + +func (e *EventLogReportPacket) FromBytes(payload []byte) *EventLogReportPacket { + siaMessage := sia.NewFromBytes(payload) + e.EventLog.FromSia(siaMessage) + copy(e.Signature[:], siaMessage.ReadByteArray8()) + + return e +} + +type BroadcastEventPacket struct { + Info model.EventLog + Signature [48]byte + Signer model.Signer +} + +func (b *BroadcastEventPacket) Sia() sia.Sia { + return sia.New(). + EmbedBytes(b.Info.Sia().Bytes()). + AddByteArray8(b.Signature[:]). + EmbedBytes(b.Signer.Sia().Bytes()) +} + +func (b *BroadcastEventPacket) FromBytes(payload []byte) *BroadcastEventPacket { + siaMessage := sia.NewFromBytes(payload) + + b.Info.FromSia(siaMessage) + copy(b.Signature[:], siaMessage.ReadByteArray8()) + b.Signer.FromSia(siaMessage) + + return b +} diff --git a/internal/transport/server/packet/price.go b/internal/transport/server/packet/price.go new file mode 100644 index 00000000..6fe51e44 --- /dev/null +++ b/internal/transport/server/packet/price.go @@ -0,0 +1,52 @@ +package packet + +import ( + "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/service/uniswap/types" + sia "github.com/pouya-eghbali/go-sia/v2/pkg" +) + +type PriceReportPacket struct { + PriceInfo types.PriceInfo + Signature [48]byte +} + +func (p *PriceReportPacket) Sia() sia.Sia { + return sia.New(). + EmbedBytes(p.PriceInfo.Sia().Bytes()). + AddByteArray8(p.Signature[:]) +} + +func (p *PriceReportPacket) FromBytes(payload []byte) *PriceReportPacket { + siaMessage := sia.NewFromBytes(payload) + return p.FromSia(siaMessage) +} + +func (p *PriceReportPacket) FromSia(sia sia.Sia) *PriceReportPacket { + p.PriceInfo.FromSia(sia) + copy(p.Signature[:], sia.ReadByteArray8()) + + return p +} + +type BroadcastPricePacket struct { + Info types.PriceInfo + Signature [48]byte + Signer model.Signer +} + +func (b *BroadcastPricePacket) Sia() sia.Sia { + return sia.New(). + EmbedBytes(b.Info.Sia().Bytes()). + AddByteArray8(b.Signature[:]). + EmbedBytes(b.Signer.Sia().Bytes()) +} + +func (b *BroadcastPricePacket) FromBytes(payload []byte) *BroadcastPricePacket { + siaMessage := sia.NewFromBytes(payload) + b.Info.FromSia(siaMessage) + copy(b.Signature[:], siaMessage.ReadByteArray8()) + b.Signer.FromSia(siaMessage) + + return b +} diff --git a/internal/transport/server/websocket/handler/correctness.go b/internal/transport/server/websocket/handler/correctness.go index c99a9354..5c588aec 100644 --- a/internal/transport/server/websocket/handler/correctness.go +++ b/internal/transport/server/websocket/handler/correctness.go @@ -1,8 +1,7 @@ package handler import ( - "github.com/TimeleapLabs/unchained/internal/consts" - "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" "github.com/TimeleapLabs/unchained/internal/transport/server/websocket/middleware" "github.com/gorilla/websocket" ) @@ -13,18 +12,15 @@ func CorrectnessRecord(conn *websocket.Conn, payload []byte) ([]byte, error) { return []byte{}, err } - correctness := new(model.CorrectnessReportPacket).FromBytes(payload) - correctnessHash, err := correctness.Correctness.Bls() - if err != nil { - return []byte{}, consts.ErrInternalError - } + correctness := new(packet.CorrectnessReportPacket).FromBytes(payload) + correctnessHash := correctness.Correctness.Bls() signer, err := middleware.IsMessageValid(conn, correctnessHash, correctness.Signature) if err != nil { return []byte{}, err } - broadcastPacket := model.BroadcastCorrectnessPacket{ + broadcastPacket := packet.BroadcastCorrectnessPacket{ Info: correctness.Correctness, Signature: correctness.Signature, Signer: signer, diff --git a/internal/transport/server/websocket/handler/event.go b/internal/transport/server/websocket/handler/event.go index 4aa3d206..69c0d619 100644 --- a/internal/transport/server/websocket/handler/event.go +++ b/internal/transport/server/websocket/handler/event.go @@ -2,7 +2,7 @@ package handler import ( "github.com/TimeleapLabs/unchained/internal/consts" - "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" "github.com/TimeleapLabs/unchained/internal/transport/server/websocket/middleware" "github.com/gorilla/websocket" ) @@ -13,7 +13,7 @@ func EventLog(conn *websocket.Conn, payload []byte) ([]byte, error) { return []byte{}, err } - priceReport := new(model.EventLogReportPacket).FromBytes(payload) + priceReport := new(packet.EventLogReportPacket).FromBytes(payload) priceInfoHash, err := priceReport.EventLog.Bls() if err != nil { return []byte{}, consts.ErrInternalError @@ -24,7 +24,7 @@ func EventLog(conn *websocket.Conn, payload []byte) ([]byte, error) { return []byte{}, err } - broadcastPacket := model.BroadcastEventPacket{ + broadcastPacket := packet.BroadcastEventPacket{ Info: priceReport.EventLog, Signature: priceReport.Signature, Signer: signer, diff --git a/internal/transport/server/websocket/handler/hello.go b/internal/transport/server/websocket/handler/hello.go index b76d5d4e..f4f0a2f7 100644 --- a/internal/transport/server/websocket/handler/hello.go +++ b/internal/transport/server/websocket/handler/hello.go @@ -3,6 +3,7 @@ package handler import ( "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" "github.com/TimeleapLabs/unchained/internal/transport/server/websocket/store" "github.com/TimeleapLabs/unchained/internal/utils" "github.com/gorilla/websocket" @@ -27,7 +28,7 @@ func Hello(conn *websocket.Conn, payload []byte) ([]byte, error) { store.Signers.Store(conn, *signer) // Start KOSK verification - challenge := model.ChallengePacket{Random: utils.NewChallenge()} + challenge := packet.ChallengePacket{Random: utils.NewChallenge()} store.Challenges.Store(conn, challenge) return challenge.Sia().Bytes(), nil diff --git a/internal/transport/server/websocket/handler/kosk.go b/internal/transport/server/websocket/handler/kosk.go index 9555ca70..afb7a96d 100644 --- a/internal/transport/server/websocket/handler/kosk.go +++ b/internal/transport/server/websocket/handler/kosk.go @@ -3,14 +3,14 @@ package handler import ( "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/crypto/bls" - "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" "github.com/TimeleapLabs/unchained/internal/transport/server/websocket/middleware" "github.com/TimeleapLabs/unchained/internal/transport/server/websocket/store" "github.com/gorilla/websocket" ) func Kosk(conn *websocket.Conn, payload []byte) error { - challenge := new(model.ChallengePacket).FromBytes(payload) + challenge := new(packet.ChallengePacket).FromBytes(payload) hash, err := bls.Hash(challenge.Random[:]) if err != nil { diff --git a/internal/transport/server/websocket/handler/price.go b/internal/transport/server/websocket/handler/price.go index f56187e9..a2fc1173 100644 --- a/internal/transport/server/websocket/handler/price.go +++ b/internal/transport/server/websocket/handler/price.go @@ -2,7 +2,7 @@ package handler import ( "github.com/TimeleapLabs/unchained/internal/consts" - "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" "github.com/TimeleapLabs/unchained/internal/transport/server/websocket/middleware" "github.com/gorilla/websocket" ) @@ -14,7 +14,7 @@ func PriceReport(conn *websocket.Conn, payload []byte) ([]byte, error) { return []byte{}, err } - priceReport := new(model.PriceReportPacket).FromBytes(payload) + priceReport := new(packet.PriceReportPacket).FromBytes(payload) priceInfoHash, err := priceReport.PriceInfo.Bls() if err != nil { return []byte{}, consts.ErrInternalError @@ -25,7 +25,7 @@ func PriceReport(conn *websocket.Conn, payload []byte) ([]byte, error) { return []byte{}, err } - priceInfo := model.BroadcastPricePacket{ + priceInfo := packet.BroadcastPricePacket{ Info: priceReport.PriceInfo, Signature: priceReport.Signature, Signer: signer, diff --git a/internal/transport/server/websocket/store/store.go b/internal/transport/server/websocket/store/store.go index 6bf69d7e..67eb731f 100644 --- a/internal/transport/server/websocket/store/store.go +++ b/internal/transport/server/websocket/store/store.go @@ -2,10 +2,11 @@ package store import ( "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" "github.com/gorilla/websocket" "github.com/puzpuzpuz/xsync/v3" ) -var Challenges = xsync.NewMapOf[*websocket.Conn, model.ChallengePacket]() +var Challenges = xsync.NewMapOf[*websocket.Conn, packet.ChallengePacket]() var Signers = xsync.NewMapOf[*websocket.Conn, model.Signer]() From ca4d9249954551e29fbc33c821dc94513b7f5508 Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Mon, 24 Jun 2024 04:55:07 +0330 Subject: [PATCH 06/26] =?UTF-8?q?=F0=9F=90=9B=20fix(mod):=20fix=20unused?= =?UTF-8?q?=20deps=20>>>=20=E2=8F=B0=2020m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 22 +--------- go.sum | 53 ------------------------ internal/generate.go | 3 -- internal/gqlgen.yml | 52 ----------------------- internal/models_gen.go | 3 -- internal/repository/mongo/assetprice.go | 1 - internal/repository/mongo/correctness.go | 1 - internal/repository/mongo/eventlog.go | 1 - internal/repository/mongo/signer.go | 1 - 9 files changed, 2 insertions(+), 135 deletions(-) delete mode 100644 internal/generate.go delete mode 100644 internal/gqlgen.yml delete mode 100644 internal/models_gen.go diff --git a/go.mod b/go.mod index 3f07eae8..527d6451 100644 --- a/go.mod +++ b/go.mod @@ -3,17 +3,12 @@ module github.com/TimeleapLabs/unchained go 1.22.1 require ( - ariga.io/atlas v0.20.0 - entgo.io/contrib v0.4.6-0.20240215171353-eff33e4dca0b - entgo.io/ent v0.13.1 - github.com/99designs/gqlgen v0.17.45 github.com/btcsuite/btcutil v1.0.2 github.com/consensys/gnark-crypto v0.12.1 github.com/dgraph-io/badger/v4 v4.2.0 github.com/ethereum/go-ethereum v1.13.14 github.com/go-co-op/gocron/v2 v2.2.6 github.com/gorilla/websocket v1.5.1 - github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/golang-lru/v2 v2.0.7 github.com/ilyakaznacheev/cleanenv v1.5.0 github.com/lmittmann/tint v1.0.4 @@ -25,10 +20,9 @@ require ( github.com/spf13/cobra v1.8.0 github.com/stretchr/testify v1.9.0 github.com/tryvium-travels/memongo v0.12.0 - github.com/vektah/gqlparser/v2 v2.5.11 go.mongodb.org/mongo-driver v1.15.1 golang.org/x/crypto v0.21.0 - golang.org/x/sync v0.6.0 + golang.org/x/net v0.22.0 golang.org/x/text v0.14.0 gopkg.in/yaml.v3 v3.0.1 gorm.io/driver/postgres v1.5.9 @@ -41,9 +35,6 @@ require ( github.com/Microsoft/go-winio v0.6.1 // indirect github.com/VictoriaMetrics/fastcache v1.12.1 // indirect github.com/acobaugh/osrelease v0.0.0-20181218015638-a93a0a55a249 // indirect - github.com/agext/levenshtein v1.2.3 // indirect - github.com/agnivade/levenshtein v1.1.1 // indirect - github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bits-and-blooms/bitset v1.13.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect @@ -70,7 +61,6 @@ require ( github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect github.com/go-ole/go-ole v1.3.0 // indirect - github.com/go-openapi/inflect v0.21.0 // indirect github.com/gofrs/flock v0.8.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect @@ -79,11 +69,8 @@ require ( github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/flatbuffers v24.3.7+incompatible // indirect - github.com/google/go-cmp v0.6.0 // indirect github.com/google/uuid v1.6.0 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-bexpr v0.1.10 // indirect - github.com/hashicorp/hcl/v2 v2.20.0 // indirect github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 // indirect github.com/holiman/bloomfilter/v2 v2.0.3 // indirect github.com/holiman/uint256 v1.2.4 // indirect @@ -104,7 +91,6 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect - github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/pointerstructure v1.2.0 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect @@ -123,7 +109,6 @@ require ( github.com/rs/cors v1.7.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect - github.com/sosodev/duration v1.2.0 // indirect github.com/spf13/afero v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/status-im/keycard-go v0.2.0 // indirect @@ -134,19 +119,16 @@ require ( github.com/tklauser/numcpus v0.7.0 // indirect github.com/tyler-smith/go-bip39 v1.1.0 // indirect github.com/urfave/cli/v2 v2.27.1 // indirect - github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect - github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.1.2 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect - github.com/zclconf/go-cty v1.14.4 // indirect go.opencensus.io v0.24.0 // indirect golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81 // indirect golang.org/x/mod v0.16.0 // indirect - golang.org/x/net v0.22.0 // indirect + golang.org/x/sync v0.6.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.19.0 // indirect diff --git a/go.sum b/go.sum index aee5e98f..c65a161b 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -ariga.io/atlas v0.20.0 h1:b2dL/OIubrCDKDUUXtudS+lJjoTzzKsTamfEg0VkcPI= -ariga.io/atlas v0.20.0/go.mod h1:VPlcXdd4w2KqKnH54yEZcry79UAhpaWaxEsmn5JRNoE= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= @@ -33,12 +31,6 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -entgo.io/contrib v0.4.6-0.20240215171353-eff33e4dca0b h1:jJwnBBJavk5NfJNyg8fvEVp+BUHewhFOlWe4C8IXvh4= -entgo.io/contrib v0.4.6-0.20240215171353-eff33e4dca0b/go.mod h1:q8dXQCmzqpSlVdT2bWDydjgznGcy3y4zmsYmVFC9V/U= -entgo.io/ent v0.13.1 h1:uD8QwN1h6SNphdCCzmkMN3feSUzNnVvV/WIkHKMbzOE= -entgo.io/ent v0.13.1/go.mod h1:qCEmo+biw3ccBn9OyL4ZK5dfpwg++l1Gxwac5B1206A= -github.com/99designs/gqlgen v0.17.45 h1:bH0AH67vIJo8JKNKPJP+pOPpQhZeuVRQLf53dKIpDik= -github.com/99designs/gqlgen v0.17.45/go.mod h1:Bas0XQ+Jiu/Xm5E33jC8sES3G+iC2esHBMXcq0fUPs0= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= @@ -47,26 +39,18 @@ github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw= github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w= -github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= -github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= github.com/Joker/jade v1.0.1-0.20190614124447-d475f43051e7/go.mod h1:6E6s8o2AE4KhCrqr6GRJjdC/gNfTdxkIXvuGZZda2VM= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/PuerkitoBio/goquery v1.9.1 h1:mTL6XjbJTZdpfL+Gwl5U2h1l9yEkJjhmlTeV9VPW7UI= -github.com/PuerkitoBio/goquery v1.9.1/go.mod h1:cW1n6TmIMDoORQU5IU/P1T3tGFunOeXEpGP2WHRwkbY= github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40= github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= github.com/acobaugh/osrelease v0.0.0-20181218015638-a93a0a55a249 h1:fMi9ZZ/it4orHj3xWrM6cLkVFcCbkXQALFUiNtHtCPs= github.com/acobaugh/osrelease v0.0.0-20181218015638-a93a0a55a249/go.mod h1:iU1PxQMQwoHZZWmMKrMkrNlY+3+p9vxIjpZOVyxWa0g= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= -github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= -github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= -github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -75,14 +59,6 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= -github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= -github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss= -github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU= -github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= -github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= -github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= -github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -168,8 +144,6 @@ github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkz github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g= -github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= @@ -217,11 +191,7 @@ github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AE github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= -github.com/go-openapi/inflect v0.21.0 h1:FoBjBTQEcbg2cJUWX6uwL9OyIW8eqc9k4KhN4lfbeYk= -github.com/go-openapi/inflect v0.21.0/go.mod h1:INezMuUu7SJQc2AyR3WO0DqqYUJSj8Kb4hBd7WtjlAw= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= -github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= @@ -315,21 +285,14 @@ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORR github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= -github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= -github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= -github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/hcl/v2 v2.20.0 h1:l++cRs/5jQOiKVvqXZm/P1ZEfVXJmvLS9WSVxkaeTb4= -github.com/hashicorp/hcl/v2 v2.20.0/go.mod h1:WmcD/Ym72MDOOx5F62Ly+leloeu6H7m0pG7VBiU6pQk= github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4= github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= @@ -432,8 +395,6 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= -github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= @@ -442,8 +403,6 @@ github.com/mediocregopher/mediocre-go-lib v0.0.0-20181029021733-cb65787f37ed/go. github.com/mediocregopher/radix/v3 v3.3.0/go.mod h1:EmfVyvspXz1uZEyPBMyGK+kjWiKQGvsUt6O3Pj+LDCQ= github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= -github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= @@ -542,8 +501,6 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= -github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= @@ -552,8 +509,6 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/sosodev/duration v1.2.0 h1:pqK/FLSjsAADWY74SyWDCjOcd5l7H8GSnnOGEB9A1Us= -github.com/sosodev/duration v1.2.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= @@ -604,12 +559,6 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= -github.com/vektah/gqlparser/v2 v2.5.11 h1:JJxLtXIoN7+3x6MBdtIP59TP1RANnY7pXOaDnADQSf8= -github.com/vektah/gqlparser/v2 v2.5.11/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc= -github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= -github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= -github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= -github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= @@ -635,8 +584,6 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= -github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= -github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= go.mongodb.org/mongo-driver v1.15.1 h1:l+RvoUOoMXFmADTLfYDm7On9dRm7p4T80/lEQM+r7HU= go.mongodb.org/mongo-driver v1.15.1/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= diff --git a/internal/generate.go b/internal/generate.go deleted file mode 100644 index 4c8d5812..00000000 --- a/internal/generate.go +++ /dev/null @@ -1,3 +0,0 @@ -package main - -//go:generate go run github.com/99designs/gqlgen diff --git a/internal/gqlgen.yml b/internal/gqlgen.yml deleted file mode 100644 index 25e5934c..00000000 --- a/internal/gqlgen.yml +++ /dev/null @@ -1,52 +0,0 @@ -# schema tells gqlgen where the GraphQL schema is located. -schema: - - transport/server/gql/*.graphql - -# resolver reports where the resolver implementations go. -resolver: - layout: follow-schema - dir: transport/server/gql - package: gql - filename_template: "{name}.resolvers.go" - -exec: - layout: follow-schema - dir: transport/server/gql/generated - package: generated - -# gqlgen will search for any type names in the schema in these go packages -# if they match it will use them, otherwise it will generate them. - -# autobind tells gqngen to search for any type names in the GraphQL schema in the -# provided package. If they match it will use them, otherwise it will generate new. -autobind: - - github.com/TimeleapLabs/unchained/internal/ent - - github.com/TimeleapLabs/unchained/internal/ent/assetprice - - github.com/TimeleapLabs/unchained/internal/ent/eventlog - - github.com/TimeleapLabs/unchained/internal/datasets - - github.com/TimeleapLabs/unchained/internal/transport/server/gql/types - - github.com/99designs/gqlgen/graphql - -# This section declares type mapping between the GraphQL and Go type systems. -models: - # Defines the ID field as Go 'int'. - ID: - model: - - github.com/99designs/gqlgen/graphql.IntID - Node: - model: - - github.com/TimeleapLabs/unchained/internal/ent.Noder - EventLogArg: - model: - - github.com/TimeleapLabs/unchained/internal/datasets.EventLogArg - Uint: - model: - - github.com/99designs/gqlgen/graphql.Uint64 - - github.com/99designs/gqlgen/graphql.Uint - - github.com/99designs/gqlgen/graphql.Uint32 - Bytes: - model: - - github.com/TimeleapLabs/unchained/internal/transport/server/gql/types.Bytes - Any: - model: - - github.com/99designs/gqlgen/graphql.Any diff --git a/internal/models_gen.go b/internal/models_gen.go deleted file mode 100644 index c153dc8b..00000000 --- a/internal/models_gen.go +++ /dev/null @@ -1,3 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package main diff --git a/internal/repository/mongo/assetprice.go b/internal/repository/mongo/assetprice.go index 0aea88d2..61421d5d 100644 --- a/internal/repository/mongo/assetprice.go +++ b/internal/repository/mongo/assetprice.go @@ -10,7 +10,6 @@ import ( "go.mongodb.org/mongo-driver/mongo/options" "github.com/TimeleapLabs/unchained/internal/consts" - "github.com/TimeleapLabs/unchained/internal/ent" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" "github.com/TimeleapLabs/unchained/internal/transport/database" diff --git a/internal/repository/mongo/correctness.go b/internal/repository/mongo/correctness.go index 2819380e..688429c0 100644 --- a/internal/repository/mongo/correctness.go +++ b/internal/repository/mongo/correctness.go @@ -8,7 +8,6 @@ import ( "go.mongodb.org/mongo-driver/mongo/options" "github.com/TimeleapLabs/unchained/internal/consts" - "github.com/TimeleapLabs/unchained/internal/ent" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" "github.com/TimeleapLabs/unchained/internal/transport/database" diff --git a/internal/repository/mongo/eventlog.go b/internal/repository/mongo/eventlog.go index 9c4e7663..3177e790 100644 --- a/internal/repository/mongo/eventlog.go +++ b/internal/repository/mongo/eventlog.go @@ -8,7 +8,6 @@ import ( "go.mongodb.org/mongo-driver/mongo/options" "github.com/TimeleapLabs/unchained/internal/consts" - "github.com/TimeleapLabs/unchained/internal/ent" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" "github.com/TimeleapLabs/unchained/internal/transport/database" diff --git a/internal/repository/mongo/signer.go b/internal/repository/mongo/signer.go index 9ffcd9de..2f95791b 100644 --- a/internal/repository/mongo/signer.go +++ b/internal/repository/mongo/signer.go @@ -7,7 +7,6 @@ import ( "github.com/TimeleapLabs/unchained/internal/config" "github.com/TimeleapLabs/unchained/internal/consts" - "github.com/TimeleapLabs/unchained/internal/ent" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" "github.com/TimeleapLabs/unchained/internal/transport/database" From b2d0cfc28cb4ecf6e7e06c6862fa7b8ed3c2cfeb Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Mon, 24 Jun 2024 05:02:11 +0330 Subject: [PATCH 07/26] =?UTF-8?q?=F0=9F=90=9B=20fix(linter):=20fix=20error?= =?UTF-8?q?s=20>>>=20=E2=8F=B0=2010m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/model/dataframe.go | 7 ++++++- internal/model/proof.go | 8 +++++++- internal/model/signer.go | 2 ++ internal/repository/mongo/assetprice.go | 8 ++++---- internal/repository/mongo/correctness.go | 4 ++-- internal/repository/mongo/eventlog.go | 4 ++-- internal/repository/mongo/signer.go | 4 ++-- 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/internal/model/dataframe.go b/internal/model/dataframe.go index d49d3c26..99f1c75e 100644 --- a/internal/model/dataframe.go +++ b/internal/model/dataframe.go @@ -1,8 +1,13 @@ package model -import "time" +import ( + "time" + + "gorm.io/gorm" +) type DataFrame struct { + gorm.Model Hash []byte `bson:"hash" json:"hash"` Timestamp time.Time `bson:"timestamp" json:"timestamp"` Data interface{} `bson:"data" gorm:"embedded" json:"data"` diff --git a/internal/model/proof.go b/internal/model/proof.go index d69cd8e7..0735b7bf 100644 --- a/internal/model/proof.go +++ b/internal/model/proof.go @@ -1,8 +1,14 @@ package model -import "time" +import ( + "time" + + "gorm.io/gorm" +) type Proof struct { + gorm.Model + Hash []byte `bson:"hash" json:"hash"` Timestamp time.Time `bson:"timestamp" json:"timestamp"` Signature [48]byte `bson:"signature" json:"signature"` diff --git a/internal/model/signer.go b/internal/model/signer.go index bd7d0606..b2aa1496 100644 --- a/internal/model/signer.go +++ b/internal/model/signer.go @@ -2,9 +2,11 @@ package model import ( sia "github.com/pouya-eghbali/go-sia/v2/pkg" + "gorm.io/gorm" ) type Signer struct { + gorm.Model Name string EvmAddress string PublicKey [96]byte diff --git a/internal/repository/mongo/assetprice.go b/internal/repository/mongo/assetprice.go index 61421d5d..1d962abc 100644 --- a/internal/repository/mongo/assetprice.go +++ b/internal/repository/mongo/assetprice.go @@ -58,8 +58,8 @@ func (a AssetPriceRepo) Upsert(ctx context.Context, data model.AssetPrice) error return nil } -func (a AssetPriceRepo) Find(ctx context.Context, block uint64, chain string, name string, pair string) ([]*ent.AssetPrice, error) { - currentRecords := []*ent.AssetPrice{} +func (a AssetPriceRepo) Find(ctx context.Context, block uint64, chain string, name string, pair string) ([]model.AssetPrice, error) { + currentRecords := []model.AssetPrice{} cursor, err := a.client. GetConnection(). Database(config.App.Mongo.Database). @@ -83,14 +83,14 @@ func (a AssetPriceRepo) Find(ctx context.Context, block uint64, chain string, na } }(cursor, ctx) for cursor.Next(ctx) { - var result ent.AssetPrice + var result model.AssetPrice err := cursor.Decode(&result) if err != nil { utils.Logger.With("err", err).Error("Cant decode signer record") return nil, err } - currentRecords = append(currentRecords, &result) + currentRecords = append(currentRecords, result) } if err := cursor.Err(); err != nil { utils.Logger.With("err", err).Error("Cant fetch asset price records from database") diff --git a/internal/repository/mongo/correctness.go b/internal/repository/mongo/correctness.go index 688429c0..efc4be1b 100644 --- a/internal/repository/mongo/correctness.go +++ b/internal/repository/mongo/correctness.go @@ -18,7 +18,7 @@ type CorrectnessRepo struct { client database.MongoDatabase } -func (c CorrectnessRepo) Find(ctx context.Context, hash []byte, topic []byte, timestamp uint64) ([]*ent.CorrectnessReport, error) { +func (c CorrectnessRepo) Find(ctx context.Context, hash []byte, topic []byte, timestamp uint64) ([]model.Correctness, error) { cursor, err := c.client. GetConnection(). Database(config.App.Mongo.Database). @@ -34,7 +34,7 @@ func (c CorrectnessRepo) Find(ctx context.Context, hash []byte, topic []byte, ti return nil, consts.ErrInternalError } - currentRecords, err := CursorToList[*ent.CorrectnessReport](ctx, cursor) + currentRecords, err := CursorToList[model.Correctness](ctx, cursor) if err != nil { utils.Logger.With("err", err).Error("Cant fetch correctness reports from database") return nil, consts.ErrInternalError diff --git a/internal/repository/mongo/eventlog.go b/internal/repository/mongo/eventlog.go index 3177e790..7b1f2ca0 100644 --- a/internal/repository/mongo/eventlog.go +++ b/internal/repository/mongo/eventlog.go @@ -18,7 +18,7 @@ type EventLogRepo struct { client database.MongoDatabase } -func (r EventLogRepo) Find(ctx context.Context, block uint64, hash []byte, index uint64) ([]*ent.EventLog, error) { +func (r EventLogRepo) Find(ctx context.Context, block uint64, hash []byte, index uint64) ([]model.EventLog, error) { cursor, err := r.client. GetConnection(). Database(config.App.Mongo.Database). @@ -34,7 +34,7 @@ func (r EventLogRepo) Find(ctx context.Context, block uint64, hash []byte, index return nil, consts.ErrInternalError } - currentRecords, err := CursorToList[*ent.EventLog](ctx, cursor) + currentRecords, err := CursorToList[model.EventLog](ctx, cursor) if err != nil { utils.Logger.With("err", err).Error("Cant fetch event log records from database") return nil, consts.ErrInternalError diff --git a/internal/repository/mongo/signer.go b/internal/repository/mongo/signer.go index 2f95791b..c707206a 100644 --- a/internal/repository/mongo/signer.go +++ b/internal/repository/mongo/signer.go @@ -74,14 +74,14 @@ func (s signerRepo) GetSingerIDsByKeys(ctx context.Context, keys [][]byte) ([]in } }(cursor, ctx) for cursor.Next(ctx) { - var result ent.Signer + var result model.Signer err := cursor.Decode(&result) if err != nil { utils.Logger.With("err", err).Error("Cant decode signer record") return nil, err } - ids = append(ids, result.ID) + ids = append(ids, int(result.ID)) } if err := cursor.Err(); err != nil { utils.Logger.With("err", err).Error("Cant fetch asset price records from database") From 3517dfd17ae1a4c414483f2e156b7b1125711418 Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Thu, 27 Jun 2024 03:41:07 +0330 Subject: [PATCH 08/26] =?UTF-8?q?=E2=9C=A8=20feat(mongo):=20complete=20mon?= =?UTF-8?q?go=20repositories=20>>>=20=E2=8F=B0=203h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 4 +- internal/app/consumer.go | 36 +++-- internal/app/worker.go | 6 +- internal/model/assetprice.go | 67 +++++++-- internal/model/correctness.go | 26 ++-- internal/model/dataframe.go | 14 -- internal/model/logs.go | 25 ++-- internal/model/proof.go | 52 ++++++- internal/model/signer.go | 52 ++++++- internal/repository/mongo/assetprice.go | 34 +++-- internal/repository/mongo/assetprice_test.go | 1 - internal/repository/mongo/correctness.go | 35 ++--- internal/repository/mongo/correctness_test.go | 1 - internal/repository/mongo/eventlog.go | 45 +++--- internal/repository/mongo/eventlog_test.go | 1 - .../repository/mongo/{signer.go => proof.go} | 46 ++---- .../mongo/{signer_test.go => proof_test.go} | 6 +- internal/repository/postgres/assetprice.go | 36 +++-- internal/repository/postgres/correctness.go | 21 +-- internal/repository/postgres/eventlog.go | 19 +-- internal/repository/postgres/proof.go | 56 ++++++++ internal/repository/postgres/signer.go | 71 ---------- internal/repository/repository.go | 14 +- internal/service/correctness/correctness.go | 103 ++++---------- .../service/correctness/correctness_test.go | 54 ------- internal/service/evmlog/evmlog.go | 46 ++---- internal/service/evmlog/helper.go | 13 -- internal/service/uniswap/helper.go | 18 --- internal/service/uniswap/process.go | 2 +- internal/service/uniswap/types/token.go | 32 +++-- internal/service/uniswap/types/tokenkey.go | 26 +++- internal/service/uniswap/uniswap.go | 133 +++++------------- internal/transport/database/database.go | 1 + .../transport/database/postgres/postgres.go | 10 +- 35 files changed, 537 insertions(+), 571 deletions(-) delete mode 100644 internal/model/dataframe.go rename internal/repository/mongo/{signer.go => proof.go} (60%) rename internal/repository/mongo/{signer_test.go => proof_test.go} (90%) create mode 100644 internal/repository/postgres/proof.go delete mode 100644 internal/repository/postgres/signer.go delete mode 100644 internal/service/uniswap/helper.go diff --git a/go.mod b/go.mod index 527d6451..79f8f32e 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/mattn/go-colorable v0.1.13 github.com/newrelic/go-agent/v3/integrations/nrmongo v1.1.3 github.com/peterldowns/pgtestdb v0.0.14 - github.com/pouya-eghbali/go-sia/v2 v2.1.0 + github.com/pouya-eghbali/go-sia/v2 v2.2.2 github.com/puzpuzpuz/xsync/v3 v3.1.0 github.com/spf13/cobra v1.8.0 github.com/stretchr/testify v1.9.0 diff --git a/go.sum b/go.sum index c65a161b..b330528b 100644 --- a/go.sum +++ b/go.sum @@ -459,8 +459,8 @@ github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pouya-eghbali/go-sia/v2 v2.1.0 h1:LdATSKXsEIhdZAoXRqfHJba+iIPjb8dhmRz3a11QFCA= -github.com/pouya-eghbali/go-sia/v2 v2.1.0/go.mod h1:E+hUvytS6uLa+HSBY+oi19zPvVGZdVzWSVW9zwzZnr8= +github.com/pouya-eghbali/go-sia/v2 v2.2.2 h1:W8K5CR00gLLMO3JLRfPBfeD93BSA5VpwuOOwfp5RKHw= +github.com/pouya-eghbali/go-sia/v2 v2.2.2/go.mod h1:E+hUvytS6uLa+HSBY+oi19zPvVGZdVzWSVW9zwzZnr8= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= diff --git a/internal/app/consumer.go b/internal/app/consumer.go index d73a0a84..6a3dfe38 100644 --- a/internal/app/consumer.go +++ b/internal/app/consumer.go @@ -1,9 +1,12 @@ package app import ( + "github.com/TimeleapLabs/unchained/internal/config" "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/crypto" "github.com/TimeleapLabs/unchained/internal/crypto/ethereum" + "github.com/TimeleapLabs/unchained/internal/repository" + mongoRepo "github.com/TimeleapLabs/unchained/internal/repository/mongo" postgresRepo "github.com/TimeleapLabs/unchained/internal/repository/postgres" correctnessService "github.com/TimeleapLabs/unchained/internal/service/correctness" evmlogService "github.com/TimeleapLabs/unchained/internal/service/evmlog" @@ -12,6 +15,7 @@ import ( "github.com/TimeleapLabs/unchained/internal/transport/client" "github.com/TimeleapLabs/unchained/internal/transport/client/conn" "github.com/TimeleapLabs/unchained/internal/transport/client/handler" + "github.com/TimeleapLabs/unchained/internal/transport/database/mongo" "github.com/TimeleapLabs/unchained/internal/transport/database/postgres" "github.com/TimeleapLabs/unchained/internal/utils" ) @@ -32,15 +36,31 @@ func Consumer() { ethRPC := ethereum.New() pos := pos.New(ethRPC) - db := postgres.New() - eventLogRepo := postgresRepo.NewEventLog(db) - signerRepo := postgresRepo.NewSigner(db) - assetPrice := postgresRepo.NewAssetPrice(db) - correctnessRepo := postgresRepo.NewCorrectness(db) + var eventLogRepo repository.EventLog + var proofRepo repository.Proof + var assetPrice repository.AssetPrice + var correctnessRepo repository.CorrectnessReport - correctnessService := correctnessService.New(pos, signerRepo, correctnessRepo) - evmLogService := evmlogService.New(ethRPC, pos, eventLogRepo, signerRepo, nil) - uniswapService := uniswapService.New(ethRPC, pos, signerRepo, assetPrice) + if config.App.Mongo.URL != "" { + db := mongo.New() + + eventLogRepo = mongoRepo.NewEventLog(db) + proofRepo = mongoRepo.NewProof(db) + assetPrice = mongoRepo.NewAssetPrice(db) + correctnessRepo = mongoRepo.NewCorrectness(db) + } else { + db := postgres.New() + db.Migrate() + + eventLogRepo = postgresRepo.NewEventLog(db) + proofRepo = postgresRepo.NewProof(db) + assetPrice = postgresRepo.NewAssetPrice(db) + correctnessRepo = postgresRepo.NewCorrectness(db) + } + + correctnessService := correctnessService.New(pos, proofRepo, correctnessRepo) + evmLogService := evmlogService.New(ethRPC, pos, eventLogRepo, proofRepo, nil) + uniswapService := uniswapService.New(ethRPC, pos, proofRepo, assetPrice) conn.Start() diff --git a/internal/app/worker.go b/internal/app/worker.go index d89cc579..67c9ed3b 100644 --- a/internal/app/worker.go +++ b/internal/app/worker.go @@ -33,12 +33,12 @@ func Worker() { pos := pos.New(ethRPC) eventLogRepo := postgres.NewEventLog(nil) - signerRepo := postgres.NewSigner(nil) + proofRepo := postgres.NewProof(nil) assetPrice := postgres.NewAssetPrice(nil) badger := evmlogService.NewBadger(config.App.System.ContextPath) - evmLogService := evmlogService.New(ethRPC, pos, eventLogRepo, signerRepo, badger) - uniswapService := uniswapService.New(ethRPC, pos, signerRepo, assetPrice) + evmLogService := evmlogService.New(ethRPC, pos, eventLogRepo, proofRepo, badger) + uniswapService := uniswapService.New(ethRPC, pos, proofRepo, assetPrice) scheduler := scheduler.New( scheduler.WithEthLogs(evmLogService), diff --git a/internal/model/assetprice.go b/internal/model/assetprice.go index 19222a49..c50079dd 100644 --- a/internal/model/assetprice.go +++ b/internal/model/assetprice.go @@ -1,30 +1,73 @@ package model import ( - "bytes" - "encoding/gob" - "math/big" + "github.com/TimeleapLabs/unchained/internal/crypto/bls" + "github.com/TimeleapLabs/unchained/internal/utils" + bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" + sia "github.com/pouya-eghbali/go-sia/v2/pkg" + "go.mongodb.org/mongo-driver/bson/primitive" + "time" ) +type AssetPriceDataFrame struct { + ID uint `gorm:"primarykey" bson:"-"` + DocID primitive.ObjectID `bson:"_id,omitempty" gorm:"-"` + + Hash []byte `bson:"hash" json:"hash"` + Timestamp time.Time `bson:"timestamp" json:"timestamp"` + Data AssetPrice `bson:"data" gorm:"type:jsonb" json:"data"` +} + type AssetPrice struct { Pair string Name string Chain string Block uint64 - Price big.Int + Price int64 SignersCount uint64 Signature []byte Consensus bool - Voted big.Int - SignerIDs []int - Signers []Signer + Voted int64 } -func (a AssetPrice) Hash() []byte { - var b bytes.Buffer - err := gob.NewEncoder(&b).Encode(a) +func (c *AssetPrice) Sia() sia.Sia { + return sia.New(). + AddString8(c.Pair). + AddString8(c.Name). + AddString8(c.Chain). + AddUInt64(c.Block). + AddInt64(c.Price). + AddUInt64(c.SignersCount). + AddByteArray8(c.Signature). + AddBool(c.Consensus). + AddInt64(c.Voted) +} + +func (c *AssetPrice) FromBytes(payload []byte) *AssetPrice { + siaMessage := sia.NewFromBytes(payload) + return c.FromSia(siaMessage) +} + +func (c *AssetPrice) FromSia(siaObj sia.Sia) *AssetPrice { + c.Pair = siaObj.ReadString8() + c.Name = siaObj.ReadString8() + c.Chain = siaObj.ReadString8() + c.Block = siaObj.ReadUInt64() + c.Price = siaObj.ReadInt64() + c.SignersCount = siaObj.ReadUInt64() + copy(c.Signature, siaObj.ReadByteArray8()) + c.Consensus = siaObj.ReadBool() + c.Voted = siaObj.ReadInt64() + + return c +} + +func (c *AssetPrice) Bls() *bls12381.G1Affine { + hash, err := bls.Hash(c.Sia().Bytes()) if err != nil { - return nil + utils.Logger.Error("Can't hash bls: %v", err) + return &bls12381.G1Affine{} } - return b.Bytes() + + return &hash } diff --git a/internal/model/correctness.go b/internal/model/correctness.go index ba8be0f2..d1593842 100644 --- a/internal/model/correctness.go +++ b/internal/model/correctness.go @@ -1,28 +1,34 @@ package model import ( - "math/big" - "github.com/TimeleapLabs/unchained/internal/crypto/bls" "github.com/TimeleapLabs/unchained/internal/utils" + "go.mongodb.org/mongo-driver/bson/primitive" + "time" bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" sia "github.com/pouya-eghbali/go-sia/v2/pkg" ) +type CorrectnessDataFrame struct { + ID uint `gorm:"primarykey" bson:"-"` + DocID primitive.ObjectID `bson:"_id,omitempty" gorm:"-"` + + Hash []byte `bson:"hash" json:"hash"` + Timestamp time.Time `bson:"timestamp" json:"timestamp"` + Data Correctness `bson:"data" gorm:"type:jsonb" json:"data"` +} + type Correctness struct { SignersCount uint64 Signature []byte Consensus bool - Voted big.Int - SignerIDs []int + Voted int64 Timestamp uint64 Hash []byte - Topic [64]byte + Topic []byte Correct bool - - Signers []Signer } func (c *Correctness) Sia() sia.Sia { @@ -47,12 +53,12 @@ func (c *Correctness) FromSia(sia sia.Sia) *Correctness { return c } -func (c *Correctness) Bls() bls12381.G1Affine { +func (c *Correctness) Bls() *bls12381.G1Affine { hash, err := bls.Hash(c.Sia().Bytes()) if err != nil { utils.Logger.Error("Can't hash bls: %v", err) - return bls12381.G1Affine{} + return &bls12381.G1Affine{} } - return hash + return &hash } diff --git a/internal/model/dataframe.go b/internal/model/dataframe.go deleted file mode 100644 index 99f1c75e..00000000 --- a/internal/model/dataframe.go +++ /dev/null @@ -1,14 +0,0 @@ -package model - -import ( - "time" - - "gorm.io/gorm" -) - -type DataFrame struct { - gorm.Model - Hash []byte `bson:"hash" json:"hash"` - Timestamp time.Time `bson:"timestamp" json:"timestamp"` - Data interface{} `bson:"data" gorm:"embedded" json:"data"` -} diff --git a/internal/model/logs.go b/internal/model/logs.go index f68ae5a4..8a11c9f5 100644 --- a/internal/model/logs.go +++ b/internal/model/logs.go @@ -2,10 +2,10 @@ package model import ( "encoding/json" - "math/big" - "github.com/TimeleapLabs/unchained/internal/crypto/bls" "github.com/TimeleapLabs/unchained/internal/utils" + "go.mongodb.org/mongo-driver/bson/primitive" + "time" bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" @@ -18,6 +18,15 @@ type EventLogArg struct { Value any `json:"Value"` } +type EventLogDataFrame struct { + ID uint `gorm:"primarykey" bson:"-"` + DocID primitive.ObjectID `bson:"_id,omitempty" gorm:"-"` + + Hash []byte `bson:"hash" json:"hash"` + Timestamp time.Time `bson:"timestamp" json:"timestamp"` + Data EventLog `bson:"data" gorm:"type:jsonb" json:"data"` +} + type EventLog struct { LogIndex uint64 Block uint64 @@ -25,14 +34,12 @@ type EventLog struct { Event string Chain string TxHash [32]byte - Args []EventLogArg + Args []EventLogArg `gorm:"type:jsonb"` Consensus bool SignersCount uint64 - SignerIDs []int - Signers []Signer Signature []byte - Voted *big.Int + Voted int64 } func (e *EventLog) Sia() sia.Sia { @@ -75,12 +82,12 @@ func (e *EventLog) FromSia(sia sia.Sia) *EventLog { return e } -func (e *EventLog) Bls() (bls12381.G1Affine, error) { +func (e *EventLog) Bls() *bls12381.G1Affine { hash, err := bls.Hash(e.Sia().Bytes()) if err != nil { utils.Logger.Error("Can't hash bls: %v", err) - return bls12381.G1Affine{}, err + return &bls12381.G1Affine{} } - return hash, err + return &hash } diff --git a/internal/model/proof.go b/internal/model/proof.go index 0735b7bf..deed85f4 100644 --- a/internal/model/proof.go +++ b/internal/model/proof.go @@ -1,17 +1,59 @@ package model import ( + "go.mongodb.org/mongo-driver/bson/primitive" "time" - "gorm.io/gorm" + sia "github.com/pouya-eghbali/go-sia/v2/pkg" ) type Proof struct { - gorm.Model + ID uint `gorm:"primarykey" bson:"-"` + DocID primitive.ObjectID `bson:"_id,omitempty" gorm:"-"` Hash []byte `bson:"hash" json:"hash"` Timestamp time.Time `bson:"timestamp" json:"timestamp"` - Signature [48]byte `bson:"signature" json:"signature"` - Signers []Signer `bson:"signers" json:"signers"` - // list of signers (relations in Postgres, and an array in Mongo) + Signature []byte `bson:"signature" json:"signature"` + + Signers []Signer `bson:"signers" json:"signers" gorm:"many2many:proof_signers;"` +} + +func (p *Proof) Sia() sia.Sia { + signers := sia.NewSiaArray[Signer]().AddArray64(p.Signers, func(s *sia.ArraySia[Signer], item Signer) { + s.EmbedBytes(item.Sia().Bytes()) + }) + + return sia.New(). + AddByteArray8(p.Hash). + AddInt64(p.Timestamp.Unix()). + AddByteArray8(p.Signature[:]). + AddByteArray64(signers.Bytes()) +} + +func (p *Proof) FromBytes(payload []byte) *Proof { + siaMessage := sia.NewFromBytes(payload) + return p.FromSia(siaMessage) +} + +func (p *Proof) FromSia(siaObj sia.Sia) *Proof { + signers := sia.NewArrayFromBytes[Signer](siaObj.ReadByteArray64()).ReadArray64(func(s *sia.ArraySia[Signer]) Signer { + signer := Signer{} + signer.FromBytes(s.ReadByteArray64()) + return signer + }) + + p.Hash = siaObj.ReadByteArray8() + p.Timestamp = time.Unix(siaObj.ReadInt64(), 0) + copy(p.Signature[:], siaObj.ReadByteArray8()) + p.Signers = signers + return p +} + +func NewProof(signers []Signer, signature []byte) *Proof { + return &Proof{ + Hash: Signers(signers).Bls(), + Timestamp: time.Now(), + Signature: signature, + Signers: signers, + } } diff --git a/internal/model/signer.go b/internal/model/signer.go index b2aa1496..d2049482 100644 --- a/internal/model/signer.go +++ b/internal/model/signer.go @@ -1,18 +1,41 @@ package model import ( + "github.com/TimeleapLabs/unchained/internal/crypto/bls" + "github.com/TimeleapLabs/unchained/internal/utils" + bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" sia "github.com/pouya-eghbali/go-sia/v2/pkg" + "go.mongodb.org/mongo-driver/bson/primitive" "gorm.io/gorm" + "gorm.io/gorm/clause" ) +type Signers []Signer + type Signer struct { - gorm.Model + ID uint `gorm:"primarykey" bson:"-"` + DocID primitive.ObjectID `bson:"_id,omitempty" gorm:"-"` + Name string EvmAddress string PublicKey [96]byte ShortPublicKey [48]byte } +func (s *Signer) BeforeCreate(tx *gorm.DB) error { + tx.Statement.AddClause(clause.OnConflict{ + Columns: []clause.Column{{Name: "shortkey"}}, + DoUpdates: clause.Assignments(map[string]interface{}{ + "name": "name", + "evm": "evm", + "key": "key", + "point": gorm.Expr("signer.point + 1"), + }), + }) + + return nil +} + func (s *Signer) Sia() sia.Sia { return sia.New(). AddString8(s.Name). @@ -34,3 +57,30 @@ func (s *Signer) FromSia(sia sia.Sia) *Signer { return s } + +func (s *Signer) Bls() bls12381.G1Affine { + hash, err := bls.Hash(s.Sia().Bytes()) + if err != nil { + utils.Logger.Error("Can't hash bls: %v", err) + return bls12381.G1Affine{} + } + + return hash +} + +func (s Signers) Bls() []byte { + bytes := []byte{} + + for _, signer := range s { + hash, err := bls.Hash(signer.Sia().Bytes()) + if err != nil { + utils.Logger.Error("Can't hash bls: %v", err) + return bytes + } + + hashBytes := hash.Bytes() + bytes = append(bytes, hashBytes[:]...) + } + + return bytes +} diff --git a/internal/repository/mongo/assetprice.go b/internal/repository/mongo/assetprice.go index 1d962abc..0c864fee 100644 --- a/internal/repository/mongo/assetprice.go +++ b/internal/repository/mongo/assetprice.go @@ -2,6 +2,7 @@ package mongo import ( "context" + "time" "go.mongodb.org/mongo-driver/mongo" @@ -28,25 +29,28 @@ func (a AssetPriceRepo) Upsert(ctx context.Context, data model.AssetPrice) error Database(config.App.Mongo.Database). Collection("assetprice"). UpdateOne(ctx, bson.M{ - "block": data.Block, - "chain": data.Chain, - "asset": data.Name, - "pair": data.Pair, + "data.block": data.Block, + "data.chain": data.Chain, + "data.asset": data.Name, + "data.pair": data.Pair, }, bson.M{ "$set": bson.M{ - "name": data.Name, - "price": data.Price, - "signers_count": data.SignersCount, - "signature": data.Signature, - "consensus": data.Consensus, - "voted": data.Voted, - "signer_ids": data.SignerIDs, + "data.name": data.Name, + "data.price": data.Price, + "data.signers_count": data.SignersCount, + "data.signature": data.Signature, + "data.consensus": data.Consensus, + "data.voted": data.Voted, }, "$setOnInsert": bson.M{ - "pair": data.Pair, - "chain": data.Chain, - "block": data.Block, - "asset": data.Name, + "hash": data.Bls().Bytes(), + "timestamp": time.Now(), + "data": bson.M{ + "pair": data.Pair, + "chain": data.Chain, + "block": data.Block, + "asset": data.Name, + }, }, }, opt) diff --git a/internal/repository/mongo/assetprice_test.go b/internal/repository/mongo/assetprice_test.go index 850331d3..1ac92930 100644 --- a/internal/repository/mongo/assetprice_test.go +++ b/internal/repository/mongo/assetprice_test.go @@ -26,7 +26,6 @@ var SampleAssetPrice = model.AssetPrice{ Signature: nil, Consensus: false, Voted: *big.NewInt(1000), - SignerIDs: nil, } type AssetPriceRepositoryTestSuite struct { diff --git a/internal/repository/mongo/correctness.go b/internal/repository/mongo/correctness.go index efc4be1b..a9e99462 100644 --- a/internal/repository/mongo/correctness.go +++ b/internal/repository/mongo/correctness.go @@ -2,6 +2,7 @@ package mongo import ( "context" + "time" "github.com/TimeleapLabs/unchained/internal/config" "go.mongodb.org/mongo-driver/bson" @@ -55,24 +56,26 @@ func (c CorrectnessRepo) Upsert(ctx context.Context, data model.Correctness) err "topic": data.Topic[:], }, bson.M{ "$set": bson.M{ - "correct": data.Correct, - "signers_count": data.SignersCount, - "signature": data.Signature, - "timestamp": data.Timestamp, - "consensus": data.Consensus, - "voted": data.Voted, - "signer_ids": data.SignerIDs, + "data.correct": data.Correct, + "data.signers_count": data.SignersCount, + "data.signature": data.Signature, + "data.timestamp": data.Timestamp, + "data.consensus": data.Consensus, + "data.voted": data.Voted, }, "$setOnInsert": bson.M{ - "correct": data.Correct, - "signers_count": data.SignersCount, - "signature": data.Signature, - "hash": data.Hash, - "timestamp": data.Timestamp, - "topic": data.Topic[:], - "consensus": data.Consensus, - "voted": data.Voted, - "signer_ids": data.SignerIDs, + "hash": data.Bls().Bytes(), + "timestamp": time.Now(), + "data": bson.M{ + "correct": data.Correct, + "signers_count": data.SignersCount, + "signature": data.Signature, + "hash": data.Hash, + "timestamp": data.Timestamp, + "topic": data.Topic[:], + "consensus": data.Consensus, + "voted": data.Voted, + }, }, }, opt) diff --git a/internal/repository/mongo/correctness_test.go b/internal/repository/mongo/correctness_test.go index fb3e1a6c..f6c6e77d 100644 --- a/internal/repository/mongo/correctness_test.go +++ b/internal/repository/mongo/correctness_test.go @@ -21,7 +21,6 @@ var sampleCorrectness = model.Correctness{ Signature: nil, Consensus: false, Voted: *big.NewInt(1000), - SignerIDs: nil, Timestamp: 999, Hash: nil, Topic: [64]byte{}, diff --git a/internal/repository/mongo/eventlog.go b/internal/repository/mongo/eventlog.go index 7b1f2ca0..f6a0d792 100644 --- a/internal/repository/mongo/eventlog.go +++ b/internal/repository/mongo/eventlog.go @@ -2,6 +2,7 @@ package mongo import ( "context" + "time" "github.com/TimeleapLabs/unchained/internal/config" "go.mongodb.org/mongo-driver/bson" @@ -56,29 +57,31 @@ func (r EventLogRepo) Upsert(ctx context.Context, data model.EventLog) error { "index": data.LogIndex, }, bson.M{ "$set": bson.M{ - "chain": data.Chain, - "address": data.Address, - "event": data.Event, - "signers_count": data.SignersCount, - "signature": data.Signature, - "args": data.Args, - "consensus": data.Consensus, - "voted": data.Voted, - "signer_ids": data.SignerIDs, + "data.chain": data.Chain, + "data.address": data.Address, + "data.event": data.Event, + "data.signers_count": data.SignersCount, + "data.signature": data.Signature, + "data.args": data.Args, + "data.consensus": data.Consensus, + "data.voted": data.Voted, }, "$setOnInsert": bson.M{ - "block": data.Block, - "chain": data.Chain, - "address": data.Address, - "event": data.Event, - "index": data.LogIndex, - "transaction": data.TxHash[:], - "signers_count": data.SignersCount, - "signature": data.Signature, - "args": data.Args, - "consensus": data.Consensus, - "voted": data.Voted, - "signer_ids": data.SignerIDs, + "hash": data.Bls().Bytes(), + "timestamp": time.Now(), + "data": bson.M{ + "block": data.Block, + "chain": data.Chain, + "address": data.Address, + "event": data.Event, + "index": data.LogIndex, + "transaction": data.TxHash[:], + "signers_count": data.SignersCount, + "signature": data.Signature, + "args": data.Args, + "consensus": data.Consensus, + "voted": data.Voted, + }, }, }, opt) diff --git a/internal/repository/mongo/eventlog_test.go b/internal/repository/mongo/eventlog_test.go index 1756b000..2c031b8c 100644 --- a/internal/repository/mongo/eventlog_test.go +++ b/internal/repository/mongo/eventlog_test.go @@ -26,7 +26,6 @@ var sampleEventLog = model.EventLog{ Args: nil, Consensus: false, SignersCount: 100, - SignerIDs: nil, Signature: nil, Voted: nil, } diff --git a/internal/repository/mongo/signer.go b/internal/repository/mongo/proof.go similarity index 60% rename from internal/repository/mongo/signer.go rename to internal/repository/mongo/proof.go index c707206a..99f949b8 100644 --- a/internal/repository/mongo/signer.go +++ b/internal/repository/mongo/proof.go @@ -15,50 +15,34 @@ import ( "go.mongodb.org/mongo-driver/mongo/options" ) -type signerRepo struct { +type proofRepo struct { client database.MongoDatabase } -func (s signerRepo) CreateSigners(ctx context.Context, signers []model.Signer) error { - for _, singer := range signers { - opt := options.Update().SetUpsert(true) +func (s proofRepo) CreateProof(ctx context.Context, signature [48]byte, signers []model.Signer) error { + proof := model.NewProof(signers, signature[:]) - _, err := s.client. - GetConnection(). - Database(config.App.Mongo.Database). - Collection("signer"). - UpdateOne(ctx, - bson.M{ - "shortkey": singer.ShortPublicKey[:], - }, bson.M{ - "$set": bson.M{ - "name": singer.Name, - "evm": singer.EvmAddress, - "key": singer.PublicKey[:], - "points": bson.M{"$inc": 1}, - }, "$setOnInsert": bson.M{ - "shortkey": singer.ShortPublicKey[:], - }, - }, - opt, - ) - if err != nil { - utils.Logger.With("err", err).Error("Cant create signers in database") - return consts.ErrInternalError - } + _, err := s.client. + GetConnection(). + Database(config.App.Mongo.Database). + Collection("signer"). + InsertOne(ctx, proof) + if err != nil { + utils.Logger.With("err", err).Error("Cant create signers in database") + return consts.ErrInternalError } return nil } -func (s signerRepo) GetSingerIDsByKeys(ctx context.Context, keys [][]byte) ([]int, error) { +func (s proofRepo) GetSingerIDsByKeys(ctx context.Context, keys [][]byte) ([]int, error) { opt := options.Find().SetProjection(bson.M{"_id": 1}) cursor, err := s.client. GetConnection(). Database(config.App.Mongo.Database). Collection("signer"). Find(ctx, bson.M{ - "key": bson.M{"$in": keys}, + "data.key": bson.M{"$in": keys}, }, opt) if err != nil { @@ -91,8 +75,8 @@ func (s signerRepo) GetSingerIDsByKeys(ctx context.Context, keys [][]byte) ([]in return ids, nil } -func NewSigner(client database.MongoDatabase) repository.Signer { - return &signerRepo{ +func NewProof(client database.MongoDatabase) repository.Proof { + return &proofRepo{ client: client, } } diff --git a/internal/repository/mongo/signer_test.go b/internal/repository/mongo/proof_test.go similarity index 90% rename from internal/repository/mongo/signer_test.go rename to internal/repository/mongo/proof_test.go index c596ebac..c3f67c29 100644 --- a/internal/repository/mongo/signer_test.go +++ b/internal/repository/mongo/proof_test.go @@ -20,7 +20,7 @@ var sampleSigner = model.Signer{} type SignerRepositoryTestSuite struct { suite.Suite dbServer *memongo.Server - repo repository.Signer + repo repository.Proof } func (s *SignerRepositoryTestSuite) SetupTest() { @@ -44,11 +44,11 @@ func (s *SignerRepositoryTestSuite) SetupTest() { config.App.Mongo.URL = s.dbServer.URI() config.App.Mongo.Database = memongo.RandomDatabase() db := mongo.New() - s.repo = NewSigner(db) + s.repo = NewProof(db) } func (s *SignerRepositoryTestSuite) TestUpsert() { - err := s.repo.CreateSigners(context.TODO(), []model.Signer{sampleSigner}) + err := s.repo.CreateProof(context.TODO(), [48]byte{}, []model.Signer{sampleSigner}) s.Require().NoError(err) } diff --git a/internal/repository/postgres/assetprice.go b/internal/repository/postgres/assetprice.go index f1570fbc..e69151e1 100644 --- a/internal/repository/postgres/assetprice.go +++ b/internal/repository/postgres/assetprice.go @@ -18,16 +18,17 @@ type AssetPriceRepo struct { } func (a AssetPriceRepo) Upsert(ctx context.Context, data model.AssetPrice) error { + dataHash := data.Bls().Bytes() + err := a.client. GetConnection(). WithContext(ctx). - Table("asset_price"). Clauses(clause.OnConflict{ - Columns: []clause.Column{{Name: "block"}, {Name: "chain"}, {Name: "asset"}, {Name: "pair"}}, + Columns: []clause.Column{{Name: "data.block"}, {Name: "data.chain"}, {Name: "data.asset"}, {Name: "data.pair"}}, UpdateAll: true, }). - Create(&model.DataFrame{ - Hash: data.Hash(), + Create(&model.AssetPriceDataFrame{ + Hash: dataHash[:], Timestamp: time.Now(), Data: data, }) @@ -41,24 +42,29 @@ func (a AssetPriceRepo) Upsert(ctx context.Context, data model.AssetPrice) error } func (a AssetPriceRepo) Find(ctx context.Context, block uint64, chain string, name string, pair string) ([]model.AssetPrice, error) { - currentRecords := []model.AssetPrice{} - err := a.client. + currentRecords := []model.AssetPriceDataFrame{} + tx := a.client. GetConnection(). WithContext(ctx). - Table("asset_price"). - Where("block", block). - Where("chain", chain). - Where("name", name). - Where("pair", pair). - Preload("Signer"). + Where(model.AssetPriceDataFrame{Data: model.AssetPrice{ + Pair: pair, + Name: name, + Chain: chain, + Block: block, + }}). Find(¤tRecords) - if err != nil { - utils.Logger.With("err", err).Error("Cant fetch asset price records from database") + if tx.Error != nil { + utils.Logger.With("err", tx.Error).Error("Cant fetch asset price records from database") return nil, consts.ErrInternalError } - return currentRecords, nil + results := []model.AssetPrice{} + for _, record := range currentRecords { + results = append(results, record.Data) + } + + return results, nil } func NewAssetPrice(client database.Database) repository.AssetPrice { diff --git a/internal/repository/postgres/correctness.go b/internal/repository/postgres/correctness.go index 48f9d862..4eb5ef62 100644 --- a/internal/repository/postgres/correctness.go +++ b/internal/repository/postgres/correctness.go @@ -17,22 +17,26 @@ type CorrectnessRepo struct { } func (c CorrectnessRepo) Find(ctx context.Context, hash []byte, topic []byte, timestamp uint64) ([]model.Correctness, error) { - currentRecords := []model.Correctness{} - err := c.client. + currentRecords := []model.CorrectnessDataFrame{} + tx := c.client. GetConnection(). WithContext(ctx). - Table("correctness"). Where("hash", hash). Where("topic", topic). Where("timestamp", timestamp). Find(¤tRecords) - if err != nil { - utils.Logger.With("err", err).Error("Cant fetch correctness reports from database") + if tx.Error != nil { + utils.Logger.With("err", tx.Error).Error("Cant fetch correctness reports from database") return nil, consts.ErrInternalError } - return currentRecords, nil + results := []model.Correctness{} + for _, record := range currentRecords { + results = append(results, record.Data) + } + + return results, nil } func (c CorrectnessRepo) Upsert(ctx context.Context, data model.Correctness) error { @@ -42,12 +46,11 @@ func (c CorrectnessRepo) Upsert(ctx context.Context, data model.Correctness) err err := c.client. GetConnection(). WithContext(ctx). - Table("correctness"). Clauses(clause.OnConflict{ - Columns: []clause.Column{{Name: "topic"}, {Name: "hash"}}, + Columns: []clause.Column{{Name: "data.topic"}, {Name: "data.hash"}}, UpdateAll: true, }). - Create(&model.DataFrame{ + Create(&model.CorrectnessDataFrame{ Hash: dataBlsHash, Timestamp: time.Now(), Data: data, diff --git a/internal/repository/postgres/eventlog.go b/internal/repository/postgres/eventlog.go index 09aa565e..89113757 100644 --- a/internal/repository/postgres/eventlog.go +++ b/internal/repository/postgres/eventlog.go @@ -18,35 +18,38 @@ type EventLogRepo struct { } func (r EventLogRepo) Find(ctx context.Context, block uint64, hash []byte, index uint64) ([]model.EventLog, error) { - currentRecords := []model.EventLog{} - err := r.client. + currentRecords := []model.EventLogDataFrame{} + tx := r.client. GetConnection(). WithContext(ctx). - Table("event_log"). Where("block", block). Where("transaction", hash). Where("index", index). Preload("Signers"). Find(¤tRecords) - if err != nil { - utils.Logger.With("err", err).Error("Cant fetch event log records from database") + if tx.Error != nil { + utils.Logger.With("err", tx.Error).Error("Cant fetch event log records from database") return nil, consts.ErrInternalError } - return currentRecords, nil + results := []model.EventLog{} + for _, record := range currentRecords { + results = append(results, record.Data) + } + + return results, nil } func (r EventLogRepo) Upsert(ctx context.Context, data model.EventLog) error { err := r.client. GetConnection(). WithContext(ctx). - Table("event_log"). Clauses(clause.OnConflict{ Columns: []clause.Column{{Name: "block"}, {Name: "transaction"}, {Name: "index"}}, UpdateAll: true, }). - Create(&model.DataFrame{ + Create(&model.EventLogDataFrame{ Hash: nil, Timestamp: time.Now(), Data: data, diff --git a/internal/repository/postgres/proof.go b/internal/repository/postgres/proof.go new file mode 100644 index 00000000..b8231c59 --- /dev/null +++ b/internal/repository/postgres/proof.go @@ -0,0 +1,56 @@ +package postgres + +import ( + "context" + + "github.com/TimeleapLabs/unchained/internal/consts" + "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/repository" + "github.com/TimeleapLabs/unchained/internal/transport/database" + "github.com/TimeleapLabs/unchained/internal/utils" +) + +type proofRepo struct { + client database.Database +} + +func (s proofRepo) CreateProof(ctx context.Context, signature [48]byte, signers []model.Signer) error { + proof := model.NewProof(signers, signature[:]) + + err := s.client. + GetConnection(). + WithContext(ctx). + Create(&proof) + + if err != nil { + utils.Logger.With("err", err).Error("Cant create signers in database") + return consts.ErrInternalError + } + + return nil +} + +func (s proofRepo) GetSingerIDsByKeys(ctx context.Context, keys [][]byte) ([]int, error) { + ids := []int{} + + tx := s.client. + GetConnection(). + WithContext(ctx). + Table("proofs"). + Select("id"). + Where("data.key in ?", keys). + Find(&ids) + + if tx.Error != nil { + utils.Logger.With("err", tx.Error).Error("Cant fetch signer IDs from database") + return []int{}, consts.ErrInternalError + } + + return ids, nil +} + +func NewProof(client database.Database) repository.Proof { + return &proofRepo{ + client: client, + } +} diff --git a/internal/repository/postgres/signer.go b/internal/repository/postgres/signer.go deleted file mode 100644 index 26eb8a57..00000000 --- a/internal/repository/postgres/signer.go +++ /dev/null @@ -1,71 +0,0 @@ -package postgres - -import ( - "context" - - "gorm.io/gorm" - "gorm.io/gorm/clause" - - "github.com/TimeleapLabs/unchained/internal/consts" - "github.com/TimeleapLabs/unchained/internal/model" - "github.com/TimeleapLabs/unchained/internal/repository" - "github.com/TimeleapLabs/unchained/internal/transport/database" - "github.com/TimeleapLabs/unchained/internal/utils" -) - -type signerRepo struct { - client database.Database -} - -func (s signerRepo) CreateSigners(ctx context.Context, signers []model.Signer) error { - err := s.client. - GetConnection(). - WithContext(ctx). - Table("signer"). - Clauses(clause.OnConflict{ - Columns: []clause.Column{{Name: "shortkey"}}, - DoUpdates: clause.Assignments(map[string]interface{}{ - "name": "name", - "evm": "evm", - "key": "key", - "point": gorm.Expr("signer.point + 1"), - }), - }). - CreateInBatches(&signers, 100) - - // Update(func(su *ent.SignerUpsert) { - // su.AddPoints(1) - // }). - - if err != nil { - utils.Logger.With("err", err).Error("Cant create signers in database") - return consts.ErrInternalError - } - - return nil -} - -func (s signerRepo) GetSingerIDsByKeys(ctx context.Context, keys [][]byte) ([]int, error) { - ids := []int{} - - err := s.client. - GetConnection(). - WithContext(ctx). - Table("signer"). - Select("id"). - Where("data.key in ?", keys). - Find(&ids) - - if err != nil { - utils.Logger.With("err", err).Error("Cant fetch signer IDs from database") - return []int{}, consts.ErrInternalError - } - - return ids, nil -} - -func NewSigner(client database.Database) repository.Signer { - return &signerRepo{ - client: client, - } -} diff --git a/internal/repository/repository.go b/internal/repository/repository.go index 732593c9..51856fca 100644 --- a/internal/repository/repository.go +++ b/internal/repository/repository.go @@ -6,18 +6,18 @@ import ( "github.com/TimeleapLabs/unchained/internal/model" ) -// EvenetLog interface represents the methods that can be used to interact with the EventLog table in the database. +// Proof interface represents the methods that can be used to interact with the Proof table in the database. +type Proof interface { + CreateProof(ctx context.Context, signature [48]byte, signers []model.Signer) error + GetSingerIDsByKeys(ctx context.Context, keys [][]byte) ([]int, error) +} + +// EventLog interface represents the methods that can be used to interact with the EventLog table in the database. type EventLog interface { Find(ctx context.Context, block uint64, hash []byte, index uint64) ([]model.EventLog, error) Upsert(ctx context.Context, data model.EventLog) error } -// Signer interface represents the methods that can be used to interact with the Signer table in the database. -type Signer interface { - CreateSigners(ctx context.Context, signers []model.Signer) error - GetSingerIDsByKeys(ctx context.Context, keys [][]byte) ([]int, error) -} - // AssetPrice interface represents the methods that can be used to interact with the AssetPrice table in the database. type AssetPrice interface { Find(ctx context.Context, block uint64, chain string, name string, pair string) ([]model.AssetPrice, error) diff --git a/internal/service/correctness/correctness.go b/internal/service/correctness/correctness.go index 802337ba..fc337f99 100644 --- a/internal/service/correctness/correctness.go +++ b/internal/service/correctness/correctness.go @@ -35,7 +35,6 @@ type SaveSignatureArgs struct { } type Service interface { - IsNewSigner(signature Signature, records []model.Correctness) bool RecordSignature( ctx context.Context, signature bls12381.G1Affine, signer model.Signer, hash bls12381.G1Affine, info model.Correctness, debounce bool, ) error @@ -44,7 +43,7 @@ type Service interface { type service struct { pos pos.Service - signerRepo repository.Signer + proofRepo repository.Proof correctnessRepo repository.CorrectnessReport signatureCache *lru.Cache[bls12381.G1Affine, []Signature] @@ -55,26 +54,12 @@ type service struct { supportedTopics map[[64]byte]bool } -// IsNewSigner checks if the signer's pub key is in the records signers or not. -func (s *service) IsNewSigner(signature Signature, records []model.Correctness) bool { - // TODO: This isn't efficient, we should use a map - for _, record := range records { - for _, signer := range record.Signers { - if signature.Signer.PublicKey == signer.PublicKey { - return false - } - } - } - - return true -} - // TODO: How should we handle older records? // Possible Solution: Add a not after timestamp to the document. func (s *service) RecordSignature( ctx context.Context, signature bls12381.G1Affine, signer model.Signer, hash bls12381.G1Affine, info model.Correctness, debounce bool, ) error { - if supported := s.supportedTopics[info.Topic]; !supported { + if supported := s.supportedTopics[[64]byte(info.Topic)]; !supported { utils.Logger. With("Topic", info.Topic). Debug("Token not supported") @@ -96,11 +81,6 @@ func (s *service) RecordSignature( } } - packed := Signature{ - Signature: signature, - Signer: signer, - } - key := Key{ Hash: fmt.Sprintf("%x", info.Hash), Topic: fmt.Sprintf("%x", info.Topic), @@ -112,7 +92,6 @@ func (s *service) RecordSignature( } reportedValues, _ := s.consensus.Get(key) - isMajority := true voted, ok := reportedValues.Load(hash) if !ok { voted = *big.NewInt(0) @@ -129,6 +108,7 @@ func (s *service) RecordSignature( totalVoted := new(big.Int).Add(votingPower, &voted) + isMajority := true reportedValues.Range(func(_ bls12381.G1Affine, value big.Int) bool { if value.Cmp(totalVoted) == 1 { isMajority = false @@ -137,7 +117,10 @@ func (s *service) RecordSignature( }) reportedValues.Store(hash, *totalVoted) - signatures = append(signatures, packed) + signatures = append(signatures, Signature{ + Signature: signature, + Signer: signer, + }) s.signatureCache.Add(hash, signatures) saveArgs := SaveSignatureArgs{ @@ -166,47 +149,20 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er return consts.ErrSignatureNotfound } - var newSigners []model.Signer - var newSignatures []bls12381.G1Affine - var keys [][]byte - - for i := range signatures { - signature := signatures[i] - keys = append(keys, signature.Signer.PublicKey[:]) - } - currentRecords, err := s.correctnessRepo.Find(ctx, args.Info.Hash, args.Info.Topic[:], args.Info.Timestamp) if err != nil { return err } + var newSigners []model.Signer + var newSignatures []bls12381.G1Affine // Select the new signers and signatures - - for i := range signatures { - signature := signatures[i] - - if !s.IsNewSigner(signature, currentRecords) { - continue - } - + for _, signature := range signatures { newSigners = append(newSigners, signature.Signer) newSignatures = append(newSignatures, signature.Signature) } // TODO: This part can be a shared library - - err = s.signerRepo.CreateSigners(ctx, newSigners) - if err != nil { - return err - } - - signerIDs, err := s.signerRepo.GetSingerIDsByKeys(ctx, keys) - if err != nil { - return err - } - - var aggregate bls12381.G1Affine - for _, record := range currentRecords { if record.Correct == args.Info.Correct { currentSignature, err := bls.RecoverSignature([48]byte(record.Signature)) @@ -220,6 +176,7 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er } } + var aggregate bls12381.G1Affine aggregate, err = bls.AggregateSignatures(newSignatures) if err != nil { return consts.ErrCantAggregateSignatures @@ -227,12 +184,16 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er signatureBytes := aggregate.Bytes() + err = s.proofRepo.CreateProof(ctx, signatureBytes, newSigners) + if err != nil { + return err + } + err = s.correctnessRepo.Upsert(ctx, model.Correctness{ SignersCount: uint64(len(signatures)), Signature: signatureBytes[:], Consensus: args.Consensus, - Voted: *args.Voted, - SignerIDs: signerIDs, + Voted: args.Voted.Int64(), Timestamp: args.Info.Timestamp, Hash: args.Info.Hash, Topic: args.Info.Topic, @@ -247,36 +208,28 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er return nil } -func (s *service) init() { - var err error - - s.DebouncedSaveSignatures = utils.Debounce[bls12381.G1Affine, SaveSignatureArgs](5*time.Second, s.SaveSignatures) - s.signatureMutex = new(sync.Mutex) - s.supportedTopics = make(map[[64]byte]bool) - s.signatureCache, err = lru.New[bls12381.G1Affine, []Signature](LruSize) - - if err != nil { - panic(err) - } -} - func New( - pos pos.Service, - signerRepo repository.Signer, - correctnessRepo repository.CorrectnessReport, + pos pos.Service, proofRepo repository.Proof, correctnessRepo repository.CorrectnessReport, ) Service { c := service{ pos: pos, - signerRepo: signerRepo, + proofRepo: proofRepo, correctnessRepo: correctnessRepo, } - c.init() + + var err error + c.DebouncedSaveSignatures = utils.Debounce[bls12381.G1Affine, SaveSignatureArgs](5*time.Second, c.SaveSignatures) + c.signatureMutex = new(sync.Mutex) + c.supportedTopics = make(map[[64]byte]bool) + c.signatureCache, err = lru.New[bls12381.G1Affine, []Signature](LruSize) + if err != nil { + panic(err) + } for _, conf := range config.App.Plugins.Correctness { c.supportedTopics[[64]byte(utils.Shake([]byte(conf)))] = true } - var err error c.consensus, err = lru.New[Key, xsync.MapOf[bls12381.G1Affine, big.Int]](LruSize) if err != nil { utils.Logger. diff --git a/internal/service/correctness/correctness_test.go b/internal/service/correctness/correctness_test.go index a70024d1..84a9e969 100644 --- a/internal/service/correctness/correctness_test.go +++ b/internal/service/correctness/correctness_test.go @@ -7,7 +7,6 @@ import ( postgresRepo "github.com/TimeleapLabs/unchained/internal/repository/postgres" "github.com/TimeleapLabs/unchained/internal/service/pos" "github.com/TimeleapLabs/unchained/internal/transport/database/mock" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) @@ -40,59 +39,6 @@ func (s *CorrectnessTestSuite) SetupTest() { s.service = New(posService, signerRepo, correctnessRepo) } -func (s *CorrectnessTestSuite) TestIsNewSigner() { - s.Run("Check if new signer with empty values", func() { - isSigner := s.service.IsNewSigner(Signature{}, []model.Correctness{}) - assert.False(s.T(), isSigner) - }) - - s.Run("Check when sign is new signer", func() { - signers := make([]byte, 96) - for i := 1; i < 4; i++ { - signers[i] = byte(i) - } - - isSigner := s.service.IsNewSigner( - SignerOne, - []model.Correctness{ - //{ - // Edges: ent.CorrectnessReportEdges{ - // Signers: []*ent.Signer{ - // { - // Key: signers, - // }, - // }, - // }, - // }, - }, - ) - assert.True(s.T(), isSigner) - }) - - s.Run("Check when sign is not new signer", func() { - signers := make([]byte, 96) - for i := 2; i < 4; i++ { - signers[i] = byte(i) - } - - isSigner := s.service.IsNewSigner( - SignerTwo, - []model.Correctness{ - { - //Edges: ent.CorrectnessReportEdges{ - // Signers: []*ent.Signer{ - // { - // Key: signers, - // }, - // }, - // }, - }, - }, - ) - assert.True(s.T(), isSigner) - }) -} - func TestCorrectnessSuite(t *testing.T) { suite.Run(t, new(CorrectnessTestSuite)) } diff --git a/internal/service/evmlog/evmlog.go b/internal/service/evmlog/evmlog.go index c9d92fe3..6cb5582d 100644 --- a/internal/service/evmlog/evmlog.go +++ b/internal/service/evmlog/evmlog.go @@ -54,7 +54,7 @@ type service struct { ethRPC ethereum.RPC pos pos.Service eventLogRepo repository.EventLog - signerRepo repository.Signer + proofRepo repository.Proof persistence *Badger consensus *lru.Cache[EventKey, map[bls12381.G1Affine]big.Int] @@ -85,7 +85,6 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er var newSigners []model.Signer var newSignatures []bls12381.G1Affine - var keys [][]byte currentRecords, err := s.eventLogRepo.Find(ctx, args.Info.Block, args.Info.TxHash[:], args.Info.LogIndex) if err != nil { @@ -94,29 +93,11 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er for i := range signatures { signature := signatures[i] - keys = append(keys, signature.Signer.PublicKey[:]) - - if !isNewSigner(signature, currentRecords) { - continue - } newSignatures = append(newSignatures, signature.Signature) newSigners = append(newSigners, signature.Signer) } - err = s.signerRepo.CreateSigners(ctx, newSigners) - - if err != nil { - return err - } - - signerIDs, err := s.signerRepo.GetSingerIDsByKeys(ctx, keys) - if err != nil { - return err - } - - var aggregate bls12381.G1Affine - sortedCurrentArgs := make([]model.EventLogArg, len(args.Info.Args)) copy(sortedCurrentArgs, args.Info.Args) slices.SortFunc(sortedCurrentArgs, sortEventArgs) @@ -146,7 +127,6 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er } currentAggregate, err := bls.RecoverSignature([48]byte(record.Signature)) - if err != nil { utils.Logger. With("Block", args.Info.Block). @@ -163,21 +143,25 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er break } + var aggregate bls12381.G1Affine aggregate, err = bls.AggregateSignatures(newSignatures) - if err != nil { return consts.ErrCantAggregateSignatures } signatureBytes := aggregate.Bytes() + err = s.proofRepo.CreateProof(ctx, signatureBytes, newSigners) + if err != nil { + return err + } + args.Info.SignersCount = uint64(len(signatures)) - args.Info.SignerIDs = signerIDs args.Info.Consensus = args.Consensus args.Info.Signature = signatureBytes[:] - args.Info.Voted = args.Voted - err = s.eventLogRepo.Upsert(ctx, args.Info) + args.Info.Voted = args.Voted.Int64() + err = s.eventLogRepo.Upsert(ctx, args.Info) if err != nil { return err } @@ -186,28 +170,22 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er } func (s *service) SendPriceReport(signature bls12381.G1Affine, event model.EventLog) { - compressedSignature := signature.Bytes() - priceReport := packet.EventLogReportPacket{ EventLog: event, - Signature: compressedSignature, + Signature: signature.Bytes(), } conn.Send(consts.OpCodeEventLog, priceReport.Sia().Bytes()) } func New( - ethRPC ethereum.RPC, - pos pos.Service, - eventLogRepo repository.EventLog, - signerRepo repository.Signer, - persistence *Badger, + ethRPC ethereum.RPC, pos pos.Service, eventLogRepo repository.EventLog, proofRepo repository.Proof, persistence *Badger, ) Service { s := service{ ethRPC: ethRPC, pos: pos, eventLogRepo: eventLogRepo, - signerRepo: signerRepo, + proofRepo: proofRepo, persistence: persistence, signatureMutex: new(sync.Mutex), diff --git a/internal/service/evmlog/helper.go b/internal/service/evmlog/helper.go index dda1f396..4e2a4d2a 100644 --- a/internal/service/evmlog/helper.go +++ b/internal/service/evmlog/helper.go @@ -2,21 +2,8 @@ package evmlog import ( "github.com/TimeleapLabs/unchained/internal/model" - "github.com/TimeleapLabs/unchained/internal/service/correctness" ) -func isNewSigner(signature correctness.Signature, records []model.EventLog) bool { - for _, record := range records { - for _, signer := range record.Signers { - if signature.Signer.PublicKey == signer.PublicKey { - return false - } - } - } - - return true -} - func sortEventArgs(lhs model.EventLogArg, rhs model.EventLogArg) int { if lhs.Name < rhs.Name { return -1 diff --git a/internal/service/uniswap/helper.go b/internal/service/uniswap/helper.go deleted file mode 100644 index 9688238f..00000000 --- a/internal/service/uniswap/helper.go +++ /dev/null @@ -1,18 +0,0 @@ -package uniswap - -import ( - "github.com/TimeleapLabs/unchained/internal/model" - "github.com/TimeleapLabs/unchained/internal/service/correctness" -) - -func IsNewSigner(signature correctness.Signature, records []model.AssetPrice) bool { - for _, record := range records { - for _, signer := range record.Signers { - if signature.Signer.PublicKey == signer.PublicKey { - return false - } - } - } - - return true -} diff --git a/internal/service/uniswap/process.go b/internal/service/uniswap/process.go index c7bac60f..6c1874bf 100644 --- a/internal/service/uniswap/process.go +++ b/internal/service/uniswap/process.go @@ -21,7 +21,7 @@ func (s *service) ProcessBlocks(ctx context.Context, chain string) error { } // TODO: this can be cached - key := s.TokenKey(token) + key := types.NewTokenKey(token.GetCrossTokenKeys(s.crossTokens), token) tokenLastBlock, exists := s.LastBlock.Load(*key) if !exists { diff --git a/internal/service/uniswap/types/token.go b/internal/service/uniswap/types/token.go index 48ab8e2e..0f3d0ee8 100644 --- a/internal/service/uniswap/types/token.go +++ b/internal/service/uniswap/types/token.go @@ -3,17 +3,27 @@ package types import "github.com/TimeleapLabs/unchained/internal/config" type Token struct { - ID *string `mapstructure:"id"` - Chain string `mapstructure:"chain"` - Name string `mapstructure:"name"` - Pair string `mapstructure:"pair"` - Unit string `mapstructure:"unit"` - Symbol string `mapstructure:"symbol"` - Delta int64 `mapstructure:"delta"` - Invert bool `mapstructure:"invert"` - Store bool `mapstructure:"store"` - Send bool `mapstructure:"send"` - Cross []string `mapstructure:"cross"` + ID *string `json:"id"` + Chain string `json:"chain"` + Name string `json:"name"` + Pair string `json:"pair"` + Unit string `json:"unit"` + Symbol string `json:"symbol"` + Delta int64 `json:"delta"` + Invert bool `json:"invert"` + Store bool `json:"store"` + Send bool `json:"send"` + Cross []string `json:"cross"` +} + +func (t Token) GetCrossTokenKeys(crossTokens map[string]TokenKey) TokenKeys { + var cross []TokenKey + + for _, id := range t.Cross { + cross = append(cross, crossTokens[id]) + } + + return cross } func NewTokensFromCfg(input []config.Token) []Token { diff --git a/internal/service/uniswap/types/tokenkey.go b/internal/service/uniswap/types/tokenkey.go index 6593bf62..434f35b0 100644 --- a/internal/service/uniswap/types/tokenkey.go +++ b/internal/service/uniswap/types/tokenkey.go @@ -1,6 +1,13 @@ package types -import sia "github.com/pouya-eghbali/go-sia/v2/pkg" +import ( + "strings" + + "github.com/TimeleapLabs/unchained/internal/utils" + sia "github.com/pouya-eghbali/go-sia/v2/pkg" +) + +type TokenKeys []TokenKey type TokenKey struct { Name string @@ -21,6 +28,12 @@ func (t *TokenKey) Sia() sia.Sia { AddString8(t.Cross) } +func (t TokenKeys) Sia() sia.Sia { + return sia.NewSiaArray[TokenKey]().AddArray8(t, func(s *sia.ArraySia[TokenKey], item TokenKey) { + s.EmbedBytes(item.Sia().Bytes()) + }) +} + func (t *TokenKey) FromSia(sia sia.Sia) *TokenKey { t.Name = sia.ReadString8() t.Pair = sia.ReadString8() @@ -31,3 +44,14 @@ func (t *TokenKey) FromSia(sia sia.Sia) *TokenKey { return t } + +func NewTokenKey(cross TokenKeys, token Token) *TokenKey { + return &TokenKey{ + Name: strings.ToLower(token.Name), + Pair: strings.ToLower(token.Pair), + Chain: strings.ToLower(token.Chain), + Delta: token.Delta, + Invert: token.Invert, + Cross: string(utils.Shake(cross.Sia().Bytes())), + } +} diff --git a/internal/service/uniswap/uniswap.go b/internal/service/uniswap/uniswap.go index ae909411..8d3b0bad 100644 --- a/internal/service/uniswap/uniswap.go +++ b/internal/service/uniswap/uniswap.go @@ -29,7 +29,6 @@ import ( bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" "github.com/ethereum/go-ethereum/accounts/abi/bind" lru "github.com/hashicorp/golang-lru/v2" - sia "github.com/pouya-eghbali/go-sia/v2/pkg" "github.com/puzpuzpuz/xsync/v3" "golang.org/x/text/cases" "golang.org/x/text/language" @@ -42,6 +41,13 @@ const ( var DebouncedSaveSignatures func(key types.AssetKey, arg SaveSignatureArgs) +type SaveSignatureArgs struct { + Info types.PriceInfo + Hash bls12381.G1Affine + Consensus bool + Voted *big.Int +} + type Service interface { checkAndCacheSignature( reportedValues *xsync.MapOf[bls12381.G1Affine, big.Int], signature bls12381.G1Affine, signer model.Signer, @@ -51,7 +57,6 @@ type Service interface { GetBlockNumber(ctx context.Context, network string) (*uint64, error) GetPriceAtBlockFromPair(network string, blockNumber uint64, pairAddr string, decimalDif int64, inverse bool) (*big.Int, error) SyncBlocks(ctx context.Context, token types.Token, key types.TokenKey, latest uint64) error - TokenKey(token types.Token) *types.TokenKey RecordSignature( ctx context.Context, signature bls12381.G1Affine, signer model.Signer, hash bls12381.G1Affine, info types.PriceInfo, debounce bool, historical bool, ) error @@ -61,7 +66,7 @@ type Service interface { type service struct { ethRPC ethereum.RPC pos pos.Service - signerRepo repository.Signer + proofRepo repository.Proof assetPriceRepo repository.AssetPrice consensus *lru.Cache[types.AssetKey, xsync.MapOf[bls12381.G1Affine, big.Int]] @@ -88,11 +93,6 @@ func (s *service) checkAndCacheSignature( cached, _ := s.signatureCache.Get(hash) - packed := correctness.Signature{ - Signature: signature, - Signer: signer, - } - for _, item := range cached { if item.Signer.PublicKey == signer.PublicKey { utils.Logger. @@ -103,19 +103,15 @@ func (s *service) checkAndCacheSignature( } reportedValues.Store(hash, *totalVoted) - cached = append(cached, packed) + cached = append(cached, correctness.Signature{ + Signature: signature, + Signer: signer, + }) s.signatureCache.Add(hash, cached) return nil } -type SaveSignatureArgs struct { - Info types.PriceInfo - Hash bls12381.G1Affine - Consensus bool - Voted *big.Int -} - func (s *service) saveSignatures(ctx context.Context, args SaveSignatureArgs) error { utils.Logger. With("Block", args.Info.Asset.Block). @@ -131,53 +127,25 @@ func (s *service) saveSignatures(ctx context.Context, args SaveSignatureArgs) er return consts.ErrSignatureNotfound } - var newSigners []model.Signer - var newSignatures []bls12381.G1Affine - var keys [][]byte - currentRecords, err := s.assetPriceRepo.Find( - ctx, - args.Info.Asset.Block, args.Info.Asset.Token.Chain, args.Info.Asset.Token.Name, args.Info.Asset.Token.Pair, + ctx, args.Info.Asset.Block, args.Info.Asset.Token.Chain, args.Info.Asset.Token.Name, args.Info.Asset.Token.Pair, ) - if err != nil { return err } + var newSigners []model.Signer + var newSignatures []bls12381.G1Affine + for i := range signatures { signature := signatures[i] - keys = append(keys, signature.Signer.PublicKey[:]) - - if !IsNewSigner(signature, currentRecords) { - continue - } newSignatures = append(newSignatures, signature.Signature) newSigners = append(newSigners, signature.Signer) } - err = s.signerRepo.CreateSigners(ctx, newSigners) - if err != nil { - utils.Logger. - With("Block", args.Info.Asset.Block). - With("Hash", fmt.Sprintf("%x", args.Hash.Bytes())[:8]). - Debug("Failed to upsert token signers.") - return err - } - - signerIDs, err := s.signerRepo.GetSingerIDsByKeys(ctx, keys) - if err != nil { - utils.Logger. - With("Block", args.Info.Asset.Block). - With("Hash", fmt.Sprintf("%x", args.Hash.Bytes())[:8]). - Debug("Filed to upsert signers") - return err - } - - var aggregate bls12381.G1Affine - for _, record := range currentRecords { - if record.Price.Cmp(&args.Info.Price) == 0 { + if record.Price == args.Info.Price.Int64() { currentAggregate, err := bls.RecoverSignature([48]byte(record.Signature)) if err != nil { utils.Logger. @@ -193,8 +161,7 @@ func (s *service) saveSignatures(ctx context.Context, args SaveSignatureArgs) er } } - aggregate, err = bls.AggregateSignatures(newSignatures) - + aggregate, err := bls.AggregateSignatures(newSignatures) if err != nil { utils.Logger. With("Block", args.Info.Asset.Block). @@ -205,20 +172,28 @@ func (s *service) saveSignatures(ctx context.Context, args SaveSignatureArgs) er signatureBytes := aggregate.Bytes() + err = s.proofRepo.CreateProof(ctx, signatureBytes, newSigners) + if err != nil { + utils.Logger. + With("Block", args.Info.Asset.Block). + With("Hash", fmt.Sprintf("%x", args.Hash.Bytes())[:8]). + Debug("Failed to upsert token signers.") + return err + } + // TODO: Handle cases where signerIDs need to be removed err = s.assetPriceRepo.Upsert(ctx, model.AssetPrice{ Pair: strings.ToLower(args.Info.Asset.Token.Pair), Name: args.Info.Asset.Token.Name, Chain: args.Info.Asset.Token.Chain, Block: args.Info.Asset.Block, - Price: args.Info.Price, + Price: args.Info.Price.Int64(), SignersCount: uint64(len(signatures)), Signature: signatureBytes[:], Consensus: args.Consensus, - Voted: *args.Voted, - SignerIDs: signerIDs, + Voted: args.Voted.Int64(), }) - + // @TODO: upsert proof if err != nil { utils.Logger. With("Block", args.Info.Asset.Block). @@ -232,7 +207,6 @@ func (s *service) saveSignatures(ctx context.Context, args SaveSignatureArgs) er func (s *service) GetBlockNumber(ctx context.Context, network string) (*uint64, error) { blockNumber, err := s.ethRPC.GetBlockNumber(ctx, network) - if err != nil { s.ethRPC.RefreshRPC(network) return nil, err @@ -245,17 +219,12 @@ func (s *service) GetPriceAtBlockFromPair( network string, blockNumber uint64, pairAddr string, decimalDif int64, inverse bool, ) (*big.Int, error) { pair, err := s.ethRPC.GetNewUniV3Contract(network, pairAddr, false) - if err != nil { s.ethRPC.RefreshRPC(network) return nil, err } - data, err := pair.Slot0( - &bind.CallOpts{ - BlockNumber: big.NewInt(int64(blockNumber)), - }) - + data, err := pair.Slot0(&bind.CallOpts{BlockNumber: big.NewInt(int64(blockNumber))}) if err != nil { s.ethRPC.RefreshRPC(network) return nil, err @@ -293,7 +262,6 @@ func (s *service) priceFromSqrtX96(sqrtPriceX96 *big.Int, decimalDif int64, inve func (s *service) syncBlock(ctx context.Context, token types.Token, caser cases.Caser, key *types.TokenKey, blockInx uint64) error { lastSynced, ok := s.LastBlock.Load(*key) - if ok && blockInx <= lastSynced { return consts.ErrDataTooOld } @@ -305,7 +273,6 @@ func (s *service) syncBlock(ctx context.Context, token types.Token, caser cases. token.Delta, token.Invert, ) - if err != nil { utils.Logger.Error( fmt.Sprintf("Failed to get token price from %s RPC.", token.Chain)) @@ -336,7 +303,6 @@ func (s *service) syncBlock(ctx context.Context, token types.Token, caser cases. priceStr := fmt.Sprintf("%.18f %s", &priceF, token.Unit) lastSynced, ok = s.LastBlock.Load(*key) - if ok && blockInx <= lastSynced { return consts.ErrDataTooOld } @@ -346,7 +312,7 @@ func (s *service) syncBlock(ctx context.Context, token types.Token, caser cases. With("Price", priceStr). Info(caser.String(token.Name)) - key = s.TokenKey(token) + key = types.NewTokenKey(token.GetCrossTokenKeys(s.crossTokens), token) priceInfo := types.PriceInfo{ Price: *price, @@ -407,42 +373,13 @@ func (s *service) SyncBlocks(ctx context.Context, token types.Token, key types.T return nil } -func (s *service) TokenKey(token types.Token) *types.TokenKey { - var cross []types.TokenKey - - for _, id := range token.Cross { - cross = append(cross, s.crossTokens[id]) - } - - toHash := new(sia.ArraySia[types.TokenKey]). - AddArray8(cross, func(s *sia.ArraySia[types.TokenKey], item types.TokenKey) { - s.EmbedBytes(item.Sia().Bytes()) - }).Bytes() - - hash := utils.Shake(toHash) - - key := types.TokenKey{ - Name: strings.ToLower(token.Name), - Pair: strings.ToLower(token.Pair), - Chain: strings.ToLower(token.Chain), - Delta: token.Delta, - Invert: token.Invert, - Cross: string(hash), - } - - return &key -} - func New( - ethRPC ethereum.RPC, - pos pos.Service, - signerRepo repository.Signer, - assetPriceRepo repository.AssetPrice, + ethRPC ethereum.RPC, pos pos.Service, proofRepo repository.Proof, assetPriceRepo repository.AssetPrice, ) Service { s := service{ ethRPC: ethRPC, pos: pos, - signerRepo: signerRepo, + proofRepo: proofRepo, assetPriceRepo: assetPriceRepo, consensus: nil, @@ -465,7 +402,7 @@ func New( for _, t := range config.App.Plugins.Uniswap.Tokens { token := types.NewTokenFromCfg(t) - key := s.TokenKey(token) + key := types.NewTokenKey(token.GetCrossTokenKeys(s.crossTokens), token) s.SupportedTokens[*key] = true } } diff --git a/internal/transport/database/database.go b/internal/transport/database/database.go index c6c79c7a..255bbdc8 100644 --- a/internal/transport/database/database.go +++ b/internal/transport/database/database.go @@ -10,6 +10,7 @@ import ( type Database interface { GetConnection() *gorm.DB + Migrate() HealthCheck(ctx context.Context) bool } diff --git a/internal/transport/database/postgres/postgres.go b/internal/transport/database/postgres/postgres.go index b641b326..db240f12 100644 --- a/internal/transport/database/postgres/postgres.go +++ b/internal/transport/database/postgres/postgres.go @@ -2,6 +2,7 @@ package postgres import ( "context" + "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/config" "github.com/TimeleapLabs/unchained/internal/transport/database" @@ -46,7 +47,7 @@ func (c *connection) GetConnection() *gorm.DB { var err error - utils.Logger.Info("Connecting to DB") + utils.Logger.Info("Connecting to PostgresSQL") c.db, err = gorm.Open( postgres.Open(config.App.Postgres.URL), @@ -67,7 +68,12 @@ func (c *connection) Migrate() { c.GetConnection() } - err := c.db.AutoMigrate() + err := c.db.AutoMigrate( + &model.Proof{}, + &model.CorrectnessDataFrame{}, + &model.EventLogDataFrame{}, + &model.AssetPriceDataFrame{}, + ) if err != nil { utils.Logger.With("Error", err).Error("Failed to migrate DB") From 5fd64e03e054caa9b833960595d7c79b245b6ad0 Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Thu, 27 Jun 2024 03:44:08 +0330 Subject: [PATCH 09/26] =?UTF-8?q?=F0=9F=90=9B=20fix(linters):=20fix=20lint?= =?UTF-8?q?er=20problems=20>>>=20=E2=8F=B0=2010m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/model/assetprice.go | 7 ++++--- internal/model/correctness.go | 11 ++++++----- internal/model/logs.go | 7 ++++--- internal/model/proof.go | 11 ++++++----- internal/model/signer.go | 2 +- internal/repository/mongo/assetprice_test.go | 5 ++--- internal/repository/mongo/correctness.go | 4 ++-- internal/repository/mongo/correctness_test.go | 7 +++---- internal/repository/mongo/eventlog_test.go | 2 +- internal/repository/postgres/correctness.go | 5 +---- internal/service/correctness/correctness.go | 2 +- internal/service/correctness/correctness_test.go | 2 +- internal/transport/client/handler/correctness.go | 4 +--- internal/transport/client/handler/event.go | 7 +------ internal/transport/database/mock/postgres_mock.go | 2 ++ internal/transport/database/postgres/postgres.go | 1 + .../transport/server/websocket/handler/correctness.go | 3 +-- internal/transport/server/websocket/handler/event.go | 7 +------ 18 files changed, 39 insertions(+), 50 deletions(-) diff --git a/internal/model/assetprice.go b/internal/model/assetprice.go index c50079dd..a9c8c9d6 100644 --- a/internal/model/assetprice.go +++ b/internal/model/assetprice.go @@ -1,21 +1,22 @@ package model import ( + "time" + "github.com/TimeleapLabs/unchained/internal/crypto/bls" "github.com/TimeleapLabs/unchained/internal/utils" bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" sia "github.com/pouya-eghbali/go-sia/v2/pkg" "go.mongodb.org/mongo-driver/bson/primitive" - "time" ) type AssetPriceDataFrame struct { - ID uint `gorm:"primarykey" bson:"-"` + ID uint `bson:"-" gorm:"primarykey"` DocID primitive.ObjectID `bson:"_id,omitempty" gorm:"-"` Hash []byte `bson:"hash" json:"hash"` Timestamp time.Time `bson:"timestamp" json:"timestamp"` - Data AssetPrice `bson:"data" gorm:"type:jsonb" json:"data"` + Data AssetPrice `bson:"data" gorm:"type:jsonb" json:"data"` } type AssetPrice struct { diff --git a/internal/model/correctness.go b/internal/model/correctness.go index d1593842..03cada6e 100644 --- a/internal/model/correctness.go +++ b/internal/model/correctness.go @@ -1,10 +1,11 @@ package model import ( + "time" + "github.com/TimeleapLabs/unchained/internal/crypto/bls" "github.com/TimeleapLabs/unchained/internal/utils" "go.mongodb.org/mongo-driver/bson/primitive" - "time" bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" @@ -12,12 +13,12 @@ import ( ) type CorrectnessDataFrame struct { - ID uint `gorm:"primarykey" bson:"-"` + ID uint `bson:"-" gorm:"primarykey"` DocID primitive.ObjectID `bson:"_id,omitempty" gorm:"-"` Hash []byte `bson:"hash" json:"hash"` Timestamp time.Time `bson:"timestamp" json:"timestamp"` - Data Correctness `bson:"data" gorm:"type:jsonb" json:"data"` + Data Correctness `bson:"data" gorm:"type:jsonb" json:"data"` } type Correctness struct { @@ -35,7 +36,7 @@ func (c *Correctness) Sia() sia.Sia { return sia.New(). AddUInt64(c.Timestamp). AddByteArray8(c.Hash). - AddByteArray8(c.Topic[:]). + AddByteArray8(c.Topic). AddBool(c.Correct) } @@ -47,7 +48,7 @@ func (c *Correctness) FromBytes(payload []byte) *Correctness { func (c *Correctness) FromSia(sia sia.Sia) *Correctness { c.Timestamp = sia.ReadUInt64() copy(c.Hash, sia.ReadByteArray8()) - copy(c.Topic[:], sia.ReadByteArray8()) + copy(c.Topic, sia.ReadByteArray8()) c.Correct = sia.ReadBool() return c diff --git a/internal/model/logs.go b/internal/model/logs.go index 8a11c9f5..c1881588 100644 --- a/internal/model/logs.go +++ b/internal/model/logs.go @@ -2,10 +2,11 @@ package model import ( "encoding/json" + "time" + "github.com/TimeleapLabs/unchained/internal/crypto/bls" "github.com/TimeleapLabs/unchained/internal/utils" "go.mongodb.org/mongo-driver/bson/primitive" - "time" bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" @@ -19,12 +20,12 @@ type EventLogArg struct { } type EventLogDataFrame struct { - ID uint `gorm:"primarykey" bson:"-"` + ID uint `bson:"-" gorm:"primarykey"` DocID primitive.ObjectID `bson:"_id,omitempty" gorm:"-"` Hash []byte `bson:"hash" json:"hash"` Timestamp time.Time `bson:"timestamp" json:"timestamp"` - Data EventLog `bson:"data" gorm:"type:jsonb" json:"data"` + Data EventLog `bson:"data" gorm:"type:jsonb" json:"data"` } type EventLog struct { diff --git a/internal/model/proof.go b/internal/model/proof.go index deed85f4..a267742b 100644 --- a/internal/model/proof.go +++ b/internal/model/proof.go @@ -1,21 +1,22 @@ package model import ( - "go.mongodb.org/mongo-driver/bson/primitive" "time" + "go.mongodb.org/mongo-driver/bson/primitive" + sia "github.com/pouya-eghbali/go-sia/v2/pkg" ) type Proof struct { - ID uint `gorm:"primarykey" bson:"-"` + ID uint `bson:"-" gorm:"primarykey"` DocID primitive.ObjectID `bson:"_id,omitempty" gorm:"-"` Hash []byte `bson:"hash" json:"hash"` Timestamp time.Time `bson:"timestamp" json:"timestamp"` Signature []byte `bson:"signature" json:"signature"` - Signers []Signer `bson:"signers" json:"signers" gorm:"many2many:proof_signers;"` + Signers []Signer `bson:"signers" gorm:"many2many:proof_signers;" json:"signers"` } func (p *Proof) Sia() sia.Sia { @@ -26,7 +27,7 @@ func (p *Proof) Sia() sia.Sia { return sia.New(). AddByteArray8(p.Hash). AddInt64(p.Timestamp.Unix()). - AddByteArray8(p.Signature[:]). + AddByteArray8(p.Signature). AddByteArray64(signers.Bytes()) } @@ -44,7 +45,7 @@ func (p *Proof) FromSia(siaObj sia.Sia) *Proof { p.Hash = siaObj.ReadByteArray8() p.Timestamp = time.Unix(siaObj.ReadInt64(), 0) - copy(p.Signature[:], siaObj.ReadByteArray8()) + copy(p.Signature, siaObj.ReadByteArray8()) p.Signers = signers return p } diff --git a/internal/model/signer.go b/internal/model/signer.go index d2049482..7e087236 100644 --- a/internal/model/signer.go +++ b/internal/model/signer.go @@ -13,7 +13,7 @@ import ( type Signers []Signer type Signer struct { - ID uint `gorm:"primarykey" bson:"-"` + ID uint `bson:"-" gorm:"primarykey"` DocID primitive.ObjectID `bson:"_id,omitempty" gorm:"-"` Name string diff --git a/internal/repository/mongo/assetprice_test.go b/internal/repository/mongo/assetprice_test.go index 1ac92930..cbd26806 100644 --- a/internal/repository/mongo/assetprice_test.go +++ b/internal/repository/mongo/assetprice_test.go @@ -3,7 +3,6 @@ package mongo import ( "context" "log" - "math/big" "runtime" "testing" @@ -21,11 +20,11 @@ var SampleAssetPrice = model.AssetPrice{ Name: "USDT", Chain: "ETH", Block: 999, - Price: *big.NewInt(1000), + Price: 1000, SignersCount: 10, Signature: nil, Consensus: false, - Voted: *big.NewInt(1000), + Voted: 1000, } type AssetPriceRepositoryTestSuite struct { diff --git a/internal/repository/mongo/correctness.go b/internal/repository/mongo/correctness.go index a9e99462..3c157e68 100644 --- a/internal/repository/mongo/correctness.go +++ b/internal/repository/mongo/correctness.go @@ -53,7 +53,7 @@ func (c CorrectnessRepo) Upsert(ctx context.Context, data model.Correctness) err Collection("correctnessreport"). UpdateOne(ctx, bson.M{ "hash": data.Hash, - "topic": data.Topic[:], + "topic": data.Topic, }, bson.M{ "$set": bson.M{ "data.correct": data.Correct, @@ -72,7 +72,7 @@ func (c CorrectnessRepo) Upsert(ctx context.Context, data model.Correctness) err "signature": data.Signature, "hash": data.Hash, "timestamp": data.Timestamp, - "topic": data.Topic[:], + "topic": data.Topic, "consensus": data.Consensus, "voted": data.Voted, }, diff --git a/internal/repository/mongo/correctness_test.go b/internal/repository/mongo/correctness_test.go index f6c6e77d..07234463 100644 --- a/internal/repository/mongo/correctness_test.go +++ b/internal/repository/mongo/correctness_test.go @@ -3,7 +3,6 @@ package mongo import ( "context" "log" - "math/big" "runtime" "testing" @@ -20,10 +19,10 @@ var sampleCorrectness = model.Correctness{ SignersCount: 100, Signature: nil, Consensus: false, - Voted: *big.NewInt(1000), + Voted: 1000, Timestamp: 999, Hash: nil, - Topic: [64]byte{}, + Topic: []byte{}, Correct: false, } @@ -66,7 +65,7 @@ func (s *CorrectnessRepositoryTestSuite) TestFind() { err := s.repo.Upsert(context.TODO(), sampleCorrectness) s.NoError(err) - result, err := s.repo.Find(context.TODO(), sampleCorrectness.Hash, sampleCorrectness.Topic[:], sampleCorrectness.Timestamp) + result, err := s.repo.Find(context.TODO(), sampleCorrectness.Hash, sampleCorrectness.Topic, sampleCorrectness.Timestamp) s.NoError(err) s.Len(result, 1) } diff --git a/internal/repository/mongo/eventlog_test.go b/internal/repository/mongo/eventlog_test.go index 2c031b8c..f27d0e8f 100644 --- a/internal/repository/mongo/eventlog_test.go +++ b/internal/repository/mongo/eventlog_test.go @@ -27,7 +27,7 @@ var sampleEventLog = model.EventLog{ Consensus: false, SignersCount: 100, Signature: nil, - Voted: nil, + Voted: 0, } type EventLogRepositoryTestSuite struct { diff --git a/internal/repository/postgres/correctness.go b/internal/repository/postgres/correctness.go index 4eb5ef62..ff5dd218 100644 --- a/internal/repository/postgres/correctness.go +++ b/internal/repository/postgres/correctness.go @@ -40,9 +40,6 @@ func (c CorrectnessRepo) Find(ctx context.Context, hash []byte, topic []byte, ti } func (c CorrectnessRepo) Upsert(ctx context.Context, data model.Correctness) error { - dataBls := data.Bls() - dataBlsHash := (&dataBls).Marshal() - err := c.client. GetConnection(). WithContext(ctx). @@ -51,7 +48,7 @@ func (c CorrectnessRepo) Upsert(ctx context.Context, data model.Correctness) err UpdateAll: true, }). Create(&model.CorrectnessDataFrame{ - Hash: dataBlsHash, + Hash: data.Bls().Marshal(), Timestamp: time.Now(), Data: data, }) diff --git a/internal/service/correctness/correctness.go b/internal/service/correctness/correctness.go index fc337f99..bb32ffc1 100644 --- a/internal/service/correctness/correctness.go +++ b/internal/service/correctness/correctness.go @@ -149,7 +149,7 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er return consts.ErrSignatureNotfound } - currentRecords, err := s.correctnessRepo.Find(ctx, args.Info.Hash, args.Info.Topic[:], args.Info.Timestamp) + currentRecords, err := s.correctnessRepo.Find(ctx, args.Info.Hash, args.Info.Topic, args.Info.Timestamp) if err != nil { return err } diff --git a/internal/service/correctness/correctness_test.go b/internal/service/correctness/correctness_test.go index 84a9e969..0b0dceea 100644 --- a/internal/service/correctness/correctness_test.go +++ b/internal/service/correctness/correctness_test.go @@ -33,7 +33,7 @@ func (s *CorrectnessTestSuite) SetupTest() { posService := new(pos.MockService) - signerRepo := postgresRepo.NewSigner(db) + signerRepo := postgresRepo.NewProof(db) correctnessRepo := postgresRepo.NewCorrectness(db) s.service = New(posService, signerRepo, correctnessRepo) diff --git a/internal/transport/client/handler/correctness.go b/internal/transport/client/handler/correctness.go index fdd3c0b0..a190b801 100644 --- a/internal/transport/client/handler/correctness.go +++ b/internal/transport/client/handler/correctness.go @@ -12,8 +12,6 @@ import ( func (h *consumer) CorrectnessReport(ctx context.Context, message []byte) { packet := new(packet.BroadcastCorrectnessPacket).FromBytes(message) - correctnessHash := packet.Info.Bls() - signature, err := bls.RecoverSignature(packet.Signature) if err != nil { utils.Logger. @@ -27,7 +25,7 @@ func (h *consumer) CorrectnessReport(ctx context.Context, message []byte) { ctx, signature, packet.Signer, - correctnessHash, + *packet.Info.Bls(), packet.Info, true, ) diff --git a/internal/transport/client/handler/event.go b/internal/transport/client/handler/event.go index c8c48417..45db0c7a 100644 --- a/internal/transport/client/handler/event.go +++ b/internal/transport/client/handler/event.go @@ -12,11 +12,6 @@ import ( func (h *consumer) EventLog(ctx context.Context, message []byte) { packet := new(packet.BroadcastEventPacket).FromBytes(message) - eventLogHash, err := packet.Info.Bls() - if err != nil { - return - } - signature, err := bls.RecoverSignature(packet.Signature) if err != nil { utils.Logger. @@ -30,7 +25,7 @@ func (h *consumer) EventLog(ctx context.Context, message []byte) { ctx, signature, packet.Signer, - eventLogHash, + *packet.Info.Bls(), packet.Info, true, false, diff --git a/internal/transport/database/mock/postgres_mock.go b/internal/transport/database/mock/postgres_mock.go index 5827cd5b..9eb87329 100644 --- a/internal/transport/database/mock/postgres_mock.go +++ b/internal/transport/database/mock/postgres_mock.go @@ -18,6 +18,8 @@ type mockConnection struct { db *gorm.DB } +func (m *mockConnection) Migrate() {} + func (m *mockConnection) GetConnection() *gorm.DB { if m.db != nil { return m.db diff --git a/internal/transport/database/postgres/postgres.go b/internal/transport/database/postgres/postgres.go index db240f12..150ef131 100644 --- a/internal/transport/database/postgres/postgres.go +++ b/internal/transport/database/postgres/postgres.go @@ -2,6 +2,7 @@ package postgres import ( "context" + "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/config" diff --git a/internal/transport/server/websocket/handler/correctness.go b/internal/transport/server/websocket/handler/correctness.go index 5c588aec..a60708e8 100644 --- a/internal/transport/server/websocket/handler/correctness.go +++ b/internal/transport/server/websocket/handler/correctness.go @@ -13,9 +13,8 @@ func CorrectnessRecord(conn *websocket.Conn, payload []byte) ([]byte, error) { } correctness := new(packet.CorrectnessReportPacket).FromBytes(payload) - correctnessHash := correctness.Correctness.Bls() - signer, err := middleware.IsMessageValid(conn, correctnessHash, correctness.Signature) + signer, err := middleware.IsMessageValid(conn, *correctness.Correctness.Bls(), correctness.Signature) if err != nil { return []byte{}, err } diff --git a/internal/transport/server/websocket/handler/event.go b/internal/transport/server/websocket/handler/event.go index 69c0d619..ebe823a8 100644 --- a/internal/transport/server/websocket/handler/event.go +++ b/internal/transport/server/websocket/handler/event.go @@ -1,7 +1,6 @@ package handler import ( - "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/transport/server/packet" "github.com/TimeleapLabs/unchained/internal/transport/server/websocket/middleware" "github.com/gorilla/websocket" @@ -14,12 +13,8 @@ func EventLog(conn *websocket.Conn, payload []byte) ([]byte, error) { } priceReport := new(packet.EventLogReportPacket).FromBytes(payload) - priceInfoHash, err := priceReport.EventLog.Bls() - if err != nil { - return []byte{}, consts.ErrInternalError - } - signer, err := middleware.IsMessageValid(conn, priceInfoHash, priceReport.Signature) + signer, err := middleware.IsMessageValid(conn, *priceReport.EventLog.Bls(), priceReport.Signature) if err != nil { return []byte{}, err } From 2cff013ee9c1fe72f89bfbd19ba8e3ca2b249096 Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Sun, 30 Jun 2024 03:05:49 +0330 Subject: [PATCH 10/26] =?UTF-8?q?=E2=9C=A8=20feat(postgres):=20fix=20probl?= =?UTF-8?q?em=20of=20modeling=20postgres=20tables=20>>>=20=E2=8F=B0=206h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 3 + go.sum | 4 + internal/crypto/identity.go | 9 +- internal/model/assetprice.go | 22 ++--- internal/model/correctness.go | 8 +- internal/model/logs.go | 8 +- internal/model/proof.go | 31 +++++-- internal/model/signer.go | 46 +++++----- internal/repository/postgres/assetprice.go | 11 +-- .../repository/postgres/assetprice_test.go | 86 +++++++++++++++++++ internal/repository/postgres/correctness.go | 14 +-- internal/repository/postgres/eventlog.go | 8 +- internal/repository/postgres/proof.go | 6 +- internal/service/correctness/correctness.go | 9 +- .../service/correctness/correctness_test.go | 10 ++- internal/service/evmlog/record.go | 9 +- internal/service/uniswap/record.go | 8 +- internal/service/uniswap/uniswap.go | 9 +- .../transport/database/mock/postgres_mock.go | 64 -------------- .../server/websocket/middleware/signature.go | 10 ++- 20 files changed, 231 insertions(+), 144 deletions(-) create mode 100644 internal/repository/postgres/assetprice_test.go delete mode 100644 internal/transport/database/mock/postgres_mock.go diff --git a/go.mod b/go.mod index 79f8f32e..7ef56a9b 100644 --- a/go.mod +++ b/go.mod @@ -56,6 +56,7 @@ require ( github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/ethereum/c-kzg-4844 v1.0.0 // indirect + github.com/fergusstrange/embedded-postgres v1.27.0 // indirect github.com/fjl/memsize v0.0.2 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect @@ -88,6 +89,7 @@ require ( github.com/klauspost/compress v1.17.7 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect + github.com/lib/pq v1.10.9 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect @@ -122,6 +124,7 @@ require ( github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.1.2 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect + github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect diff --git a/go.sum b/go.sum index b330528b..49d6d8b3 100644 --- a/go.sum +++ b/go.sum @@ -159,6 +159,8 @@ github.com/ethereum/go-ethereum v1.13.14 h1:EwiY3FZP94derMCIam1iW4HFVrSgIcpsu0Hw github.com/ethereum/go-ethereum v1.13.14/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU= github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/fergusstrange/embedded-postgres v1.27.0 h1:RAlpWL194IhEpPgeJceTM0ifMJKhiSVxBVIDYB1Jee8= +github.com/fergusstrange/embedded-postgres v1.27.0/go.mod h1:t/MLs0h9ukYM6FSt99R7InCHs1nW0ordoVCcnzmpTYw= github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA= github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4/go.mod h1:T9YF2M40nIgbVgp3rreNmTged+9HrbNTIQf1PsaIiTA= @@ -568,6 +570,8 @@ github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gi github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= +github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= +github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= diff --git a/internal/crypto/identity.go b/internal/crypto/identity.go index 10b02809..b9098aa7 100644 --- a/internal/crypto/identity.go +++ b/internal/crypto/identity.go @@ -1,6 +1,8 @@ package crypto import ( + "encoding/hex" + "github.com/TimeleapLabs/unchained/internal/config" "github.com/TimeleapLabs/unchained/internal/crypto/bls" "github.com/TimeleapLabs/unchained/internal/crypto/ethereum" @@ -39,11 +41,14 @@ func InitMachineIdentity(options ...Option) { // ExportEvmSigner returns EVM signer from machine identity. func (i *MachineIdentity) ExportEvmSigner() *model.Signer { + publicKey := Identity.Bls.PublicKey.Bytes() + shortPublicKey := Identity.Bls.ShortPublicKey.Bytes() + return &model.Signer{ Name: config.App.System.Name, EvmAddress: Identity.Eth.Address, - PublicKey: Identity.Bls.PublicKey.Bytes(), - ShortPublicKey: Identity.Bls.ShortPublicKey.Bytes(), + PublicKey: hex.EncodeToString(publicKey[:]), + ShortPublicKey: hex.EncodeToString(shortPublicKey[:]), } } diff --git a/internal/model/assetprice.go b/internal/model/assetprice.go index a9c8c9d6..06fa2939 100644 --- a/internal/model/assetprice.go +++ b/internal/model/assetprice.go @@ -14,21 +14,21 @@ type AssetPriceDataFrame struct { ID uint `bson:"-" gorm:"primarykey"` DocID primitive.ObjectID `bson:"_id,omitempty" gorm:"-"` - Hash []byte `bson:"hash" json:"hash"` + Hash string `bson:"hash" json:"hash"` Timestamp time.Time `bson:"timestamp" json:"timestamp"` - Data AssetPrice `bson:"data" gorm:"type:jsonb" json:"data"` + Data AssetPrice `bson:"data" gorm:"embedded" json:"data"` } type AssetPrice struct { - Pair string - Name string - Chain string - Block uint64 - Price int64 - SignersCount uint64 - Signature []byte - Consensus bool - Voted int64 + Pair string `json:"pair" gorm:"uniqueIndex:idx_pair_name_chain_block"` + Name string `json:"name" gorm:"uniqueIndex:idx_pair_name_chain_block"` + Chain string `json:"chain" gorm:"uniqueIndex:idx_pair_name_chain_block"` + Block uint64 `json:"block" gorm:"uniqueIndex:idx_pair_name_chain_block"` + Price int64 `json:"price"` + SignersCount uint64 `json:"signers_count"` + Signature []byte `json:"signature"` + Consensus bool `json:"consensus"` + Voted int64 `json:"voted"` } func (c *AssetPrice) Sia() sia.Sia { diff --git a/internal/model/correctness.go b/internal/model/correctness.go index 03cada6e..f4155c86 100644 --- a/internal/model/correctness.go +++ b/internal/model/correctness.go @@ -16,9 +16,9 @@ type CorrectnessDataFrame struct { ID uint `bson:"-" gorm:"primarykey"` DocID primitive.ObjectID `bson:"_id,omitempty" gorm:"-"` - Hash []byte `bson:"hash" json:"hash"` + Hash string `bson:"hash" json:"hash"` Timestamp time.Time `bson:"timestamp" json:"timestamp"` - Data Correctness `bson:"data" gorm:"type:jsonb" json:"data"` + Data Correctness `bson:"data" gorm:"embedded" json:"data"` } type Correctness struct { @@ -27,8 +27,8 @@ type Correctness struct { Consensus bool Voted int64 Timestamp uint64 - Hash []byte - Topic []byte + Hash []byte `gorm:"uniqueIndex:idx_topic_hash"` + Topic []byte `gorm:"uniqueIndex:idx_topic_hash"` Correct bool } diff --git a/internal/model/logs.go b/internal/model/logs.go index c1881588..6da41072 100644 --- a/internal/model/logs.go +++ b/internal/model/logs.go @@ -23,18 +23,18 @@ type EventLogDataFrame struct { ID uint `bson:"-" gorm:"primarykey"` DocID primitive.ObjectID `bson:"_id,omitempty" gorm:"-"` - Hash []byte `bson:"hash" json:"hash"` + Hash string `bson:"hash" json:"hash"` Timestamp time.Time `bson:"timestamp" json:"timestamp"` - Data EventLog `bson:"data" gorm:"type:jsonb" json:"data"` + Data EventLog `bson:"data" gorm:"embedded" json:"data"` } type EventLog struct { LogIndex uint64 - Block uint64 + Block uint64 `gorm:"uniqueIndex:idx_block_tx_index"` Address string Event string Chain string - TxHash [32]byte + TxHash [32]byte `gorm:"uniqueIndex:idx_block_tx_index"` Args []EventLogArg `gorm:"type:jsonb"` Consensus bool diff --git a/internal/model/proof.go b/internal/model/proof.go index a267742b..73de1cd1 100644 --- a/internal/model/proof.go +++ b/internal/model/proof.go @@ -1,8 +1,11 @@ package model import ( + "encoding/hex" "time" + "github.com/TimeleapLabs/unchained/internal/utils" + "go.mongodb.org/mongo-driver/bson/primitive" sia "github.com/pouya-eghbali/go-sia/v2/pkg" @@ -12,9 +15,9 @@ type Proof struct { ID uint `bson:"-" gorm:"primarykey"` DocID primitive.ObjectID `bson:"_id,omitempty" gorm:"-"` - Hash []byte `bson:"hash" json:"hash"` + Hash string `bson:"hash" json:"hash"` Timestamp time.Time `bson:"timestamp" json:"timestamp"` - Signature []byte `bson:"signature" json:"signature"` + Signature string `bson:"signature" json:"signature"` Signers []Signer `bson:"signers" gorm:"many2many:proof_signers;" json:"signers"` } @@ -24,10 +27,22 @@ func (p *Proof) Sia() sia.Sia { s.EmbedBytes(item.Sia().Bytes()) }) + hashBytes, err := hex.DecodeString(p.Hash) + if err != nil { + utils.Logger.Error("Can't decode hash: %v", err) + return sia.New() + } + + signatureBytes, err := hex.DecodeString(p.Signature) + if err != nil { + utils.Logger.Error("Can't decode signature: %v", err) + return sia.New() + } + return sia.New(). - AddByteArray8(p.Hash). + AddByteArray8(hashBytes). AddInt64(p.Timestamp.Unix()). - AddByteArray8(p.Signature). + AddByteArray8(signatureBytes). AddByteArray64(signers.Bytes()) } @@ -43,18 +58,18 @@ func (p *Proof) FromSia(siaObj sia.Sia) *Proof { return signer }) - p.Hash = siaObj.ReadByteArray8() + p.Hash = hex.EncodeToString(siaObj.ReadByteArray8()) p.Timestamp = time.Unix(siaObj.ReadInt64(), 0) - copy(p.Signature, siaObj.ReadByteArray8()) + p.Signature = hex.EncodeToString(siaObj.ReadByteArray8()) p.Signers = signers return p } func NewProof(signers []Signer, signature []byte) *Proof { return &Proof{ - Hash: Signers(signers).Bls(), + Hash: hex.EncodeToString(Signers(signers).Bls()), Timestamp: time.Now(), - Signature: signature, + Signature: hex.EncodeToString(signature), Signers: signers, } } diff --git a/internal/model/signer.go b/internal/model/signer.go index 7e087236..71b3b7e3 100644 --- a/internal/model/signer.go +++ b/internal/model/signer.go @@ -1,13 +1,13 @@ package model import ( + "encoding/hex" + "github.com/TimeleapLabs/unchained/internal/crypto/bls" "github.com/TimeleapLabs/unchained/internal/utils" bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" sia "github.com/pouya-eghbali/go-sia/v2/pkg" "go.mongodb.org/mongo-driver/bson/primitive" - "gorm.io/gorm" - "gorm.io/gorm/clause" ) type Signers []Signer @@ -16,32 +16,30 @@ type Signer struct { ID uint `bson:"-" gorm:"primarykey"` DocID primitive.ObjectID `bson:"_id,omitempty" gorm:"-"` - Name string - EvmAddress string - PublicKey [96]byte - ShortPublicKey [48]byte -} - -func (s *Signer) BeforeCreate(tx *gorm.DB) error { - tx.Statement.AddClause(clause.OnConflict{ - Columns: []clause.Column{{Name: "shortkey"}}, - DoUpdates: clause.Assignments(map[string]interface{}{ - "name": "name", - "evm": "evm", - "key": "key", - "point": gorm.Expr("signer.point + 1"), - }), - }) - - return nil + Name string `json:"name"` + EvmAddress string `json:"evm_address"` + PublicKey string `json:"public_key"` + ShortPublicKey string `json:"short_public_key"` } func (s *Signer) Sia() sia.Sia { + publicKeyBytes, err := hex.DecodeString(s.PublicKey) + if err != nil { + utils.Logger.Error("Can't decode public key: %v", err) + return sia.New() + } + + shortPublicKey, err := hex.DecodeString(s.ShortPublicKey) + if err != nil { + utils.Logger.Error("Can't decode short public key: %v", err) + return sia.New() + } + return sia.New(). AddString8(s.Name). AddString8(s.EvmAddress). - AddByteArray8(s.PublicKey[:]). - AddByteArray8(s.ShortPublicKey[:]) + AddByteArray8(publicKeyBytes). + AddByteArray8(shortPublicKey) } func (s *Signer) FromBytes(payload []byte) *Signer { @@ -52,8 +50,8 @@ func (s *Signer) FromBytes(payload []byte) *Signer { func (s *Signer) FromSia(sia sia.Sia) *Signer { s.Name = sia.ReadString8() s.EvmAddress = sia.ReadString8() - copy(s.PublicKey[:], sia.ReadByteArray8()) - copy(s.ShortPublicKey[:], sia.ReadByteArray8()) + s.PublicKey = hex.EncodeToString(sia.ReadByteArray8()) + s.ShortPublicKey = hex.EncodeToString(sia.ReadByteArray8()) return s } diff --git a/internal/repository/postgres/assetprice.go b/internal/repository/postgres/assetprice.go index e69151e1..e5ed2dc8 100644 --- a/internal/repository/postgres/assetprice.go +++ b/internal/repository/postgres/assetprice.go @@ -2,6 +2,7 @@ package postgres import ( "context" + "encoding/hex" "time" "gorm.io/gorm/clause" @@ -20,21 +21,21 @@ type AssetPriceRepo struct { func (a AssetPriceRepo) Upsert(ctx context.Context, data model.AssetPrice) error { dataHash := data.Bls().Bytes() - err := a.client. + tx := a.client. GetConnection(). WithContext(ctx). Clauses(clause.OnConflict{ - Columns: []clause.Column{{Name: "data.block"}, {Name: "data.chain"}, {Name: "data.asset"}, {Name: "data.pair"}}, + Columns: []clause.Column{{Name: "block"}, {Name: "chain"}, {Name: "name"}, {Name: "pair"}}, UpdateAll: true, }). Create(&model.AssetPriceDataFrame{ - Hash: dataHash[:], + Hash: hex.EncodeToString(dataHash[:]), Timestamp: time.Now(), Data: data, }) - if err != nil { - utils.Logger.With("err", err).Error("Cant upsert asset price record in database") + if tx.Error != nil { + utils.Logger.With("err", tx.Error).Error("Cant upsert asset price record in database") return consts.ErrInternalError } diff --git a/internal/repository/postgres/assetprice_test.go b/internal/repository/postgres/assetprice_test.go new file mode 100644 index 00000000..911a5948 --- /dev/null +++ b/internal/repository/postgres/assetprice_test.go @@ -0,0 +1,86 @@ +package postgres + +import ( + "context" + "fmt" + "os" + "testing" + + "github.com/TimeleapLabs/unchained/internal/config" + "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/repository" + "github.com/TimeleapLabs/unchained/internal/transport/database" + "github.com/TimeleapLabs/unchained/internal/transport/database/postgres" + "github.com/TimeleapLabs/unchained/internal/utils" + embeddedpostgres "github.com/fergusstrange/embedded-postgres" + "github.com/google/uuid" + "github.com/stretchr/testify/suite" +) + +var SampleAssetPrice = model.AssetPrice{ + Pair: "USDT/ETH", + Name: "USDT", + Chain: "ETH", + Block: 999, + Price: 1000, + SignersCount: 10, + Signature: nil, + Consensus: false, + Voted: 1000, +} + +type AssetPriceRepositoryTestSuite struct { + suite.Suite + + db *embeddedpostgres.EmbeddedPostgres + ins database.Database + cacheDir string + repo repository.AssetPrice +} + +func (s *AssetPriceRepositoryTestSuite) SetupTest() { + utils.SetupLogger(config.App.System.Log) + + cachePath := fmt.Sprintf("embedded-postgres-go-%s", uuid.NewString()) + cacheDir, err := os.MkdirTemp("", cachePath) + s.Require().NoError(err) + s.cacheDir = cacheDir + + s.db = embeddedpostgres.NewDatabase( + embeddedpostgres. + DefaultConfig(). + CachePath(s.cacheDir), + ) + err = s.db.Start() + s.Require().NoError(err) + + config.App.Postgres.URL = "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" + s.ins = postgres.New() + s.ins.Migrate() + s.repo = NewAssetPrice(s.ins) +} + +func (s *AssetPriceRepositoryTestSuite) TestUpsert() { + err := s.repo.Upsert(context.TODO(), SampleAssetPrice) + s.Require().NoError(err) +} + +func (s *AssetPriceRepositoryTestSuite) TestFind() { + err := s.repo.Upsert(context.TODO(), SampleAssetPrice) + s.Require().NoError(err) + + assetPrices, err := s.repo.Find(context.TODO(), SampleAssetPrice.Block, SampleAssetPrice.Chain, SampleAssetPrice.Name, SampleAssetPrice.Pair) + s.Require().NoError(err) + s.Len(assetPrices, 1) +} + +func (s *AssetPriceRepositoryTestSuite) TearDownSuite() { + s.T().Log("Stopping the pg server") + err := s.db.Stop() + s.Require().NoError(err) + os.RemoveAll(s.cacheDir) +} + +func TestAssetPriceRepositoryTestSuite(t *testing.T) { + suite.Run(t, &AssetPriceRepositoryTestSuite{}) +} diff --git a/internal/repository/postgres/correctness.go b/internal/repository/postgres/correctness.go index ff5dd218..04d5423d 100644 --- a/internal/repository/postgres/correctness.go +++ b/internal/repository/postgres/correctness.go @@ -2,14 +2,16 @@ package postgres import ( "context" + "encoding/hex" "time" + "gorm.io/gorm/clause" + "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" "github.com/TimeleapLabs/unchained/internal/transport/database" "github.com/TimeleapLabs/unchained/internal/utils" - "gorm.io/gorm/clause" ) type CorrectnessRepo struct { @@ -40,21 +42,21 @@ func (c CorrectnessRepo) Find(ctx context.Context, hash []byte, topic []byte, ti } func (c CorrectnessRepo) Upsert(ctx context.Context, data model.Correctness) error { - err := c.client. + tx := c.client. GetConnection(). WithContext(ctx). Clauses(clause.OnConflict{ - Columns: []clause.Column{{Name: "data.topic"}, {Name: "data.hash"}}, + Columns: []clause.Column{{Name: "topic"}, {Name: "hash"}}, UpdateAll: true, }). Create(&model.CorrectnessDataFrame{ - Hash: data.Bls().Marshal(), + Hash: hex.EncodeToString(data.Bls().Marshal()), Timestamp: time.Now(), Data: data, }) - if err != nil { - utils.Logger.With("err", err).Error("Cant upsert correctness report in database") + if tx.Error != nil { + utils.Logger.With("err", tx.Error).Error("Cant upsert correctness report in database") return consts.ErrInternalError } diff --git a/internal/repository/postgres/eventlog.go b/internal/repository/postgres/eventlog.go index 89113757..496cec70 100644 --- a/internal/repository/postgres/eventlog.go +++ b/internal/repository/postgres/eventlog.go @@ -42,7 +42,7 @@ func (r EventLogRepo) Find(ctx context.Context, block uint64, hash []byte, index } func (r EventLogRepo) Upsert(ctx context.Context, data model.EventLog) error { - err := r.client. + tx := r.client. GetConnection(). WithContext(ctx). Clauses(clause.OnConflict{ @@ -50,13 +50,13 @@ func (r EventLogRepo) Upsert(ctx context.Context, data model.EventLog) error { UpdateAll: true, }). Create(&model.EventLogDataFrame{ - Hash: nil, + Hash: "", Timestamp: time.Now(), Data: data, }) - if err != nil { - utils.Logger.With("err", err).Error("Cant upsert event log record to database") + if tx.Error != nil { + utils.Logger.With("err", tx.Error).Error("Cant upsert event log record to database") return consts.ErrInternalError } diff --git a/internal/repository/postgres/proof.go b/internal/repository/postgres/proof.go index b8231c59..e574beab 100644 --- a/internal/repository/postgres/proof.go +++ b/internal/repository/postgres/proof.go @@ -17,13 +17,13 @@ type proofRepo struct { func (s proofRepo) CreateProof(ctx context.Context, signature [48]byte, signers []model.Signer) error { proof := model.NewProof(signers, signature[:]) - err := s.client. + tx := s.client. GetConnection(). WithContext(ctx). Create(&proof) - if err != nil { - utils.Logger.With("err", err).Error("Cant create signers in database") + if tx.Error != nil { + utils.Logger.With("err", tx.Error).Error("Cant create signers in database") return consts.ErrInternalError } diff --git a/internal/service/correctness/correctness.go b/internal/service/correctness/correctness.go index bb32ffc1..b9c06641 100644 --- a/internal/service/correctness/correctness.go +++ b/internal/service/correctness/correctness.go @@ -2,6 +2,7 @@ package correctness import ( "context" + "encoding/hex" "fmt" "math/big" "os" @@ -99,8 +100,14 @@ func (s *service) RecordSignature( votingPower, err := s.pos.GetVotingPowerOfEvm(ctx, signer.EvmAddress) if err != nil { + publicKeyBytes, err := hex.DecodeString(signer.PublicKey) + if err != nil { + utils.Logger.Error("Can't decode public key: %v", err) + return err + } + utils.Logger. - With("Address", address.Calculate(signer.PublicKey[:])). + With("Address", address.Calculate(publicKeyBytes)). With("Error", err). Error("Failed to get voting power") return err diff --git a/internal/service/correctness/correctness_test.go b/internal/service/correctness/correctness_test.go index 0b0dceea..265eb8b8 100644 --- a/internal/service/correctness/correctness_test.go +++ b/internal/service/correctness/correctness_test.go @@ -1,24 +1,26 @@ package correctness import ( + "encoding/hex" "testing" + "github.com/TimeleapLabs/unchained/internal/transport/database/postgres" + "github.com/TimeleapLabs/unchained/internal/model" postgresRepo "github.com/TimeleapLabs/unchained/internal/repository/postgres" "github.com/TimeleapLabs/unchained/internal/service/pos" - "github.com/TimeleapLabs/unchained/internal/transport/database/mock" "github.com/stretchr/testify/suite" ) var ( SignerOne = Signature{ Signer: model.Signer{ - PublicKey: [96]byte{1, 2, 3}, + PublicKey: hex.EncodeToString([]byte{1, 2, 3}), }, } SignerTwo = Signature{ Signer: model.Signer{ - PublicKey: [96]byte{3, 2, 1}, + PublicKey: hex.EncodeToString([]byte{3, 2, 1}), }, } ) @@ -29,7 +31,7 @@ type CorrectnessTestSuite struct { } func (s *CorrectnessTestSuite) SetupTest() { - db := mock.New(s.T()) + db := postgres.New() posService := new(pos.MockService) diff --git a/internal/service/evmlog/record.go b/internal/service/evmlog/record.go index 01e98741..1b394645 100644 --- a/internal/service/evmlog/record.go +++ b/internal/service/evmlog/record.go @@ -2,6 +2,7 @@ package evmlog import ( "context" + "encoding/hex" "math/big" "github.com/TimeleapLabs/unchained/internal/service/correctness" @@ -69,8 +70,14 @@ func (s *service) RecordSignature( votingPower, err := s.pos.GetVotingPowerOfEvm(ctx, signer.EvmAddress) if err != nil { + publicKeyBytes, err := hex.DecodeString(signer.PublicKey) + if err != nil { + utils.Logger.Error("Can't decode public key: %v", err) + return err + } + utils.Logger. - With("Address", address.Calculate(signer.PublicKey[:])). + With("Address", address.Calculate(publicKeyBytes)). With("Error", err). Error("Failed to get voting power") return err diff --git a/internal/service/uniswap/record.go b/internal/service/uniswap/record.go index 8d81ecf8..4da98961 100644 --- a/internal/service/uniswap/record.go +++ b/internal/service/uniswap/record.go @@ -2,6 +2,7 @@ package uniswap import ( "context" + "encoding/hex" "fmt" "math/big" @@ -62,8 +63,13 @@ func (s *service) RecordSignature( votingPower, err := s.pos.GetVotingPowerOfEvm(ctx, signer.EvmAddress) if err != nil { + publicKeyBytes, err := hex.DecodeString(signer.PublicKey) + if err != nil { + utils.Logger.Error("Can't decode public key: %v", err) + return err + } utils.Logger. - With("Address", address.Calculate(signer.PublicKey[:])). + With("Address", address.Calculate(publicKeyBytes)). With("Error", err). Error("Failed to get voting power") return err diff --git a/internal/service/uniswap/uniswap.go b/internal/service/uniswap/uniswap.go index 8d3b0bad..a221926a 100644 --- a/internal/service/uniswap/uniswap.go +++ b/internal/service/uniswap/uniswap.go @@ -2,6 +2,7 @@ package uniswap import ( "context" + "encoding/hex" "fmt" "math/big" "os" @@ -95,8 +96,14 @@ func (s *service) checkAndCacheSignature( for _, item := range cached { if item.Signer.PublicKey == signer.PublicKey { + publicKeyBytes, err := hex.DecodeString(signer.PublicKey) + if err != nil { + utils.Logger.Error("Can't decode public key: %v", err) + return err + } + utils.Logger. - With("Address", address.Calculate(signer.PublicKey[:])). + With("Address", address.Calculate(publicKeyBytes)). Debug("Duplicated signature") return fmt.Errorf("duplicated signature") } diff --git a/internal/transport/database/mock/postgres_mock.go b/internal/transport/database/mock/postgres_mock.go deleted file mode 100644 index 9eb87329..00000000 --- a/internal/transport/database/mock/postgres_mock.go +++ /dev/null @@ -1,64 +0,0 @@ -package mock - -import ( - "context" - "testing" - - "gorm.io/driver/postgres" - "gorm.io/gorm" - "gorm.io/gorm/logger" - - "github.com/TimeleapLabs/unchained/internal/transport/database" - - "github.com/peterldowns/pgtestdb" -) - -type mockConnection struct { - t *testing.T - db *gorm.DB -} - -func (m *mockConnection) Migrate() {} - -func (m *mockConnection) GetConnection() *gorm.DB { - if m.db != nil { - return m.db - } - - _ = pgtestdb.New( - m.t, - pgtestdb.Config{ - DriverName: "pgx", - User: "postgres", - Password: "password", - Host: "localhost", - Port: "5433", - Options: "sslmode=disable", - }, - pgtestdb.NoopMigrator{}, - ) - - var err error - m.db, err = gorm.Open( - postgres.Open("postgresql://postgres:password@127.0.0.1:5433/unchained?sslmode=disable"), - &gorm.Config{ - Logger: logger.Default.LogMode(logger.Warn), - TranslateError: true, - }, - ) - if err != nil { - panic(err) - } - - return m.db -} - -func (m *mockConnection) HealthCheck(_ context.Context) bool { - return true -} - -func New(t *testing.T) database.Database { - return &mockConnection{ - t: t, - } -} diff --git a/internal/transport/server/websocket/middleware/signature.go b/internal/transport/server/websocket/middleware/signature.go index 4cf3dbde..2b62eb2c 100644 --- a/internal/transport/server/websocket/middleware/signature.go +++ b/internal/transport/server/websocket/middleware/signature.go @@ -1,6 +1,8 @@ package middleware import ( + "encoding/hex" + "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/crypto" "github.com/TimeleapLabs/unchained/internal/crypto/bls" @@ -23,7 +25,13 @@ func IsMessageValid(conn *websocket.Conn, message bls12381.G1Affine, signature [ return model.Signer{}, consts.ErrInternalError } - pk, err := bls.RecoverPublicKey(signer.PublicKey) + publicKeyBytes, err := hex.DecodeString(signer.PublicKey) + if err != nil { + utils.Logger.Error("Can't decode public key: %v", err) + return model.Signer{}, consts.ErrInternalError + } + + pk, err := bls.RecoverPublicKey([96]byte(publicKeyBytes)) if err != nil { utils.Logger.With("Err", err).Error("Can't recover pub key pub-key") return model.Signer{}, consts.ErrInternalError From ba77a0dfd2516c01fd40b0bce0d765afef62ce77 Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Sun, 30 Jun 2024 04:34:27 +0330 Subject: [PATCH 11/26] =?UTF-8?q?=F0=9F=90=9B=20fix(pubsub):=20fix=20probl?= =?UTF-8?q?em=20of=20removing=20unused=20channels=20>>>=20=E2=8F=B0=201h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/transport/server/pubsub/pubsub.go | 14 ++++++++++++++ .../transport/server/websocket/handler/helper.go | 5 +++-- internal/transport/server/websocket/websocket.go | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/internal/transport/server/pubsub/pubsub.go b/internal/transport/server/pubsub/pubsub.go index 71f1596b..18b19191 100644 --- a/internal/transport/server/pubsub/pubsub.go +++ b/internal/transport/server/pubsub/pubsub.go @@ -37,6 +37,20 @@ func Publish(destinationTopic consts.Channels, operation consts.OpCode, message } } +func Unsubscribe(topic string, ch chan []byte) { + mu.Lock() + defer mu.Unlock() + + for key, subscribers := range topics[consts.Channels(topic)] { + if subscribers == ch { + topics[consts.Channels(topic)] = append(topics[consts.Channels(topic)][:key], topics[consts.Channels(topic)][key+1:]...) + break + } + } + + close(ch) +} + func Subscribe(topic string) chan []byte { mu.Lock() defer mu.Unlock() diff --git a/internal/transport/server/websocket/handler/helper.go b/internal/transport/server/websocket/handler/helper.go index e6db66a5..4aabacbc 100644 --- a/internal/transport/server/websocket/handler/helper.go +++ b/internal/transport/server/websocket/handler/helper.go @@ -2,6 +2,7 @@ package handler import ( "context" + "github.com/TimeleapLabs/unchained/internal/transport/server/pubsub" "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/utils" @@ -24,12 +25,12 @@ func SendMessage(conn *websocket.Conn, messageType int, opCode consts.OpCode, me Send(conn, messageType, opCode, []byte(message)) } -func BroadcastListener(ctx context.Context, conn *websocket.Conn, ch chan []byte) { +func BroadcastListener(ctx context.Context, conn *websocket.Conn, topic string, ch chan []byte) { for { select { case <-ctx.Done(): utils.Logger.Info("Closing connection") - close(ch) + pubsub.Unsubscribe(topic, ch) return case message := <-ch: err := conn.WriteMessage(websocket.BinaryMessage, message) diff --git a/internal/transport/server/websocket/websocket.go b/internal/transport/server/websocket/websocket.go index f94cd296..2f59f0db 100644 --- a/internal/transport/server/websocket/websocket.go +++ b/internal/transport/server/websocket/websocket.go @@ -107,7 +107,8 @@ func multiplexer(w http.ResponseWriter, r *http.Request) { With("Channel", string(payload[1:])). Info("New Consumer registered") - go handler.BroadcastListener(ctx, conn, pubsub.Subscribe(string(payload[1:]))) + topic := string(payload[1:]) + go handler.BroadcastListener(ctx, conn, topic, pubsub.Subscribe(topic)) default: handler.SendError(conn, messageType, consts.OpCodeError, consts.ErrNotSupportedInstruction) } From 8ef71c73273b2a3585c27647bd6c77e438391466 Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Sun, 30 Jun 2024 04:37:21 +0330 Subject: [PATCH 12/26] =?UTF-8?q?=F0=9F=90=9B=20fix(linter):=20fix=20error?= =?UTF-8?q?s=20>>>=20=E2=8F=B0=201m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/model/assetprice.go | 8 ++++---- internal/transport/server/websocket/handler/helper.go | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/model/assetprice.go b/internal/model/assetprice.go index 06fa2939..9c5ede5b 100644 --- a/internal/model/assetprice.go +++ b/internal/model/assetprice.go @@ -20,10 +20,10 @@ type AssetPriceDataFrame struct { } type AssetPrice struct { - Pair string `json:"pair" gorm:"uniqueIndex:idx_pair_name_chain_block"` - Name string `json:"name" gorm:"uniqueIndex:idx_pair_name_chain_block"` - Chain string `json:"chain" gorm:"uniqueIndex:idx_pair_name_chain_block"` - Block uint64 `json:"block" gorm:"uniqueIndex:idx_pair_name_chain_block"` + Pair string `gorm:"uniqueIndex:idx_pair_name_chain_block" json:"pair"` + Name string `gorm:"uniqueIndex:idx_pair_name_chain_block" json:"name"` + Chain string `gorm:"uniqueIndex:idx_pair_name_chain_block" json:"chain"` + Block uint64 `gorm:"uniqueIndex:idx_pair_name_chain_block" json:"block"` Price int64 `json:"price"` SignersCount uint64 `json:"signers_count"` Signature []byte `json:"signature"` diff --git a/internal/transport/server/websocket/handler/helper.go b/internal/transport/server/websocket/handler/helper.go index 4aabacbc..6a64b7fd 100644 --- a/internal/transport/server/websocket/handler/helper.go +++ b/internal/transport/server/websocket/handler/helper.go @@ -2,6 +2,7 @@ package handler import ( "context" + "github.com/TimeleapLabs/unchained/internal/transport/server/pubsub" "github.com/TimeleapLabs/unchained/internal/consts" From 0bb82292cc14ce86404754ba5d782e03a96493cb Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Mon, 24 Jun 2024 01:48:49 +0330 Subject: [PATCH 13/26] =?UTF-8?q?=E2=9C=A8=20feat(postgres):=20rewrite=20r?= =?UTF-8?q?epositories=20with=20gorm=20-=20remove=20gql=20-=20seprate=20pa?= =?UTF-8?q?ckets=20from=20models=20>>>=20=E2=8F=B0=205h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .golangci.yml | 3 + go.sum | 8 + internal/app/consumer.go | 6 +- internal/ent/assetprice.go | 255 - internal/ent/assetprice/assetprice.go | 148 - internal/ent/assetprice/where.go | 583 -- internal/ent/assetprice_create.go | 1077 -- internal/ent/assetprice_delete.go | 88 - internal/ent/assetprice_query.go | 671 -- internal/ent/assetprice_update.go | 735 -- internal/ent/client.go | 868 -- internal/ent/correctnessreport.go | 239 - .../correctnessreport/correctnessreport.go | 134 - internal/ent/correctnessreport/where.go | 393 - internal/ent/correctnessreport_create.go | 934 -- internal/ent/correctnessreport_delete.go | 88 - internal/ent/correctnessreport_query.go | 671 -- internal/ent/correctnessreport_update.go | 633 -- internal/ent/ent.go | 614 -- internal/ent/entc.go | 32 - internal/ent/enttest/enttest.go | 84 - internal/ent/eventlog.go | 278 - internal/ent/eventlog/eventlog.go | 156 - internal/ent/eventlog/where.go | 588 -- internal/ent/eventlog_create.go | 1109 --- internal/ent/eventlog_delete.go | 88 - internal/ent/eventlog_query.go | 671 -- internal/ent/eventlog_update.go | 769 -- internal/ent/gql_collection.go | 678 -- internal/ent/gql_edge.go | 81 - internal/ent/gql_node.go | 348 - internal/ent/gql_pagination.go | 1282 --- internal/ent/gql_transaction.go | 30 - internal/ent/gql_where_input.go | 1563 --- internal/ent/helpers/bigint.go | 34 - internal/ent/hook/hook.go | 235 - internal/ent/migrate/migrate.go | 64 - internal/ent/migrate/schema.go | 226 - internal/ent/mutation.go | 3837 -------- internal/ent/predicate/predicate.go | 19 - internal/ent/runtime.go | 101 - internal/ent/runtime/runtime.go | 10 - internal/ent/schema/assetprice.go | 77 - internal/ent/schema/correctness.go | 75 - internal/ent/schema/eventlog.go | 80 - internal/ent/schema/signer.go | 68 - internal/ent/signer.go | 288 - internal/ent/signer/signer.go | 175 - internal/ent/signer/where.go | 423 - internal/ent/signer_create.go | 822 -- internal/ent/signer_delete.go | 88 - internal/ent/signer_query.go | 927 -- internal/ent/signer_update.go | 886 -- internal/ent/tx.go | 219 - internal/generate.go | 1 - internal/model/assetprice.go | 16 +- internal/model/correctness.go | 53 +- internal/model/dataframe.go | 9 + internal/model/logs.go | 47 +- internal/model/price.go | 28 - internal/model/proof.go | 11 + internal/model/{bls.go => signer.go} | 29 - internal/model/uniswap.go | 115 - internal/repository/postgres/assetprice.go | 55 +- internal/repository/postgres/correctness.go | 52 +- internal/repository/postgres/eventlog.go | 54 +- internal/repository/postgres/signer.go | 50 +- internal/repository/repository.go | 7 +- internal/service/correctness/correctness.go | 22 +- .../service/correctness/correctness_test.go | 43 +- internal/service/correctness/types.go | 34 + internal/service/evmlog/evmlog.go | 15 +- internal/service/evmlog/helper.go | 8 +- internal/service/evmlog/record.go | 4 +- internal/service/uniswap/helper.go | 8 +- internal/service/uniswap/process.go | 5 +- internal/service/uniswap/record.go | 4 +- internal/service/uniswap/types/assetkey.go | 21 + internal/service/uniswap/types/priceinfo.go | 43 + .../{model => service/uniswap/types}/token.go | 2 +- internal/service/uniswap/types/tokenkey.go | 33 + internal/service/uniswap/uniswap.go | 67 +- .../transport/client/handler/challenge.go | 6 +- .../transport/client/handler/correctness.go | 10 +- internal/transport/client/handler/event.go | 5 +- internal/transport/client/handler/price.go | 5 +- internal/transport/database/database.go | 4 +- .../transport/database/mock/postgres_mock.go | 17 +- .../transport/database/postgres/postgres.go | 51 +- internal/transport/server/gql/args.graphql | 7 - .../transport/server/gql/args.resolvers.go | 39 - .../transport/server/gql/extensions.graphql | 8 - .../server/gql/extensions.resolvers.go | 65 - .../server/gql/generated/args.generated.go | 279 - .../server/gql/generated/prelude.generated.go | 2969 ------ .../server/gql/generated/root_.generated.go | 1712 ---- .../gql/generated/unchained.generated.go | 8709 ----------------- internal/transport/server/gql/resolver.go | 18 - internal/transport/server/gql/server.go | 21 - internal/transport/server/gql/types/bytes.go | 34 - .../transport/server/gql/unchained.graphql | 847 -- .../server/gql/unchained.resolvers.go | 342 - .../server/packet/challenge.go} | 2 +- .../transport/server/packet/correctness.go | 49 + internal/transport/server/packet/eventlog.go | 48 + internal/transport/server/packet/price.go | 52 + .../server/websocket/handler/hello.go | 3 +- .../transport/server/websocket/store/store.go | 3 +- 108 files changed, 602 insertions(+), 40098 deletions(-) delete mode 100644 internal/ent/assetprice.go delete mode 100644 internal/ent/assetprice/assetprice.go delete mode 100644 internal/ent/assetprice/where.go delete mode 100644 internal/ent/assetprice_create.go delete mode 100644 internal/ent/assetprice_delete.go delete mode 100644 internal/ent/assetprice_query.go delete mode 100644 internal/ent/assetprice_update.go delete mode 100644 internal/ent/client.go delete mode 100644 internal/ent/correctnessreport.go delete mode 100644 internal/ent/correctnessreport/correctnessreport.go delete mode 100644 internal/ent/correctnessreport/where.go delete mode 100644 internal/ent/correctnessreport_create.go delete mode 100644 internal/ent/correctnessreport_delete.go delete mode 100644 internal/ent/correctnessreport_query.go delete mode 100644 internal/ent/correctnessreport_update.go delete mode 100644 internal/ent/ent.go delete mode 100644 internal/ent/entc.go delete mode 100644 internal/ent/enttest/enttest.go delete mode 100644 internal/ent/eventlog.go delete mode 100644 internal/ent/eventlog/eventlog.go delete mode 100644 internal/ent/eventlog/where.go delete mode 100644 internal/ent/eventlog_create.go delete mode 100644 internal/ent/eventlog_delete.go delete mode 100644 internal/ent/eventlog_query.go delete mode 100644 internal/ent/eventlog_update.go delete mode 100644 internal/ent/gql_collection.go delete mode 100644 internal/ent/gql_edge.go delete mode 100644 internal/ent/gql_node.go delete mode 100644 internal/ent/gql_pagination.go delete mode 100644 internal/ent/gql_transaction.go delete mode 100644 internal/ent/gql_where_input.go delete mode 100644 internal/ent/helpers/bigint.go delete mode 100644 internal/ent/hook/hook.go delete mode 100644 internal/ent/migrate/migrate.go delete mode 100644 internal/ent/migrate/schema.go delete mode 100644 internal/ent/mutation.go delete mode 100644 internal/ent/predicate/predicate.go delete mode 100644 internal/ent/runtime.go delete mode 100644 internal/ent/runtime/runtime.go delete mode 100644 internal/ent/schema/assetprice.go delete mode 100644 internal/ent/schema/correctness.go delete mode 100644 internal/ent/schema/eventlog.go delete mode 100644 internal/ent/schema/signer.go delete mode 100644 internal/ent/signer.go delete mode 100644 internal/ent/signer/signer.go delete mode 100644 internal/ent/signer/where.go delete mode 100644 internal/ent/signer_create.go delete mode 100644 internal/ent/signer_delete.go delete mode 100644 internal/ent/signer_query.go delete mode 100644 internal/ent/signer_update.go delete mode 100644 internal/ent/tx.go create mode 100644 internal/model/dataframe.go delete mode 100644 internal/model/price.go create mode 100644 internal/model/proof.go rename internal/model/{bls.go => signer.go} (54%) delete mode 100644 internal/model/uniswap.go create mode 100644 internal/service/uniswap/types/assetkey.go create mode 100644 internal/service/uniswap/types/priceinfo.go rename internal/{model => service/uniswap/types}/token.go (98%) create mode 100644 internal/service/uniswap/types/tokenkey.go delete mode 100644 internal/transport/server/gql/args.graphql delete mode 100644 internal/transport/server/gql/args.resolvers.go delete mode 100644 internal/transport/server/gql/extensions.graphql delete mode 100644 internal/transport/server/gql/extensions.resolvers.go delete mode 100644 internal/transport/server/gql/generated/args.generated.go delete mode 100644 internal/transport/server/gql/generated/prelude.generated.go delete mode 100644 internal/transport/server/gql/generated/root_.generated.go delete mode 100644 internal/transport/server/gql/generated/unchained.generated.go delete mode 100644 internal/transport/server/gql/resolver.go delete mode 100644 internal/transport/server/gql/server.go delete mode 100644 internal/transport/server/gql/types/bytes.go delete mode 100644 internal/transport/server/gql/unchained.graphql delete mode 100644 internal/transport/server/gql/unchained.resolvers.go rename internal/{model/kosk.go => transport/server/packet/challenge.go} (97%) create mode 100644 internal/transport/server/packet/correctness.go create mode 100644 internal/transport/server/packet/eventlog.go create mode 100644 internal/transport/server/packet/price.go diff --git a/.golangci.yml b/.golangci.yml index bc2b437a..a1fdb50e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -199,6 +199,9 @@ issues: linters: [ godot ] - source: "//noinspection" linters: [ gocritic ] + - path: "internal/transport/server/packet/*" + linters: + - dupl - path: "cmd" linters: - funlen diff --git a/go.sum b/go.sum index b995a2a2..b0492408 100644 --- a/go.sum +++ b/go.sum @@ -220,6 +220,10 @@ github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFr github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4= @@ -495,6 +499,10 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/driver/postgres v1.5.9 h1:DkegyItji119OlcaLjqN11kHoUgZ/j13E0jkJZgD6A8= +gorm.io/driver/postgres v1.5.9/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI= +gorm.io/gorm v1.25.10 h1:dQpO+33KalOA+aFYGlK+EfxcI5MbO7EP2yYygwh9h+s= +gorm.io/gorm v1.25.10/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= olympos.io/encoding/edn v0.0.0-20201019073823-d3554ca0b0a3 h1:slmdOY3vp8a7KQbHkL+FLbvbkgMqmXojpFUO/jENuqQ= diff --git a/internal/app/consumer.go b/internal/app/consumer.go index 726a798d..37a226bc 100644 --- a/internal/app/consumer.go +++ b/internal/app/consumer.go @@ -13,8 +13,6 @@ import ( "github.com/TimeleapLabs/unchained/internal/transport/client/conn" "github.com/TimeleapLabs/unchained/internal/transport/client/handler" "github.com/TimeleapLabs/unchained/internal/transport/database/postgres" - "github.com/TimeleapLabs/unchained/internal/transport/server" - "github.com/TimeleapLabs/unchained/internal/transport/server/gql" "github.com/TimeleapLabs/unchained/internal/utils" ) @@ -49,7 +47,5 @@ func Consumer() { handler := handler.NewConsumerHandler(correctnessService, uniswapService, evmLogService) client.NewRPC(handler) - server.New( - gql.WithGraphQL(db), - ) + select {} } diff --git a/internal/ent/assetprice.go b/internal/ent/assetprice.go deleted file mode 100644 index fa9814ef..00000000 --- a/internal/ent/assetprice.go +++ /dev/null @@ -1,255 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "fmt" - "strings" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" -) - -// AssetPrice is the model entity for the AssetPrice schema. -type AssetPrice struct { - config `json:"-"` - // ID of the ent. - ID int `json:"id,omitempty"` - // Block holds the value of the "block" field. - Block uint64 `json:"block,omitempty"` - // SignersCount holds the value of the "signersCount" field. - SignersCount *uint64 `json:"signersCount,omitempty"` - // Price holds the value of the "price" field. - Price *helpers.BigInt `json:"price,omitempty"` - // Signature holds the value of the "signature" field. - Signature []byte `json:"signature,omitempty"` - // Asset holds the value of the "asset" field. - Asset string `json:"asset,omitempty"` - // Chain holds the value of the "chain" field. - Chain string `json:"chain,omitempty"` - // Pair holds the value of the "pair" field. - Pair string `json:"pair,omitempty"` - // Consensus holds the value of the "consensus" field. - Consensus bool `json:"consensus,omitempty"` - // Voted holds the value of the "voted" field. - Voted *helpers.BigInt `json:"voted,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the AssetPriceQuery when eager-loading is set. - Edges AssetPriceEdges `json:"edges"` - selectValues sql.SelectValues -} - -// AssetPriceEdges holds the relations/edges for other nodes in the graph. -type AssetPriceEdges struct { - // Signers holds the value of the signers edge. - Signers []*Signer `json:"signers,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [1]bool - // totalCount holds the count of the edges above. - totalCount [1]map[string]int - - namedSigners map[string][]*Signer -} - -// SignersOrErr returns the Signers value or an error if the edge -// was not loaded in eager-loading. -func (e AssetPriceEdges) SignersOrErr() ([]*Signer, error) { - if e.loadedTypes[0] { - return e.Signers, nil - } - return nil, &NotLoadedError{edge: "signers"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*AssetPrice) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case assetprice.FieldSignature: - values[i] = new([]byte) - case assetprice.FieldPrice, assetprice.FieldVoted: - values[i] = new(helpers.BigInt) - case assetprice.FieldConsensus: - values[i] = new(sql.NullBool) - case assetprice.FieldID, assetprice.FieldBlock, assetprice.FieldSignersCount: - values[i] = new(sql.NullInt64) - case assetprice.FieldAsset, assetprice.FieldChain, assetprice.FieldPair: - 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 AssetPrice fields. -func (ap *AssetPrice) 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 assetprice.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) - } - ap.ID = int(value.Int64) - case assetprice.FieldBlock: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field block", values[i]) - } else if value.Valid { - ap.Block = uint64(value.Int64) - } - case assetprice.FieldSignersCount: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field signersCount", values[i]) - } else if value.Valid { - ap.SignersCount = new(uint64) - *ap.SignersCount = uint64(value.Int64) - } - case assetprice.FieldPrice: - if value, ok := values[i].(*helpers.BigInt); !ok { - return fmt.Errorf("unexpected type %T for field price", values[i]) - } else if value != nil { - ap.Price = value - } - case assetprice.FieldSignature: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field signature", values[i]) - } else if value != nil { - ap.Signature = *value - } - case assetprice.FieldAsset: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field asset", values[i]) - } else if value.Valid { - ap.Asset = value.String - } - case assetprice.FieldChain: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field chain", values[i]) - } else if value.Valid { - ap.Chain = value.String - } - case assetprice.FieldPair: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field pair", values[i]) - } else if value.Valid { - ap.Pair = value.String - } - case assetprice.FieldConsensus: - if value, ok := values[i].(*sql.NullBool); !ok { - return fmt.Errorf("unexpected type %T for field consensus", values[i]) - } else if value.Valid { - ap.Consensus = value.Bool - } - case assetprice.FieldVoted: - if value, ok := values[i].(*helpers.BigInt); !ok { - return fmt.Errorf("unexpected type %T for field voted", values[i]) - } else if value != nil { - ap.Voted = value - } - default: - ap.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the AssetPrice. -// This includes values selected through modifiers, order, etc. -func (ap *AssetPrice) Value(name string) (ent.Value, error) { - return ap.selectValues.Get(name) -} - -// QuerySigners queries the "signers" edge of the AssetPrice entity. -func (ap *AssetPrice) QuerySigners() *SignerQuery { - return NewAssetPriceClient(ap.config).QuerySigners(ap) -} - -// Update returns a builder for updating this AssetPrice. -// Note that you need to call AssetPrice.Unwrap() before calling this method if this AssetPrice -// was returned from a transaction, and the transaction was committed or rolled back. -func (ap *AssetPrice) Update() *AssetPriceUpdateOne { - return NewAssetPriceClient(ap.config).UpdateOne(ap) -} - -// Unwrap unwraps the AssetPrice 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 (ap *AssetPrice) Unwrap() *AssetPrice { - _tx, ok := ap.config.driver.(*txDriver) - if !ok { - panic("ent: AssetPrice is not a transactional entity") - } - ap.config.driver = _tx.drv - return ap -} - -// String implements the fmt.Stringer. -func (ap *AssetPrice) String() string { - var builder strings.Builder - builder.WriteString("AssetPrice(") - builder.WriteString(fmt.Sprintf("id=%v, ", ap.ID)) - builder.WriteString("block=") - builder.WriteString(fmt.Sprintf("%v", ap.Block)) - builder.WriteString(", ") - if v := ap.SignersCount; v != nil { - builder.WriteString("signersCount=") - builder.WriteString(fmt.Sprintf("%v", *v)) - } - builder.WriteString(", ") - builder.WriteString("price=") - builder.WriteString(fmt.Sprintf("%v", ap.Price)) - builder.WriteString(", ") - builder.WriteString("signature=") - builder.WriteString(fmt.Sprintf("%v", ap.Signature)) - builder.WriteString(", ") - builder.WriteString("asset=") - builder.WriteString(ap.Asset) - builder.WriteString(", ") - builder.WriteString("chain=") - builder.WriteString(ap.Chain) - builder.WriteString(", ") - builder.WriteString("pair=") - builder.WriteString(ap.Pair) - builder.WriteString(", ") - builder.WriteString("consensus=") - builder.WriteString(fmt.Sprintf("%v", ap.Consensus)) - builder.WriteString(", ") - builder.WriteString("voted=") - builder.WriteString(fmt.Sprintf("%v", ap.Voted)) - builder.WriteByte(')') - return builder.String() -} - -// NamedSigners returns the Signers named value or an error if the edge was not -// loaded in eager-loading with this name. -func (ap *AssetPrice) NamedSigners(name string) ([]*Signer, error) { - if ap.Edges.namedSigners == nil { - return nil, &NotLoadedError{edge: name} - } - nodes, ok := ap.Edges.namedSigners[name] - if !ok { - return nil, &NotLoadedError{edge: name} - } - return nodes, nil -} - -func (ap *AssetPrice) appendNamedSigners(name string, edges ...*Signer) { - if ap.Edges.namedSigners == nil { - ap.Edges.namedSigners = make(map[string][]*Signer) - } - if len(edges) == 0 { - ap.Edges.namedSigners[name] = []*Signer{} - } else { - ap.Edges.namedSigners[name] = append(ap.Edges.namedSigners[name], edges...) - } -} - -// AssetPrices is a parsable slice of AssetPrice. -type AssetPrices []*AssetPrice diff --git a/internal/ent/assetprice/assetprice.go b/internal/ent/assetprice/assetprice.go deleted file mode 100644 index e233d7d7..00000000 --- a/internal/ent/assetprice/assetprice.go +++ /dev/null @@ -1,148 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package assetprice - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the assetprice type in the database. - Label = "asset_price" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldBlock holds the string denoting the block field in the database. - FieldBlock = "block" - // FieldSignersCount holds the string denoting the signerscount field in the database. - FieldSignersCount = "signers_count" - // FieldPrice holds the string denoting the price field in the database. - FieldPrice = "price" - // FieldSignature holds the string denoting the signature field in the database. - FieldSignature = "signature" - // FieldAsset holds the string denoting the asset field in the database. - FieldAsset = "asset" - // FieldChain holds the string denoting the chain field in the database. - FieldChain = "chain" - // FieldPair holds the string denoting the pair field in the database. - FieldPair = "pair" - // FieldConsensus holds the string denoting the consensus field in the database. - FieldConsensus = "consensus" - // FieldVoted holds the string denoting the voted field in the database. - FieldVoted = "voted" - // EdgeSigners holds the string denoting the signers edge name in mutations. - EdgeSigners = "signers" - // Table holds the table name of the assetprice in the database. - Table = "asset_prices" - // SignersTable is the table that holds the signers relation/edge. The primary key declared below. - SignersTable = "asset_price_signers" - // SignersInverseTable is the table name for the Signer entity. - // It exists in this package in order to avoid circular dependency with the "signer" package. - SignersInverseTable = "signers" -) - -// Columns holds all SQL columns for assetprice fields. -var Columns = []string{ - FieldID, - FieldBlock, - FieldSignersCount, - FieldPrice, - FieldSignature, - FieldAsset, - FieldChain, - FieldPair, - FieldConsensus, - FieldVoted, -} - -var ( - // SignersPrimaryKey and SignersColumn2 are the table columns denoting the - // primary key for the signers relation (M2M). - SignersPrimaryKey = []string{"asset_price_id", "signer_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 -} - -var ( - // SignatureValidator is a validator for the "signature" field. It is called by the builders before save. - SignatureValidator func([]byte) error - // DefaultConsensus holds the default value on creation for the "consensus" field. - DefaultConsensus bool -) - -// OrderOption defines the ordering options for the AssetPrice 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() -} - -// ByBlock orders the results by the block field. -func ByBlock(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldBlock, opts...).ToFunc() -} - -// BySignersCountField orders the results by the signersCount field. -func BySignersCountField(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSignersCount, opts...).ToFunc() -} - -// ByPrice orders the results by the price field. -func ByPrice(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPrice, opts...).ToFunc() -} - -// ByAsset orders the results by the asset field. -func ByAsset(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldAsset, opts...).ToFunc() -} - -// ByChain orders the results by the chain field. -func ByChain(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldChain, opts...).ToFunc() -} - -// ByPair orders the results by the pair field. -func ByPair(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPair, opts...).ToFunc() -} - -// ByConsensus orders the results by the consensus field. -func ByConsensus(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldConsensus, opts...).ToFunc() -} - -// ByVoted orders the results by the voted field. -func ByVoted(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldVoted, opts...).ToFunc() -} - -// BySignersCount orders the results by signers count. -func BySignersCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newSignersStep(), opts...) - } -} - -// BySigners orders the results by signers terms. -func BySigners(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newSignersStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newSignersStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(SignersInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, SignersTable, SignersPrimaryKey...), - ) -} diff --git a/internal/ent/assetprice/where.go b/internal/ent/assetprice/where.go deleted file mode 100644 index d8fa4389..00000000 --- a/internal/ent/assetprice/where.go +++ /dev/null @@ -1,583 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package assetprice - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLTE(FieldID, id)) -} - -// Block applies equality check predicate on the "block" field. It's identical to BlockEQ. -func Block(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldBlock, v)) -} - -// SignersCount applies equality check predicate on the "signersCount" field. It's identical to SignersCountEQ. -func SignersCount(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldSignersCount, v)) -} - -// Price applies equality check predicate on the "price" field. It's identical to PriceEQ. -func Price(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldPrice, v)) -} - -// Signature applies equality check predicate on the "signature" field. It's identical to SignatureEQ. -func Signature(v []byte) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldSignature, v)) -} - -// Asset applies equality check predicate on the "asset" field. It's identical to AssetEQ. -func Asset(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldAsset, v)) -} - -// Chain applies equality check predicate on the "chain" field. It's identical to ChainEQ. -func Chain(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldChain, v)) -} - -// Pair applies equality check predicate on the "pair" field. It's identical to PairEQ. -func Pair(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldPair, v)) -} - -// Consensus applies equality check predicate on the "consensus" field. It's identical to ConsensusEQ. -func Consensus(v bool) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldConsensus, v)) -} - -// Voted applies equality check predicate on the "voted" field. It's identical to VotedEQ. -func Voted(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldVoted, v)) -} - -// BlockEQ applies the EQ predicate on the "block" field. -func BlockEQ(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldBlock, v)) -} - -// BlockNEQ applies the NEQ predicate on the "block" field. -func BlockNEQ(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldBlock, v)) -} - -// BlockIn applies the In predicate on the "block" field. -func BlockIn(vs ...uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIn(FieldBlock, vs...)) -} - -// BlockNotIn applies the NotIn predicate on the "block" field. -func BlockNotIn(vs ...uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotIn(FieldBlock, vs...)) -} - -// BlockGT applies the GT predicate on the "block" field. -func BlockGT(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGT(FieldBlock, v)) -} - -// BlockGTE applies the GTE predicate on the "block" field. -func BlockGTE(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGTE(FieldBlock, v)) -} - -// BlockLT applies the LT predicate on the "block" field. -func BlockLT(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLT(FieldBlock, v)) -} - -// BlockLTE applies the LTE predicate on the "block" field. -func BlockLTE(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLTE(FieldBlock, v)) -} - -// SignersCountEQ applies the EQ predicate on the "signersCount" field. -func SignersCountEQ(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldSignersCount, v)) -} - -// SignersCountNEQ applies the NEQ predicate on the "signersCount" field. -func SignersCountNEQ(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldSignersCount, v)) -} - -// SignersCountIn applies the In predicate on the "signersCount" field. -func SignersCountIn(vs ...uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIn(FieldSignersCount, vs...)) -} - -// SignersCountNotIn applies the NotIn predicate on the "signersCount" field. -func SignersCountNotIn(vs ...uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotIn(FieldSignersCount, vs...)) -} - -// SignersCountGT applies the GT predicate on the "signersCount" field. -func SignersCountGT(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGT(FieldSignersCount, v)) -} - -// SignersCountGTE applies the GTE predicate on the "signersCount" field. -func SignersCountGTE(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGTE(FieldSignersCount, v)) -} - -// SignersCountLT applies the LT predicate on the "signersCount" field. -func SignersCountLT(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLT(FieldSignersCount, v)) -} - -// SignersCountLTE applies the LTE predicate on the "signersCount" field. -func SignersCountLTE(v uint64) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLTE(FieldSignersCount, v)) -} - -// SignersCountIsNil applies the IsNil predicate on the "signersCount" field. -func SignersCountIsNil() predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIsNull(FieldSignersCount)) -} - -// SignersCountNotNil applies the NotNil predicate on the "signersCount" field. -func SignersCountNotNil() predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotNull(FieldSignersCount)) -} - -// PriceEQ applies the EQ predicate on the "price" field. -func PriceEQ(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldPrice, v)) -} - -// PriceNEQ applies the NEQ predicate on the "price" field. -func PriceNEQ(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldPrice, v)) -} - -// PriceIn applies the In predicate on the "price" field. -func PriceIn(vs ...*helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIn(FieldPrice, vs...)) -} - -// PriceNotIn applies the NotIn predicate on the "price" field. -func PriceNotIn(vs ...*helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotIn(FieldPrice, vs...)) -} - -// PriceGT applies the GT predicate on the "price" field. -func PriceGT(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGT(FieldPrice, v)) -} - -// PriceGTE applies the GTE predicate on the "price" field. -func PriceGTE(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGTE(FieldPrice, v)) -} - -// PriceLT applies the LT predicate on the "price" field. -func PriceLT(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLT(FieldPrice, v)) -} - -// PriceLTE applies the LTE predicate on the "price" field. -func PriceLTE(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLTE(FieldPrice, v)) -} - -// SignatureEQ applies the EQ predicate on the "signature" field. -func SignatureEQ(v []byte) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldSignature, v)) -} - -// SignatureNEQ applies the NEQ predicate on the "signature" field. -func SignatureNEQ(v []byte) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldSignature, v)) -} - -// SignatureIn applies the In predicate on the "signature" field. -func SignatureIn(vs ...[]byte) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIn(FieldSignature, vs...)) -} - -// SignatureNotIn applies the NotIn predicate on the "signature" field. -func SignatureNotIn(vs ...[]byte) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotIn(FieldSignature, vs...)) -} - -// SignatureGT applies the GT predicate on the "signature" field. -func SignatureGT(v []byte) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGT(FieldSignature, v)) -} - -// SignatureGTE applies the GTE predicate on the "signature" field. -func SignatureGTE(v []byte) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGTE(FieldSignature, v)) -} - -// SignatureLT applies the LT predicate on the "signature" field. -func SignatureLT(v []byte) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLT(FieldSignature, v)) -} - -// SignatureLTE applies the LTE predicate on the "signature" field. -func SignatureLTE(v []byte) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLTE(FieldSignature, v)) -} - -// AssetEQ applies the EQ predicate on the "asset" field. -func AssetEQ(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldAsset, v)) -} - -// AssetNEQ applies the NEQ predicate on the "asset" field. -func AssetNEQ(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldAsset, v)) -} - -// AssetIn applies the In predicate on the "asset" field. -func AssetIn(vs ...string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIn(FieldAsset, vs...)) -} - -// AssetNotIn applies the NotIn predicate on the "asset" field. -func AssetNotIn(vs ...string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotIn(FieldAsset, vs...)) -} - -// AssetGT applies the GT predicate on the "asset" field. -func AssetGT(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGT(FieldAsset, v)) -} - -// AssetGTE applies the GTE predicate on the "asset" field. -func AssetGTE(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGTE(FieldAsset, v)) -} - -// AssetLT applies the LT predicate on the "asset" field. -func AssetLT(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLT(FieldAsset, v)) -} - -// AssetLTE applies the LTE predicate on the "asset" field. -func AssetLTE(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLTE(FieldAsset, v)) -} - -// AssetContains applies the Contains predicate on the "asset" field. -func AssetContains(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldContains(FieldAsset, v)) -} - -// AssetHasPrefix applies the HasPrefix predicate on the "asset" field. -func AssetHasPrefix(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldHasPrefix(FieldAsset, v)) -} - -// AssetHasSuffix applies the HasSuffix predicate on the "asset" field. -func AssetHasSuffix(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldHasSuffix(FieldAsset, v)) -} - -// AssetIsNil applies the IsNil predicate on the "asset" field. -func AssetIsNil() predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIsNull(FieldAsset)) -} - -// AssetNotNil applies the NotNil predicate on the "asset" field. -func AssetNotNil() predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotNull(FieldAsset)) -} - -// AssetEqualFold applies the EqualFold predicate on the "asset" field. -func AssetEqualFold(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEqualFold(FieldAsset, v)) -} - -// AssetContainsFold applies the ContainsFold predicate on the "asset" field. -func AssetContainsFold(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldContainsFold(FieldAsset, v)) -} - -// ChainEQ applies the EQ predicate on the "chain" field. -func ChainEQ(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldChain, v)) -} - -// ChainNEQ applies the NEQ predicate on the "chain" field. -func ChainNEQ(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldChain, v)) -} - -// ChainIn applies the In predicate on the "chain" field. -func ChainIn(vs ...string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIn(FieldChain, vs...)) -} - -// ChainNotIn applies the NotIn predicate on the "chain" field. -func ChainNotIn(vs ...string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotIn(FieldChain, vs...)) -} - -// ChainGT applies the GT predicate on the "chain" field. -func ChainGT(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGT(FieldChain, v)) -} - -// ChainGTE applies the GTE predicate on the "chain" field. -func ChainGTE(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGTE(FieldChain, v)) -} - -// ChainLT applies the LT predicate on the "chain" field. -func ChainLT(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLT(FieldChain, v)) -} - -// ChainLTE applies the LTE predicate on the "chain" field. -func ChainLTE(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLTE(FieldChain, v)) -} - -// ChainContains applies the Contains predicate on the "chain" field. -func ChainContains(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldContains(FieldChain, v)) -} - -// ChainHasPrefix applies the HasPrefix predicate on the "chain" field. -func ChainHasPrefix(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldHasPrefix(FieldChain, v)) -} - -// ChainHasSuffix applies the HasSuffix predicate on the "chain" field. -func ChainHasSuffix(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldHasSuffix(FieldChain, v)) -} - -// ChainIsNil applies the IsNil predicate on the "chain" field. -func ChainIsNil() predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIsNull(FieldChain)) -} - -// ChainNotNil applies the NotNil predicate on the "chain" field. -func ChainNotNil() predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotNull(FieldChain)) -} - -// ChainEqualFold applies the EqualFold predicate on the "chain" field. -func ChainEqualFold(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEqualFold(FieldChain, v)) -} - -// ChainContainsFold applies the ContainsFold predicate on the "chain" field. -func ChainContainsFold(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldContainsFold(FieldChain, v)) -} - -// PairEQ applies the EQ predicate on the "pair" field. -func PairEQ(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldPair, v)) -} - -// PairNEQ applies the NEQ predicate on the "pair" field. -func PairNEQ(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldPair, v)) -} - -// PairIn applies the In predicate on the "pair" field. -func PairIn(vs ...string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIn(FieldPair, vs...)) -} - -// PairNotIn applies the NotIn predicate on the "pair" field. -func PairNotIn(vs ...string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotIn(FieldPair, vs...)) -} - -// PairGT applies the GT predicate on the "pair" field. -func PairGT(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGT(FieldPair, v)) -} - -// PairGTE applies the GTE predicate on the "pair" field. -func PairGTE(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGTE(FieldPair, v)) -} - -// PairLT applies the LT predicate on the "pair" field. -func PairLT(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLT(FieldPair, v)) -} - -// PairLTE applies the LTE predicate on the "pair" field. -func PairLTE(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLTE(FieldPair, v)) -} - -// PairContains applies the Contains predicate on the "pair" field. -func PairContains(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldContains(FieldPair, v)) -} - -// PairHasPrefix applies the HasPrefix predicate on the "pair" field. -func PairHasPrefix(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldHasPrefix(FieldPair, v)) -} - -// PairHasSuffix applies the HasSuffix predicate on the "pair" field. -func PairHasSuffix(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldHasSuffix(FieldPair, v)) -} - -// PairIsNil applies the IsNil predicate on the "pair" field. -func PairIsNil() predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIsNull(FieldPair)) -} - -// PairNotNil applies the NotNil predicate on the "pair" field. -func PairNotNil() predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotNull(FieldPair)) -} - -// PairEqualFold applies the EqualFold predicate on the "pair" field. -func PairEqualFold(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEqualFold(FieldPair, v)) -} - -// PairContainsFold applies the ContainsFold predicate on the "pair" field. -func PairContainsFold(v string) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldContainsFold(FieldPair, v)) -} - -// ConsensusEQ applies the EQ predicate on the "consensus" field. -func ConsensusEQ(v bool) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldConsensus, v)) -} - -// ConsensusNEQ applies the NEQ predicate on the "consensus" field. -func ConsensusNEQ(v bool) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldConsensus, v)) -} - -// VotedEQ applies the EQ predicate on the "voted" field. -func VotedEQ(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldEQ(FieldVoted, v)) -} - -// VotedNEQ applies the NEQ predicate on the "voted" field. -func VotedNEQ(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNEQ(FieldVoted, v)) -} - -// VotedIn applies the In predicate on the "voted" field. -func VotedIn(vs ...*helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldIn(FieldVoted, vs...)) -} - -// VotedNotIn applies the NotIn predicate on the "voted" field. -func VotedNotIn(vs ...*helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldNotIn(FieldVoted, vs...)) -} - -// VotedGT applies the GT predicate on the "voted" field. -func VotedGT(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGT(FieldVoted, v)) -} - -// VotedGTE applies the GTE predicate on the "voted" field. -func VotedGTE(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldGTE(FieldVoted, v)) -} - -// VotedLT applies the LT predicate on the "voted" field. -func VotedLT(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLT(FieldVoted, v)) -} - -// VotedLTE applies the LTE predicate on the "voted" field. -func VotedLTE(v *helpers.BigInt) predicate.AssetPrice { - return predicate.AssetPrice(sql.FieldLTE(FieldVoted, v)) -} - -// HasSigners applies the HasEdge predicate on the "signers" edge. -func HasSigners() predicate.AssetPrice { - return predicate.AssetPrice(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, SignersTable, SignersPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasSignersWith applies the HasEdge predicate on the "signers" edge with a given conditions (other predicates). -func HasSignersWith(preds ...predicate.Signer) predicate.AssetPrice { - return predicate.AssetPrice(func(s *sql.Selector) { - step := newSignersStep() - 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.AssetPrice) predicate.AssetPrice { - return predicate.AssetPrice(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.AssetPrice) predicate.AssetPrice { - return predicate.AssetPrice(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.AssetPrice) predicate.AssetPrice { - return predicate.AssetPrice(sql.NotPredicates(p)) -} diff --git a/internal/ent/assetprice_create.go b/internal/ent/assetprice_create.go deleted file mode 100644 index d81c50b3..00000000 --- a/internal/ent/assetprice_create.go +++ /dev/null @@ -1,1077 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// AssetPriceCreate is the builder for creating a AssetPrice entity. -type AssetPriceCreate struct { - config - mutation *AssetPriceMutation - hooks []Hook - conflict []sql.ConflictOption -} - -// SetBlock sets the "block" field. -func (apc *AssetPriceCreate) SetBlock(u uint64) *AssetPriceCreate { - apc.mutation.SetBlock(u) - return apc -} - -// SetSignersCount sets the "signersCount" field. -func (apc *AssetPriceCreate) SetSignersCount(u uint64) *AssetPriceCreate { - apc.mutation.SetSignersCount(u) - return apc -} - -// SetNillableSignersCount sets the "signersCount" field if the given value is not nil. -func (apc *AssetPriceCreate) SetNillableSignersCount(u *uint64) *AssetPriceCreate { - if u != nil { - apc.SetSignersCount(*u) - } - return apc -} - -// SetPrice sets the "price" field. -func (apc *AssetPriceCreate) SetPrice(hi *helpers.BigInt) *AssetPriceCreate { - apc.mutation.SetPrice(hi) - return apc -} - -// SetSignature sets the "signature" field. -func (apc *AssetPriceCreate) SetSignature(b []byte) *AssetPriceCreate { - apc.mutation.SetSignature(b) - return apc -} - -// SetAsset sets the "asset" field. -func (apc *AssetPriceCreate) SetAsset(s string) *AssetPriceCreate { - apc.mutation.SetAsset(s) - return apc -} - -// SetNillableAsset sets the "asset" field if the given value is not nil. -func (apc *AssetPriceCreate) SetNillableAsset(s *string) *AssetPriceCreate { - if s != nil { - apc.SetAsset(*s) - } - return apc -} - -// SetChain sets the "chain" field. -func (apc *AssetPriceCreate) SetChain(s string) *AssetPriceCreate { - apc.mutation.SetChain(s) - return apc -} - -// SetNillableChain sets the "chain" field if the given value is not nil. -func (apc *AssetPriceCreate) SetNillableChain(s *string) *AssetPriceCreate { - if s != nil { - apc.SetChain(*s) - } - return apc -} - -// SetPair sets the "pair" field. -func (apc *AssetPriceCreate) SetPair(s string) *AssetPriceCreate { - apc.mutation.SetPair(s) - return apc -} - -// SetNillablePair sets the "pair" field if the given value is not nil. -func (apc *AssetPriceCreate) SetNillablePair(s *string) *AssetPriceCreate { - if s != nil { - apc.SetPair(*s) - } - return apc -} - -// SetConsensus sets the "consensus" field. -func (apc *AssetPriceCreate) SetConsensus(b bool) *AssetPriceCreate { - apc.mutation.SetConsensus(b) - return apc -} - -// SetNillableConsensus sets the "consensus" field if the given value is not nil. -func (apc *AssetPriceCreate) SetNillableConsensus(b *bool) *AssetPriceCreate { - if b != nil { - apc.SetConsensus(*b) - } - return apc -} - -// SetVoted sets the "voted" field. -func (apc *AssetPriceCreate) SetVoted(hi *helpers.BigInt) *AssetPriceCreate { - apc.mutation.SetVoted(hi) - return apc -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by IDs. -func (apc *AssetPriceCreate) AddSignerIDs(ids ...int) *AssetPriceCreate { - apc.mutation.AddSignerIDs(ids...) - return apc -} - -// AddSigners adds the "signers" edges to the Signer entity. -func (apc *AssetPriceCreate) AddSigners(s ...*Signer) *AssetPriceCreate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return apc.AddSignerIDs(ids...) -} - -// Mutation returns the AssetPriceMutation object of the builder. -func (apc *AssetPriceCreate) Mutation() *AssetPriceMutation { - return apc.mutation -} - -// Save creates the AssetPrice in the database. -func (apc *AssetPriceCreate) Save(ctx context.Context) (*AssetPrice, error) { - apc.defaults() - return withHooks(ctx, apc.sqlSave, apc.mutation, apc.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (apc *AssetPriceCreate) SaveX(ctx context.Context) *AssetPrice { - v, err := apc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (apc *AssetPriceCreate) Exec(ctx context.Context) error { - _, err := apc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (apc *AssetPriceCreate) ExecX(ctx context.Context) { - if err := apc.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (apc *AssetPriceCreate) defaults() { - if _, ok := apc.mutation.Consensus(); !ok { - v := assetprice.DefaultConsensus - apc.mutation.SetConsensus(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (apc *AssetPriceCreate) check() error { - if _, ok := apc.mutation.Block(); !ok { - return &ValidationError{Name: "block", err: errors.New(`ent: missing required field "AssetPrice.block"`)} - } - if _, ok := apc.mutation.Price(); !ok { - return &ValidationError{Name: "price", err: errors.New(`ent: missing required field "AssetPrice.price"`)} - } - if _, ok := apc.mutation.Signature(); !ok { - return &ValidationError{Name: "signature", err: errors.New(`ent: missing required field "AssetPrice.signature"`)} - } - if v, ok := apc.mutation.Signature(); ok { - if err := assetprice.SignatureValidator(v); err != nil { - return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "AssetPrice.signature": %w`, err)} - } - } - if _, ok := apc.mutation.Consensus(); !ok { - return &ValidationError{Name: "consensus", err: errors.New(`ent: missing required field "AssetPrice.consensus"`)} - } - if _, ok := apc.mutation.Voted(); !ok { - return &ValidationError{Name: "voted", err: errors.New(`ent: missing required field "AssetPrice.voted"`)} - } - if len(apc.mutation.SignersIDs()) == 0 { - return &ValidationError{Name: "signers", err: errors.New(`ent: missing required edge "AssetPrice.signers"`)} - } - return nil -} - -func (apc *AssetPriceCreate) sqlSave(ctx context.Context) (*AssetPrice, error) { - if err := apc.check(); err != nil { - return nil, err - } - _node, _spec := apc.createSpec() - if err := sqlgraph.CreateNode(ctx, apc.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) - apc.mutation.id = &_node.ID - apc.mutation.done = true - return _node, nil -} - -func (apc *AssetPriceCreate) createSpec() (*AssetPrice, *sqlgraph.CreateSpec) { - var ( - _node = &AssetPrice{config: apc.config} - _spec = sqlgraph.NewCreateSpec(assetprice.Table, sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt)) - ) - _spec.OnConflict = apc.conflict - if value, ok := apc.mutation.Block(); ok { - _spec.SetField(assetprice.FieldBlock, field.TypeUint64, value) - _node.Block = value - } - if value, ok := apc.mutation.SignersCount(); ok { - _spec.SetField(assetprice.FieldSignersCount, field.TypeUint64, value) - _node.SignersCount = &value - } - if value, ok := apc.mutation.Price(); ok { - _spec.SetField(assetprice.FieldPrice, field.TypeUint, value) - _node.Price = value - } - if value, ok := apc.mutation.Signature(); ok { - _spec.SetField(assetprice.FieldSignature, field.TypeBytes, value) - _node.Signature = value - } - if value, ok := apc.mutation.Asset(); ok { - _spec.SetField(assetprice.FieldAsset, field.TypeString, value) - _node.Asset = value - } - if value, ok := apc.mutation.Chain(); ok { - _spec.SetField(assetprice.FieldChain, field.TypeString, value) - _node.Chain = value - } - if value, ok := apc.mutation.Pair(); ok { - _spec.SetField(assetprice.FieldPair, field.TypeString, value) - _node.Pair = value - } - if value, ok := apc.mutation.Consensus(); ok { - _spec.SetField(assetprice.FieldConsensus, field.TypeBool, value) - _node.Consensus = value - } - if value, ok := apc.mutation.Voted(); ok { - _spec.SetField(assetprice.FieldVoted, field.TypeUint, value) - _node.Voted = value - } - if nodes := apc.mutation.SignersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: assetprice.SignersTable, - Columns: assetprice.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.AssetPrice.Create(). -// SetBlock(v). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.AssetPriceUpsert) { -// SetBlock(v+v). -// }). -// Exec(ctx) -func (apc *AssetPriceCreate) OnConflict(opts ...sql.ConflictOption) *AssetPriceUpsertOne { - apc.conflict = opts - return &AssetPriceUpsertOne{ - create: apc, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.AssetPrice.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (apc *AssetPriceCreate) OnConflictColumns(columns ...string) *AssetPriceUpsertOne { - apc.conflict = append(apc.conflict, sql.ConflictColumns(columns...)) - return &AssetPriceUpsertOne{ - create: apc, - } -} - -type ( - // AssetPriceUpsertOne is the builder for "upsert"-ing - // one AssetPrice node. - AssetPriceUpsertOne struct { - create *AssetPriceCreate - } - - // AssetPriceUpsert is the "OnConflict" setter. - AssetPriceUpsert struct { - *sql.UpdateSet - } -) - -// SetBlock sets the "block" field. -func (u *AssetPriceUpsert) SetBlock(v uint64) *AssetPriceUpsert { - u.Set(assetprice.FieldBlock, v) - return u -} - -// UpdateBlock sets the "block" field to the value that was provided on create. -func (u *AssetPriceUpsert) UpdateBlock() *AssetPriceUpsert { - u.SetExcluded(assetprice.FieldBlock) - return u -} - -// AddBlock adds v to the "block" field. -func (u *AssetPriceUpsert) AddBlock(v uint64) *AssetPriceUpsert { - u.Add(assetprice.FieldBlock, v) - return u -} - -// SetSignersCount sets the "signersCount" field. -func (u *AssetPriceUpsert) SetSignersCount(v uint64) *AssetPriceUpsert { - u.Set(assetprice.FieldSignersCount, v) - return u -} - -// UpdateSignersCount sets the "signersCount" field to the value that was provided on create. -func (u *AssetPriceUpsert) UpdateSignersCount() *AssetPriceUpsert { - u.SetExcluded(assetprice.FieldSignersCount) - return u -} - -// AddSignersCount adds v to the "signersCount" field. -func (u *AssetPriceUpsert) AddSignersCount(v uint64) *AssetPriceUpsert { - u.Add(assetprice.FieldSignersCount, v) - return u -} - -// ClearSignersCount clears the value of the "signersCount" field. -func (u *AssetPriceUpsert) ClearSignersCount() *AssetPriceUpsert { - u.SetNull(assetprice.FieldSignersCount) - return u -} - -// SetPrice sets the "price" field. -func (u *AssetPriceUpsert) SetPrice(v *helpers.BigInt) *AssetPriceUpsert { - u.Set(assetprice.FieldPrice, v) - return u -} - -// UpdatePrice sets the "price" field to the value that was provided on create. -func (u *AssetPriceUpsert) UpdatePrice() *AssetPriceUpsert { - u.SetExcluded(assetprice.FieldPrice) - return u -} - -// SetSignature sets the "signature" field. -func (u *AssetPriceUpsert) SetSignature(v []byte) *AssetPriceUpsert { - u.Set(assetprice.FieldSignature, v) - return u -} - -// UpdateSignature sets the "signature" field to the value that was provided on create. -func (u *AssetPriceUpsert) UpdateSignature() *AssetPriceUpsert { - u.SetExcluded(assetprice.FieldSignature) - return u -} - -// SetAsset sets the "asset" field. -func (u *AssetPriceUpsert) SetAsset(v string) *AssetPriceUpsert { - u.Set(assetprice.FieldAsset, v) - return u -} - -// UpdateAsset sets the "asset" field to the value that was provided on create. -func (u *AssetPriceUpsert) UpdateAsset() *AssetPriceUpsert { - u.SetExcluded(assetprice.FieldAsset) - return u -} - -// ClearAsset clears the value of the "asset" field. -func (u *AssetPriceUpsert) ClearAsset() *AssetPriceUpsert { - u.SetNull(assetprice.FieldAsset) - return u -} - -// SetChain sets the "chain" field. -func (u *AssetPriceUpsert) SetChain(v string) *AssetPriceUpsert { - u.Set(assetprice.FieldChain, v) - return u -} - -// UpdateChain sets the "chain" field to the value that was provided on create. -func (u *AssetPriceUpsert) UpdateChain() *AssetPriceUpsert { - u.SetExcluded(assetprice.FieldChain) - return u -} - -// ClearChain clears the value of the "chain" field. -func (u *AssetPriceUpsert) ClearChain() *AssetPriceUpsert { - u.SetNull(assetprice.FieldChain) - return u -} - -// SetPair sets the "pair" field. -func (u *AssetPriceUpsert) SetPair(v string) *AssetPriceUpsert { - u.Set(assetprice.FieldPair, v) - return u -} - -// UpdatePair sets the "pair" field to the value that was provided on create. -func (u *AssetPriceUpsert) UpdatePair() *AssetPriceUpsert { - u.SetExcluded(assetprice.FieldPair) - return u -} - -// ClearPair clears the value of the "pair" field. -func (u *AssetPriceUpsert) ClearPair() *AssetPriceUpsert { - u.SetNull(assetprice.FieldPair) - return u -} - -// SetConsensus sets the "consensus" field. -func (u *AssetPriceUpsert) SetConsensus(v bool) *AssetPriceUpsert { - u.Set(assetprice.FieldConsensus, v) - return u -} - -// UpdateConsensus sets the "consensus" field to the value that was provided on create. -func (u *AssetPriceUpsert) UpdateConsensus() *AssetPriceUpsert { - u.SetExcluded(assetprice.FieldConsensus) - return u -} - -// SetVoted sets the "voted" field. -func (u *AssetPriceUpsert) SetVoted(v *helpers.BigInt) *AssetPriceUpsert { - u.Set(assetprice.FieldVoted, v) - return u -} - -// UpdateVoted sets the "voted" field to the value that was provided on create. -func (u *AssetPriceUpsert) UpdateVoted() *AssetPriceUpsert { - u.SetExcluded(assetprice.FieldVoted) - return u -} - -// UpdateNewValues updates the mutable fields using the new values that were set on create. -// Using this option is equivalent to using: -// -// client.AssetPrice.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *AssetPriceUpsertOne) UpdateNewValues() *AssetPriceUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.AssetPrice.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *AssetPriceUpsertOne) Ignore() *AssetPriceUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *AssetPriceUpsertOne) DoNothing() *AssetPriceUpsertOne { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the AssetPriceCreate.OnConflict -// documentation for more info. -func (u *AssetPriceUpsertOne) Update(set func(*AssetPriceUpsert)) *AssetPriceUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&AssetPriceUpsert{UpdateSet: update}) - })) - return u -} - -// SetBlock sets the "block" field. -func (u *AssetPriceUpsertOne) SetBlock(v uint64) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.SetBlock(v) - }) -} - -// AddBlock adds v to the "block" field. -func (u *AssetPriceUpsertOne) AddBlock(v uint64) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.AddBlock(v) - }) -} - -// UpdateBlock sets the "block" field to the value that was provided on create. -func (u *AssetPriceUpsertOne) UpdateBlock() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateBlock() - }) -} - -// SetSignersCount sets the "signersCount" field. -func (u *AssetPriceUpsertOne) SetSignersCount(v uint64) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.SetSignersCount(v) - }) -} - -// AddSignersCount adds v to the "signersCount" field. -func (u *AssetPriceUpsertOne) AddSignersCount(v uint64) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.AddSignersCount(v) - }) -} - -// UpdateSignersCount sets the "signersCount" field to the value that was provided on create. -func (u *AssetPriceUpsertOne) UpdateSignersCount() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateSignersCount() - }) -} - -// ClearSignersCount clears the value of the "signersCount" field. -func (u *AssetPriceUpsertOne) ClearSignersCount() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.ClearSignersCount() - }) -} - -// SetPrice sets the "price" field. -func (u *AssetPriceUpsertOne) SetPrice(v *helpers.BigInt) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.SetPrice(v) - }) -} - -// UpdatePrice sets the "price" field to the value that was provided on create. -func (u *AssetPriceUpsertOne) UpdatePrice() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdatePrice() - }) -} - -// SetSignature sets the "signature" field. -func (u *AssetPriceUpsertOne) SetSignature(v []byte) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.SetSignature(v) - }) -} - -// UpdateSignature sets the "signature" field to the value that was provided on create. -func (u *AssetPriceUpsertOne) UpdateSignature() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateSignature() - }) -} - -// SetAsset sets the "asset" field. -func (u *AssetPriceUpsertOne) SetAsset(v string) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.SetAsset(v) - }) -} - -// UpdateAsset sets the "asset" field to the value that was provided on create. -func (u *AssetPriceUpsertOne) UpdateAsset() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateAsset() - }) -} - -// ClearAsset clears the value of the "asset" field. -func (u *AssetPriceUpsertOne) ClearAsset() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.ClearAsset() - }) -} - -// SetChain sets the "chain" field. -func (u *AssetPriceUpsertOne) SetChain(v string) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.SetChain(v) - }) -} - -// UpdateChain sets the "chain" field to the value that was provided on create. -func (u *AssetPriceUpsertOne) UpdateChain() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateChain() - }) -} - -// ClearChain clears the value of the "chain" field. -func (u *AssetPriceUpsertOne) ClearChain() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.ClearChain() - }) -} - -// SetPair sets the "pair" field. -func (u *AssetPriceUpsertOne) SetPair(v string) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.SetPair(v) - }) -} - -// UpdatePair sets the "pair" field to the value that was provided on create. -func (u *AssetPriceUpsertOne) UpdatePair() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdatePair() - }) -} - -// ClearPair clears the value of the "pair" field. -func (u *AssetPriceUpsertOne) ClearPair() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.ClearPair() - }) -} - -// SetConsensus sets the "consensus" field. -func (u *AssetPriceUpsertOne) SetConsensus(v bool) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.SetConsensus(v) - }) -} - -// UpdateConsensus sets the "consensus" field to the value that was provided on create. -func (u *AssetPriceUpsertOne) UpdateConsensus() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateConsensus() - }) -} - -// SetVoted sets the "voted" field. -func (u *AssetPriceUpsertOne) SetVoted(v *helpers.BigInt) *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.SetVoted(v) - }) -} - -// UpdateVoted sets the "voted" field to the value that was provided on create. -func (u *AssetPriceUpsertOne) UpdateVoted() *AssetPriceUpsertOne { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateVoted() - }) -} - -// Exec executes the query. -func (u *AssetPriceUpsertOne) Exec(ctx context.Context) error { - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for AssetPriceCreate.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *AssetPriceUpsertOne) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} - -// Exec executes the UPSERT query and returns the inserted/updated ID. -func (u *AssetPriceUpsertOne) ID(ctx context.Context) (id int, err error) { - node, err := u.create.Save(ctx) - if err != nil { - return id, err - } - return node.ID, nil -} - -// IDX is like ID, but panics if an error occurs. -func (u *AssetPriceUpsertOne) IDX(ctx context.Context) int { - id, err := u.ID(ctx) - if err != nil { - panic(err) - } - return id -} - -// AssetPriceCreateBulk is the builder for creating many AssetPrice entities in bulk. -type AssetPriceCreateBulk struct { - config - err error - builders []*AssetPriceCreate - conflict []sql.ConflictOption -} - -// Save creates the AssetPrice entities in the database. -func (apcb *AssetPriceCreateBulk) Save(ctx context.Context) ([]*AssetPrice, error) { - if apcb.err != nil { - return nil, apcb.err - } - specs := make([]*sqlgraph.CreateSpec, len(apcb.builders)) - nodes := make([]*AssetPrice, len(apcb.builders)) - mutators := make([]Mutator, len(apcb.builders)) - for i := range apcb.builders { - func(i int, root context.Context) { - builder := apcb.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*AssetPriceMutation) - 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, apcb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - spec.OnConflict = apcb.conflict - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, apcb.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, apcb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (apcb *AssetPriceCreateBulk) SaveX(ctx context.Context) []*AssetPrice { - v, err := apcb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (apcb *AssetPriceCreateBulk) Exec(ctx context.Context) error { - _, err := apcb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (apcb *AssetPriceCreateBulk) ExecX(ctx context.Context) { - if err := apcb.Exec(ctx); err != nil { - panic(err) - } -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.AssetPrice.CreateBulk(builders...). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.AssetPriceUpsert) { -// SetBlock(v+v). -// }). -// Exec(ctx) -func (apcb *AssetPriceCreateBulk) OnConflict(opts ...sql.ConflictOption) *AssetPriceUpsertBulk { - apcb.conflict = opts - return &AssetPriceUpsertBulk{ - create: apcb, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.AssetPrice.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (apcb *AssetPriceCreateBulk) OnConflictColumns(columns ...string) *AssetPriceUpsertBulk { - apcb.conflict = append(apcb.conflict, sql.ConflictColumns(columns...)) - return &AssetPriceUpsertBulk{ - create: apcb, - } -} - -// AssetPriceUpsertBulk is the builder for "upsert"-ing -// a bulk of AssetPrice nodes. -type AssetPriceUpsertBulk struct { - create *AssetPriceCreateBulk -} - -// UpdateNewValues updates the mutable fields using the new values that -// were set on create. Using this option is equivalent to using: -// -// client.AssetPrice.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *AssetPriceUpsertBulk) UpdateNewValues() *AssetPriceUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.AssetPrice.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *AssetPriceUpsertBulk) Ignore() *AssetPriceUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *AssetPriceUpsertBulk) DoNothing() *AssetPriceUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the AssetPriceCreateBulk.OnConflict -// documentation for more info. -func (u *AssetPriceUpsertBulk) Update(set func(*AssetPriceUpsert)) *AssetPriceUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&AssetPriceUpsert{UpdateSet: update}) - })) - return u -} - -// SetBlock sets the "block" field. -func (u *AssetPriceUpsertBulk) SetBlock(v uint64) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.SetBlock(v) - }) -} - -// AddBlock adds v to the "block" field. -func (u *AssetPriceUpsertBulk) AddBlock(v uint64) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.AddBlock(v) - }) -} - -// UpdateBlock sets the "block" field to the value that was provided on create. -func (u *AssetPriceUpsertBulk) UpdateBlock() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateBlock() - }) -} - -// SetSignersCount sets the "signersCount" field. -func (u *AssetPriceUpsertBulk) SetSignersCount(v uint64) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.SetSignersCount(v) - }) -} - -// AddSignersCount adds v to the "signersCount" field. -func (u *AssetPriceUpsertBulk) AddSignersCount(v uint64) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.AddSignersCount(v) - }) -} - -// UpdateSignersCount sets the "signersCount" field to the value that was provided on create. -func (u *AssetPriceUpsertBulk) UpdateSignersCount() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateSignersCount() - }) -} - -// ClearSignersCount clears the value of the "signersCount" field. -func (u *AssetPriceUpsertBulk) ClearSignersCount() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.ClearSignersCount() - }) -} - -// SetPrice sets the "price" field. -func (u *AssetPriceUpsertBulk) SetPrice(v *helpers.BigInt) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.SetPrice(v) - }) -} - -// UpdatePrice sets the "price" field to the value that was provided on create. -func (u *AssetPriceUpsertBulk) UpdatePrice() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdatePrice() - }) -} - -// SetSignature sets the "signature" field. -func (u *AssetPriceUpsertBulk) SetSignature(v []byte) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.SetSignature(v) - }) -} - -// UpdateSignature sets the "signature" field to the value that was provided on create. -func (u *AssetPriceUpsertBulk) UpdateSignature() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateSignature() - }) -} - -// SetAsset sets the "asset" field. -func (u *AssetPriceUpsertBulk) SetAsset(v string) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.SetAsset(v) - }) -} - -// UpdateAsset sets the "asset" field to the value that was provided on create. -func (u *AssetPriceUpsertBulk) UpdateAsset() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateAsset() - }) -} - -// ClearAsset clears the value of the "asset" field. -func (u *AssetPriceUpsertBulk) ClearAsset() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.ClearAsset() - }) -} - -// SetChain sets the "chain" field. -func (u *AssetPriceUpsertBulk) SetChain(v string) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.SetChain(v) - }) -} - -// UpdateChain sets the "chain" field to the value that was provided on create. -func (u *AssetPriceUpsertBulk) UpdateChain() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateChain() - }) -} - -// ClearChain clears the value of the "chain" field. -func (u *AssetPriceUpsertBulk) ClearChain() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.ClearChain() - }) -} - -// SetPair sets the "pair" field. -func (u *AssetPriceUpsertBulk) SetPair(v string) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.SetPair(v) - }) -} - -// UpdatePair sets the "pair" field to the value that was provided on create. -func (u *AssetPriceUpsertBulk) UpdatePair() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdatePair() - }) -} - -// ClearPair clears the value of the "pair" field. -func (u *AssetPriceUpsertBulk) ClearPair() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.ClearPair() - }) -} - -// SetConsensus sets the "consensus" field. -func (u *AssetPriceUpsertBulk) SetConsensus(v bool) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.SetConsensus(v) - }) -} - -// UpdateConsensus sets the "consensus" field to the value that was provided on create. -func (u *AssetPriceUpsertBulk) UpdateConsensus() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateConsensus() - }) -} - -// SetVoted sets the "voted" field. -func (u *AssetPriceUpsertBulk) SetVoted(v *helpers.BigInt) *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.SetVoted(v) - }) -} - -// UpdateVoted sets the "voted" field to the value that was provided on create. -func (u *AssetPriceUpsertBulk) UpdateVoted() *AssetPriceUpsertBulk { - return u.Update(func(s *AssetPriceUpsert) { - s.UpdateVoted() - }) -} - -// Exec executes the query. -func (u *AssetPriceUpsertBulk) Exec(ctx context.Context) error { - if u.create.err != nil { - return u.create.err - } - for i, b := range u.create.builders { - if len(b.conflict) != 0 { - return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the AssetPriceCreateBulk instead", i) - } - } - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for AssetPriceCreateBulk.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *AssetPriceUpsertBulk) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/ent/assetprice_delete.go b/internal/ent/assetprice_delete.go deleted file mode 100644 index 3e83a733..00000000 --- a/internal/ent/assetprice_delete.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" -) - -// AssetPriceDelete is the builder for deleting a AssetPrice entity. -type AssetPriceDelete struct { - config - hooks []Hook - mutation *AssetPriceMutation -} - -// Where appends a list predicates to the AssetPriceDelete builder. -func (apd *AssetPriceDelete) Where(ps ...predicate.AssetPrice) *AssetPriceDelete { - apd.mutation.Where(ps...) - return apd -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (apd *AssetPriceDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, apd.sqlExec, apd.mutation, apd.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (apd *AssetPriceDelete) ExecX(ctx context.Context) int { - n, err := apd.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (apd *AssetPriceDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(assetprice.Table, sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt)) - if ps := apd.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, apd.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - apd.mutation.done = true - return affected, err -} - -// AssetPriceDeleteOne is the builder for deleting a single AssetPrice entity. -type AssetPriceDeleteOne struct { - apd *AssetPriceDelete -} - -// Where appends a list predicates to the AssetPriceDelete builder. -func (apdo *AssetPriceDeleteOne) Where(ps ...predicate.AssetPrice) *AssetPriceDeleteOne { - apdo.apd.mutation.Where(ps...) - return apdo -} - -// Exec executes the deletion query. -func (apdo *AssetPriceDeleteOne) Exec(ctx context.Context) error { - n, err := apdo.apd.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{assetprice.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (apdo *AssetPriceDeleteOne) ExecX(ctx context.Context) { - if err := apdo.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/ent/assetprice_query.go b/internal/ent/assetprice_query.go deleted file mode 100644 index 12624a34..00000000 --- a/internal/ent/assetprice_query.go +++ /dev/null @@ -1,671 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "database/sql/driver" - "fmt" - "math" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// AssetPriceQuery is the builder for querying AssetPrice entities. -type AssetPriceQuery struct { - config - ctx *QueryContext - order []assetprice.OrderOption - inters []Interceptor - predicates []predicate.AssetPrice - withSigners *SignerQuery - modifiers []func(*sql.Selector) - loadTotal []func(context.Context, []*AssetPrice) error - withNamedSigners map[string]*SignerQuery - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the AssetPriceQuery builder. -func (apq *AssetPriceQuery) Where(ps ...predicate.AssetPrice) *AssetPriceQuery { - apq.predicates = append(apq.predicates, ps...) - return apq -} - -// Limit the number of records to be returned by this query. -func (apq *AssetPriceQuery) Limit(limit int) *AssetPriceQuery { - apq.ctx.Limit = &limit - return apq -} - -// Offset to start from. -func (apq *AssetPriceQuery) Offset(offset int) *AssetPriceQuery { - apq.ctx.Offset = &offset - return apq -} - -// 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 (apq *AssetPriceQuery) Unique(unique bool) *AssetPriceQuery { - apq.ctx.Unique = &unique - return apq -} - -// Order specifies how the records should be ordered. -func (apq *AssetPriceQuery) Order(o ...assetprice.OrderOption) *AssetPriceQuery { - apq.order = append(apq.order, o...) - return apq -} - -// QuerySigners chains the current query on the "signers" edge. -func (apq *AssetPriceQuery) QuerySigners() *SignerQuery { - query := (&SignerClient{config: apq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := apq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := apq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(assetprice.Table, assetprice.FieldID, selector), - sqlgraph.To(signer.Table, signer.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, assetprice.SignersTable, assetprice.SignersPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(apq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first AssetPrice entity from the query. -// Returns a *NotFoundError when no AssetPrice was found. -func (apq *AssetPriceQuery) First(ctx context.Context) (*AssetPrice, error) { - nodes, err := apq.Limit(1).All(setContextOp(ctx, apq.ctx, "First")) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{assetprice.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (apq *AssetPriceQuery) FirstX(ctx context.Context) *AssetPrice { - node, err := apq.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first AssetPrice ID from the query. -// Returns a *NotFoundError when no AssetPrice ID was found. -func (apq *AssetPriceQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = apq.Limit(1).IDs(setContextOp(ctx, apq.ctx, "FirstID")); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{assetprice.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (apq *AssetPriceQuery) FirstIDX(ctx context.Context) int { - id, err := apq.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single AssetPrice entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one AssetPrice entity is found. -// Returns a *NotFoundError when no AssetPrice entities are found. -func (apq *AssetPriceQuery) Only(ctx context.Context) (*AssetPrice, error) { - nodes, err := apq.Limit(2).All(setContextOp(ctx, apq.ctx, "Only")) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{assetprice.Label} - default: - return nil, &NotSingularError{assetprice.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (apq *AssetPriceQuery) OnlyX(ctx context.Context) *AssetPrice { - node, err := apq.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only AssetPrice ID in the query. -// Returns a *NotSingularError when more than one AssetPrice ID is found. -// Returns a *NotFoundError when no entities are found. -func (apq *AssetPriceQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = apq.Limit(2).IDs(setContextOp(ctx, apq.ctx, "OnlyID")); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{assetprice.Label} - default: - err = &NotSingularError{assetprice.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (apq *AssetPriceQuery) OnlyIDX(ctx context.Context) int { - id, err := apq.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of AssetPrices. -func (apq *AssetPriceQuery) All(ctx context.Context) ([]*AssetPrice, error) { - ctx = setContextOp(ctx, apq.ctx, "All") - if err := apq.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*AssetPrice, *AssetPriceQuery]() - return withInterceptors[[]*AssetPrice](ctx, apq, qr, apq.inters) -} - -// AllX is like All, but panics if an error occurs. -func (apq *AssetPriceQuery) AllX(ctx context.Context) []*AssetPrice { - nodes, err := apq.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of AssetPrice IDs. -func (apq *AssetPriceQuery) IDs(ctx context.Context) (ids []int, err error) { - if apq.ctx.Unique == nil && apq.path != nil { - apq.Unique(true) - } - ctx = setContextOp(ctx, apq.ctx, "IDs") - if err = apq.Select(assetprice.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (apq *AssetPriceQuery) IDsX(ctx context.Context) []int { - ids, err := apq.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (apq *AssetPriceQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, apq.ctx, "Count") - if err := apq.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, apq, querierCount[*AssetPriceQuery](), apq.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (apq *AssetPriceQuery) CountX(ctx context.Context) int { - count, err := apq.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (apq *AssetPriceQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, apq.ctx, "Exist") - switch _, err := apq.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 (apq *AssetPriceQuery) ExistX(ctx context.Context) bool { - exist, err := apq.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the AssetPriceQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (apq *AssetPriceQuery) Clone() *AssetPriceQuery { - if apq == nil { - return nil - } - return &AssetPriceQuery{ - config: apq.config, - ctx: apq.ctx.Clone(), - order: append([]assetprice.OrderOption{}, apq.order...), - inters: append([]Interceptor{}, apq.inters...), - predicates: append([]predicate.AssetPrice{}, apq.predicates...), - withSigners: apq.withSigners.Clone(), - // clone intermediate query. - sql: apq.sql.Clone(), - path: apq.path, - } -} - -// WithSigners tells the query-builder to eager-load the nodes that are connected to -// the "signers" edge. The optional arguments are used to configure the query builder of the edge. -func (apq *AssetPriceQuery) WithSigners(opts ...func(*SignerQuery)) *AssetPriceQuery { - query := (&SignerClient{config: apq.config}).Query() - for _, opt := range opts { - opt(query) - } - apq.withSigners = query - return apq -} - -// 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 { -// Block uint64 `json:"block,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.AssetPrice.Query(). -// GroupBy(assetprice.FieldBlock). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (apq *AssetPriceQuery) GroupBy(field string, fields ...string) *AssetPriceGroupBy { - apq.ctx.Fields = append([]string{field}, fields...) - grbuild := &AssetPriceGroupBy{build: apq} - grbuild.flds = &apq.ctx.Fields - grbuild.label = assetprice.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 { -// Block uint64 `json:"block,omitempty"` -// } -// -// client.AssetPrice.Query(). -// Select(assetprice.FieldBlock). -// Scan(ctx, &v) -func (apq *AssetPriceQuery) Select(fields ...string) *AssetPriceSelect { - apq.ctx.Fields = append(apq.ctx.Fields, fields...) - sbuild := &AssetPriceSelect{AssetPriceQuery: apq} - sbuild.label = assetprice.Label - sbuild.flds, sbuild.scan = &apq.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a AssetPriceSelect configured with the given aggregations. -func (apq *AssetPriceQuery) Aggregate(fns ...AggregateFunc) *AssetPriceSelect { - return apq.Select().Aggregate(fns...) -} - -func (apq *AssetPriceQuery) prepareQuery(ctx context.Context) error { - for _, inter := range apq.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, apq); err != nil { - return err - } - } - } - for _, f := range apq.ctx.Fields { - if !assetprice.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if apq.path != nil { - prev, err := apq.path(ctx) - if err != nil { - return err - } - apq.sql = prev - } - return nil -} - -func (apq *AssetPriceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AssetPrice, error) { - var ( - nodes = []*AssetPrice{} - _spec = apq.querySpec() - loadedTypes = [1]bool{ - apq.withSigners != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*AssetPrice).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &AssetPrice{config: apq.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(apq.modifiers) > 0 { - _spec.Modifiers = apq.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, apq.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := apq.withSigners; query != nil { - if err := apq.loadSigners(ctx, query, nodes, - func(n *AssetPrice) { n.Edges.Signers = []*Signer{} }, - func(n *AssetPrice, e *Signer) { n.Edges.Signers = append(n.Edges.Signers, e) }); err != nil { - return nil, err - } - } - for name, query := range apq.withNamedSigners { - if err := apq.loadSigners(ctx, query, nodes, - func(n *AssetPrice) { n.appendNamedSigners(name) }, - func(n *AssetPrice, e *Signer) { n.appendNamedSigners(name, e) }); err != nil { - return nil, err - } - } - for i := range apq.loadTotal { - if err := apq.loadTotal[i](ctx, nodes); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (apq *AssetPriceQuery) loadSigners(ctx context.Context, query *SignerQuery, nodes []*AssetPrice, init func(*AssetPrice), assign func(*AssetPrice, *Signer)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int]*AssetPrice) - nids := make(map[int]map[*AssetPrice]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(assetprice.SignersTable) - s.Join(joinT).On(s.C(signer.FieldID), joinT.C(assetprice.SignersPrimaryKey[1])) - s.Where(sql.InValues(joinT.C(assetprice.SignersPrimaryKey[0]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(assetprice.SignersPrimaryKey[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[*AssetPrice]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*Signer](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 "signers" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} - -func (apq *AssetPriceQuery) sqlCount(ctx context.Context) (int, error) { - _spec := apq.querySpec() - if len(apq.modifiers) > 0 { - _spec.Modifiers = apq.modifiers - } - _spec.Node.Columns = apq.ctx.Fields - if len(apq.ctx.Fields) > 0 { - _spec.Unique = apq.ctx.Unique != nil && *apq.ctx.Unique - } - return sqlgraph.CountNodes(ctx, apq.driver, _spec) -} - -func (apq *AssetPriceQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(assetprice.Table, assetprice.Columns, sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt)) - _spec.From = apq.sql - if unique := apq.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if apq.path != nil { - _spec.Unique = true - } - if fields := apq.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, assetprice.FieldID) - for i := range fields { - if fields[i] != assetprice.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := apq.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := apq.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := apq.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := apq.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (apq *AssetPriceQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(apq.driver.Dialect()) - t1 := builder.Table(assetprice.Table) - columns := apq.ctx.Fields - if len(columns) == 0 { - columns = assetprice.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if apq.sql != nil { - selector = apq.sql - selector.Select(selector.Columns(columns...)...) - } - if apq.ctx.Unique != nil && *apq.ctx.Unique { - selector.Distinct() - } - for _, p := range apq.predicates { - p(selector) - } - for _, p := range apq.order { - p(selector) - } - if offset := apq.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 := apq.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// WithNamedSigners tells the query-builder to eager-load the nodes that are connected to the "signers" -// edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (apq *AssetPriceQuery) WithNamedSigners(name string, opts ...func(*SignerQuery)) *AssetPriceQuery { - query := (&SignerClient{config: apq.config}).Query() - for _, opt := range opts { - opt(query) - } - if apq.withNamedSigners == nil { - apq.withNamedSigners = make(map[string]*SignerQuery) - } - apq.withNamedSigners[name] = query - return apq -} - -// AssetPriceGroupBy is the group-by builder for AssetPrice entities. -type AssetPriceGroupBy struct { - selector - build *AssetPriceQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (apgb *AssetPriceGroupBy) Aggregate(fns ...AggregateFunc) *AssetPriceGroupBy { - apgb.fns = append(apgb.fns, fns...) - return apgb -} - -// Scan applies the selector query and scans the result into the given value. -func (apgb *AssetPriceGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, apgb.build.ctx, "GroupBy") - if err := apgb.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*AssetPriceQuery, *AssetPriceGroupBy](ctx, apgb.build, apgb, apgb.build.inters, v) -} - -func (apgb *AssetPriceGroupBy) sqlScan(ctx context.Context, root *AssetPriceQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(apgb.fns)) - for _, fn := range apgb.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*apgb.flds)+len(apgb.fns)) - for _, f := range *apgb.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*apgb.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := apgb.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// AssetPriceSelect is the builder for selecting fields of AssetPrice entities. -type AssetPriceSelect struct { - *AssetPriceQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (aps *AssetPriceSelect) Aggregate(fns ...AggregateFunc) *AssetPriceSelect { - aps.fns = append(aps.fns, fns...) - return aps -} - -// Scan applies the selector query and scans the result into the given value. -func (aps *AssetPriceSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, aps.ctx, "Select") - if err := aps.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*AssetPriceQuery, *AssetPriceSelect](ctx, aps.AssetPriceQuery, aps, aps.inters, v) -} - -func (aps *AssetPriceSelect) sqlScan(ctx context.Context, root *AssetPriceQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(aps.fns)) - for _, fn := range aps.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*aps.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 := aps.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} diff --git a/internal/ent/assetprice_update.go b/internal/ent/assetprice_update.go deleted file mode 100644 index 5d1cb9e5..00000000 --- a/internal/ent/assetprice_update.go +++ /dev/null @@ -1,735 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// AssetPriceUpdate is the builder for updating AssetPrice entities. -type AssetPriceUpdate struct { - config - hooks []Hook - mutation *AssetPriceMutation -} - -// Where appends a list predicates to the AssetPriceUpdate builder. -func (apu *AssetPriceUpdate) Where(ps ...predicate.AssetPrice) *AssetPriceUpdate { - apu.mutation.Where(ps...) - return apu -} - -// SetBlock sets the "block" field. -func (apu *AssetPriceUpdate) SetBlock(u uint64) *AssetPriceUpdate { - apu.mutation.ResetBlock() - apu.mutation.SetBlock(u) - return apu -} - -// SetNillableBlock sets the "block" field if the given value is not nil. -func (apu *AssetPriceUpdate) SetNillableBlock(u *uint64) *AssetPriceUpdate { - if u != nil { - apu.SetBlock(*u) - } - return apu -} - -// AddBlock adds u to the "block" field. -func (apu *AssetPriceUpdate) AddBlock(u int64) *AssetPriceUpdate { - apu.mutation.AddBlock(u) - return apu -} - -// SetSignersCount sets the "signersCount" field. -func (apu *AssetPriceUpdate) SetSignersCount(u uint64) *AssetPriceUpdate { - apu.mutation.ResetSignersCount() - apu.mutation.SetSignersCount(u) - return apu -} - -// SetNillableSignersCount sets the "signersCount" field if the given value is not nil. -func (apu *AssetPriceUpdate) SetNillableSignersCount(u *uint64) *AssetPriceUpdate { - if u != nil { - apu.SetSignersCount(*u) - } - return apu -} - -// AddSignersCount adds u to the "signersCount" field. -func (apu *AssetPriceUpdate) AddSignersCount(u int64) *AssetPriceUpdate { - apu.mutation.AddSignersCount(u) - return apu -} - -// ClearSignersCount clears the value of the "signersCount" field. -func (apu *AssetPriceUpdate) ClearSignersCount() *AssetPriceUpdate { - apu.mutation.ClearSignersCount() - return apu -} - -// SetPrice sets the "price" field. -func (apu *AssetPriceUpdate) SetPrice(hi *helpers.BigInt) *AssetPriceUpdate { - apu.mutation.SetPrice(hi) - return apu -} - -// SetSignature sets the "signature" field. -func (apu *AssetPriceUpdate) SetSignature(b []byte) *AssetPriceUpdate { - apu.mutation.SetSignature(b) - return apu -} - -// SetAsset sets the "asset" field. -func (apu *AssetPriceUpdate) SetAsset(s string) *AssetPriceUpdate { - apu.mutation.SetAsset(s) - return apu -} - -// SetNillableAsset sets the "asset" field if the given value is not nil. -func (apu *AssetPriceUpdate) SetNillableAsset(s *string) *AssetPriceUpdate { - if s != nil { - apu.SetAsset(*s) - } - return apu -} - -// ClearAsset clears the value of the "asset" field. -func (apu *AssetPriceUpdate) ClearAsset() *AssetPriceUpdate { - apu.mutation.ClearAsset() - return apu -} - -// SetChain sets the "chain" field. -func (apu *AssetPriceUpdate) SetChain(s string) *AssetPriceUpdate { - apu.mutation.SetChain(s) - return apu -} - -// SetNillableChain sets the "chain" field if the given value is not nil. -func (apu *AssetPriceUpdate) SetNillableChain(s *string) *AssetPriceUpdate { - if s != nil { - apu.SetChain(*s) - } - return apu -} - -// ClearChain clears the value of the "chain" field. -func (apu *AssetPriceUpdate) ClearChain() *AssetPriceUpdate { - apu.mutation.ClearChain() - return apu -} - -// SetPair sets the "pair" field. -func (apu *AssetPriceUpdate) SetPair(s string) *AssetPriceUpdate { - apu.mutation.SetPair(s) - return apu -} - -// SetNillablePair sets the "pair" field if the given value is not nil. -func (apu *AssetPriceUpdate) SetNillablePair(s *string) *AssetPriceUpdate { - if s != nil { - apu.SetPair(*s) - } - return apu -} - -// ClearPair clears the value of the "pair" field. -func (apu *AssetPriceUpdate) ClearPair() *AssetPriceUpdate { - apu.mutation.ClearPair() - return apu -} - -// SetConsensus sets the "consensus" field. -func (apu *AssetPriceUpdate) SetConsensus(b bool) *AssetPriceUpdate { - apu.mutation.SetConsensus(b) - return apu -} - -// SetNillableConsensus sets the "consensus" field if the given value is not nil. -func (apu *AssetPriceUpdate) SetNillableConsensus(b *bool) *AssetPriceUpdate { - if b != nil { - apu.SetConsensus(*b) - } - return apu -} - -// SetVoted sets the "voted" field. -func (apu *AssetPriceUpdate) SetVoted(hi *helpers.BigInt) *AssetPriceUpdate { - apu.mutation.SetVoted(hi) - return apu -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by IDs. -func (apu *AssetPriceUpdate) AddSignerIDs(ids ...int) *AssetPriceUpdate { - apu.mutation.AddSignerIDs(ids...) - return apu -} - -// AddSigners adds the "signers" edges to the Signer entity. -func (apu *AssetPriceUpdate) AddSigners(s ...*Signer) *AssetPriceUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return apu.AddSignerIDs(ids...) -} - -// Mutation returns the AssetPriceMutation object of the builder. -func (apu *AssetPriceUpdate) Mutation() *AssetPriceMutation { - return apu.mutation -} - -// ClearSigners clears all "signers" edges to the Signer entity. -func (apu *AssetPriceUpdate) ClearSigners() *AssetPriceUpdate { - apu.mutation.ClearSigners() - return apu -} - -// RemoveSignerIDs removes the "signers" edge to Signer entities by IDs. -func (apu *AssetPriceUpdate) RemoveSignerIDs(ids ...int) *AssetPriceUpdate { - apu.mutation.RemoveSignerIDs(ids...) - return apu -} - -// RemoveSigners removes "signers" edges to Signer entities. -func (apu *AssetPriceUpdate) RemoveSigners(s ...*Signer) *AssetPriceUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return apu.RemoveSignerIDs(ids...) -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (apu *AssetPriceUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, apu.sqlSave, apu.mutation, apu.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (apu *AssetPriceUpdate) SaveX(ctx context.Context) int { - affected, err := apu.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (apu *AssetPriceUpdate) Exec(ctx context.Context) error { - _, err := apu.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (apu *AssetPriceUpdate) ExecX(ctx context.Context) { - if err := apu.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (apu *AssetPriceUpdate) check() error { - if v, ok := apu.mutation.Signature(); ok { - if err := assetprice.SignatureValidator(v); err != nil { - return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "AssetPrice.signature": %w`, err)} - } - } - return nil -} - -func (apu *AssetPriceUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := apu.check(); err != nil { - return n, err - } - _spec := sqlgraph.NewUpdateSpec(assetprice.Table, assetprice.Columns, sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt)) - if ps := apu.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := apu.mutation.Block(); ok { - _spec.SetField(assetprice.FieldBlock, field.TypeUint64, value) - } - if value, ok := apu.mutation.AddedBlock(); ok { - _spec.AddField(assetprice.FieldBlock, field.TypeUint64, value) - } - if value, ok := apu.mutation.SignersCount(); ok { - _spec.SetField(assetprice.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := apu.mutation.AddedSignersCount(); ok { - _spec.AddField(assetprice.FieldSignersCount, field.TypeUint64, value) - } - if apu.mutation.SignersCountCleared() { - _spec.ClearField(assetprice.FieldSignersCount, field.TypeUint64) - } - if value, ok := apu.mutation.Price(); ok { - _spec.SetField(assetprice.FieldPrice, field.TypeUint, value) - } - if value, ok := apu.mutation.Signature(); ok { - _spec.SetField(assetprice.FieldSignature, field.TypeBytes, value) - } - if value, ok := apu.mutation.Asset(); ok { - _spec.SetField(assetprice.FieldAsset, field.TypeString, value) - } - if apu.mutation.AssetCleared() { - _spec.ClearField(assetprice.FieldAsset, field.TypeString) - } - if value, ok := apu.mutation.Chain(); ok { - _spec.SetField(assetprice.FieldChain, field.TypeString, value) - } - if apu.mutation.ChainCleared() { - _spec.ClearField(assetprice.FieldChain, field.TypeString) - } - if value, ok := apu.mutation.Pair(); ok { - _spec.SetField(assetprice.FieldPair, field.TypeString, value) - } - if apu.mutation.PairCleared() { - _spec.ClearField(assetprice.FieldPair, field.TypeString) - } - if value, ok := apu.mutation.Consensus(); ok { - _spec.SetField(assetprice.FieldConsensus, field.TypeBool, value) - } - if value, ok := apu.mutation.Voted(); ok { - _spec.SetField(assetprice.FieldVoted, field.TypeUint, value) - } - if apu.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: assetprice.SignersTable, - Columns: assetprice.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := apu.mutation.RemovedSignersIDs(); len(nodes) > 0 && !apu.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: assetprice.SignersTable, - Columns: assetprice.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.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 := apu.mutation.SignersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: assetprice.SignersTable, - Columns: assetprice.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.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, apu.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{assetprice.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - apu.mutation.done = true - return n, nil -} - -// AssetPriceUpdateOne is the builder for updating a single AssetPrice entity. -type AssetPriceUpdateOne struct { - config - fields []string - hooks []Hook - mutation *AssetPriceMutation -} - -// SetBlock sets the "block" field. -func (apuo *AssetPriceUpdateOne) SetBlock(u uint64) *AssetPriceUpdateOne { - apuo.mutation.ResetBlock() - apuo.mutation.SetBlock(u) - return apuo -} - -// SetNillableBlock sets the "block" field if the given value is not nil. -func (apuo *AssetPriceUpdateOne) SetNillableBlock(u *uint64) *AssetPriceUpdateOne { - if u != nil { - apuo.SetBlock(*u) - } - return apuo -} - -// AddBlock adds u to the "block" field. -func (apuo *AssetPriceUpdateOne) AddBlock(u int64) *AssetPriceUpdateOne { - apuo.mutation.AddBlock(u) - return apuo -} - -// SetSignersCount sets the "signersCount" field. -func (apuo *AssetPriceUpdateOne) SetSignersCount(u uint64) *AssetPriceUpdateOne { - apuo.mutation.ResetSignersCount() - apuo.mutation.SetSignersCount(u) - return apuo -} - -// SetNillableSignersCount sets the "signersCount" field if the given value is not nil. -func (apuo *AssetPriceUpdateOne) SetNillableSignersCount(u *uint64) *AssetPriceUpdateOne { - if u != nil { - apuo.SetSignersCount(*u) - } - return apuo -} - -// AddSignersCount adds u to the "signersCount" field. -func (apuo *AssetPriceUpdateOne) AddSignersCount(u int64) *AssetPriceUpdateOne { - apuo.mutation.AddSignersCount(u) - return apuo -} - -// ClearSignersCount clears the value of the "signersCount" field. -func (apuo *AssetPriceUpdateOne) ClearSignersCount() *AssetPriceUpdateOne { - apuo.mutation.ClearSignersCount() - return apuo -} - -// SetPrice sets the "price" field. -func (apuo *AssetPriceUpdateOne) SetPrice(hi *helpers.BigInt) *AssetPriceUpdateOne { - apuo.mutation.SetPrice(hi) - return apuo -} - -// SetSignature sets the "signature" field. -func (apuo *AssetPriceUpdateOne) SetSignature(b []byte) *AssetPriceUpdateOne { - apuo.mutation.SetSignature(b) - return apuo -} - -// SetAsset sets the "asset" field. -func (apuo *AssetPriceUpdateOne) SetAsset(s string) *AssetPriceUpdateOne { - apuo.mutation.SetAsset(s) - return apuo -} - -// SetNillableAsset sets the "asset" field if the given value is not nil. -func (apuo *AssetPriceUpdateOne) SetNillableAsset(s *string) *AssetPriceUpdateOne { - if s != nil { - apuo.SetAsset(*s) - } - return apuo -} - -// ClearAsset clears the value of the "asset" field. -func (apuo *AssetPriceUpdateOne) ClearAsset() *AssetPriceUpdateOne { - apuo.mutation.ClearAsset() - return apuo -} - -// SetChain sets the "chain" field. -func (apuo *AssetPriceUpdateOne) SetChain(s string) *AssetPriceUpdateOne { - apuo.mutation.SetChain(s) - return apuo -} - -// SetNillableChain sets the "chain" field if the given value is not nil. -func (apuo *AssetPriceUpdateOne) SetNillableChain(s *string) *AssetPriceUpdateOne { - if s != nil { - apuo.SetChain(*s) - } - return apuo -} - -// ClearChain clears the value of the "chain" field. -func (apuo *AssetPriceUpdateOne) ClearChain() *AssetPriceUpdateOne { - apuo.mutation.ClearChain() - return apuo -} - -// SetPair sets the "pair" field. -func (apuo *AssetPriceUpdateOne) SetPair(s string) *AssetPriceUpdateOne { - apuo.mutation.SetPair(s) - return apuo -} - -// SetNillablePair sets the "pair" field if the given value is not nil. -func (apuo *AssetPriceUpdateOne) SetNillablePair(s *string) *AssetPriceUpdateOne { - if s != nil { - apuo.SetPair(*s) - } - return apuo -} - -// ClearPair clears the value of the "pair" field. -func (apuo *AssetPriceUpdateOne) ClearPair() *AssetPriceUpdateOne { - apuo.mutation.ClearPair() - return apuo -} - -// SetConsensus sets the "consensus" field. -func (apuo *AssetPriceUpdateOne) SetConsensus(b bool) *AssetPriceUpdateOne { - apuo.mutation.SetConsensus(b) - return apuo -} - -// SetNillableConsensus sets the "consensus" field if the given value is not nil. -func (apuo *AssetPriceUpdateOne) SetNillableConsensus(b *bool) *AssetPriceUpdateOne { - if b != nil { - apuo.SetConsensus(*b) - } - return apuo -} - -// SetVoted sets the "voted" field. -func (apuo *AssetPriceUpdateOne) SetVoted(hi *helpers.BigInt) *AssetPriceUpdateOne { - apuo.mutation.SetVoted(hi) - return apuo -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by IDs. -func (apuo *AssetPriceUpdateOne) AddSignerIDs(ids ...int) *AssetPriceUpdateOne { - apuo.mutation.AddSignerIDs(ids...) - return apuo -} - -// AddSigners adds the "signers" edges to the Signer entity. -func (apuo *AssetPriceUpdateOne) AddSigners(s ...*Signer) *AssetPriceUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return apuo.AddSignerIDs(ids...) -} - -// Mutation returns the AssetPriceMutation object of the builder. -func (apuo *AssetPriceUpdateOne) Mutation() *AssetPriceMutation { - return apuo.mutation -} - -// ClearSigners clears all "signers" edges to the Signer entity. -func (apuo *AssetPriceUpdateOne) ClearSigners() *AssetPriceUpdateOne { - apuo.mutation.ClearSigners() - return apuo -} - -// RemoveSignerIDs removes the "signers" edge to Signer entities by IDs. -func (apuo *AssetPriceUpdateOne) RemoveSignerIDs(ids ...int) *AssetPriceUpdateOne { - apuo.mutation.RemoveSignerIDs(ids...) - return apuo -} - -// RemoveSigners removes "signers" edges to Signer entities. -func (apuo *AssetPriceUpdateOne) RemoveSigners(s ...*Signer) *AssetPriceUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return apuo.RemoveSignerIDs(ids...) -} - -// Where appends a list predicates to the AssetPriceUpdate builder. -func (apuo *AssetPriceUpdateOne) Where(ps ...predicate.AssetPrice) *AssetPriceUpdateOne { - apuo.mutation.Where(ps...) - return apuo -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (apuo *AssetPriceUpdateOne) Select(field string, fields ...string) *AssetPriceUpdateOne { - apuo.fields = append([]string{field}, fields...) - return apuo -} - -// Save executes the query and returns the updated AssetPrice entity. -func (apuo *AssetPriceUpdateOne) Save(ctx context.Context) (*AssetPrice, error) { - return withHooks(ctx, apuo.sqlSave, apuo.mutation, apuo.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (apuo *AssetPriceUpdateOne) SaveX(ctx context.Context) *AssetPrice { - node, err := apuo.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (apuo *AssetPriceUpdateOne) Exec(ctx context.Context) error { - _, err := apuo.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (apuo *AssetPriceUpdateOne) ExecX(ctx context.Context) { - if err := apuo.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (apuo *AssetPriceUpdateOne) check() error { - if v, ok := apuo.mutation.Signature(); ok { - if err := assetprice.SignatureValidator(v); err != nil { - return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "AssetPrice.signature": %w`, err)} - } - } - return nil -} - -func (apuo *AssetPriceUpdateOne) sqlSave(ctx context.Context) (_node *AssetPrice, err error) { - if err := apuo.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(assetprice.Table, assetprice.Columns, sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt)) - id, ok := apuo.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AssetPrice.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := apuo.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, assetprice.FieldID) - for _, f := range fields { - if !assetprice.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != assetprice.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := apuo.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := apuo.mutation.Block(); ok { - _spec.SetField(assetprice.FieldBlock, field.TypeUint64, value) - } - if value, ok := apuo.mutation.AddedBlock(); ok { - _spec.AddField(assetprice.FieldBlock, field.TypeUint64, value) - } - if value, ok := apuo.mutation.SignersCount(); ok { - _spec.SetField(assetprice.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := apuo.mutation.AddedSignersCount(); ok { - _spec.AddField(assetprice.FieldSignersCount, field.TypeUint64, value) - } - if apuo.mutation.SignersCountCleared() { - _spec.ClearField(assetprice.FieldSignersCount, field.TypeUint64) - } - if value, ok := apuo.mutation.Price(); ok { - _spec.SetField(assetprice.FieldPrice, field.TypeUint, value) - } - if value, ok := apuo.mutation.Signature(); ok { - _spec.SetField(assetprice.FieldSignature, field.TypeBytes, value) - } - if value, ok := apuo.mutation.Asset(); ok { - _spec.SetField(assetprice.FieldAsset, field.TypeString, value) - } - if apuo.mutation.AssetCleared() { - _spec.ClearField(assetprice.FieldAsset, field.TypeString) - } - if value, ok := apuo.mutation.Chain(); ok { - _spec.SetField(assetprice.FieldChain, field.TypeString, value) - } - if apuo.mutation.ChainCleared() { - _spec.ClearField(assetprice.FieldChain, field.TypeString) - } - if value, ok := apuo.mutation.Pair(); ok { - _spec.SetField(assetprice.FieldPair, field.TypeString, value) - } - if apuo.mutation.PairCleared() { - _spec.ClearField(assetprice.FieldPair, field.TypeString) - } - if value, ok := apuo.mutation.Consensus(); ok { - _spec.SetField(assetprice.FieldConsensus, field.TypeBool, value) - } - if value, ok := apuo.mutation.Voted(); ok { - _spec.SetField(assetprice.FieldVoted, field.TypeUint, value) - } - if apuo.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: assetprice.SignersTable, - Columns: assetprice.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := apuo.mutation.RemovedSignersIDs(); len(nodes) > 0 && !apuo.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: assetprice.SignersTable, - Columns: assetprice.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.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 := apuo.mutation.SignersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: assetprice.SignersTable, - Columns: assetprice.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _node = &AssetPrice{config: apuo.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, apuo.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{assetprice.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - apuo.mutation.done = true - return _node, nil -} diff --git a/internal/ent/client.go b/internal/ent/client.go deleted file mode 100644 index c21176ce..00000000 --- a/internal/ent/client.go +++ /dev/null @@ -1,868 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "log" - "reflect" - - "github.com/TimeleapLabs/unchained/internal/ent/migrate" - - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// 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 - // AssetPrice is the client for interacting with the AssetPrice builders. - AssetPrice *AssetPriceClient - // CorrectnessReport is the client for interacting with the CorrectnessReport builders. - CorrectnessReport *CorrectnessReportClient - // EventLog is the client for interacting with the EventLog builders. - EventLog *EventLogClient - // Signer is the client for interacting with the Signer builders. - Signer *SignerClient - // additional fields for node api - tables tables -} - -// 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.AssetPrice = NewAssetPriceClient(c.config) - c.CorrectnessReport = NewCorrectnessReportClient(c.config) - c.EventLog = NewEventLogClient(c.config) - c.Signer = NewSignerClient(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, - AssetPrice: NewAssetPriceClient(cfg), - CorrectnessReport: NewCorrectnessReportClient(cfg), - EventLog: NewEventLogClient(cfg), - Signer: NewSignerClient(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, - AssetPrice: NewAssetPriceClient(cfg), - CorrectnessReport: NewCorrectnessReportClient(cfg), - EventLog: NewEventLogClient(cfg), - Signer: NewSignerClient(cfg), - }, nil -} - -// Debug returns a new debug-client. It's used to get verbose logging on specific operations. -// -// client.Debug(). -// AssetPrice. -// 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.AssetPrice.Use(hooks...) - c.CorrectnessReport.Use(hooks...) - c.EventLog.Use(hooks...) - c.Signer.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.AssetPrice.Intercept(interceptors...) - c.CorrectnessReport.Intercept(interceptors...) - c.EventLog.Intercept(interceptors...) - c.Signer.Intercept(interceptors...) -} - -// Mutate implements the ent.Mutator interface. -func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { - switch m := m.(type) { - case *AssetPriceMutation: - return c.AssetPrice.mutate(ctx, m) - case *CorrectnessReportMutation: - return c.CorrectnessReport.mutate(ctx, m) - case *EventLogMutation: - return c.EventLog.mutate(ctx, m) - case *SignerMutation: - return c.Signer.mutate(ctx, m) - default: - return nil, fmt.Errorf("ent: unknown mutation type %T", m) - } -} - -// AssetPriceClient is a client for the AssetPrice schema. -type AssetPriceClient struct { - config -} - -// NewAssetPriceClient returns a client for the AssetPrice from the given config. -func NewAssetPriceClient(c config) *AssetPriceClient { - return &AssetPriceClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `assetprice.Hooks(f(g(h())))`. -func (c *AssetPriceClient) Use(hooks ...Hook) { - c.hooks.AssetPrice = append(c.hooks.AssetPrice, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `assetprice.Intercept(f(g(h())))`. -func (c *AssetPriceClient) Intercept(interceptors ...Interceptor) { - c.inters.AssetPrice = append(c.inters.AssetPrice, interceptors...) -} - -// Create returns a builder for creating a AssetPrice entity. -func (c *AssetPriceClient) Create() *AssetPriceCreate { - mutation := newAssetPriceMutation(c.config, OpCreate) - return &AssetPriceCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of AssetPrice entities. -func (c *AssetPriceClient) CreateBulk(builders ...*AssetPriceCreate) *AssetPriceCreateBulk { - return &AssetPriceCreateBulk{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 *AssetPriceClient) MapCreateBulk(slice any, setFunc func(*AssetPriceCreate, int)) *AssetPriceCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &AssetPriceCreateBulk{err: fmt.Errorf("calling to AssetPriceClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*AssetPriceCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &AssetPriceCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for AssetPrice. -func (c *AssetPriceClient) Update() *AssetPriceUpdate { - mutation := newAssetPriceMutation(c.config, OpUpdate) - return &AssetPriceUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *AssetPriceClient) UpdateOne(ap *AssetPrice) *AssetPriceUpdateOne { - mutation := newAssetPriceMutation(c.config, OpUpdateOne, withAssetPrice(ap)) - return &AssetPriceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *AssetPriceClient) UpdateOneID(id int) *AssetPriceUpdateOne { - mutation := newAssetPriceMutation(c.config, OpUpdateOne, withAssetPriceID(id)) - return &AssetPriceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for AssetPrice. -func (c *AssetPriceClient) Delete() *AssetPriceDelete { - mutation := newAssetPriceMutation(c.config, OpDelete) - return &AssetPriceDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *AssetPriceClient) DeleteOne(ap *AssetPrice) *AssetPriceDeleteOne { - return c.DeleteOneID(ap.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *AssetPriceClient) DeleteOneID(id int) *AssetPriceDeleteOne { - builder := c.Delete().Where(assetprice.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &AssetPriceDeleteOne{builder} -} - -// Query returns a query builder for AssetPrice. -func (c *AssetPriceClient) Query() *AssetPriceQuery { - return &AssetPriceQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeAssetPrice}, - inters: c.Interceptors(), - } -} - -// Get returns a AssetPrice entity by its id. -func (c *AssetPriceClient) Get(ctx context.Context, id int) (*AssetPrice, error) { - return c.Query().Where(assetprice.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *AssetPriceClient) GetX(ctx context.Context, id int) *AssetPrice { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QuerySigners queries the signers edge of a AssetPrice. -func (c *AssetPriceClient) QuerySigners(ap *AssetPrice) *SignerQuery { - query := (&SignerClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := ap.ID - step := sqlgraph.NewStep( - sqlgraph.From(assetprice.Table, assetprice.FieldID, id), - sqlgraph.To(signer.Table, signer.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, assetprice.SignersTable, assetprice.SignersPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(ap.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *AssetPriceClient) Hooks() []Hook { - return c.hooks.AssetPrice -} - -// Interceptors returns the client interceptors. -func (c *AssetPriceClient) Interceptors() []Interceptor { - return c.inters.AssetPrice -} - -func (c *AssetPriceClient) mutate(ctx context.Context, m *AssetPriceMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&AssetPriceCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&AssetPriceUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&AssetPriceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&AssetPriceDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown AssetPrice mutation op: %q", m.Op()) - } -} - -// CorrectnessReportClient is a client for the CorrectnessReport schema. -type CorrectnessReportClient struct { - config -} - -// NewCorrectnessReportClient returns a client for the CorrectnessReport from the given config. -func NewCorrectnessReportClient(c config) *CorrectnessReportClient { - return &CorrectnessReportClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `correctnessreport.Hooks(f(g(h())))`. -func (c *CorrectnessReportClient) Use(hooks ...Hook) { - c.hooks.CorrectnessReport = append(c.hooks.CorrectnessReport, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `correctnessreport.Intercept(f(g(h())))`. -func (c *CorrectnessReportClient) Intercept(interceptors ...Interceptor) { - c.inters.CorrectnessReport = append(c.inters.CorrectnessReport, interceptors...) -} - -// Create returns a builder for creating a CorrectnessReport entity. -func (c *CorrectnessReportClient) Create() *CorrectnessReportCreate { - mutation := newCorrectnessReportMutation(c.config, OpCreate) - return &CorrectnessReportCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of CorrectnessReport entities. -func (c *CorrectnessReportClient) CreateBulk(builders ...*CorrectnessReportCreate) *CorrectnessReportCreateBulk { - return &CorrectnessReportCreateBulk{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 *CorrectnessReportClient) MapCreateBulk(slice any, setFunc func(*CorrectnessReportCreate, int)) *CorrectnessReportCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &CorrectnessReportCreateBulk{err: fmt.Errorf("calling to CorrectnessReportClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*CorrectnessReportCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &CorrectnessReportCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for CorrectnessReport. -func (c *CorrectnessReportClient) Update() *CorrectnessReportUpdate { - mutation := newCorrectnessReportMutation(c.config, OpUpdate) - return &CorrectnessReportUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *CorrectnessReportClient) UpdateOne(cr *CorrectnessReport) *CorrectnessReportUpdateOne { - mutation := newCorrectnessReportMutation(c.config, OpUpdateOne, withCorrectnessReport(cr)) - return &CorrectnessReportUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *CorrectnessReportClient) UpdateOneID(id int) *CorrectnessReportUpdateOne { - mutation := newCorrectnessReportMutation(c.config, OpUpdateOne, withCorrectnessReportID(id)) - return &CorrectnessReportUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for CorrectnessReport. -func (c *CorrectnessReportClient) Delete() *CorrectnessReportDelete { - mutation := newCorrectnessReportMutation(c.config, OpDelete) - return &CorrectnessReportDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *CorrectnessReportClient) DeleteOne(cr *CorrectnessReport) *CorrectnessReportDeleteOne { - return c.DeleteOneID(cr.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *CorrectnessReportClient) DeleteOneID(id int) *CorrectnessReportDeleteOne { - builder := c.Delete().Where(correctnessreport.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &CorrectnessReportDeleteOne{builder} -} - -// Query returns a query builder for CorrectnessReport. -func (c *CorrectnessReportClient) Query() *CorrectnessReportQuery { - return &CorrectnessReportQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeCorrectnessReport}, - inters: c.Interceptors(), - } -} - -// Get returns a CorrectnessReport entity by its id. -func (c *CorrectnessReportClient) Get(ctx context.Context, id int) (*CorrectnessReport, error) { - return c.Query().Where(correctnessreport.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *CorrectnessReportClient) GetX(ctx context.Context, id int) *CorrectnessReport { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QuerySigners queries the signers edge of a CorrectnessReport. -func (c *CorrectnessReportClient) QuerySigners(cr *CorrectnessReport) *SignerQuery { - query := (&SignerClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := cr.ID - step := sqlgraph.NewStep( - sqlgraph.From(correctnessreport.Table, correctnessreport.FieldID, id), - sqlgraph.To(signer.Table, signer.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, correctnessreport.SignersTable, correctnessreport.SignersPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(cr.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *CorrectnessReportClient) Hooks() []Hook { - return c.hooks.CorrectnessReport -} - -// Interceptors returns the client interceptors. -func (c *CorrectnessReportClient) Interceptors() []Interceptor { - return c.inters.CorrectnessReport -} - -func (c *CorrectnessReportClient) mutate(ctx context.Context, m *CorrectnessReportMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&CorrectnessReportCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&CorrectnessReportUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&CorrectnessReportUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&CorrectnessReportDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown CorrectnessReport mutation op: %q", m.Op()) - } -} - -// EventLogClient is a client for the EventLog schema. -type EventLogClient struct { - config -} - -// NewEventLogClient returns a client for the EventLog from the given config. -func NewEventLogClient(c config) *EventLogClient { - return &EventLogClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `eventlog.Hooks(f(g(h())))`. -func (c *EventLogClient) Use(hooks ...Hook) { - c.hooks.EventLog = append(c.hooks.EventLog, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `eventlog.Intercept(f(g(h())))`. -func (c *EventLogClient) Intercept(interceptors ...Interceptor) { - c.inters.EventLog = append(c.inters.EventLog, interceptors...) -} - -// Create returns a builder for creating a EventLog entity. -func (c *EventLogClient) Create() *EventLogCreate { - mutation := newEventLogMutation(c.config, OpCreate) - return &EventLogCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of EventLog entities. -func (c *EventLogClient) CreateBulk(builders ...*EventLogCreate) *EventLogCreateBulk { - return &EventLogCreateBulk{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 *EventLogClient) MapCreateBulk(slice any, setFunc func(*EventLogCreate, int)) *EventLogCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &EventLogCreateBulk{err: fmt.Errorf("calling to EventLogClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*EventLogCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &EventLogCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for EventLog. -func (c *EventLogClient) Update() *EventLogUpdate { - mutation := newEventLogMutation(c.config, OpUpdate) - return &EventLogUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *EventLogClient) UpdateOne(el *EventLog) *EventLogUpdateOne { - mutation := newEventLogMutation(c.config, OpUpdateOne, withEventLog(el)) - return &EventLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *EventLogClient) UpdateOneID(id int) *EventLogUpdateOne { - mutation := newEventLogMutation(c.config, OpUpdateOne, withEventLogID(id)) - return &EventLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for EventLog. -func (c *EventLogClient) Delete() *EventLogDelete { - mutation := newEventLogMutation(c.config, OpDelete) - return &EventLogDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *EventLogClient) DeleteOne(el *EventLog) *EventLogDeleteOne { - return c.DeleteOneID(el.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *EventLogClient) DeleteOneID(id int) *EventLogDeleteOne { - builder := c.Delete().Where(eventlog.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &EventLogDeleteOne{builder} -} - -// Query returns a query builder for EventLog. -func (c *EventLogClient) Query() *EventLogQuery { - return &EventLogQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeEventLog}, - inters: c.Interceptors(), - } -} - -// Get returns a EventLog entity by its id. -func (c *EventLogClient) Get(ctx context.Context, id int) (*EventLog, error) { - return c.Query().Where(eventlog.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *EventLogClient) GetX(ctx context.Context, id int) *EventLog { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QuerySigners queries the signers edge of a EventLog. -func (c *EventLogClient) QuerySigners(el *EventLog) *SignerQuery { - query := (&SignerClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := el.ID - step := sqlgraph.NewStep( - sqlgraph.From(eventlog.Table, eventlog.FieldID, id), - sqlgraph.To(signer.Table, signer.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, eventlog.SignersTable, eventlog.SignersPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(el.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *EventLogClient) Hooks() []Hook { - return c.hooks.EventLog -} - -// Interceptors returns the client interceptors. -func (c *EventLogClient) Interceptors() []Interceptor { - return c.inters.EventLog -} - -func (c *EventLogClient) mutate(ctx context.Context, m *EventLogMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&EventLogCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&EventLogUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&EventLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&EventLogDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown EventLog mutation op: %q", m.Op()) - } -} - -// SignerClient is a client for the Signer schema. -type SignerClient struct { - config -} - -// NewSignerClient returns a client for the Signer from the given config. -func NewSignerClient(c config) *SignerClient { - return &SignerClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `signer.Hooks(f(g(h())))`. -func (c *SignerClient) Use(hooks ...Hook) { - c.hooks.Signer = append(c.hooks.Signer, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `signer.Intercept(f(g(h())))`. -func (c *SignerClient) Intercept(interceptors ...Interceptor) { - c.inters.Signer = append(c.inters.Signer, interceptors...) -} - -// Create returns a builder for creating a Signer entity. -func (c *SignerClient) Create() *SignerCreate { - mutation := newSignerMutation(c.config, OpCreate) - return &SignerCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of Signer entities. -func (c *SignerClient) CreateBulk(builders ...*SignerCreate) *SignerCreateBulk { - return &SignerCreateBulk{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 *SignerClient) MapCreateBulk(slice any, setFunc func(*SignerCreate, int)) *SignerCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &SignerCreateBulk{err: fmt.Errorf("calling to SignerClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*SignerCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &SignerCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for Signer. -func (c *SignerClient) Update() *SignerUpdate { - mutation := newSignerMutation(c.config, OpUpdate) - return &SignerUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *SignerClient) UpdateOne(s *Signer) *SignerUpdateOne { - mutation := newSignerMutation(c.config, OpUpdateOne, withSigner(s)) - return &SignerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *SignerClient) UpdateOneID(id int) *SignerUpdateOne { - mutation := newSignerMutation(c.config, OpUpdateOne, withSignerID(id)) - return &SignerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for Signer. -func (c *SignerClient) Delete() *SignerDelete { - mutation := newSignerMutation(c.config, OpDelete) - return &SignerDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *SignerClient) DeleteOne(s *Signer) *SignerDeleteOne { - return c.DeleteOneID(s.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *SignerClient) DeleteOneID(id int) *SignerDeleteOne { - builder := c.Delete().Where(signer.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &SignerDeleteOne{builder} -} - -// Query returns a query builder for Signer. -func (c *SignerClient) Query() *SignerQuery { - return &SignerQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeSigner}, - inters: c.Interceptors(), - } -} - -// Get returns a Signer entity by its id. -func (c *SignerClient) Get(ctx context.Context, id int) (*Signer, error) { - return c.Query().Where(signer.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *SignerClient) GetX(ctx context.Context, id int) *Signer { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryAssetPrice queries the assetPrice edge of a Signer. -func (c *SignerClient) QueryAssetPrice(s *Signer) *AssetPriceQuery { - query := (&AssetPriceClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := s.ID - step := sqlgraph.NewStep( - sqlgraph.From(signer.Table, signer.FieldID, id), - sqlgraph.To(assetprice.Table, assetprice.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, signer.AssetPriceTable, signer.AssetPricePrimaryKey...), - ) - fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryEventLogs queries the eventLogs edge of a Signer. -func (c *SignerClient) QueryEventLogs(s *Signer) *EventLogQuery { - query := (&EventLogClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := s.ID - step := sqlgraph.NewStep( - sqlgraph.From(signer.Table, signer.FieldID, id), - sqlgraph.To(eventlog.Table, eventlog.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, signer.EventLogsTable, signer.EventLogsPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryCorrectnessReport queries the correctnessReport edge of a Signer. -func (c *SignerClient) QueryCorrectnessReport(s *Signer) *CorrectnessReportQuery { - query := (&CorrectnessReportClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := s.ID - step := sqlgraph.NewStep( - sqlgraph.From(signer.Table, signer.FieldID, id), - sqlgraph.To(correctnessreport.Table, correctnessreport.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, signer.CorrectnessReportTable, signer.CorrectnessReportPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *SignerClient) Hooks() []Hook { - return c.hooks.Signer -} - -// Interceptors returns the client interceptors. -func (c *SignerClient) Interceptors() []Interceptor { - return c.inters.Signer -} - -func (c *SignerClient) mutate(ctx context.Context, m *SignerMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&SignerCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&SignerUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&SignerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&SignerDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown Signer mutation op: %q", m.Op()) - } -} - -// hooks and interceptors per client, for fast access. -type ( - hooks struct { - AssetPrice, CorrectnessReport, EventLog, Signer []ent.Hook - } - inters struct { - AssetPrice, CorrectnessReport, EventLog, Signer []ent.Interceptor - } -) diff --git a/internal/ent/correctnessreport.go b/internal/ent/correctnessreport.go deleted file mode 100644 index 3e518281..00000000 --- a/internal/ent/correctnessreport.go +++ /dev/null @@ -1,239 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "fmt" - "strings" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" -) - -// CorrectnessReport is the model entity for the CorrectnessReport schema. -type CorrectnessReport struct { - config `json:"-"` - // ID of the ent. - ID int `json:"id,omitempty"` - // SignersCount holds the value of the "signersCount" field. - SignersCount uint64 `json:"signersCount,omitempty"` - // Timestamp holds the value of the "timestamp" field. - Timestamp uint64 `json:"timestamp,omitempty"` - // Signature holds the value of the "signature" field. - Signature []byte `json:"signature,omitempty"` - // Hash holds the value of the "hash" field. - Hash []byte `json:"hash,omitempty"` - // Topic holds the value of the "topic" field. - Topic []byte `json:"topic,omitempty"` - // Correct holds the value of the "correct" field. - Correct bool `json:"correct,omitempty"` - // Consensus holds the value of the "consensus" field. - Consensus bool `json:"consensus,omitempty"` - // Voted holds the value of the "voted" field. - Voted *helpers.BigInt `json:"voted,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the CorrectnessReportQuery when eager-loading is set. - Edges CorrectnessReportEdges `json:"edges"` - selectValues sql.SelectValues -} - -// CorrectnessReportEdges holds the relations/edges for other nodes in the graph. -type CorrectnessReportEdges struct { - // Signers holds the value of the signers edge. - Signers []*Signer `json:"signers,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [1]bool - // totalCount holds the count of the edges above. - totalCount [1]map[string]int - - namedSigners map[string][]*Signer -} - -// SignersOrErr returns the Signers value or an error if the edge -// was not loaded in eager-loading. -func (e CorrectnessReportEdges) SignersOrErr() ([]*Signer, error) { - if e.loadedTypes[0] { - return e.Signers, nil - } - return nil, &NotLoadedError{edge: "signers"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*CorrectnessReport) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case correctnessreport.FieldSignature, correctnessreport.FieldHash, correctnessreport.FieldTopic: - values[i] = new([]byte) - case correctnessreport.FieldVoted: - values[i] = new(helpers.BigInt) - case correctnessreport.FieldCorrect, correctnessreport.FieldConsensus: - values[i] = new(sql.NullBool) - case correctnessreport.FieldID, correctnessreport.FieldSignersCount, correctnessreport.FieldTimestamp: - 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 CorrectnessReport fields. -func (cr *CorrectnessReport) 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 correctnessreport.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) - } - cr.ID = int(value.Int64) - case correctnessreport.FieldSignersCount: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field signersCount", values[i]) - } else if value.Valid { - cr.SignersCount = uint64(value.Int64) - } - case correctnessreport.FieldTimestamp: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field timestamp", values[i]) - } else if value.Valid { - cr.Timestamp = uint64(value.Int64) - } - case correctnessreport.FieldSignature: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field signature", values[i]) - } else if value != nil { - cr.Signature = *value - } - case correctnessreport.FieldHash: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field hash", values[i]) - } else if value != nil { - cr.Hash = *value - } - case correctnessreport.FieldTopic: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field topic", values[i]) - } else if value != nil { - cr.Topic = *value - } - case correctnessreport.FieldCorrect: - if value, ok := values[i].(*sql.NullBool); !ok { - return fmt.Errorf("unexpected type %T for field correct", values[i]) - } else if value.Valid { - cr.Correct = value.Bool - } - case correctnessreport.FieldConsensus: - if value, ok := values[i].(*sql.NullBool); !ok { - return fmt.Errorf("unexpected type %T for field consensus", values[i]) - } else if value.Valid { - cr.Consensus = value.Bool - } - case correctnessreport.FieldVoted: - if value, ok := values[i].(*helpers.BigInt); !ok { - return fmt.Errorf("unexpected type %T for field voted", values[i]) - } else if value != nil { - cr.Voted = value - } - default: - cr.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the CorrectnessReport. -// This includes values selected through modifiers, order, etc. -func (cr *CorrectnessReport) Value(name string) (ent.Value, error) { - return cr.selectValues.Get(name) -} - -// QuerySigners queries the "signers" edge of the CorrectnessReport entity. -func (cr *CorrectnessReport) QuerySigners() *SignerQuery { - return NewCorrectnessReportClient(cr.config).QuerySigners(cr) -} - -// Update returns a builder for updating this CorrectnessReport. -// Note that you need to call CorrectnessReport.Unwrap() before calling this method if this CorrectnessReport -// was returned from a transaction, and the transaction was committed or rolled back. -func (cr *CorrectnessReport) Update() *CorrectnessReportUpdateOne { - return NewCorrectnessReportClient(cr.config).UpdateOne(cr) -} - -// Unwrap unwraps the CorrectnessReport 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 (cr *CorrectnessReport) Unwrap() *CorrectnessReport { - _tx, ok := cr.config.driver.(*txDriver) - if !ok { - panic("ent: CorrectnessReport is not a transactional entity") - } - cr.config.driver = _tx.drv - return cr -} - -// String implements the fmt.Stringer. -func (cr *CorrectnessReport) String() string { - var builder strings.Builder - builder.WriteString("CorrectnessReport(") - builder.WriteString(fmt.Sprintf("id=%v, ", cr.ID)) - builder.WriteString("signersCount=") - builder.WriteString(fmt.Sprintf("%v", cr.SignersCount)) - builder.WriteString(", ") - builder.WriteString("timestamp=") - builder.WriteString(fmt.Sprintf("%v", cr.Timestamp)) - builder.WriteString(", ") - builder.WriteString("signature=") - builder.WriteString(fmt.Sprintf("%v", cr.Signature)) - builder.WriteString(", ") - builder.WriteString("hash=") - builder.WriteString(fmt.Sprintf("%v", cr.Hash)) - builder.WriteString(", ") - builder.WriteString("topic=") - builder.WriteString(fmt.Sprintf("%v", cr.Topic)) - builder.WriteString(", ") - builder.WriteString("correct=") - builder.WriteString(fmt.Sprintf("%v", cr.Correct)) - builder.WriteString(", ") - builder.WriteString("consensus=") - builder.WriteString(fmt.Sprintf("%v", cr.Consensus)) - builder.WriteString(", ") - builder.WriteString("voted=") - builder.WriteString(fmt.Sprintf("%v", cr.Voted)) - builder.WriteByte(')') - return builder.String() -} - -// NamedSigners returns the Signers named value or an error if the edge was not -// loaded in eager-loading with this name. -func (cr *CorrectnessReport) NamedSigners(name string) ([]*Signer, error) { - if cr.Edges.namedSigners == nil { - return nil, &NotLoadedError{edge: name} - } - nodes, ok := cr.Edges.namedSigners[name] - if !ok { - return nil, &NotLoadedError{edge: name} - } - return nodes, nil -} - -func (cr *CorrectnessReport) appendNamedSigners(name string, edges ...*Signer) { - if cr.Edges.namedSigners == nil { - cr.Edges.namedSigners = make(map[string][]*Signer) - } - if len(edges) == 0 { - cr.Edges.namedSigners[name] = []*Signer{} - } else { - cr.Edges.namedSigners[name] = append(cr.Edges.namedSigners[name], edges...) - } -} - -// CorrectnessReports is a parsable slice of CorrectnessReport. -type CorrectnessReports []*CorrectnessReport diff --git a/internal/ent/correctnessreport/correctnessreport.go b/internal/ent/correctnessreport/correctnessreport.go deleted file mode 100644 index bc6ba45c..00000000 --- a/internal/ent/correctnessreport/correctnessreport.go +++ /dev/null @@ -1,134 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package correctnessreport - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the correctnessreport type in the database. - Label = "correctness_report" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldSignersCount holds the string denoting the signerscount field in the database. - FieldSignersCount = "signers_count" - // FieldTimestamp holds the string denoting the timestamp field in the database. - FieldTimestamp = "timestamp" - // FieldSignature holds the string denoting the signature field in the database. - FieldSignature = "signature" - // FieldHash holds the string denoting the hash field in the database. - FieldHash = "hash" - // FieldTopic holds the string denoting the topic field in the database. - FieldTopic = "topic" - // FieldCorrect holds the string denoting the correct field in the database. - FieldCorrect = "correct" - // FieldConsensus holds the string denoting the consensus field in the database. - FieldConsensus = "consensus" - // FieldVoted holds the string denoting the voted field in the database. - FieldVoted = "voted" - // EdgeSigners holds the string denoting the signers edge name in mutations. - EdgeSigners = "signers" - // Table holds the table name of the correctnessreport in the database. - Table = "correctness_reports" - // SignersTable is the table that holds the signers relation/edge. The primary key declared below. - SignersTable = "correctness_report_signers" - // SignersInverseTable is the table name for the Signer entity. - // It exists in this package in order to avoid circular dependency with the "signer" package. - SignersInverseTable = "signers" -) - -// Columns holds all SQL columns for correctnessreport fields. -var Columns = []string{ - FieldID, - FieldSignersCount, - FieldTimestamp, - FieldSignature, - FieldHash, - FieldTopic, - FieldCorrect, - FieldConsensus, - FieldVoted, -} - -var ( - // SignersPrimaryKey and SignersColumn2 are the table columns denoting the - // primary key for the signers relation (M2M). - SignersPrimaryKey = []string{"correctness_report_id", "signer_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 -} - -var ( - // SignatureValidator is a validator for the "signature" field. It is called by the builders before save. - SignatureValidator func([]byte) error - // HashValidator is a validator for the "hash" field. It is called by the builders before save. - HashValidator func([]byte) error - // TopicValidator is a validator for the "topic" field. It is called by the builders before save. - TopicValidator func([]byte) error - // DefaultConsensus holds the default value on creation for the "consensus" field. - DefaultConsensus bool -) - -// OrderOption defines the ordering options for the CorrectnessReport 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() -} - -// BySignersCountField orders the results by the signersCount field. -func BySignersCountField(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSignersCount, opts...).ToFunc() -} - -// ByTimestamp orders the results by the timestamp field. -func ByTimestamp(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldTimestamp, opts...).ToFunc() -} - -// ByCorrect orders the results by the correct field. -func ByCorrect(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCorrect, opts...).ToFunc() -} - -// ByConsensus orders the results by the consensus field. -func ByConsensus(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldConsensus, opts...).ToFunc() -} - -// ByVoted orders the results by the voted field. -func ByVoted(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldVoted, opts...).ToFunc() -} - -// BySignersCount orders the results by signers count. -func BySignersCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newSignersStep(), opts...) - } -} - -// BySigners orders the results by signers terms. -func BySigners(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newSignersStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newSignersStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(SignersInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, SignersTable, SignersPrimaryKey...), - ) -} diff --git a/internal/ent/correctnessreport/where.go b/internal/ent/correctnessreport/where.go deleted file mode 100644 index 17bd1bd8..00000000 --- a/internal/ent/correctnessreport/where.go +++ /dev/null @@ -1,393 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package correctnessreport - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLTE(FieldID, id)) -} - -// SignersCount applies equality check predicate on the "signersCount" field. It's identical to SignersCountEQ. -func SignersCount(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldSignersCount, v)) -} - -// Timestamp applies equality check predicate on the "timestamp" field. It's identical to TimestampEQ. -func Timestamp(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldTimestamp, v)) -} - -// Signature applies equality check predicate on the "signature" field. It's identical to SignatureEQ. -func Signature(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldSignature, v)) -} - -// Hash applies equality check predicate on the "hash" field. It's identical to HashEQ. -func Hash(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldHash, v)) -} - -// Topic applies equality check predicate on the "topic" field. It's identical to TopicEQ. -func Topic(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldTopic, v)) -} - -// Correct applies equality check predicate on the "correct" field. It's identical to CorrectEQ. -func Correct(v bool) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldCorrect, v)) -} - -// Consensus applies equality check predicate on the "consensus" field. It's identical to ConsensusEQ. -func Consensus(v bool) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldConsensus, v)) -} - -// Voted applies equality check predicate on the "voted" field. It's identical to VotedEQ. -func Voted(v *helpers.BigInt) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldVoted, v)) -} - -// SignersCountEQ applies the EQ predicate on the "signersCount" field. -func SignersCountEQ(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldSignersCount, v)) -} - -// SignersCountNEQ applies the NEQ predicate on the "signersCount" field. -func SignersCountNEQ(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNEQ(FieldSignersCount, v)) -} - -// SignersCountIn applies the In predicate on the "signersCount" field. -func SignersCountIn(vs ...uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldIn(FieldSignersCount, vs...)) -} - -// SignersCountNotIn applies the NotIn predicate on the "signersCount" field. -func SignersCountNotIn(vs ...uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNotIn(FieldSignersCount, vs...)) -} - -// SignersCountGT applies the GT predicate on the "signersCount" field. -func SignersCountGT(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGT(FieldSignersCount, v)) -} - -// SignersCountGTE applies the GTE predicate on the "signersCount" field. -func SignersCountGTE(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGTE(FieldSignersCount, v)) -} - -// SignersCountLT applies the LT predicate on the "signersCount" field. -func SignersCountLT(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLT(FieldSignersCount, v)) -} - -// SignersCountLTE applies the LTE predicate on the "signersCount" field. -func SignersCountLTE(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLTE(FieldSignersCount, v)) -} - -// TimestampEQ applies the EQ predicate on the "timestamp" field. -func TimestampEQ(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldTimestamp, v)) -} - -// TimestampNEQ applies the NEQ predicate on the "timestamp" field. -func TimestampNEQ(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNEQ(FieldTimestamp, v)) -} - -// TimestampIn applies the In predicate on the "timestamp" field. -func TimestampIn(vs ...uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldIn(FieldTimestamp, vs...)) -} - -// TimestampNotIn applies the NotIn predicate on the "timestamp" field. -func TimestampNotIn(vs ...uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNotIn(FieldTimestamp, vs...)) -} - -// TimestampGT applies the GT predicate on the "timestamp" field. -func TimestampGT(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGT(FieldTimestamp, v)) -} - -// TimestampGTE applies the GTE predicate on the "timestamp" field. -func TimestampGTE(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGTE(FieldTimestamp, v)) -} - -// TimestampLT applies the LT predicate on the "timestamp" field. -func TimestampLT(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLT(FieldTimestamp, v)) -} - -// TimestampLTE applies the LTE predicate on the "timestamp" field. -func TimestampLTE(v uint64) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLTE(FieldTimestamp, v)) -} - -// SignatureEQ applies the EQ predicate on the "signature" field. -func SignatureEQ(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldSignature, v)) -} - -// SignatureNEQ applies the NEQ predicate on the "signature" field. -func SignatureNEQ(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNEQ(FieldSignature, v)) -} - -// SignatureIn applies the In predicate on the "signature" field. -func SignatureIn(vs ...[]byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldIn(FieldSignature, vs...)) -} - -// SignatureNotIn applies the NotIn predicate on the "signature" field. -func SignatureNotIn(vs ...[]byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNotIn(FieldSignature, vs...)) -} - -// SignatureGT applies the GT predicate on the "signature" field. -func SignatureGT(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGT(FieldSignature, v)) -} - -// SignatureGTE applies the GTE predicate on the "signature" field. -func SignatureGTE(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGTE(FieldSignature, v)) -} - -// SignatureLT applies the LT predicate on the "signature" field. -func SignatureLT(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLT(FieldSignature, v)) -} - -// SignatureLTE applies the LTE predicate on the "signature" field. -func SignatureLTE(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLTE(FieldSignature, v)) -} - -// HashEQ applies the EQ predicate on the "hash" field. -func HashEQ(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldHash, v)) -} - -// HashNEQ applies the NEQ predicate on the "hash" field. -func HashNEQ(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNEQ(FieldHash, v)) -} - -// HashIn applies the In predicate on the "hash" field. -func HashIn(vs ...[]byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldIn(FieldHash, vs...)) -} - -// HashNotIn applies the NotIn predicate on the "hash" field. -func HashNotIn(vs ...[]byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNotIn(FieldHash, vs...)) -} - -// HashGT applies the GT predicate on the "hash" field. -func HashGT(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGT(FieldHash, v)) -} - -// HashGTE applies the GTE predicate on the "hash" field. -func HashGTE(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGTE(FieldHash, v)) -} - -// HashLT applies the LT predicate on the "hash" field. -func HashLT(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLT(FieldHash, v)) -} - -// HashLTE applies the LTE predicate on the "hash" field. -func HashLTE(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLTE(FieldHash, v)) -} - -// TopicEQ applies the EQ predicate on the "topic" field. -func TopicEQ(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldTopic, v)) -} - -// TopicNEQ applies the NEQ predicate on the "topic" field. -func TopicNEQ(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNEQ(FieldTopic, v)) -} - -// TopicIn applies the In predicate on the "topic" field. -func TopicIn(vs ...[]byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldIn(FieldTopic, vs...)) -} - -// TopicNotIn applies the NotIn predicate on the "topic" field. -func TopicNotIn(vs ...[]byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNotIn(FieldTopic, vs...)) -} - -// TopicGT applies the GT predicate on the "topic" field. -func TopicGT(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGT(FieldTopic, v)) -} - -// TopicGTE applies the GTE predicate on the "topic" field. -func TopicGTE(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGTE(FieldTopic, v)) -} - -// TopicLT applies the LT predicate on the "topic" field. -func TopicLT(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLT(FieldTopic, v)) -} - -// TopicLTE applies the LTE predicate on the "topic" field. -func TopicLTE(v []byte) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLTE(FieldTopic, v)) -} - -// CorrectEQ applies the EQ predicate on the "correct" field. -func CorrectEQ(v bool) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldCorrect, v)) -} - -// CorrectNEQ applies the NEQ predicate on the "correct" field. -func CorrectNEQ(v bool) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNEQ(FieldCorrect, v)) -} - -// ConsensusEQ applies the EQ predicate on the "consensus" field. -func ConsensusEQ(v bool) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldConsensus, v)) -} - -// ConsensusNEQ applies the NEQ predicate on the "consensus" field. -func ConsensusNEQ(v bool) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNEQ(FieldConsensus, v)) -} - -// VotedEQ applies the EQ predicate on the "voted" field. -func VotedEQ(v *helpers.BigInt) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldEQ(FieldVoted, v)) -} - -// VotedNEQ applies the NEQ predicate on the "voted" field. -func VotedNEQ(v *helpers.BigInt) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNEQ(FieldVoted, v)) -} - -// VotedIn applies the In predicate on the "voted" field. -func VotedIn(vs ...*helpers.BigInt) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldIn(FieldVoted, vs...)) -} - -// VotedNotIn applies the NotIn predicate on the "voted" field. -func VotedNotIn(vs ...*helpers.BigInt) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldNotIn(FieldVoted, vs...)) -} - -// VotedGT applies the GT predicate on the "voted" field. -func VotedGT(v *helpers.BigInt) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGT(FieldVoted, v)) -} - -// VotedGTE applies the GTE predicate on the "voted" field. -func VotedGTE(v *helpers.BigInt) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldGTE(FieldVoted, v)) -} - -// VotedLT applies the LT predicate on the "voted" field. -func VotedLT(v *helpers.BigInt) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLT(FieldVoted, v)) -} - -// VotedLTE applies the LTE predicate on the "voted" field. -func VotedLTE(v *helpers.BigInt) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.FieldLTE(FieldVoted, v)) -} - -// HasSigners applies the HasEdge predicate on the "signers" edge. -func HasSigners() predicate.CorrectnessReport { - return predicate.CorrectnessReport(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, SignersTable, SignersPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasSignersWith applies the HasEdge predicate on the "signers" edge with a given conditions (other predicates). -func HasSignersWith(preds ...predicate.Signer) predicate.CorrectnessReport { - return predicate.CorrectnessReport(func(s *sql.Selector) { - step := newSignersStep() - 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.CorrectnessReport) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.CorrectnessReport) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.CorrectnessReport) predicate.CorrectnessReport { - return predicate.CorrectnessReport(sql.NotPredicates(p)) -} diff --git a/internal/ent/correctnessreport_create.go b/internal/ent/correctnessreport_create.go deleted file mode 100644 index 7a8ea285..00000000 --- a/internal/ent/correctnessreport_create.go +++ /dev/null @@ -1,934 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// CorrectnessReportCreate is the builder for creating a CorrectnessReport entity. -type CorrectnessReportCreate struct { - config - mutation *CorrectnessReportMutation - hooks []Hook - conflict []sql.ConflictOption -} - -// SetSignersCount sets the "signersCount" field. -func (crc *CorrectnessReportCreate) SetSignersCount(u uint64) *CorrectnessReportCreate { - crc.mutation.SetSignersCount(u) - return crc -} - -// SetTimestamp sets the "timestamp" field. -func (crc *CorrectnessReportCreate) SetTimestamp(u uint64) *CorrectnessReportCreate { - crc.mutation.SetTimestamp(u) - return crc -} - -// SetSignature sets the "signature" field. -func (crc *CorrectnessReportCreate) SetSignature(b []byte) *CorrectnessReportCreate { - crc.mutation.SetSignature(b) - return crc -} - -// SetHash sets the "hash" field. -func (crc *CorrectnessReportCreate) SetHash(b []byte) *CorrectnessReportCreate { - crc.mutation.SetHash(b) - return crc -} - -// SetTopic sets the "topic" field. -func (crc *CorrectnessReportCreate) SetTopic(b []byte) *CorrectnessReportCreate { - crc.mutation.SetTopic(b) - return crc -} - -// SetCorrect sets the "correct" field. -func (crc *CorrectnessReportCreate) SetCorrect(b bool) *CorrectnessReportCreate { - crc.mutation.SetCorrect(b) - return crc -} - -// SetConsensus sets the "consensus" field. -func (crc *CorrectnessReportCreate) SetConsensus(b bool) *CorrectnessReportCreate { - crc.mutation.SetConsensus(b) - return crc -} - -// SetNillableConsensus sets the "consensus" field if the given value is not nil. -func (crc *CorrectnessReportCreate) SetNillableConsensus(b *bool) *CorrectnessReportCreate { - if b != nil { - crc.SetConsensus(*b) - } - return crc -} - -// SetVoted sets the "voted" field. -func (crc *CorrectnessReportCreate) SetVoted(hi *helpers.BigInt) *CorrectnessReportCreate { - crc.mutation.SetVoted(hi) - return crc -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by IDs. -func (crc *CorrectnessReportCreate) AddSignerIDs(ids ...int) *CorrectnessReportCreate { - crc.mutation.AddSignerIDs(ids...) - return crc -} - -// AddSigners adds the "signers" edges to the Signer entity. -func (crc *CorrectnessReportCreate) AddSigners(s ...*Signer) *CorrectnessReportCreate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return crc.AddSignerIDs(ids...) -} - -// Mutation returns the CorrectnessReportMutation object of the builder. -func (crc *CorrectnessReportCreate) Mutation() *CorrectnessReportMutation { - return crc.mutation -} - -// Save creates the CorrectnessReport in the database. -func (crc *CorrectnessReportCreate) Save(ctx context.Context) (*CorrectnessReport, error) { - crc.defaults() - return withHooks(ctx, crc.sqlSave, crc.mutation, crc.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (crc *CorrectnessReportCreate) SaveX(ctx context.Context) *CorrectnessReport { - v, err := crc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (crc *CorrectnessReportCreate) Exec(ctx context.Context) error { - _, err := crc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (crc *CorrectnessReportCreate) ExecX(ctx context.Context) { - if err := crc.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (crc *CorrectnessReportCreate) defaults() { - if _, ok := crc.mutation.Consensus(); !ok { - v := correctnessreport.DefaultConsensus - crc.mutation.SetConsensus(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (crc *CorrectnessReportCreate) check() error { - if _, ok := crc.mutation.SignersCount(); !ok { - return &ValidationError{Name: "signersCount", err: errors.New(`ent: missing required field "CorrectnessReport.signersCount"`)} - } - if _, ok := crc.mutation.Timestamp(); !ok { - return &ValidationError{Name: "timestamp", err: errors.New(`ent: missing required field "CorrectnessReport.timestamp"`)} - } - if _, ok := crc.mutation.Signature(); !ok { - return &ValidationError{Name: "signature", err: errors.New(`ent: missing required field "CorrectnessReport.signature"`)} - } - if v, ok := crc.mutation.Signature(); ok { - if err := correctnessreport.SignatureValidator(v); err != nil { - return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "CorrectnessReport.signature": %w`, err)} - } - } - if _, ok := crc.mutation.Hash(); !ok { - return &ValidationError{Name: "hash", err: errors.New(`ent: missing required field "CorrectnessReport.hash"`)} - } - if v, ok := crc.mutation.Hash(); ok { - if err := correctnessreport.HashValidator(v); err != nil { - return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "CorrectnessReport.hash": %w`, err)} - } - } - if _, ok := crc.mutation.Topic(); !ok { - return &ValidationError{Name: "topic", err: errors.New(`ent: missing required field "CorrectnessReport.topic"`)} - } - if v, ok := crc.mutation.Topic(); ok { - if err := correctnessreport.TopicValidator(v); err != nil { - return &ValidationError{Name: "topic", err: fmt.Errorf(`ent: validator failed for field "CorrectnessReport.topic": %w`, err)} - } - } - if _, ok := crc.mutation.Correct(); !ok { - return &ValidationError{Name: "correct", err: errors.New(`ent: missing required field "CorrectnessReport.correct"`)} - } - if _, ok := crc.mutation.Consensus(); !ok { - return &ValidationError{Name: "consensus", err: errors.New(`ent: missing required field "CorrectnessReport.consensus"`)} - } - if _, ok := crc.mutation.Voted(); !ok { - return &ValidationError{Name: "voted", err: errors.New(`ent: missing required field "CorrectnessReport.voted"`)} - } - if len(crc.mutation.SignersIDs()) == 0 { - return &ValidationError{Name: "signers", err: errors.New(`ent: missing required edge "CorrectnessReport.signers"`)} - } - return nil -} - -func (crc *CorrectnessReportCreate) sqlSave(ctx context.Context) (*CorrectnessReport, error) { - if err := crc.check(); err != nil { - return nil, err - } - _node, _spec := crc.createSpec() - if err := sqlgraph.CreateNode(ctx, crc.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) - crc.mutation.id = &_node.ID - crc.mutation.done = true - return _node, nil -} - -func (crc *CorrectnessReportCreate) createSpec() (*CorrectnessReport, *sqlgraph.CreateSpec) { - var ( - _node = &CorrectnessReport{config: crc.config} - _spec = sqlgraph.NewCreateSpec(correctnessreport.Table, sqlgraph.NewFieldSpec(correctnessreport.FieldID, field.TypeInt)) - ) - _spec.OnConflict = crc.conflict - if value, ok := crc.mutation.SignersCount(); ok { - _spec.SetField(correctnessreport.FieldSignersCount, field.TypeUint64, value) - _node.SignersCount = value - } - if value, ok := crc.mutation.Timestamp(); ok { - _spec.SetField(correctnessreport.FieldTimestamp, field.TypeUint64, value) - _node.Timestamp = value - } - if value, ok := crc.mutation.Signature(); ok { - _spec.SetField(correctnessreport.FieldSignature, field.TypeBytes, value) - _node.Signature = value - } - if value, ok := crc.mutation.Hash(); ok { - _spec.SetField(correctnessreport.FieldHash, field.TypeBytes, value) - _node.Hash = value - } - if value, ok := crc.mutation.Topic(); ok { - _spec.SetField(correctnessreport.FieldTopic, field.TypeBytes, value) - _node.Topic = value - } - if value, ok := crc.mutation.Correct(); ok { - _spec.SetField(correctnessreport.FieldCorrect, field.TypeBool, value) - _node.Correct = value - } - if value, ok := crc.mutation.Consensus(); ok { - _spec.SetField(correctnessreport.FieldConsensus, field.TypeBool, value) - _node.Consensus = value - } - if value, ok := crc.mutation.Voted(); ok { - _spec.SetField(correctnessreport.FieldVoted, field.TypeUint, value) - _node.Voted = value - } - if nodes := crc.mutation.SignersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: correctnessreport.SignersTable, - Columns: correctnessreport.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.CorrectnessReport.Create(). -// SetSignersCount(v). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.CorrectnessReportUpsert) { -// SetSignersCount(v+v). -// }). -// Exec(ctx) -func (crc *CorrectnessReportCreate) OnConflict(opts ...sql.ConflictOption) *CorrectnessReportUpsertOne { - crc.conflict = opts - return &CorrectnessReportUpsertOne{ - create: crc, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.CorrectnessReport.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (crc *CorrectnessReportCreate) OnConflictColumns(columns ...string) *CorrectnessReportUpsertOne { - crc.conflict = append(crc.conflict, sql.ConflictColumns(columns...)) - return &CorrectnessReportUpsertOne{ - create: crc, - } -} - -type ( - // CorrectnessReportUpsertOne is the builder for "upsert"-ing - // one CorrectnessReport node. - CorrectnessReportUpsertOne struct { - create *CorrectnessReportCreate - } - - // CorrectnessReportUpsert is the "OnConflict" setter. - CorrectnessReportUpsert struct { - *sql.UpdateSet - } -) - -// SetSignersCount sets the "signersCount" field. -func (u *CorrectnessReportUpsert) SetSignersCount(v uint64) *CorrectnessReportUpsert { - u.Set(correctnessreport.FieldSignersCount, v) - return u -} - -// UpdateSignersCount sets the "signersCount" field to the value that was provided on create. -func (u *CorrectnessReportUpsert) UpdateSignersCount() *CorrectnessReportUpsert { - u.SetExcluded(correctnessreport.FieldSignersCount) - return u -} - -// AddSignersCount adds v to the "signersCount" field. -func (u *CorrectnessReportUpsert) AddSignersCount(v uint64) *CorrectnessReportUpsert { - u.Add(correctnessreport.FieldSignersCount, v) - return u -} - -// SetTimestamp sets the "timestamp" field. -func (u *CorrectnessReportUpsert) SetTimestamp(v uint64) *CorrectnessReportUpsert { - u.Set(correctnessreport.FieldTimestamp, v) - return u -} - -// UpdateTimestamp sets the "timestamp" field to the value that was provided on create. -func (u *CorrectnessReportUpsert) UpdateTimestamp() *CorrectnessReportUpsert { - u.SetExcluded(correctnessreport.FieldTimestamp) - return u -} - -// AddTimestamp adds v to the "timestamp" field. -func (u *CorrectnessReportUpsert) AddTimestamp(v uint64) *CorrectnessReportUpsert { - u.Add(correctnessreport.FieldTimestamp, v) - return u -} - -// SetSignature sets the "signature" field. -func (u *CorrectnessReportUpsert) SetSignature(v []byte) *CorrectnessReportUpsert { - u.Set(correctnessreport.FieldSignature, v) - return u -} - -// UpdateSignature sets the "signature" field to the value that was provided on create. -func (u *CorrectnessReportUpsert) UpdateSignature() *CorrectnessReportUpsert { - u.SetExcluded(correctnessreport.FieldSignature) - return u -} - -// SetHash sets the "hash" field. -func (u *CorrectnessReportUpsert) SetHash(v []byte) *CorrectnessReportUpsert { - u.Set(correctnessreport.FieldHash, v) - return u -} - -// UpdateHash sets the "hash" field to the value that was provided on create. -func (u *CorrectnessReportUpsert) UpdateHash() *CorrectnessReportUpsert { - u.SetExcluded(correctnessreport.FieldHash) - return u -} - -// SetTopic sets the "topic" field. -func (u *CorrectnessReportUpsert) SetTopic(v []byte) *CorrectnessReportUpsert { - u.Set(correctnessreport.FieldTopic, v) - return u -} - -// UpdateTopic sets the "topic" field to the value that was provided on create. -func (u *CorrectnessReportUpsert) UpdateTopic() *CorrectnessReportUpsert { - u.SetExcluded(correctnessreport.FieldTopic) - return u -} - -// SetCorrect sets the "correct" field. -func (u *CorrectnessReportUpsert) SetCorrect(v bool) *CorrectnessReportUpsert { - u.Set(correctnessreport.FieldCorrect, v) - return u -} - -// UpdateCorrect sets the "correct" field to the value that was provided on create. -func (u *CorrectnessReportUpsert) UpdateCorrect() *CorrectnessReportUpsert { - u.SetExcluded(correctnessreport.FieldCorrect) - return u -} - -// SetConsensus sets the "consensus" field. -func (u *CorrectnessReportUpsert) SetConsensus(v bool) *CorrectnessReportUpsert { - u.Set(correctnessreport.FieldConsensus, v) - return u -} - -// UpdateConsensus sets the "consensus" field to the value that was provided on create. -func (u *CorrectnessReportUpsert) UpdateConsensus() *CorrectnessReportUpsert { - u.SetExcluded(correctnessreport.FieldConsensus) - return u -} - -// SetVoted sets the "voted" field. -func (u *CorrectnessReportUpsert) SetVoted(v *helpers.BigInt) *CorrectnessReportUpsert { - u.Set(correctnessreport.FieldVoted, v) - return u -} - -// UpdateVoted sets the "voted" field to the value that was provided on create. -func (u *CorrectnessReportUpsert) UpdateVoted() *CorrectnessReportUpsert { - u.SetExcluded(correctnessreport.FieldVoted) - return u -} - -// UpdateNewValues updates the mutable fields using the new values that were set on create. -// Using this option is equivalent to using: -// -// client.CorrectnessReport.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *CorrectnessReportUpsertOne) UpdateNewValues() *CorrectnessReportUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.CorrectnessReport.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *CorrectnessReportUpsertOne) Ignore() *CorrectnessReportUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *CorrectnessReportUpsertOne) DoNothing() *CorrectnessReportUpsertOne { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the CorrectnessReportCreate.OnConflict -// documentation for more info. -func (u *CorrectnessReportUpsertOne) Update(set func(*CorrectnessReportUpsert)) *CorrectnessReportUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&CorrectnessReportUpsert{UpdateSet: update}) - })) - return u -} - -// SetSignersCount sets the "signersCount" field. -func (u *CorrectnessReportUpsertOne) SetSignersCount(v uint64) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetSignersCount(v) - }) -} - -// AddSignersCount adds v to the "signersCount" field. -func (u *CorrectnessReportUpsertOne) AddSignersCount(v uint64) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.AddSignersCount(v) - }) -} - -// UpdateSignersCount sets the "signersCount" field to the value that was provided on create. -func (u *CorrectnessReportUpsertOne) UpdateSignersCount() *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateSignersCount() - }) -} - -// SetTimestamp sets the "timestamp" field. -func (u *CorrectnessReportUpsertOne) SetTimestamp(v uint64) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetTimestamp(v) - }) -} - -// AddTimestamp adds v to the "timestamp" field. -func (u *CorrectnessReportUpsertOne) AddTimestamp(v uint64) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.AddTimestamp(v) - }) -} - -// UpdateTimestamp sets the "timestamp" field to the value that was provided on create. -func (u *CorrectnessReportUpsertOne) UpdateTimestamp() *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateTimestamp() - }) -} - -// SetSignature sets the "signature" field. -func (u *CorrectnessReportUpsertOne) SetSignature(v []byte) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetSignature(v) - }) -} - -// UpdateSignature sets the "signature" field to the value that was provided on create. -func (u *CorrectnessReportUpsertOne) UpdateSignature() *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateSignature() - }) -} - -// SetHash sets the "hash" field. -func (u *CorrectnessReportUpsertOne) SetHash(v []byte) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetHash(v) - }) -} - -// UpdateHash sets the "hash" field to the value that was provided on create. -func (u *CorrectnessReportUpsertOne) UpdateHash() *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateHash() - }) -} - -// SetTopic sets the "topic" field. -func (u *CorrectnessReportUpsertOne) SetTopic(v []byte) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetTopic(v) - }) -} - -// UpdateTopic sets the "topic" field to the value that was provided on create. -func (u *CorrectnessReportUpsertOne) UpdateTopic() *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateTopic() - }) -} - -// SetCorrect sets the "correct" field. -func (u *CorrectnessReportUpsertOne) SetCorrect(v bool) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetCorrect(v) - }) -} - -// UpdateCorrect sets the "correct" field to the value that was provided on create. -func (u *CorrectnessReportUpsertOne) UpdateCorrect() *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateCorrect() - }) -} - -// SetConsensus sets the "consensus" field. -func (u *CorrectnessReportUpsertOne) SetConsensus(v bool) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetConsensus(v) - }) -} - -// UpdateConsensus sets the "consensus" field to the value that was provided on create. -func (u *CorrectnessReportUpsertOne) UpdateConsensus() *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateConsensus() - }) -} - -// SetVoted sets the "voted" field. -func (u *CorrectnessReportUpsertOne) SetVoted(v *helpers.BigInt) *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetVoted(v) - }) -} - -// UpdateVoted sets the "voted" field to the value that was provided on create. -func (u *CorrectnessReportUpsertOne) UpdateVoted() *CorrectnessReportUpsertOne { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateVoted() - }) -} - -// Exec executes the query. -func (u *CorrectnessReportUpsertOne) Exec(ctx context.Context) error { - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for CorrectnessReportCreate.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *CorrectnessReportUpsertOne) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} - -// Exec executes the UPSERT query and returns the inserted/updated ID. -func (u *CorrectnessReportUpsertOne) ID(ctx context.Context) (id int, err error) { - node, err := u.create.Save(ctx) - if err != nil { - return id, err - } - return node.ID, nil -} - -// IDX is like ID, but panics if an error occurs. -func (u *CorrectnessReportUpsertOne) IDX(ctx context.Context) int { - id, err := u.ID(ctx) - if err != nil { - panic(err) - } - return id -} - -// CorrectnessReportCreateBulk is the builder for creating many CorrectnessReport entities in bulk. -type CorrectnessReportCreateBulk struct { - config - err error - builders []*CorrectnessReportCreate - conflict []sql.ConflictOption -} - -// Save creates the CorrectnessReport entities in the database. -func (crcb *CorrectnessReportCreateBulk) Save(ctx context.Context) ([]*CorrectnessReport, error) { - if crcb.err != nil { - return nil, crcb.err - } - specs := make([]*sqlgraph.CreateSpec, len(crcb.builders)) - nodes := make([]*CorrectnessReport, len(crcb.builders)) - mutators := make([]Mutator, len(crcb.builders)) - for i := range crcb.builders { - func(i int, root context.Context) { - builder := crcb.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*CorrectnessReportMutation) - 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, crcb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - spec.OnConflict = crcb.conflict - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, crcb.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, crcb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (crcb *CorrectnessReportCreateBulk) SaveX(ctx context.Context) []*CorrectnessReport { - v, err := crcb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (crcb *CorrectnessReportCreateBulk) Exec(ctx context.Context) error { - _, err := crcb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (crcb *CorrectnessReportCreateBulk) ExecX(ctx context.Context) { - if err := crcb.Exec(ctx); err != nil { - panic(err) - } -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.CorrectnessReport.CreateBulk(builders...). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.CorrectnessReportUpsert) { -// SetSignersCount(v+v). -// }). -// Exec(ctx) -func (crcb *CorrectnessReportCreateBulk) OnConflict(opts ...sql.ConflictOption) *CorrectnessReportUpsertBulk { - crcb.conflict = opts - return &CorrectnessReportUpsertBulk{ - create: crcb, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.CorrectnessReport.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (crcb *CorrectnessReportCreateBulk) OnConflictColumns(columns ...string) *CorrectnessReportUpsertBulk { - crcb.conflict = append(crcb.conflict, sql.ConflictColumns(columns...)) - return &CorrectnessReportUpsertBulk{ - create: crcb, - } -} - -// CorrectnessReportUpsertBulk is the builder for "upsert"-ing -// a bulk of CorrectnessReport nodes. -type CorrectnessReportUpsertBulk struct { - create *CorrectnessReportCreateBulk -} - -// UpdateNewValues updates the mutable fields using the new values that -// were set on create. Using this option is equivalent to using: -// -// client.CorrectnessReport.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *CorrectnessReportUpsertBulk) UpdateNewValues() *CorrectnessReportUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.CorrectnessReport.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *CorrectnessReportUpsertBulk) Ignore() *CorrectnessReportUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *CorrectnessReportUpsertBulk) DoNothing() *CorrectnessReportUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the CorrectnessReportCreateBulk.OnConflict -// documentation for more info. -func (u *CorrectnessReportUpsertBulk) Update(set func(*CorrectnessReportUpsert)) *CorrectnessReportUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&CorrectnessReportUpsert{UpdateSet: update}) - })) - return u -} - -// SetSignersCount sets the "signersCount" field. -func (u *CorrectnessReportUpsertBulk) SetSignersCount(v uint64) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetSignersCount(v) - }) -} - -// AddSignersCount adds v to the "signersCount" field. -func (u *CorrectnessReportUpsertBulk) AddSignersCount(v uint64) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.AddSignersCount(v) - }) -} - -// UpdateSignersCount sets the "signersCount" field to the value that was provided on create. -func (u *CorrectnessReportUpsertBulk) UpdateSignersCount() *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateSignersCount() - }) -} - -// SetTimestamp sets the "timestamp" field. -func (u *CorrectnessReportUpsertBulk) SetTimestamp(v uint64) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetTimestamp(v) - }) -} - -// AddTimestamp adds v to the "timestamp" field. -func (u *CorrectnessReportUpsertBulk) AddTimestamp(v uint64) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.AddTimestamp(v) - }) -} - -// UpdateTimestamp sets the "timestamp" field to the value that was provided on create. -func (u *CorrectnessReportUpsertBulk) UpdateTimestamp() *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateTimestamp() - }) -} - -// SetSignature sets the "signature" field. -func (u *CorrectnessReportUpsertBulk) SetSignature(v []byte) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetSignature(v) - }) -} - -// UpdateSignature sets the "signature" field to the value that was provided on create. -func (u *CorrectnessReportUpsertBulk) UpdateSignature() *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateSignature() - }) -} - -// SetHash sets the "hash" field. -func (u *CorrectnessReportUpsertBulk) SetHash(v []byte) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetHash(v) - }) -} - -// UpdateHash sets the "hash" field to the value that was provided on create. -func (u *CorrectnessReportUpsertBulk) UpdateHash() *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateHash() - }) -} - -// SetTopic sets the "topic" field. -func (u *CorrectnessReportUpsertBulk) SetTopic(v []byte) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetTopic(v) - }) -} - -// UpdateTopic sets the "topic" field to the value that was provided on create. -func (u *CorrectnessReportUpsertBulk) UpdateTopic() *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateTopic() - }) -} - -// SetCorrect sets the "correct" field. -func (u *CorrectnessReportUpsertBulk) SetCorrect(v bool) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetCorrect(v) - }) -} - -// UpdateCorrect sets the "correct" field to the value that was provided on create. -func (u *CorrectnessReportUpsertBulk) UpdateCorrect() *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateCorrect() - }) -} - -// SetConsensus sets the "consensus" field. -func (u *CorrectnessReportUpsertBulk) SetConsensus(v bool) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetConsensus(v) - }) -} - -// UpdateConsensus sets the "consensus" field to the value that was provided on create. -func (u *CorrectnessReportUpsertBulk) UpdateConsensus() *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateConsensus() - }) -} - -// SetVoted sets the "voted" field. -func (u *CorrectnessReportUpsertBulk) SetVoted(v *helpers.BigInt) *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.SetVoted(v) - }) -} - -// UpdateVoted sets the "voted" field to the value that was provided on create. -func (u *CorrectnessReportUpsertBulk) UpdateVoted() *CorrectnessReportUpsertBulk { - return u.Update(func(s *CorrectnessReportUpsert) { - s.UpdateVoted() - }) -} - -// Exec executes the query. -func (u *CorrectnessReportUpsertBulk) Exec(ctx context.Context) error { - if u.create.err != nil { - return u.create.err - } - for i, b := range u.create.builders { - if len(b.conflict) != 0 { - return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the CorrectnessReportCreateBulk instead", i) - } - } - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for CorrectnessReportCreateBulk.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *CorrectnessReportUpsertBulk) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/ent/correctnessreport_delete.go b/internal/ent/correctnessreport_delete.go deleted file mode 100644 index bff65704..00000000 --- a/internal/ent/correctnessreport_delete.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" -) - -// CorrectnessReportDelete is the builder for deleting a CorrectnessReport entity. -type CorrectnessReportDelete struct { - config - hooks []Hook - mutation *CorrectnessReportMutation -} - -// Where appends a list predicates to the CorrectnessReportDelete builder. -func (crd *CorrectnessReportDelete) Where(ps ...predicate.CorrectnessReport) *CorrectnessReportDelete { - crd.mutation.Where(ps...) - return crd -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (crd *CorrectnessReportDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, crd.sqlExec, crd.mutation, crd.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (crd *CorrectnessReportDelete) ExecX(ctx context.Context) int { - n, err := crd.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (crd *CorrectnessReportDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(correctnessreport.Table, sqlgraph.NewFieldSpec(correctnessreport.FieldID, field.TypeInt)) - if ps := crd.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, crd.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - crd.mutation.done = true - return affected, err -} - -// CorrectnessReportDeleteOne is the builder for deleting a single CorrectnessReport entity. -type CorrectnessReportDeleteOne struct { - crd *CorrectnessReportDelete -} - -// Where appends a list predicates to the CorrectnessReportDelete builder. -func (crdo *CorrectnessReportDeleteOne) Where(ps ...predicate.CorrectnessReport) *CorrectnessReportDeleteOne { - crdo.crd.mutation.Where(ps...) - return crdo -} - -// Exec executes the deletion query. -func (crdo *CorrectnessReportDeleteOne) Exec(ctx context.Context) error { - n, err := crdo.crd.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{correctnessreport.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (crdo *CorrectnessReportDeleteOne) ExecX(ctx context.Context) { - if err := crdo.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/ent/correctnessreport_query.go b/internal/ent/correctnessreport_query.go deleted file mode 100644 index 7c796519..00000000 --- a/internal/ent/correctnessreport_query.go +++ /dev/null @@ -1,671 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "database/sql/driver" - "fmt" - "math" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// CorrectnessReportQuery is the builder for querying CorrectnessReport entities. -type CorrectnessReportQuery struct { - config - ctx *QueryContext - order []correctnessreport.OrderOption - inters []Interceptor - predicates []predicate.CorrectnessReport - withSigners *SignerQuery - modifiers []func(*sql.Selector) - loadTotal []func(context.Context, []*CorrectnessReport) error - withNamedSigners map[string]*SignerQuery - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the CorrectnessReportQuery builder. -func (crq *CorrectnessReportQuery) Where(ps ...predicate.CorrectnessReport) *CorrectnessReportQuery { - crq.predicates = append(crq.predicates, ps...) - return crq -} - -// Limit the number of records to be returned by this query. -func (crq *CorrectnessReportQuery) Limit(limit int) *CorrectnessReportQuery { - crq.ctx.Limit = &limit - return crq -} - -// Offset to start from. -func (crq *CorrectnessReportQuery) Offset(offset int) *CorrectnessReportQuery { - crq.ctx.Offset = &offset - return crq -} - -// 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 (crq *CorrectnessReportQuery) Unique(unique bool) *CorrectnessReportQuery { - crq.ctx.Unique = &unique - return crq -} - -// Order specifies how the records should be ordered. -func (crq *CorrectnessReportQuery) Order(o ...correctnessreport.OrderOption) *CorrectnessReportQuery { - crq.order = append(crq.order, o...) - return crq -} - -// QuerySigners chains the current query on the "signers" edge. -func (crq *CorrectnessReportQuery) QuerySigners() *SignerQuery { - query := (&SignerClient{config: crq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := crq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := crq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(correctnessreport.Table, correctnessreport.FieldID, selector), - sqlgraph.To(signer.Table, signer.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, correctnessreport.SignersTable, correctnessreport.SignersPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(crq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first CorrectnessReport entity from the query. -// Returns a *NotFoundError when no CorrectnessReport was found. -func (crq *CorrectnessReportQuery) First(ctx context.Context) (*CorrectnessReport, error) { - nodes, err := crq.Limit(1).All(setContextOp(ctx, crq.ctx, "First")) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{correctnessreport.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (crq *CorrectnessReportQuery) FirstX(ctx context.Context) *CorrectnessReport { - node, err := crq.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first CorrectnessReport ID from the query. -// Returns a *NotFoundError when no CorrectnessReport ID was found. -func (crq *CorrectnessReportQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = crq.Limit(1).IDs(setContextOp(ctx, crq.ctx, "FirstID")); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{correctnessreport.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (crq *CorrectnessReportQuery) FirstIDX(ctx context.Context) int { - id, err := crq.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single CorrectnessReport entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one CorrectnessReport entity is found. -// Returns a *NotFoundError when no CorrectnessReport entities are found. -func (crq *CorrectnessReportQuery) Only(ctx context.Context) (*CorrectnessReport, error) { - nodes, err := crq.Limit(2).All(setContextOp(ctx, crq.ctx, "Only")) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{correctnessreport.Label} - default: - return nil, &NotSingularError{correctnessreport.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (crq *CorrectnessReportQuery) OnlyX(ctx context.Context) *CorrectnessReport { - node, err := crq.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only CorrectnessReport ID in the query. -// Returns a *NotSingularError when more than one CorrectnessReport ID is found. -// Returns a *NotFoundError when no entities are found. -func (crq *CorrectnessReportQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = crq.Limit(2).IDs(setContextOp(ctx, crq.ctx, "OnlyID")); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{correctnessreport.Label} - default: - err = &NotSingularError{correctnessreport.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (crq *CorrectnessReportQuery) OnlyIDX(ctx context.Context) int { - id, err := crq.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of CorrectnessReports. -func (crq *CorrectnessReportQuery) All(ctx context.Context) ([]*CorrectnessReport, error) { - ctx = setContextOp(ctx, crq.ctx, "All") - if err := crq.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*CorrectnessReport, *CorrectnessReportQuery]() - return withInterceptors[[]*CorrectnessReport](ctx, crq, qr, crq.inters) -} - -// AllX is like All, but panics if an error occurs. -func (crq *CorrectnessReportQuery) AllX(ctx context.Context) []*CorrectnessReport { - nodes, err := crq.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of CorrectnessReport IDs. -func (crq *CorrectnessReportQuery) IDs(ctx context.Context) (ids []int, err error) { - if crq.ctx.Unique == nil && crq.path != nil { - crq.Unique(true) - } - ctx = setContextOp(ctx, crq.ctx, "IDs") - if err = crq.Select(correctnessreport.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (crq *CorrectnessReportQuery) IDsX(ctx context.Context) []int { - ids, err := crq.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (crq *CorrectnessReportQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, crq.ctx, "Count") - if err := crq.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, crq, querierCount[*CorrectnessReportQuery](), crq.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (crq *CorrectnessReportQuery) CountX(ctx context.Context) int { - count, err := crq.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (crq *CorrectnessReportQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, crq.ctx, "Exist") - switch _, err := crq.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 (crq *CorrectnessReportQuery) ExistX(ctx context.Context) bool { - exist, err := crq.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the CorrectnessReportQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (crq *CorrectnessReportQuery) Clone() *CorrectnessReportQuery { - if crq == nil { - return nil - } - return &CorrectnessReportQuery{ - config: crq.config, - ctx: crq.ctx.Clone(), - order: append([]correctnessreport.OrderOption{}, crq.order...), - inters: append([]Interceptor{}, crq.inters...), - predicates: append([]predicate.CorrectnessReport{}, crq.predicates...), - withSigners: crq.withSigners.Clone(), - // clone intermediate query. - sql: crq.sql.Clone(), - path: crq.path, - } -} - -// WithSigners tells the query-builder to eager-load the nodes that are connected to -// the "signers" edge. The optional arguments are used to configure the query builder of the edge. -func (crq *CorrectnessReportQuery) WithSigners(opts ...func(*SignerQuery)) *CorrectnessReportQuery { - query := (&SignerClient{config: crq.config}).Query() - for _, opt := range opts { - opt(query) - } - crq.withSigners = query - return crq -} - -// 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 { -// SignersCount uint64 `json:"signersCount,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.CorrectnessReport.Query(). -// GroupBy(correctnessreport.FieldSignersCount). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (crq *CorrectnessReportQuery) GroupBy(field string, fields ...string) *CorrectnessReportGroupBy { - crq.ctx.Fields = append([]string{field}, fields...) - grbuild := &CorrectnessReportGroupBy{build: crq} - grbuild.flds = &crq.ctx.Fields - grbuild.label = correctnessreport.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 { -// SignersCount uint64 `json:"signersCount,omitempty"` -// } -// -// client.CorrectnessReport.Query(). -// Select(correctnessreport.FieldSignersCount). -// Scan(ctx, &v) -func (crq *CorrectnessReportQuery) Select(fields ...string) *CorrectnessReportSelect { - crq.ctx.Fields = append(crq.ctx.Fields, fields...) - sbuild := &CorrectnessReportSelect{CorrectnessReportQuery: crq} - sbuild.label = correctnessreport.Label - sbuild.flds, sbuild.scan = &crq.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a CorrectnessReportSelect configured with the given aggregations. -func (crq *CorrectnessReportQuery) Aggregate(fns ...AggregateFunc) *CorrectnessReportSelect { - return crq.Select().Aggregate(fns...) -} - -func (crq *CorrectnessReportQuery) prepareQuery(ctx context.Context) error { - for _, inter := range crq.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, crq); err != nil { - return err - } - } - } - for _, f := range crq.ctx.Fields { - if !correctnessreport.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if crq.path != nil { - prev, err := crq.path(ctx) - if err != nil { - return err - } - crq.sql = prev - } - return nil -} - -func (crq *CorrectnessReportQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*CorrectnessReport, error) { - var ( - nodes = []*CorrectnessReport{} - _spec = crq.querySpec() - loadedTypes = [1]bool{ - crq.withSigners != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*CorrectnessReport).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &CorrectnessReport{config: crq.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(crq.modifiers) > 0 { - _spec.Modifiers = crq.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, crq.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := crq.withSigners; query != nil { - if err := crq.loadSigners(ctx, query, nodes, - func(n *CorrectnessReport) { n.Edges.Signers = []*Signer{} }, - func(n *CorrectnessReport, e *Signer) { n.Edges.Signers = append(n.Edges.Signers, e) }); err != nil { - return nil, err - } - } - for name, query := range crq.withNamedSigners { - if err := crq.loadSigners(ctx, query, nodes, - func(n *CorrectnessReport) { n.appendNamedSigners(name) }, - func(n *CorrectnessReport, e *Signer) { n.appendNamedSigners(name, e) }); err != nil { - return nil, err - } - } - for i := range crq.loadTotal { - if err := crq.loadTotal[i](ctx, nodes); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (crq *CorrectnessReportQuery) loadSigners(ctx context.Context, query *SignerQuery, nodes []*CorrectnessReport, init func(*CorrectnessReport), assign func(*CorrectnessReport, *Signer)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int]*CorrectnessReport) - nids := make(map[int]map[*CorrectnessReport]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(correctnessreport.SignersTable) - s.Join(joinT).On(s.C(signer.FieldID), joinT.C(correctnessreport.SignersPrimaryKey[1])) - s.Where(sql.InValues(joinT.C(correctnessreport.SignersPrimaryKey[0]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(correctnessreport.SignersPrimaryKey[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[*CorrectnessReport]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*Signer](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 "signers" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} - -func (crq *CorrectnessReportQuery) sqlCount(ctx context.Context) (int, error) { - _spec := crq.querySpec() - if len(crq.modifiers) > 0 { - _spec.Modifiers = crq.modifiers - } - _spec.Node.Columns = crq.ctx.Fields - if len(crq.ctx.Fields) > 0 { - _spec.Unique = crq.ctx.Unique != nil && *crq.ctx.Unique - } - return sqlgraph.CountNodes(ctx, crq.driver, _spec) -} - -func (crq *CorrectnessReportQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(correctnessreport.Table, correctnessreport.Columns, sqlgraph.NewFieldSpec(correctnessreport.FieldID, field.TypeInt)) - _spec.From = crq.sql - if unique := crq.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if crq.path != nil { - _spec.Unique = true - } - if fields := crq.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, correctnessreport.FieldID) - for i := range fields { - if fields[i] != correctnessreport.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := crq.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := crq.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := crq.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := crq.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (crq *CorrectnessReportQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(crq.driver.Dialect()) - t1 := builder.Table(correctnessreport.Table) - columns := crq.ctx.Fields - if len(columns) == 0 { - columns = correctnessreport.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if crq.sql != nil { - selector = crq.sql - selector.Select(selector.Columns(columns...)...) - } - if crq.ctx.Unique != nil && *crq.ctx.Unique { - selector.Distinct() - } - for _, p := range crq.predicates { - p(selector) - } - for _, p := range crq.order { - p(selector) - } - if offset := crq.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 := crq.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// WithNamedSigners tells the query-builder to eager-load the nodes that are connected to the "signers" -// edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (crq *CorrectnessReportQuery) WithNamedSigners(name string, opts ...func(*SignerQuery)) *CorrectnessReportQuery { - query := (&SignerClient{config: crq.config}).Query() - for _, opt := range opts { - opt(query) - } - if crq.withNamedSigners == nil { - crq.withNamedSigners = make(map[string]*SignerQuery) - } - crq.withNamedSigners[name] = query - return crq -} - -// CorrectnessReportGroupBy is the group-by builder for CorrectnessReport entities. -type CorrectnessReportGroupBy struct { - selector - build *CorrectnessReportQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (crgb *CorrectnessReportGroupBy) Aggregate(fns ...AggregateFunc) *CorrectnessReportGroupBy { - crgb.fns = append(crgb.fns, fns...) - return crgb -} - -// Scan applies the selector query and scans the result into the given value. -func (crgb *CorrectnessReportGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, crgb.build.ctx, "GroupBy") - if err := crgb.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*CorrectnessReportQuery, *CorrectnessReportGroupBy](ctx, crgb.build, crgb, crgb.build.inters, v) -} - -func (crgb *CorrectnessReportGroupBy) sqlScan(ctx context.Context, root *CorrectnessReportQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(crgb.fns)) - for _, fn := range crgb.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*crgb.flds)+len(crgb.fns)) - for _, f := range *crgb.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*crgb.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := crgb.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// CorrectnessReportSelect is the builder for selecting fields of CorrectnessReport entities. -type CorrectnessReportSelect struct { - *CorrectnessReportQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (crs *CorrectnessReportSelect) Aggregate(fns ...AggregateFunc) *CorrectnessReportSelect { - crs.fns = append(crs.fns, fns...) - return crs -} - -// Scan applies the selector query and scans the result into the given value. -func (crs *CorrectnessReportSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, crs.ctx, "Select") - if err := crs.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*CorrectnessReportQuery, *CorrectnessReportSelect](ctx, crs.CorrectnessReportQuery, crs, crs.inters, v) -} - -func (crs *CorrectnessReportSelect) sqlScan(ctx context.Context, root *CorrectnessReportQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(crs.fns)) - for _, fn := range crs.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*crs.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 := crs.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} diff --git a/internal/ent/correctnessreport_update.go b/internal/ent/correctnessreport_update.go deleted file mode 100644 index 2e6a0c99..00000000 --- a/internal/ent/correctnessreport_update.go +++ /dev/null @@ -1,633 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// CorrectnessReportUpdate is the builder for updating CorrectnessReport entities. -type CorrectnessReportUpdate struct { - config - hooks []Hook - mutation *CorrectnessReportMutation -} - -// Where appends a list predicates to the CorrectnessReportUpdate builder. -func (cru *CorrectnessReportUpdate) Where(ps ...predicate.CorrectnessReport) *CorrectnessReportUpdate { - cru.mutation.Where(ps...) - return cru -} - -// SetSignersCount sets the "signersCount" field. -func (cru *CorrectnessReportUpdate) SetSignersCount(u uint64) *CorrectnessReportUpdate { - cru.mutation.ResetSignersCount() - cru.mutation.SetSignersCount(u) - return cru -} - -// SetNillableSignersCount sets the "signersCount" field if the given value is not nil. -func (cru *CorrectnessReportUpdate) SetNillableSignersCount(u *uint64) *CorrectnessReportUpdate { - if u != nil { - cru.SetSignersCount(*u) - } - return cru -} - -// AddSignersCount adds u to the "signersCount" field. -func (cru *CorrectnessReportUpdate) AddSignersCount(u int64) *CorrectnessReportUpdate { - cru.mutation.AddSignersCount(u) - return cru -} - -// SetTimestamp sets the "timestamp" field. -func (cru *CorrectnessReportUpdate) SetTimestamp(u uint64) *CorrectnessReportUpdate { - cru.mutation.ResetTimestamp() - cru.mutation.SetTimestamp(u) - return cru -} - -// SetNillableTimestamp sets the "timestamp" field if the given value is not nil. -func (cru *CorrectnessReportUpdate) SetNillableTimestamp(u *uint64) *CorrectnessReportUpdate { - if u != nil { - cru.SetTimestamp(*u) - } - return cru -} - -// AddTimestamp adds u to the "timestamp" field. -func (cru *CorrectnessReportUpdate) AddTimestamp(u int64) *CorrectnessReportUpdate { - cru.mutation.AddTimestamp(u) - return cru -} - -// SetSignature sets the "signature" field. -func (cru *CorrectnessReportUpdate) SetSignature(b []byte) *CorrectnessReportUpdate { - cru.mutation.SetSignature(b) - return cru -} - -// SetHash sets the "hash" field. -func (cru *CorrectnessReportUpdate) SetHash(b []byte) *CorrectnessReportUpdate { - cru.mutation.SetHash(b) - return cru -} - -// SetTopic sets the "topic" field. -func (cru *CorrectnessReportUpdate) SetTopic(b []byte) *CorrectnessReportUpdate { - cru.mutation.SetTopic(b) - return cru -} - -// SetCorrect sets the "correct" field. -func (cru *CorrectnessReportUpdate) SetCorrect(b bool) *CorrectnessReportUpdate { - cru.mutation.SetCorrect(b) - return cru -} - -// SetNillableCorrect sets the "correct" field if the given value is not nil. -func (cru *CorrectnessReportUpdate) SetNillableCorrect(b *bool) *CorrectnessReportUpdate { - if b != nil { - cru.SetCorrect(*b) - } - return cru -} - -// SetConsensus sets the "consensus" field. -func (cru *CorrectnessReportUpdate) SetConsensus(b bool) *CorrectnessReportUpdate { - cru.mutation.SetConsensus(b) - return cru -} - -// SetNillableConsensus sets the "consensus" field if the given value is not nil. -func (cru *CorrectnessReportUpdate) SetNillableConsensus(b *bool) *CorrectnessReportUpdate { - if b != nil { - cru.SetConsensus(*b) - } - return cru -} - -// SetVoted sets the "voted" field. -func (cru *CorrectnessReportUpdate) SetVoted(hi *helpers.BigInt) *CorrectnessReportUpdate { - cru.mutation.SetVoted(hi) - return cru -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by IDs. -func (cru *CorrectnessReportUpdate) AddSignerIDs(ids ...int) *CorrectnessReportUpdate { - cru.mutation.AddSignerIDs(ids...) - return cru -} - -// AddSigners adds the "signers" edges to the Signer entity. -func (cru *CorrectnessReportUpdate) AddSigners(s ...*Signer) *CorrectnessReportUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return cru.AddSignerIDs(ids...) -} - -// Mutation returns the CorrectnessReportMutation object of the builder. -func (cru *CorrectnessReportUpdate) Mutation() *CorrectnessReportMutation { - return cru.mutation -} - -// ClearSigners clears all "signers" edges to the Signer entity. -func (cru *CorrectnessReportUpdate) ClearSigners() *CorrectnessReportUpdate { - cru.mutation.ClearSigners() - return cru -} - -// RemoveSignerIDs removes the "signers" edge to Signer entities by IDs. -func (cru *CorrectnessReportUpdate) RemoveSignerIDs(ids ...int) *CorrectnessReportUpdate { - cru.mutation.RemoveSignerIDs(ids...) - return cru -} - -// RemoveSigners removes "signers" edges to Signer entities. -func (cru *CorrectnessReportUpdate) RemoveSigners(s ...*Signer) *CorrectnessReportUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return cru.RemoveSignerIDs(ids...) -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (cru *CorrectnessReportUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, cru.sqlSave, cru.mutation, cru.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (cru *CorrectnessReportUpdate) SaveX(ctx context.Context) int { - affected, err := cru.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (cru *CorrectnessReportUpdate) Exec(ctx context.Context) error { - _, err := cru.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (cru *CorrectnessReportUpdate) ExecX(ctx context.Context) { - if err := cru.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (cru *CorrectnessReportUpdate) check() error { - if v, ok := cru.mutation.Signature(); ok { - if err := correctnessreport.SignatureValidator(v); err != nil { - return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "CorrectnessReport.signature": %w`, err)} - } - } - if v, ok := cru.mutation.Hash(); ok { - if err := correctnessreport.HashValidator(v); err != nil { - return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "CorrectnessReport.hash": %w`, err)} - } - } - if v, ok := cru.mutation.Topic(); ok { - if err := correctnessreport.TopicValidator(v); err != nil { - return &ValidationError{Name: "topic", err: fmt.Errorf(`ent: validator failed for field "CorrectnessReport.topic": %w`, err)} - } - } - return nil -} - -func (cru *CorrectnessReportUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := cru.check(); err != nil { - return n, err - } - _spec := sqlgraph.NewUpdateSpec(correctnessreport.Table, correctnessreport.Columns, sqlgraph.NewFieldSpec(correctnessreport.FieldID, field.TypeInt)) - if ps := cru.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := cru.mutation.SignersCount(); ok { - _spec.SetField(correctnessreport.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := cru.mutation.AddedSignersCount(); ok { - _spec.AddField(correctnessreport.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := cru.mutation.Timestamp(); ok { - _spec.SetField(correctnessreport.FieldTimestamp, field.TypeUint64, value) - } - if value, ok := cru.mutation.AddedTimestamp(); ok { - _spec.AddField(correctnessreport.FieldTimestamp, field.TypeUint64, value) - } - if value, ok := cru.mutation.Signature(); ok { - _spec.SetField(correctnessreport.FieldSignature, field.TypeBytes, value) - } - if value, ok := cru.mutation.Hash(); ok { - _spec.SetField(correctnessreport.FieldHash, field.TypeBytes, value) - } - if value, ok := cru.mutation.Topic(); ok { - _spec.SetField(correctnessreport.FieldTopic, field.TypeBytes, value) - } - if value, ok := cru.mutation.Correct(); ok { - _spec.SetField(correctnessreport.FieldCorrect, field.TypeBool, value) - } - if value, ok := cru.mutation.Consensus(); ok { - _spec.SetField(correctnessreport.FieldConsensus, field.TypeBool, value) - } - if value, ok := cru.mutation.Voted(); ok { - _spec.SetField(correctnessreport.FieldVoted, field.TypeUint, value) - } - if cru.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: correctnessreport.SignersTable, - Columns: correctnessreport.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := cru.mutation.RemovedSignersIDs(); len(nodes) > 0 && !cru.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: correctnessreport.SignersTable, - Columns: correctnessreport.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.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 := cru.mutation.SignersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: correctnessreport.SignersTable, - Columns: correctnessreport.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.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, cru.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{correctnessreport.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - cru.mutation.done = true - return n, nil -} - -// CorrectnessReportUpdateOne is the builder for updating a single CorrectnessReport entity. -type CorrectnessReportUpdateOne struct { - config - fields []string - hooks []Hook - mutation *CorrectnessReportMutation -} - -// SetSignersCount sets the "signersCount" field. -func (cruo *CorrectnessReportUpdateOne) SetSignersCount(u uint64) *CorrectnessReportUpdateOne { - cruo.mutation.ResetSignersCount() - cruo.mutation.SetSignersCount(u) - return cruo -} - -// SetNillableSignersCount sets the "signersCount" field if the given value is not nil. -func (cruo *CorrectnessReportUpdateOne) SetNillableSignersCount(u *uint64) *CorrectnessReportUpdateOne { - if u != nil { - cruo.SetSignersCount(*u) - } - return cruo -} - -// AddSignersCount adds u to the "signersCount" field. -func (cruo *CorrectnessReportUpdateOne) AddSignersCount(u int64) *CorrectnessReportUpdateOne { - cruo.mutation.AddSignersCount(u) - return cruo -} - -// SetTimestamp sets the "timestamp" field. -func (cruo *CorrectnessReportUpdateOne) SetTimestamp(u uint64) *CorrectnessReportUpdateOne { - cruo.mutation.ResetTimestamp() - cruo.mutation.SetTimestamp(u) - return cruo -} - -// SetNillableTimestamp sets the "timestamp" field if the given value is not nil. -func (cruo *CorrectnessReportUpdateOne) SetNillableTimestamp(u *uint64) *CorrectnessReportUpdateOne { - if u != nil { - cruo.SetTimestamp(*u) - } - return cruo -} - -// AddTimestamp adds u to the "timestamp" field. -func (cruo *CorrectnessReportUpdateOne) AddTimestamp(u int64) *CorrectnessReportUpdateOne { - cruo.mutation.AddTimestamp(u) - return cruo -} - -// SetSignature sets the "signature" field. -func (cruo *CorrectnessReportUpdateOne) SetSignature(b []byte) *CorrectnessReportUpdateOne { - cruo.mutation.SetSignature(b) - return cruo -} - -// SetHash sets the "hash" field. -func (cruo *CorrectnessReportUpdateOne) SetHash(b []byte) *CorrectnessReportUpdateOne { - cruo.mutation.SetHash(b) - return cruo -} - -// SetTopic sets the "topic" field. -func (cruo *CorrectnessReportUpdateOne) SetTopic(b []byte) *CorrectnessReportUpdateOne { - cruo.mutation.SetTopic(b) - return cruo -} - -// SetCorrect sets the "correct" field. -func (cruo *CorrectnessReportUpdateOne) SetCorrect(b bool) *CorrectnessReportUpdateOne { - cruo.mutation.SetCorrect(b) - return cruo -} - -// SetNillableCorrect sets the "correct" field if the given value is not nil. -func (cruo *CorrectnessReportUpdateOne) SetNillableCorrect(b *bool) *CorrectnessReportUpdateOne { - if b != nil { - cruo.SetCorrect(*b) - } - return cruo -} - -// SetConsensus sets the "consensus" field. -func (cruo *CorrectnessReportUpdateOne) SetConsensus(b bool) *CorrectnessReportUpdateOne { - cruo.mutation.SetConsensus(b) - return cruo -} - -// SetNillableConsensus sets the "consensus" field if the given value is not nil. -func (cruo *CorrectnessReportUpdateOne) SetNillableConsensus(b *bool) *CorrectnessReportUpdateOne { - if b != nil { - cruo.SetConsensus(*b) - } - return cruo -} - -// SetVoted sets the "voted" field. -func (cruo *CorrectnessReportUpdateOne) SetVoted(hi *helpers.BigInt) *CorrectnessReportUpdateOne { - cruo.mutation.SetVoted(hi) - return cruo -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by IDs. -func (cruo *CorrectnessReportUpdateOne) AddSignerIDs(ids ...int) *CorrectnessReportUpdateOne { - cruo.mutation.AddSignerIDs(ids...) - return cruo -} - -// AddSigners adds the "signers" edges to the Signer entity. -func (cruo *CorrectnessReportUpdateOne) AddSigners(s ...*Signer) *CorrectnessReportUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return cruo.AddSignerIDs(ids...) -} - -// Mutation returns the CorrectnessReportMutation object of the builder. -func (cruo *CorrectnessReportUpdateOne) Mutation() *CorrectnessReportMutation { - return cruo.mutation -} - -// ClearSigners clears all "signers" edges to the Signer entity. -func (cruo *CorrectnessReportUpdateOne) ClearSigners() *CorrectnessReportUpdateOne { - cruo.mutation.ClearSigners() - return cruo -} - -// RemoveSignerIDs removes the "signers" edge to Signer entities by IDs. -func (cruo *CorrectnessReportUpdateOne) RemoveSignerIDs(ids ...int) *CorrectnessReportUpdateOne { - cruo.mutation.RemoveSignerIDs(ids...) - return cruo -} - -// RemoveSigners removes "signers" edges to Signer entities. -func (cruo *CorrectnessReportUpdateOne) RemoveSigners(s ...*Signer) *CorrectnessReportUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return cruo.RemoveSignerIDs(ids...) -} - -// Where appends a list predicates to the CorrectnessReportUpdate builder. -func (cruo *CorrectnessReportUpdateOne) Where(ps ...predicate.CorrectnessReport) *CorrectnessReportUpdateOne { - cruo.mutation.Where(ps...) - return cruo -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (cruo *CorrectnessReportUpdateOne) Select(field string, fields ...string) *CorrectnessReportUpdateOne { - cruo.fields = append([]string{field}, fields...) - return cruo -} - -// Save executes the query and returns the updated CorrectnessReport entity. -func (cruo *CorrectnessReportUpdateOne) Save(ctx context.Context) (*CorrectnessReport, error) { - return withHooks(ctx, cruo.sqlSave, cruo.mutation, cruo.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (cruo *CorrectnessReportUpdateOne) SaveX(ctx context.Context) *CorrectnessReport { - node, err := cruo.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (cruo *CorrectnessReportUpdateOne) Exec(ctx context.Context) error { - _, err := cruo.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (cruo *CorrectnessReportUpdateOne) ExecX(ctx context.Context) { - if err := cruo.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (cruo *CorrectnessReportUpdateOne) check() error { - if v, ok := cruo.mutation.Signature(); ok { - if err := correctnessreport.SignatureValidator(v); err != nil { - return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "CorrectnessReport.signature": %w`, err)} - } - } - if v, ok := cruo.mutation.Hash(); ok { - if err := correctnessreport.HashValidator(v); err != nil { - return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "CorrectnessReport.hash": %w`, err)} - } - } - if v, ok := cruo.mutation.Topic(); ok { - if err := correctnessreport.TopicValidator(v); err != nil { - return &ValidationError{Name: "topic", err: fmt.Errorf(`ent: validator failed for field "CorrectnessReport.topic": %w`, err)} - } - } - return nil -} - -func (cruo *CorrectnessReportUpdateOne) sqlSave(ctx context.Context) (_node *CorrectnessReport, err error) { - if err := cruo.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(correctnessreport.Table, correctnessreport.Columns, sqlgraph.NewFieldSpec(correctnessreport.FieldID, field.TypeInt)) - id, ok := cruo.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "CorrectnessReport.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := cruo.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, correctnessreport.FieldID) - for _, f := range fields { - if !correctnessreport.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != correctnessreport.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := cruo.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := cruo.mutation.SignersCount(); ok { - _spec.SetField(correctnessreport.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := cruo.mutation.AddedSignersCount(); ok { - _spec.AddField(correctnessreport.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := cruo.mutation.Timestamp(); ok { - _spec.SetField(correctnessreport.FieldTimestamp, field.TypeUint64, value) - } - if value, ok := cruo.mutation.AddedTimestamp(); ok { - _spec.AddField(correctnessreport.FieldTimestamp, field.TypeUint64, value) - } - if value, ok := cruo.mutation.Signature(); ok { - _spec.SetField(correctnessreport.FieldSignature, field.TypeBytes, value) - } - if value, ok := cruo.mutation.Hash(); ok { - _spec.SetField(correctnessreport.FieldHash, field.TypeBytes, value) - } - if value, ok := cruo.mutation.Topic(); ok { - _spec.SetField(correctnessreport.FieldTopic, field.TypeBytes, value) - } - if value, ok := cruo.mutation.Correct(); ok { - _spec.SetField(correctnessreport.FieldCorrect, field.TypeBool, value) - } - if value, ok := cruo.mutation.Consensus(); ok { - _spec.SetField(correctnessreport.FieldConsensus, field.TypeBool, value) - } - if value, ok := cruo.mutation.Voted(); ok { - _spec.SetField(correctnessreport.FieldVoted, field.TypeUint, value) - } - if cruo.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: correctnessreport.SignersTable, - Columns: correctnessreport.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := cruo.mutation.RemovedSignersIDs(); len(nodes) > 0 && !cruo.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: correctnessreport.SignersTable, - Columns: correctnessreport.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.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 := cruo.mutation.SignersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: correctnessreport.SignersTable, - Columns: correctnessreport.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _node = &CorrectnessReport{config: cruo.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, cruo.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{correctnessreport.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - cruo.mutation.done = true - return _node, nil -} diff --git a/internal/ent/ent.go b/internal/ent/ent.go deleted file mode 100644 index a09b3a29..00000000 --- a/internal/ent/ent.go +++ /dev/null @@ -1,614 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "reflect" - "sync" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// 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{ - assetprice.Table: assetprice.ValidColumn, - correctnessreport.Table: correctnessreport.ValidColumn, - eventlog.Table: eventlog.ValidColumn, - signer.Table: signer.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/internal/ent/entc.go b/internal/ent/entc.go deleted file mode 100644 index 356218e5..00000000 --- a/internal/ent/entc.go +++ /dev/null @@ -1,32 +0,0 @@ -//go:build ignore - -package main - -import ( - "log" - - "entgo.io/contrib/entgql" - "entgo.io/ent/entc" - "entgo.io/ent/entc/gen" -) - -func main() { - ex, err := entgql.NewExtension( - // Tell Ent to generate a GraphQL schema for - // the Ent schema in a file named ent.graphql. - entgql.WithWhereInputs(true), - entgql.WithSchemaGenerator(), - entgql.WithSchemaPath("transport/server/gql/unchained.graphql"), - entgql.WithConfigPath("gqlgen.yml"), - ) - if err != nil { - log.Fatalf("creating entgql extension: %v", err) - } - opts := []entc.Option{ - entc.Extensions(ex), - } - config := &gen.Config{Features: []gen.Feature{gen.FeatureUpsert}} - if err := entc.Generate("./ent/schema", config, opts...); err != nil { - log.Fatalf("running ent codegen: %v", err) - } -} diff --git a/internal/ent/enttest/enttest.go b/internal/ent/enttest/enttest.go deleted file mode 100644 index 6accd20d..00000000 --- a/internal/ent/enttest/enttest.go +++ /dev/null @@ -1,84 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package enttest - -import ( - "context" - - "github.com/TimeleapLabs/unchained/internal/ent" - // required by schema hooks. - _ "github.com/TimeleapLabs/unchained/internal/ent/runtime" - - "entgo.io/ent/dialect/sql/schema" - "github.com/TimeleapLabs/unchained/internal/ent/migrate" -) - -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/internal/ent/eventlog.go b/internal/ent/eventlog.go deleted file mode 100644 index 5e8af9ed..00000000 --- a/internal/ent/eventlog.go +++ /dev/null @@ -1,278 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "encoding/json" - "fmt" - "github.com/TimeleapLabs/unchained/internal/model" - "strings" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" -) - -// EventLog is the model entity for the EventLog schema. -type EventLog struct { - config `json:"-"` - // ID of the ent. - ID int `json:"id,omitempty"` - // Block holds the value of the "block" field. - Block uint64 `json:"block,omitempty"` - // SignersCount holds the value of the "signersCount" field. - SignersCount uint64 `json:"signersCount,omitempty"` - // Signature holds the value of the "signature" field. - Signature []byte `json:"signature,omitempty"` - // Address holds the value of the "address" field. - Address string `json:"address,omitempty"` - // Chain holds the value of the "chain" field. - Chain string `json:"chain,omitempty"` - // Index holds the value of the "index" field. - Index uint64 `json:"index,omitempty"` - // Event holds the value of the "event" field. - Event string `json:"event,omitempty"` - // Transaction holds the value of the "transaction" field. - Transaction []byte `json:"transaction,omitempty"` - // Args holds the value of the "args" field. - Args []model.EventLogArg `json:"args,omitempty"` - // Consensus holds the value of the "consensus" field. - Consensus bool `json:"consensus,omitempty"` - // Voted holds the value of the "voted" field. - Voted *helpers.BigInt `json:"voted,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the EventLogQuery when eager-loading is set. - Edges EventLogEdges `json:"edges"` - selectValues sql.SelectValues -} - -// EventLogEdges holds the relations/edges for other nodes in the graph. -type EventLogEdges struct { - // Signers holds the value of the signers edge. - Signers []*Signer `json:"signers,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [1]bool - // totalCount holds the count of the edges above. - totalCount [1]map[string]int - - namedSigners map[string][]*Signer -} - -// SignersOrErr returns the Signers value or an error if the edge -// was not loaded in eager-loading. -func (e EventLogEdges) SignersOrErr() ([]*Signer, error) { - if e.loadedTypes[0] { - return e.Signers, nil - } - return nil, &NotLoadedError{edge: "signers"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*EventLog) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case eventlog.FieldSignature, eventlog.FieldTransaction, eventlog.FieldArgs: - values[i] = new([]byte) - case eventlog.FieldVoted: - values[i] = new(helpers.BigInt) - case eventlog.FieldConsensus: - values[i] = new(sql.NullBool) - case eventlog.FieldID, eventlog.FieldBlock, eventlog.FieldSignersCount, eventlog.FieldIndex: - values[i] = new(sql.NullInt64) - case eventlog.FieldAddress, eventlog.FieldChain, eventlog.FieldEvent: - 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 EventLog fields. -func (el *EventLog) 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 eventlog.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) - } - el.ID = int(value.Int64) - case eventlog.FieldBlock: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field block", values[i]) - } else if value.Valid { - el.Block = uint64(value.Int64) - } - case eventlog.FieldSignersCount: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field signersCount", values[i]) - } else if value.Valid { - el.SignersCount = uint64(value.Int64) - } - case eventlog.FieldSignature: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field signature", values[i]) - } else if value != nil { - el.Signature = *value - } - case eventlog.FieldAddress: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field address", values[i]) - } else if value.Valid { - el.Address = value.String - } - case eventlog.FieldChain: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field chain", values[i]) - } else if value.Valid { - el.Chain = value.String - } - case eventlog.FieldIndex: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field index", values[i]) - } else if value.Valid { - el.Index = uint64(value.Int64) - } - case eventlog.FieldEvent: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field event", values[i]) - } else if value.Valid { - el.Event = value.String - } - case eventlog.FieldTransaction: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field transaction", values[i]) - } else if value != nil { - el.Transaction = *value - } - case eventlog.FieldArgs: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field args", values[i]) - } else if value != nil && len(*value) > 0 { - if err := json.Unmarshal(*value, &el.Args); err != nil { - return fmt.Errorf("unmarshal field args: %w", err) - } - } - case eventlog.FieldConsensus: - if value, ok := values[i].(*sql.NullBool); !ok { - return fmt.Errorf("unexpected type %T for field consensus", values[i]) - } else if value.Valid { - el.Consensus = value.Bool - } - case eventlog.FieldVoted: - if value, ok := values[i].(*helpers.BigInt); !ok { - return fmt.Errorf("unexpected type %T for field voted", values[i]) - } else if value != nil { - el.Voted = value - } - default: - el.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the EventLog. -// This includes values selected through modifiers, order, etc. -func (el *EventLog) Value(name string) (ent.Value, error) { - return el.selectValues.Get(name) -} - -// QuerySigners queries the "signers" edge of the EventLog entity. -func (el *EventLog) QuerySigners() *SignerQuery { - return NewEventLogClient(el.config).QuerySigners(el) -} - -// Update returns a builder for updating this EventLog. -// Note that you need to call EventLog.Unwrap() before calling this method if this EventLog -// was returned from a transaction, and the transaction was committed or rolled back. -func (el *EventLog) Update() *EventLogUpdateOne { - return NewEventLogClient(el.config).UpdateOne(el) -} - -// Unwrap unwraps the EventLog 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 (el *EventLog) Unwrap() *EventLog { - _tx, ok := el.config.driver.(*txDriver) - if !ok { - panic("ent: EventLog is not a transactional entity") - } - el.config.driver = _tx.drv - return el -} - -// String implements the fmt.Stringer. -func (el *EventLog) String() string { - var builder strings.Builder - builder.WriteString("EventLog(") - builder.WriteString(fmt.Sprintf("id=%v, ", el.ID)) - builder.WriteString("block=") - builder.WriteString(fmt.Sprintf("%v", el.Block)) - builder.WriteString(", ") - builder.WriteString("signersCount=") - builder.WriteString(fmt.Sprintf("%v", el.SignersCount)) - builder.WriteString(", ") - builder.WriteString("signature=") - builder.WriteString(fmt.Sprintf("%v", el.Signature)) - builder.WriteString(", ") - builder.WriteString("address=") - builder.WriteString(el.Address) - builder.WriteString(", ") - builder.WriteString("chain=") - builder.WriteString(el.Chain) - builder.WriteString(", ") - builder.WriteString("index=") - builder.WriteString(fmt.Sprintf("%v", el.Index)) - builder.WriteString(", ") - builder.WriteString("event=") - builder.WriteString(el.Event) - builder.WriteString(", ") - builder.WriteString("transaction=") - builder.WriteString(fmt.Sprintf("%v", el.Transaction)) - builder.WriteString(", ") - builder.WriteString("args=") - builder.WriteString(fmt.Sprintf("%v", el.Args)) - builder.WriteString(", ") - builder.WriteString("consensus=") - builder.WriteString(fmt.Sprintf("%v", el.Consensus)) - builder.WriteString(", ") - builder.WriteString("voted=") - builder.WriteString(fmt.Sprintf("%v", el.Voted)) - builder.WriteByte(')') - return builder.String() -} - -// NamedSigners returns the Signers named value or an error if the edge was not -// loaded in eager-loading with this name. -func (el *EventLog) NamedSigners(name string) ([]*Signer, error) { - if el.Edges.namedSigners == nil { - return nil, &NotLoadedError{edge: name} - } - nodes, ok := el.Edges.namedSigners[name] - if !ok { - return nil, &NotLoadedError{edge: name} - } - return nodes, nil -} - -func (el *EventLog) appendNamedSigners(name string, edges ...*Signer) { - if el.Edges.namedSigners == nil { - el.Edges.namedSigners = make(map[string][]*Signer) - } - if len(edges) == 0 { - el.Edges.namedSigners[name] = []*Signer{} - } else { - el.Edges.namedSigners[name] = append(el.Edges.namedSigners[name], edges...) - } -} - -// EventLogs is a parsable slice of EventLog. -type EventLogs []*EventLog diff --git a/internal/ent/eventlog/eventlog.go b/internal/ent/eventlog/eventlog.go deleted file mode 100644 index 3ad5c92f..00000000 --- a/internal/ent/eventlog/eventlog.go +++ /dev/null @@ -1,156 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package eventlog - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the eventlog type in the database. - Label = "event_log" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldBlock holds the string denoting the block field in the database. - FieldBlock = "block" - // FieldSignersCount holds the string denoting the signerscount field in the database. - FieldSignersCount = "signers_count" - // FieldSignature holds the string denoting the signature field in the database. - FieldSignature = "signature" - // FieldAddress holds the string denoting the address field in the database. - FieldAddress = "address" - // FieldChain holds the string denoting the chain field in the database. - FieldChain = "chain" - // FieldIndex holds the string denoting the index field in the database. - FieldIndex = "index" - // FieldEvent holds the string denoting the event field in the database. - FieldEvent = "event" - // FieldTransaction holds the string denoting the transaction field in the database. - FieldTransaction = "transaction" - // FieldArgs holds the string denoting the args field in the database. - FieldArgs = "args" - // FieldConsensus holds the string denoting the consensus field in the database. - FieldConsensus = "consensus" - // FieldVoted holds the string denoting the voted field in the database. - FieldVoted = "voted" - // EdgeSigners holds the string denoting the signers edge name in mutations. - EdgeSigners = "signers" - // Table holds the table name of the eventlog in the database. - Table = "event_logs" - // SignersTable is the table that holds the signers relation/edge. The primary key declared below. - SignersTable = "event_log_signers" - // SignersInverseTable is the table name for the Signer entity. - // It exists in this package in order to avoid circular dependency with the "signer" package. - SignersInverseTable = "signers" -) - -// Columns holds all SQL columns for eventlog fields. -var Columns = []string{ - FieldID, - FieldBlock, - FieldSignersCount, - FieldSignature, - FieldAddress, - FieldChain, - FieldIndex, - FieldEvent, - FieldTransaction, - FieldArgs, - FieldConsensus, - FieldVoted, -} - -var ( - // SignersPrimaryKey and SignersColumn2 are the table columns denoting the - // primary key for the signers relation (M2M). - SignersPrimaryKey = []string{"event_log_id", "signer_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 -} - -var ( - // SignatureValidator is a validator for the "signature" field. It is called by the builders before save. - SignatureValidator func([]byte) error - // TransactionValidator is a validator for the "transaction" field. It is called by the builders before save. - TransactionValidator func([]byte) error - // DefaultConsensus holds the default value on creation for the "consensus" field. - DefaultConsensus bool -) - -// OrderOption defines the ordering options for the EventLog 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() -} - -// ByBlock orders the results by the block field. -func ByBlock(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldBlock, opts...).ToFunc() -} - -// BySignersCountField orders the results by the signersCount field. -func BySignersCountField(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSignersCount, opts...).ToFunc() -} - -// ByAddress orders the results by the address field. -func ByAddress(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldAddress, opts...).ToFunc() -} - -// ByChain orders the results by the chain field. -func ByChain(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldChain, opts...).ToFunc() -} - -// ByIndex orders the results by the index field. -func ByIndex(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldIndex, opts...).ToFunc() -} - -// ByEvent orders the results by the event field. -func ByEvent(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldEvent, opts...).ToFunc() -} - -// ByConsensus orders the results by the consensus field. -func ByConsensus(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldConsensus, opts...).ToFunc() -} - -// ByVoted orders the results by the voted field. -func ByVoted(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldVoted, opts...).ToFunc() -} - -// BySignersCount orders the results by signers count. -func BySignersCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newSignersStep(), opts...) - } -} - -// BySigners orders the results by signers terms. -func BySigners(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newSignersStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newSignersStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(SignersInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, SignersTable, SignersPrimaryKey...), - ) -} diff --git a/internal/ent/eventlog/where.go b/internal/ent/eventlog/where.go deleted file mode 100644 index 51d92d0a..00000000 --- a/internal/ent/eventlog/where.go +++ /dev/null @@ -1,588 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package eventlog - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldID, id)) -} - -// Block applies equality check predicate on the "block" field. It's identical to BlockEQ. -func Block(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldBlock, v)) -} - -// SignersCount applies equality check predicate on the "signersCount" field. It's identical to SignersCountEQ. -func SignersCount(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldSignersCount, v)) -} - -// Signature applies equality check predicate on the "signature" field. It's identical to SignatureEQ. -func Signature(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldSignature, v)) -} - -// Address applies equality check predicate on the "address" field. It's identical to AddressEQ. -func Address(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldAddress, v)) -} - -// Chain applies equality check predicate on the "chain" field. It's identical to ChainEQ. -func Chain(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldChain, v)) -} - -// Index applies equality check predicate on the "index" field. It's identical to IndexEQ. -func Index(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldIndex, v)) -} - -// Event applies equality check predicate on the "event" field. It's identical to EventEQ. -func Event(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldEvent, v)) -} - -// Transaction applies equality check predicate on the "transaction" field. It's identical to TransactionEQ. -func Transaction(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldTransaction, v)) -} - -// Consensus applies equality check predicate on the "consensus" field. It's identical to ConsensusEQ. -func Consensus(v bool) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldConsensus, v)) -} - -// Voted applies equality check predicate on the "voted" field. It's identical to VotedEQ. -func Voted(v *helpers.BigInt) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldVoted, v)) -} - -// BlockEQ applies the EQ predicate on the "block" field. -func BlockEQ(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldBlock, v)) -} - -// BlockNEQ applies the NEQ predicate on the "block" field. -func BlockNEQ(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldBlock, v)) -} - -// BlockIn applies the In predicate on the "block" field. -func BlockIn(vs ...uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldBlock, vs...)) -} - -// BlockNotIn applies the NotIn predicate on the "block" field. -func BlockNotIn(vs ...uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldBlock, vs...)) -} - -// BlockGT applies the GT predicate on the "block" field. -func BlockGT(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldBlock, v)) -} - -// BlockGTE applies the GTE predicate on the "block" field. -func BlockGTE(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldBlock, v)) -} - -// BlockLT applies the LT predicate on the "block" field. -func BlockLT(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldBlock, v)) -} - -// BlockLTE applies the LTE predicate on the "block" field. -func BlockLTE(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldBlock, v)) -} - -// SignersCountEQ applies the EQ predicate on the "signersCount" field. -func SignersCountEQ(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldSignersCount, v)) -} - -// SignersCountNEQ applies the NEQ predicate on the "signersCount" field. -func SignersCountNEQ(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldSignersCount, v)) -} - -// SignersCountIn applies the In predicate on the "signersCount" field. -func SignersCountIn(vs ...uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldSignersCount, vs...)) -} - -// SignersCountNotIn applies the NotIn predicate on the "signersCount" field. -func SignersCountNotIn(vs ...uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldSignersCount, vs...)) -} - -// SignersCountGT applies the GT predicate on the "signersCount" field. -func SignersCountGT(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldSignersCount, v)) -} - -// SignersCountGTE applies the GTE predicate on the "signersCount" field. -func SignersCountGTE(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldSignersCount, v)) -} - -// SignersCountLT applies the LT predicate on the "signersCount" field. -func SignersCountLT(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldSignersCount, v)) -} - -// SignersCountLTE applies the LTE predicate on the "signersCount" field. -func SignersCountLTE(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldSignersCount, v)) -} - -// SignatureEQ applies the EQ predicate on the "signature" field. -func SignatureEQ(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldSignature, v)) -} - -// SignatureNEQ applies the NEQ predicate on the "signature" field. -func SignatureNEQ(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldSignature, v)) -} - -// SignatureIn applies the In predicate on the "signature" field. -func SignatureIn(vs ...[]byte) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldSignature, vs...)) -} - -// SignatureNotIn applies the NotIn predicate on the "signature" field. -func SignatureNotIn(vs ...[]byte) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldSignature, vs...)) -} - -// SignatureGT applies the GT predicate on the "signature" field. -func SignatureGT(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldSignature, v)) -} - -// SignatureGTE applies the GTE predicate on the "signature" field. -func SignatureGTE(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldSignature, v)) -} - -// SignatureLT applies the LT predicate on the "signature" field. -func SignatureLT(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldSignature, v)) -} - -// SignatureLTE applies the LTE predicate on the "signature" field. -func SignatureLTE(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldSignature, v)) -} - -// AddressEQ applies the EQ predicate on the "address" field. -func AddressEQ(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldAddress, v)) -} - -// AddressNEQ applies the NEQ predicate on the "address" field. -func AddressNEQ(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldAddress, v)) -} - -// AddressIn applies the In predicate on the "address" field. -func AddressIn(vs ...string) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldAddress, vs...)) -} - -// AddressNotIn applies the NotIn predicate on the "address" field. -func AddressNotIn(vs ...string) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldAddress, vs...)) -} - -// AddressGT applies the GT predicate on the "address" field. -func AddressGT(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldAddress, v)) -} - -// AddressGTE applies the GTE predicate on the "address" field. -func AddressGTE(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldAddress, v)) -} - -// AddressLT applies the LT predicate on the "address" field. -func AddressLT(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldAddress, v)) -} - -// AddressLTE applies the LTE predicate on the "address" field. -func AddressLTE(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldAddress, v)) -} - -// AddressContains applies the Contains predicate on the "address" field. -func AddressContains(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldContains(FieldAddress, v)) -} - -// AddressHasPrefix applies the HasPrefix predicate on the "address" field. -func AddressHasPrefix(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldHasPrefix(FieldAddress, v)) -} - -// AddressHasSuffix applies the HasSuffix predicate on the "address" field. -func AddressHasSuffix(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldHasSuffix(FieldAddress, v)) -} - -// AddressEqualFold applies the EqualFold predicate on the "address" field. -func AddressEqualFold(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldEqualFold(FieldAddress, v)) -} - -// AddressContainsFold applies the ContainsFold predicate on the "address" field. -func AddressContainsFold(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldContainsFold(FieldAddress, v)) -} - -// ChainEQ applies the EQ predicate on the "chain" field. -func ChainEQ(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldChain, v)) -} - -// ChainNEQ applies the NEQ predicate on the "chain" field. -func ChainNEQ(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldChain, v)) -} - -// ChainIn applies the In predicate on the "chain" field. -func ChainIn(vs ...string) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldChain, vs...)) -} - -// ChainNotIn applies the NotIn predicate on the "chain" field. -func ChainNotIn(vs ...string) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldChain, vs...)) -} - -// ChainGT applies the GT predicate on the "chain" field. -func ChainGT(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldChain, v)) -} - -// ChainGTE applies the GTE predicate on the "chain" field. -func ChainGTE(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldChain, v)) -} - -// ChainLT applies the LT predicate on the "chain" field. -func ChainLT(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldChain, v)) -} - -// ChainLTE applies the LTE predicate on the "chain" field. -func ChainLTE(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldChain, v)) -} - -// ChainContains applies the Contains predicate on the "chain" field. -func ChainContains(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldContains(FieldChain, v)) -} - -// ChainHasPrefix applies the HasPrefix predicate on the "chain" field. -func ChainHasPrefix(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldHasPrefix(FieldChain, v)) -} - -// ChainHasSuffix applies the HasSuffix predicate on the "chain" field. -func ChainHasSuffix(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldHasSuffix(FieldChain, v)) -} - -// ChainEqualFold applies the EqualFold predicate on the "chain" field. -func ChainEqualFold(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldEqualFold(FieldChain, v)) -} - -// ChainContainsFold applies the ContainsFold predicate on the "chain" field. -func ChainContainsFold(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldContainsFold(FieldChain, v)) -} - -// IndexEQ applies the EQ predicate on the "index" field. -func IndexEQ(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldIndex, v)) -} - -// IndexNEQ applies the NEQ predicate on the "index" field. -func IndexNEQ(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldIndex, v)) -} - -// IndexIn applies the In predicate on the "index" field. -func IndexIn(vs ...uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldIndex, vs...)) -} - -// IndexNotIn applies the NotIn predicate on the "index" field. -func IndexNotIn(vs ...uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldIndex, vs...)) -} - -// IndexGT applies the GT predicate on the "index" field. -func IndexGT(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldIndex, v)) -} - -// IndexGTE applies the GTE predicate on the "index" field. -func IndexGTE(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldIndex, v)) -} - -// IndexLT applies the LT predicate on the "index" field. -func IndexLT(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldIndex, v)) -} - -// IndexLTE applies the LTE predicate on the "index" field. -func IndexLTE(v uint64) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldIndex, v)) -} - -// EventEQ applies the EQ predicate on the "event" field. -func EventEQ(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldEvent, v)) -} - -// EventNEQ applies the NEQ predicate on the "event" field. -func EventNEQ(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldEvent, v)) -} - -// EventIn applies the In predicate on the "event" field. -func EventIn(vs ...string) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldEvent, vs...)) -} - -// EventNotIn applies the NotIn predicate on the "event" field. -func EventNotIn(vs ...string) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldEvent, vs...)) -} - -// EventGT applies the GT predicate on the "event" field. -func EventGT(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldEvent, v)) -} - -// EventGTE applies the GTE predicate on the "event" field. -func EventGTE(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldEvent, v)) -} - -// EventLT applies the LT predicate on the "event" field. -func EventLT(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldEvent, v)) -} - -// EventLTE applies the LTE predicate on the "event" field. -func EventLTE(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldEvent, v)) -} - -// EventContains applies the Contains predicate on the "event" field. -func EventContains(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldContains(FieldEvent, v)) -} - -// EventHasPrefix applies the HasPrefix predicate on the "event" field. -func EventHasPrefix(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldHasPrefix(FieldEvent, v)) -} - -// EventHasSuffix applies the HasSuffix predicate on the "event" field. -func EventHasSuffix(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldHasSuffix(FieldEvent, v)) -} - -// EventEqualFold applies the EqualFold predicate on the "event" field. -func EventEqualFold(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldEqualFold(FieldEvent, v)) -} - -// EventContainsFold applies the ContainsFold predicate on the "event" field. -func EventContainsFold(v string) predicate.EventLog { - return predicate.EventLog(sql.FieldContainsFold(FieldEvent, v)) -} - -// TransactionEQ applies the EQ predicate on the "transaction" field. -func TransactionEQ(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldTransaction, v)) -} - -// TransactionNEQ applies the NEQ predicate on the "transaction" field. -func TransactionNEQ(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldTransaction, v)) -} - -// TransactionIn applies the In predicate on the "transaction" field. -func TransactionIn(vs ...[]byte) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldTransaction, vs...)) -} - -// TransactionNotIn applies the NotIn predicate on the "transaction" field. -func TransactionNotIn(vs ...[]byte) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldTransaction, vs...)) -} - -// TransactionGT applies the GT predicate on the "transaction" field. -func TransactionGT(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldTransaction, v)) -} - -// TransactionGTE applies the GTE predicate on the "transaction" field. -func TransactionGTE(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldTransaction, v)) -} - -// TransactionLT applies the LT predicate on the "transaction" field. -func TransactionLT(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldTransaction, v)) -} - -// TransactionLTE applies the LTE predicate on the "transaction" field. -func TransactionLTE(v []byte) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldTransaction, v)) -} - -// ConsensusEQ applies the EQ predicate on the "consensus" field. -func ConsensusEQ(v bool) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldConsensus, v)) -} - -// ConsensusNEQ applies the NEQ predicate on the "consensus" field. -func ConsensusNEQ(v bool) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldConsensus, v)) -} - -// VotedEQ applies the EQ predicate on the "voted" field. -func VotedEQ(v *helpers.BigInt) predicate.EventLog { - return predicate.EventLog(sql.FieldEQ(FieldVoted, v)) -} - -// VotedNEQ applies the NEQ predicate on the "voted" field. -func VotedNEQ(v *helpers.BigInt) predicate.EventLog { - return predicate.EventLog(sql.FieldNEQ(FieldVoted, v)) -} - -// VotedIn applies the In predicate on the "voted" field. -func VotedIn(vs ...*helpers.BigInt) predicate.EventLog { - return predicate.EventLog(sql.FieldIn(FieldVoted, vs...)) -} - -// VotedNotIn applies the NotIn predicate on the "voted" field. -func VotedNotIn(vs ...*helpers.BigInt) predicate.EventLog { - return predicate.EventLog(sql.FieldNotIn(FieldVoted, vs...)) -} - -// VotedGT applies the GT predicate on the "voted" field. -func VotedGT(v *helpers.BigInt) predicate.EventLog { - return predicate.EventLog(sql.FieldGT(FieldVoted, v)) -} - -// VotedGTE applies the GTE predicate on the "voted" field. -func VotedGTE(v *helpers.BigInt) predicate.EventLog { - return predicate.EventLog(sql.FieldGTE(FieldVoted, v)) -} - -// VotedLT applies the LT predicate on the "voted" field. -func VotedLT(v *helpers.BigInt) predicate.EventLog { - return predicate.EventLog(sql.FieldLT(FieldVoted, v)) -} - -// VotedLTE applies the LTE predicate on the "voted" field. -func VotedLTE(v *helpers.BigInt) predicate.EventLog { - return predicate.EventLog(sql.FieldLTE(FieldVoted, v)) -} - -// HasSigners applies the HasEdge predicate on the "signers" edge. -func HasSigners() predicate.EventLog { - return predicate.EventLog(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, SignersTable, SignersPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasSignersWith applies the HasEdge predicate on the "signers" edge with a given conditions (other predicates). -func HasSignersWith(preds ...predicate.Signer) predicate.EventLog { - return predicate.EventLog(func(s *sql.Selector) { - step := newSignersStep() - 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.EventLog) predicate.EventLog { - return predicate.EventLog(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.EventLog) predicate.EventLog { - return predicate.EventLog(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.EventLog) predicate.EventLog { - return predicate.EventLog(sql.NotPredicates(p)) -} diff --git a/internal/ent/eventlog_create.go b/internal/ent/eventlog_create.go deleted file mode 100644 index f6dde3f7..00000000 --- a/internal/ent/eventlog_create.go +++ /dev/null @@ -1,1109 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "github.com/TimeleapLabs/unchained/internal/model" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// EventLogCreate is the builder for creating a EventLog entity. -type EventLogCreate struct { - config - mutation *EventLogMutation - hooks []Hook - conflict []sql.ConflictOption -} - -// SetBlock sets the "block" field. -func (elc *EventLogCreate) SetBlock(u uint64) *EventLogCreate { - elc.mutation.SetBlock(u) - return elc -} - -// SetSignersCount sets the "signersCount" field. -func (elc *EventLogCreate) SetSignersCount(u uint64) *EventLogCreate { - elc.mutation.SetSignersCount(u) - return elc -} - -// SetSignature sets the "signature" field. -func (elc *EventLogCreate) SetSignature(b []byte) *EventLogCreate { - elc.mutation.SetSignature(b) - return elc -} - -// SetAddress sets the "address" field. -func (elc *EventLogCreate) SetAddress(s string) *EventLogCreate { - elc.mutation.SetAddress(s) - return elc -} - -// SetChain sets the "chain" field. -func (elc *EventLogCreate) SetChain(s string) *EventLogCreate { - elc.mutation.SetChain(s) - return elc -} - -// SetIndex sets the "index" field. -func (elc *EventLogCreate) SetIndex(u uint64) *EventLogCreate { - elc.mutation.SetIndex(u) - return elc -} - -// SetEvent sets the "event" field. -func (elc *EventLogCreate) SetEvent(s string) *EventLogCreate { - elc.mutation.SetEvent(s) - return elc -} - -// SetTransaction sets the "transaction" field. -func (elc *EventLogCreate) SetTransaction(b []byte) *EventLogCreate { - elc.mutation.SetTransaction(b) - return elc -} - -// SetArgs sets the "args" field. -func (elc *EventLogCreate) SetArgs(dla []model.EventLogArg) *EventLogCreate { - elc.mutation.SetArgs(dla) - return elc -} - -// SetConsensus sets the "consensus" field. -func (elc *EventLogCreate) SetConsensus(b bool) *EventLogCreate { - elc.mutation.SetConsensus(b) - return elc -} - -// SetNillableConsensus sets the "consensus" field if the given value is not nil. -func (elc *EventLogCreate) SetNillableConsensus(b *bool) *EventLogCreate { - if b != nil { - elc.SetConsensus(*b) - } - return elc -} - -// SetVoted sets the "voted" field. -func (elc *EventLogCreate) SetVoted(hi *helpers.BigInt) *EventLogCreate { - elc.mutation.SetVoted(hi) - return elc -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by IDs. -func (elc *EventLogCreate) AddSignerIDs(ids ...int) *EventLogCreate { - elc.mutation.AddSignerIDs(ids...) - return elc -} - -// AddSigners adds the "signers" edges to the Signer entity. -func (elc *EventLogCreate) AddSigners(s ...*Signer) *EventLogCreate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return elc.AddSignerIDs(ids...) -} - -// Mutation returns the EventLogMutation object of the builder. -func (elc *EventLogCreate) Mutation() *EventLogMutation { - return elc.mutation -} - -// Save creates the EventLog in the database. -func (elc *EventLogCreate) Save(ctx context.Context) (*EventLog, error) { - elc.defaults() - return withHooks(ctx, elc.sqlSave, elc.mutation, elc.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (elc *EventLogCreate) SaveX(ctx context.Context) *EventLog { - v, err := elc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (elc *EventLogCreate) Exec(ctx context.Context) error { - _, err := elc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (elc *EventLogCreate) ExecX(ctx context.Context) { - if err := elc.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (elc *EventLogCreate) defaults() { - if _, ok := elc.mutation.Consensus(); !ok { - v := eventlog.DefaultConsensus - elc.mutation.SetConsensus(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (elc *EventLogCreate) check() error { - if _, ok := elc.mutation.Block(); !ok { - return &ValidationError{Name: "block", err: errors.New(`ent: missing required field "EventLog.block"`)} - } - if _, ok := elc.mutation.SignersCount(); !ok { - return &ValidationError{Name: "signersCount", err: errors.New(`ent: missing required field "EventLog.signersCount"`)} - } - if _, ok := elc.mutation.Signature(); !ok { - return &ValidationError{Name: "signature", err: errors.New(`ent: missing required field "EventLog.signature"`)} - } - if v, ok := elc.mutation.Signature(); ok { - if err := eventlog.SignatureValidator(v); err != nil { - return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "EventLog.signature": %w`, err)} - } - } - if _, ok := elc.mutation.Address(); !ok { - return &ValidationError{Name: "address", err: errors.New(`ent: missing required field "EventLog.address"`)} - } - if _, ok := elc.mutation.Chain(); !ok { - return &ValidationError{Name: "chain", err: errors.New(`ent: missing required field "EventLog.chain"`)} - } - if _, ok := elc.mutation.Index(); !ok { - return &ValidationError{Name: "index", err: errors.New(`ent: missing required field "EventLog.index"`)} - } - if _, ok := elc.mutation.Event(); !ok { - return &ValidationError{Name: "event", err: errors.New(`ent: missing required field "EventLog.event"`)} - } - if _, ok := elc.mutation.Transaction(); !ok { - return &ValidationError{Name: "transaction", err: errors.New(`ent: missing required field "EventLog.transaction"`)} - } - if v, ok := elc.mutation.Transaction(); ok { - if err := eventlog.TransactionValidator(v); err != nil { - return &ValidationError{Name: "transaction", err: fmt.Errorf(`ent: validator failed for field "EventLog.transaction": %w`, err)} - } - } - if _, ok := elc.mutation.Args(); !ok { - return &ValidationError{Name: "args", err: errors.New(`ent: missing required field "EventLog.args"`)} - } - if _, ok := elc.mutation.Consensus(); !ok { - return &ValidationError{Name: "consensus", err: errors.New(`ent: missing required field "EventLog.consensus"`)} - } - if _, ok := elc.mutation.Voted(); !ok { - return &ValidationError{Name: "voted", err: errors.New(`ent: missing required field "EventLog.voted"`)} - } - if len(elc.mutation.SignersIDs()) == 0 { - return &ValidationError{Name: "signers", err: errors.New(`ent: missing required edge "EventLog.signers"`)} - } - return nil -} - -func (elc *EventLogCreate) sqlSave(ctx context.Context) (*EventLog, error) { - if err := elc.check(); err != nil { - return nil, err - } - _node, _spec := elc.createSpec() - if err := sqlgraph.CreateNode(ctx, elc.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) - elc.mutation.id = &_node.ID - elc.mutation.done = true - return _node, nil -} - -func (elc *EventLogCreate) createSpec() (*EventLog, *sqlgraph.CreateSpec) { - var ( - _node = &EventLog{config: elc.config} - _spec = sqlgraph.NewCreateSpec(eventlog.Table, sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt)) - ) - _spec.OnConflict = elc.conflict - if value, ok := elc.mutation.Block(); ok { - _spec.SetField(eventlog.FieldBlock, field.TypeUint64, value) - _node.Block = value - } - if value, ok := elc.mutation.SignersCount(); ok { - _spec.SetField(eventlog.FieldSignersCount, field.TypeUint64, value) - _node.SignersCount = value - } - if value, ok := elc.mutation.Signature(); ok { - _spec.SetField(eventlog.FieldSignature, field.TypeBytes, value) - _node.Signature = value - } - if value, ok := elc.mutation.Address(); ok { - _spec.SetField(eventlog.FieldAddress, field.TypeString, value) - _node.Address = value - } - if value, ok := elc.mutation.Chain(); ok { - _spec.SetField(eventlog.FieldChain, field.TypeString, value) - _node.Chain = value - } - if value, ok := elc.mutation.Index(); ok { - _spec.SetField(eventlog.FieldIndex, field.TypeUint64, value) - _node.Index = value - } - if value, ok := elc.mutation.Event(); ok { - _spec.SetField(eventlog.FieldEvent, field.TypeString, value) - _node.Event = value - } - if value, ok := elc.mutation.Transaction(); ok { - _spec.SetField(eventlog.FieldTransaction, field.TypeBytes, value) - _node.Transaction = value - } - if value, ok := elc.mutation.Args(); ok { - _spec.SetField(eventlog.FieldArgs, field.TypeJSON, value) - _node.Args = value - } - if value, ok := elc.mutation.Consensus(); ok { - _spec.SetField(eventlog.FieldConsensus, field.TypeBool, value) - _node.Consensus = value - } - if value, ok := elc.mutation.Voted(); ok { - _spec.SetField(eventlog.FieldVoted, field.TypeUint, value) - _node.Voted = value - } - if nodes := elc.mutation.SignersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: eventlog.SignersTable, - Columns: eventlog.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.EventLog.Create(). -// SetBlock(v). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.EventLogUpsert) { -// SetBlock(v+v). -// }). -// Exec(ctx) -func (elc *EventLogCreate) OnConflict(opts ...sql.ConflictOption) *EventLogUpsertOne { - elc.conflict = opts - return &EventLogUpsertOne{ - create: elc, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.EventLog.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (elc *EventLogCreate) OnConflictColumns(columns ...string) *EventLogUpsertOne { - elc.conflict = append(elc.conflict, sql.ConflictColumns(columns...)) - return &EventLogUpsertOne{ - create: elc, - } -} - -type ( - // EventLogUpsertOne is the builder for "upsert"-ing - // one EventLog node. - EventLogUpsertOne struct { - create *EventLogCreate - } - - // EventLogUpsert is the "OnConflict" setter. - EventLogUpsert struct { - *sql.UpdateSet - } -) - -// SetBlock sets the "block" field. -func (u *EventLogUpsert) SetBlock(v uint64) *EventLogUpsert { - u.Set(eventlog.FieldBlock, v) - return u -} - -// UpdateBlock sets the "block" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateBlock() *EventLogUpsert { - u.SetExcluded(eventlog.FieldBlock) - return u -} - -// AddBlock adds v to the "block" field. -func (u *EventLogUpsert) AddBlock(v uint64) *EventLogUpsert { - u.Add(eventlog.FieldBlock, v) - return u -} - -// SetSignersCount sets the "signersCount" field. -func (u *EventLogUpsert) SetSignersCount(v uint64) *EventLogUpsert { - u.Set(eventlog.FieldSignersCount, v) - return u -} - -// UpdateSignersCount sets the "signersCount" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateSignersCount() *EventLogUpsert { - u.SetExcluded(eventlog.FieldSignersCount) - return u -} - -// AddSignersCount adds v to the "signersCount" field. -func (u *EventLogUpsert) AddSignersCount(v uint64) *EventLogUpsert { - u.Add(eventlog.FieldSignersCount, v) - return u -} - -// SetSignature sets the "signature" field. -func (u *EventLogUpsert) SetSignature(v []byte) *EventLogUpsert { - u.Set(eventlog.FieldSignature, v) - return u -} - -// UpdateSignature sets the "signature" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateSignature() *EventLogUpsert { - u.SetExcluded(eventlog.FieldSignature) - return u -} - -// SetAddress sets the "address" field. -func (u *EventLogUpsert) SetAddress(v string) *EventLogUpsert { - u.Set(eventlog.FieldAddress, v) - return u -} - -// UpdateAddress sets the "address" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateAddress() *EventLogUpsert { - u.SetExcluded(eventlog.FieldAddress) - return u -} - -// SetChain sets the "chain" field. -func (u *EventLogUpsert) SetChain(v string) *EventLogUpsert { - u.Set(eventlog.FieldChain, v) - return u -} - -// UpdateChain sets the "chain" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateChain() *EventLogUpsert { - u.SetExcluded(eventlog.FieldChain) - return u -} - -// SetIndex sets the "index" field. -func (u *EventLogUpsert) SetIndex(v uint64) *EventLogUpsert { - u.Set(eventlog.FieldIndex, v) - return u -} - -// UpdateIndex sets the "index" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateIndex() *EventLogUpsert { - u.SetExcluded(eventlog.FieldIndex) - return u -} - -// AddIndex adds v to the "index" field. -func (u *EventLogUpsert) AddIndex(v uint64) *EventLogUpsert { - u.Add(eventlog.FieldIndex, v) - return u -} - -// SetEvent sets the "event" field. -func (u *EventLogUpsert) SetEvent(v string) *EventLogUpsert { - u.Set(eventlog.FieldEvent, v) - return u -} - -// UpdateEvent sets the "event" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateEvent() *EventLogUpsert { - u.SetExcluded(eventlog.FieldEvent) - return u -} - -// SetTransaction sets the "transaction" field. -func (u *EventLogUpsert) SetTransaction(v []byte) *EventLogUpsert { - u.Set(eventlog.FieldTransaction, v) - return u -} - -// UpdateTransaction sets the "transaction" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateTransaction() *EventLogUpsert { - u.SetExcluded(eventlog.FieldTransaction) - return u -} - -// SetArgs sets the "args" field. -func (u *EventLogUpsert) SetArgs(v []model.EventLogArg) *EventLogUpsert { - u.Set(eventlog.FieldArgs, v) - return u -} - -// UpdateArgs sets the "args" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateArgs() *EventLogUpsert { - u.SetExcluded(eventlog.FieldArgs) - return u -} - -// SetConsensus sets the "consensus" field. -func (u *EventLogUpsert) SetConsensus(v bool) *EventLogUpsert { - u.Set(eventlog.FieldConsensus, v) - return u -} - -// UpdateConsensus sets the "consensus" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateConsensus() *EventLogUpsert { - u.SetExcluded(eventlog.FieldConsensus) - return u -} - -// SetVoted sets the "voted" field. -func (u *EventLogUpsert) SetVoted(v *helpers.BigInt) *EventLogUpsert { - u.Set(eventlog.FieldVoted, v) - return u -} - -// UpdateVoted sets the "voted" field to the value that was provided on create. -func (u *EventLogUpsert) UpdateVoted() *EventLogUpsert { - u.SetExcluded(eventlog.FieldVoted) - return u -} - -// UpdateNewValues updates the mutable fields using the new values that were set on create. -// Using this option is equivalent to using: -// -// client.EventLog.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *EventLogUpsertOne) UpdateNewValues() *EventLogUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.EventLog.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *EventLogUpsertOne) Ignore() *EventLogUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *EventLogUpsertOne) DoNothing() *EventLogUpsertOne { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the EventLogCreate.OnConflict -// documentation for more info. -func (u *EventLogUpsertOne) Update(set func(*EventLogUpsert)) *EventLogUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&EventLogUpsert{UpdateSet: update}) - })) - return u -} - -// SetBlock sets the "block" field. -func (u *EventLogUpsertOne) SetBlock(v uint64) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetBlock(v) - }) -} - -// AddBlock adds v to the "block" field. -func (u *EventLogUpsertOne) AddBlock(v uint64) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.AddBlock(v) - }) -} - -// UpdateBlock sets the "block" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateBlock() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateBlock() - }) -} - -// SetSignersCount sets the "signersCount" field. -func (u *EventLogUpsertOne) SetSignersCount(v uint64) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetSignersCount(v) - }) -} - -// AddSignersCount adds v to the "signersCount" field. -func (u *EventLogUpsertOne) AddSignersCount(v uint64) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.AddSignersCount(v) - }) -} - -// UpdateSignersCount sets the "signersCount" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateSignersCount() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateSignersCount() - }) -} - -// SetSignature sets the "signature" field. -func (u *EventLogUpsertOne) SetSignature(v []byte) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetSignature(v) - }) -} - -// UpdateSignature sets the "signature" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateSignature() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateSignature() - }) -} - -// SetAddress sets the "address" field. -func (u *EventLogUpsertOne) SetAddress(v string) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetAddress(v) - }) -} - -// UpdateAddress sets the "address" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateAddress() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateAddress() - }) -} - -// SetChain sets the "chain" field. -func (u *EventLogUpsertOne) SetChain(v string) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetChain(v) - }) -} - -// UpdateChain sets the "chain" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateChain() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateChain() - }) -} - -// SetIndex sets the "index" field. -func (u *EventLogUpsertOne) SetIndex(v uint64) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetIndex(v) - }) -} - -// AddIndex adds v to the "index" field. -func (u *EventLogUpsertOne) AddIndex(v uint64) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.AddIndex(v) - }) -} - -// UpdateIndex sets the "index" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateIndex() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateIndex() - }) -} - -// SetEvent sets the "event" field. -func (u *EventLogUpsertOne) SetEvent(v string) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetEvent(v) - }) -} - -// UpdateEvent sets the "event" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateEvent() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateEvent() - }) -} - -// SetTransaction sets the "transaction" field. -func (u *EventLogUpsertOne) SetTransaction(v []byte) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetTransaction(v) - }) -} - -// UpdateTransaction sets the "transaction" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateTransaction() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateTransaction() - }) -} - -// SetArgs sets the "args" field. -func (u *EventLogUpsertOne) SetArgs(v []model.EventLogArg) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetArgs(v) - }) -} - -// UpdateArgs sets the "args" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateArgs() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateArgs() - }) -} - -// SetConsensus sets the "consensus" field. -func (u *EventLogUpsertOne) SetConsensus(v bool) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetConsensus(v) - }) -} - -// UpdateConsensus sets the "consensus" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateConsensus() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateConsensus() - }) -} - -// SetVoted sets the "voted" field. -func (u *EventLogUpsertOne) SetVoted(v *helpers.BigInt) *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.SetVoted(v) - }) -} - -// UpdateVoted sets the "voted" field to the value that was provided on create. -func (u *EventLogUpsertOne) UpdateVoted() *EventLogUpsertOne { - return u.Update(func(s *EventLogUpsert) { - s.UpdateVoted() - }) -} - -// Exec executes the query. -func (u *EventLogUpsertOne) Exec(ctx context.Context) error { - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for EventLogCreate.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *EventLogUpsertOne) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} - -// Exec executes the UPSERT query and returns the inserted/updated ID. -func (u *EventLogUpsertOne) ID(ctx context.Context) (id int, err error) { - node, err := u.create.Save(ctx) - if err != nil { - return id, err - } - return node.ID, nil -} - -// IDX is like ID, but panics if an error occurs. -func (u *EventLogUpsertOne) IDX(ctx context.Context) int { - id, err := u.ID(ctx) - if err != nil { - panic(err) - } - return id -} - -// EventLogCreateBulk is the builder for creating many EventLog entities in bulk. -type EventLogCreateBulk struct { - config - err error - builders []*EventLogCreate - conflict []sql.ConflictOption -} - -// Save creates the EventLog entities in the database. -func (elcb *EventLogCreateBulk) Save(ctx context.Context) ([]*EventLog, error) { - if elcb.err != nil { - return nil, elcb.err - } - specs := make([]*sqlgraph.CreateSpec, len(elcb.builders)) - nodes := make([]*EventLog, len(elcb.builders)) - mutators := make([]Mutator, len(elcb.builders)) - for i := range elcb.builders { - func(i int, root context.Context) { - builder := elcb.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*EventLogMutation) - 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, elcb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - spec.OnConflict = elcb.conflict - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, elcb.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, elcb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (elcb *EventLogCreateBulk) SaveX(ctx context.Context) []*EventLog { - v, err := elcb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (elcb *EventLogCreateBulk) Exec(ctx context.Context) error { - _, err := elcb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (elcb *EventLogCreateBulk) ExecX(ctx context.Context) { - if err := elcb.Exec(ctx); err != nil { - panic(err) - } -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.EventLog.CreateBulk(builders...). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.EventLogUpsert) { -// SetBlock(v+v). -// }). -// Exec(ctx) -func (elcb *EventLogCreateBulk) OnConflict(opts ...sql.ConflictOption) *EventLogUpsertBulk { - elcb.conflict = opts - return &EventLogUpsertBulk{ - create: elcb, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.EventLog.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (elcb *EventLogCreateBulk) OnConflictColumns(columns ...string) *EventLogUpsertBulk { - elcb.conflict = append(elcb.conflict, sql.ConflictColumns(columns...)) - return &EventLogUpsertBulk{ - create: elcb, - } -} - -// EventLogUpsertBulk is the builder for "upsert"-ing -// a bulk of EventLog nodes. -type EventLogUpsertBulk struct { - create *EventLogCreateBulk -} - -// UpdateNewValues updates the mutable fields using the new values that -// were set on create. Using this option is equivalent to using: -// -// client.EventLog.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *EventLogUpsertBulk) UpdateNewValues() *EventLogUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.EventLog.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *EventLogUpsertBulk) Ignore() *EventLogUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *EventLogUpsertBulk) DoNothing() *EventLogUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the EventLogCreateBulk.OnConflict -// documentation for more info. -func (u *EventLogUpsertBulk) Update(set func(*EventLogUpsert)) *EventLogUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&EventLogUpsert{UpdateSet: update}) - })) - return u -} - -// SetBlock sets the "block" field. -func (u *EventLogUpsertBulk) SetBlock(v uint64) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetBlock(v) - }) -} - -// AddBlock adds v to the "block" field. -func (u *EventLogUpsertBulk) AddBlock(v uint64) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.AddBlock(v) - }) -} - -// UpdateBlock sets the "block" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateBlock() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateBlock() - }) -} - -// SetSignersCount sets the "signersCount" field. -func (u *EventLogUpsertBulk) SetSignersCount(v uint64) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetSignersCount(v) - }) -} - -// AddSignersCount adds v to the "signersCount" field. -func (u *EventLogUpsertBulk) AddSignersCount(v uint64) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.AddSignersCount(v) - }) -} - -// UpdateSignersCount sets the "signersCount" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateSignersCount() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateSignersCount() - }) -} - -// SetSignature sets the "signature" field. -func (u *EventLogUpsertBulk) SetSignature(v []byte) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetSignature(v) - }) -} - -// UpdateSignature sets the "signature" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateSignature() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateSignature() - }) -} - -// SetAddress sets the "address" field. -func (u *EventLogUpsertBulk) SetAddress(v string) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetAddress(v) - }) -} - -// UpdateAddress sets the "address" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateAddress() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateAddress() - }) -} - -// SetChain sets the "chain" field. -func (u *EventLogUpsertBulk) SetChain(v string) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetChain(v) - }) -} - -// UpdateChain sets the "chain" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateChain() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateChain() - }) -} - -// SetIndex sets the "index" field. -func (u *EventLogUpsertBulk) SetIndex(v uint64) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetIndex(v) - }) -} - -// AddIndex adds v to the "index" field. -func (u *EventLogUpsertBulk) AddIndex(v uint64) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.AddIndex(v) - }) -} - -// UpdateIndex sets the "index" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateIndex() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateIndex() - }) -} - -// SetEvent sets the "event" field. -func (u *EventLogUpsertBulk) SetEvent(v string) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetEvent(v) - }) -} - -// UpdateEvent sets the "event" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateEvent() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateEvent() - }) -} - -// SetTransaction sets the "transaction" field. -func (u *EventLogUpsertBulk) SetTransaction(v []byte) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetTransaction(v) - }) -} - -// UpdateTransaction sets the "transaction" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateTransaction() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateTransaction() - }) -} - -// SetArgs sets the "args" field. -func (u *EventLogUpsertBulk) SetArgs(v []model.EventLogArg) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetArgs(v) - }) -} - -// UpdateArgs sets the "args" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateArgs() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateArgs() - }) -} - -// SetConsensus sets the "consensus" field. -func (u *EventLogUpsertBulk) SetConsensus(v bool) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetConsensus(v) - }) -} - -// UpdateConsensus sets the "consensus" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateConsensus() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateConsensus() - }) -} - -// SetVoted sets the "voted" field. -func (u *EventLogUpsertBulk) SetVoted(v *helpers.BigInt) *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.SetVoted(v) - }) -} - -// UpdateVoted sets the "voted" field to the value that was provided on create. -func (u *EventLogUpsertBulk) UpdateVoted() *EventLogUpsertBulk { - return u.Update(func(s *EventLogUpsert) { - s.UpdateVoted() - }) -} - -// Exec executes the query. -func (u *EventLogUpsertBulk) Exec(ctx context.Context) error { - if u.create.err != nil { - return u.create.err - } - for i, b := range u.create.builders { - if len(b.conflict) != 0 { - return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the EventLogCreateBulk instead", i) - } - } - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for EventLogCreateBulk.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *EventLogUpsertBulk) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/ent/eventlog_delete.go b/internal/ent/eventlog_delete.go deleted file mode 100644 index 9ccd77a5..00000000 --- a/internal/ent/eventlog_delete.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" -) - -// EventLogDelete is the builder for deleting a EventLog entity. -type EventLogDelete struct { - config - hooks []Hook - mutation *EventLogMutation -} - -// Where appends a list predicates to the EventLogDelete builder. -func (eld *EventLogDelete) Where(ps ...predicate.EventLog) *EventLogDelete { - eld.mutation.Where(ps...) - return eld -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (eld *EventLogDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, eld.sqlExec, eld.mutation, eld.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (eld *EventLogDelete) ExecX(ctx context.Context) int { - n, err := eld.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (eld *EventLogDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(eventlog.Table, sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt)) - if ps := eld.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, eld.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - eld.mutation.done = true - return affected, err -} - -// EventLogDeleteOne is the builder for deleting a single EventLog entity. -type EventLogDeleteOne struct { - eld *EventLogDelete -} - -// Where appends a list predicates to the EventLogDelete builder. -func (eldo *EventLogDeleteOne) Where(ps ...predicate.EventLog) *EventLogDeleteOne { - eldo.eld.mutation.Where(ps...) - return eldo -} - -// Exec executes the deletion query. -func (eldo *EventLogDeleteOne) Exec(ctx context.Context) error { - n, err := eldo.eld.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{eventlog.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (eldo *EventLogDeleteOne) ExecX(ctx context.Context) { - if err := eldo.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/ent/eventlog_query.go b/internal/ent/eventlog_query.go deleted file mode 100644 index ff19f775..00000000 --- a/internal/ent/eventlog_query.go +++ /dev/null @@ -1,671 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "database/sql/driver" - "fmt" - "math" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// EventLogQuery is the builder for querying EventLog entities. -type EventLogQuery struct { - config - ctx *QueryContext - order []eventlog.OrderOption - inters []Interceptor - predicates []predicate.EventLog - withSigners *SignerQuery - modifiers []func(*sql.Selector) - loadTotal []func(context.Context, []*EventLog) error - withNamedSigners map[string]*SignerQuery - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the EventLogQuery builder. -func (elq *EventLogQuery) Where(ps ...predicate.EventLog) *EventLogQuery { - elq.predicates = append(elq.predicates, ps...) - return elq -} - -// Limit the number of records to be returned by this query. -func (elq *EventLogQuery) Limit(limit int) *EventLogQuery { - elq.ctx.Limit = &limit - return elq -} - -// Offset to start from. -func (elq *EventLogQuery) Offset(offset int) *EventLogQuery { - elq.ctx.Offset = &offset - return elq -} - -// 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 (elq *EventLogQuery) Unique(unique bool) *EventLogQuery { - elq.ctx.Unique = &unique - return elq -} - -// Order specifies how the records should be ordered. -func (elq *EventLogQuery) Order(o ...eventlog.OrderOption) *EventLogQuery { - elq.order = append(elq.order, o...) - return elq -} - -// QuerySigners chains the current query on the "signers" edge. -func (elq *EventLogQuery) QuerySigners() *SignerQuery { - query := (&SignerClient{config: elq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := elq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := elq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(eventlog.Table, eventlog.FieldID, selector), - sqlgraph.To(signer.Table, signer.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, eventlog.SignersTable, eventlog.SignersPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(elq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first EventLog entity from the query. -// Returns a *NotFoundError when no EventLog was found. -func (elq *EventLogQuery) First(ctx context.Context) (*EventLog, error) { - nodes, err := elq.Limit(1).All(setContextOp(ctx, elq.ctx, "First")) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{eventlog.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (elq *EventLogQuery) FirstX(ctx context.Context) *EventLog { - node, err := elq.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first EventLog ID from the query. -// Returns a *NotFoundError when no EventLog ID was found. -func (elq *EventLogQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = elq.Limit(1).IDs(setContextOp(ctx, elq.ctx, "FirstID")); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{eventlog.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (elq *EventLogQuery) FirstIDX(ctx context.Context) int { - id, err := elq.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single EventLog entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one EventLog entity is found. -// Returns a *NotFoundError when no EventLog entities are found. -func (elq *EventLogQuery) Only(ctx context.Context) (*EventLog, error) { - nodes, err := elq.Limit(2).All(setContextOp(ctx, elq.ctx, "Only")) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{eventlog.Label} - default: - return nil, &NotSingularError{eventlog.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (elq *EventLogQuery) OnlyX(ctx context.Context) *EventLog { - node, err := elq.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only EventLog ID in the query. -// Returns a *NotSingularError when more than one EventLog ID is found. -// Returns a *NotFoundError when no entities are found. -func (elq *EventLogQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = elq.Limit(2).IDs(setContextOp(ctx, elq.ctx, "OnlyID")); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{eventlog.Label} - default: - err = &NotSingularError{eventlog.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (elq *EventLogQuery) OnlyIDX(ctx context.Context) int { - id, err := elq.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of EventLogs. -func (elq *EventLogQuery) All(ctx context.Context) ([]*EventLog, error) { - ctx = setContextOp(ctx, elq.ctx, "All") - if err := elq.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*EventLog, *EventLogQuery]() - return withInterceptors[[]*EventLog](ctx, elq, qr, elq.inters) -} - -// AllX is like All, but panics if an error occurs. -func (elq *EventLogQuery) AllX(ctx context.Context) []*EventLog { - nodes, err := elq.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of EventLog IDs. -func (elq *EventLogQuery) IDs(ctx context.Context) (ids []int, err error) { - if elq.ctx.Unique == nil && elq.path != nil { - elq.Unique(true) - } - ctx = setContextOp(ctx, elq.ctx, "IDs") - if err = elq.Select(eventlog.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (elq *EventLogQuery) IDsX(ctx context.Context) []int { - ids, err := elq.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (elq *EventLogQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, elq.ctx, "Count") - if err := elq.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, elq, querierCount[*EventLogQuery](), elq.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (elq *EventLogQuery) CountX(ctx context.Context) int { - count, err := elq.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (elq *EventLogQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, elq.ctx, "Exist") - switch _, err := elq.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 (elq *EventLogQuery) ExistX(ctx context.Context) bool { - exist, err := elq.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the EventLogQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (elq *EventLogQuery) Clone() *EventLogQuery { - if elq == nil { - return nil - } - return &EventLogQuery{ - config: elq.config, - ctx: elq.ctx.Clone(), - order: append([]eventlog.OrderOption{}, elq.order...), - inters: append([]Interceptor{}, elq.inters...), - predicates: append([]predicate.EventLog{}, elq.predicates...), - withSigners: elq.withSigners.Clone(), - // clone intermediate query. - sql: elq.sql.Clone(), - path: elq.path, - } -} - -// WithSigners tells the query-builder to eager-load the nodes that are connected to -// the "signers" edge. The optional arguments are used to configure the query builder of the edge. -func (elq *EventLogQuery) WithSigners(opts ...func(*SignerQuery)) *EventLogQuery { - query := (&SignerClient{config: elq.config}).Query() - for _, opt := range opts { - opt(query) - } - elq.withSigners = query - return elq -} - -// 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 { -// Block uint64 `json:"block,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.EventLog.Query(). -// GroupBy(eventlog.FieldBlock). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (elq *EventLogQuery) GroupBy(field string, fields ...string) *EventLogGroupBy { - elq.ctx.Fields = append([]string{field}, fields...) - grbuild := &EventLogGroupBy{build: elq} - grbuild.flds = &elq.ctx.Fields - grbuild.label = eventlog.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 { -// Block uint64 `json:"block,omitempty"` -// } -// -// client.EventLog.Query(). -// Select(eventlog.FieldBlock). -// Scan(ctx, &v) -func (elq *EventLogQuery) Select(fields ...string) *EventLogSelect { - elq.ctx.Fields = append(elq.ctx.Fields, fields...) - sbuild := &EventLogSelect{EventLogQuery: elq} - sbuild.label = eventlog.Label - sbuild.flds, sbuild.scan = &elq.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a EventLogSelect configured with the given aggregations. -func (elq *EventLogQuery) Aggregate(fns ...AggregateFunc) *EventLogSelect { - return elq.Select().Aggregate(fns...) -} - -func (elq *EventLogQuery) prepareQuery(ctx context.Context) error { - for _, inter := range elq.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, elq); err != nil { - return err - } - } - } - for _, f := range elq.ctx.Fields { - if !eventlog.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if elq.path != nil { - prev, err := elq.path(ctx) - if err != nil { - return err - } - elq.sql = prev - } - return nil -} - -func (elq *EventLogQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*EventLog, error) { - var ( - nodes = []*EventLog{} - _spec = elq.querySpec() - loadedTypes = [1]bool{ - elq.withSigners != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*EventLog).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &EventLog{config: elq.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(elq.modifiers) > 0 { - _spec.Modifiers = elq.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, elq.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := elq.withSigners; query != nil { - if err := elq.loadSigners(ctx, query, nodes, - func(n *EventLog) { n.Edges.Signers = []*Signer{} }, - func(n *EventLog, e *Signer) { n.Edges.Signers = append(n.Edges.Signers, e) }); err != nil { - return nil, err - } - } - for name, query := range elq.withNamedSigners { - if err := elq.loadSigners(ctx, query, nodes, - func(n *EventLog) { n.appendNamedSigners(name) }, - func(n *EventLog, e *Signer) { n.appendNamedSigners(name, e) }); err != nil { - return nil, err - } - } - for i := range elq.loadTotal { - if err := elq.loadTotal[i](ctx, nodes); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (elq *EventLogQuery) loadSigners(ctx context.Context, query *SignerQuery, nodes []*EventLog, init func(*EventLog), assign func(*EventLog, *Signer)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int]*EventLog) - nids := make(map[int]map[*EventLog]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(eventlog.SignersTable) - s.Join(joinT).On(s.C(signer.FieldID), joinT.C(eventlog.SignersPrimaryKey[1])) - s.Where(sql.InValues(joinT.C(eventlog.SignersPrimaryKey[0]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(eventlog.SignersPrimaryKey[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[*EventLog]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*Signer](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 "signers" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} - -func (elq *EventLogQuery) sqlCount(ctx context.Context) (int, error) { - _spec := elq.querySpec() - if len(elq.modifiers) > 0 { - _spec.Modifiers = elq.modifiers - } - _spec.Node.Columns = elq.ctx.Fields - if len(elq.ctx.Fields) > 0 { - _spec.Unique = elq.ctx.Unique != nil && *elq.ctx.Unique - } - return sqlgraph.CountNodes(ctx, elq.driver, _spec) -} - -func (elq *EventLogQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(eventlog.Table, eventlog.Columns, sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt)) - _spec.From = elq.sql - if unique := elq.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if elq.path != nil { - _spec.Unique = true - } - if fields := elq.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, eventlog.FieldID) - for i := range fields { - if fields[i] != eventlog.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := elq.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := elq.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := elq.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := elq.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (elq *EventLogQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(elq.driver.Dialect()) - t1 := builder.Table(eventlog.Table) - columns := elq.ctx.Fields - if len(columns) == 0 { - columns = eventlog.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if elq.sql != nil { - selector = elq.sql - selector.Select(selector.Columns(columns...)...) - } - if elq.ctx.Unique != nil && *elq.ctx.Unique { - selector.Distinct() - } - for _, p := range elq.predicates { - p(selector) - } - for _, p := range elq.order { - p(selector) - } - if offset := elq.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 := elq.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// WithNamedSigners tells the query-builder to eager-load the nodes that are connected to the "signers" -// edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (elq *EventLogQuery) WithNamedSigners(name string, opts ...func(*SignerQuery)) *EventLogQuery { - query := (&SignerClient{config: elq.config}).Query() - for _, opt := range opts { - opt(query) - } - if elq.withNamedSigners == nil { - elq.withNamedSigners = make(map[string]*SignerQuery) - } - elq.withNamedSigners[name] = query - return elq -} - -// EventLogGroupBy is the group-by builder for EventLog entities. -type EventLogGroupBy struct { - selector - build *EventLogQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (elgb *EventLogGroupBy) Aggregate(fns ...AggregateFunc) *EventLogGroupBy { - elgb.fns = append(elgb.fns, fns...) - return elgb -} - -// Scan applies the selector query and scans the result into the given value. -func (elgb *EventLogGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, elgb.build.ctx, "GroupBy") - if err := elgb.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*EventLogQuery, *EventLogGroupBy](ctx, elgb.build, elgb, elgb.build.inters, v) -} - -func (elgb *EventLogGroupBy) sqlScan(ctx context.Context, root *EventLogQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(elgb.fns)) - for _, fn := range elgb.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*elgb.flds)+len(elgb.fns)) - for _, f := range *elgb.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*elgb.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := elgb.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// EventLogSelect is the builder for selecting fields of EventLog entities. -type EventLogSelect struct { - *EventLogQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (els *EventLogSelect) Aggregate(fns ...AggregateFunc) *EventLogSelect { - els.fns = append(els.fns, fns...) - return els -} - -// Scan applies the selector query and scans the result into the given value. -func (els *EventLogSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, els.ctx, "Select") - if err := els.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*EventLogQuery, *EventLogSelect](ctx, els.EventLogQuery, els, els.inters, v) -} - -func (els *EventLogSelect) sqlScan(ctx context.Context, root *EventLogQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(els.fns)) - for _, fn := range els.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*els.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 := els.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} diff --git a/internal/ent/eventlog_update.go b/internal/ent/eventlog_update.go deleted file mode 100644 index 00120a19..00000000 --- a/internal/ent/eventlog_update.go +++ /dev/null @@ -1,769 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "github.com/TimeleapLabs/unchained/internal/model" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/dialect/sql/sqljson" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// EventLogUpdate is the builder for updating EventLog entities. -type EventLogUpdate struct { - config - hooks []Hook - mutation *EventLogMutation -} - -// Where appends a list predicates to the EventLogUpdate builder. -func (elu *EventLogUpdate) Where(ps ...predicate.EventLog) *EventLogUpdate { - elu.mutation.Where(ps...) - return elu -} - -// SetBlock sets the "block" field. -func (elu *EventLogUpdate) SetBlock(u uint64) *EventLogUpdate { - elu.mutation.ResetBlock() - elu.mutation.SetBlock(u) - return elu -} - -// SetNillableBlock sets the "block" field if the given value is not nil. -func (elu *EventLogUpdate) SetNillableBlock(u *uint64) *EventLogUpdate { - if u != nil { - elu.SetBlock(*u) - } - return elu -} - -// AddBlock adds u to the "block" field. -func (elu *EventLogUpdate) AddBlock(u int64) *EventLogUpdate { - elu.mutation.AddBlock(u) - return elu -} - -// SetSignersCount sets the "signersCount" field. -func (elu *EventLogUpdate) SetSignersCount(u uint64) *EventLogUpdate { - elu.mutation.ResetSignersCount() - elu.mutation.SetSignersCount(u) - return elu -} - -// SetNillableSignersCount sets the "signersCount" field if the given value is not nil. -func (elu *EventLogUpdate) SetNillableSignersCount(u *uint64) *EventLogUpdate { - if u != nil { - elu.SetSignersCount(*u) - } - return elu -} - -// AddSignersCount adds u to the "signersCount" field. -func (elu *EventLogUpdate) AddSignersCount(u int64) *EventLogUpdate { - elu.mutation.AddSignersCount(u) - return elu -} - -// SetSignature sets the "signature" field. -func (elu *EventLogUpdate) SetSignature(b []byte) *EventLogUpdate { - elu.mutation.SetSignature(b) - return elu -} - -// SetAddress sets the "address" field. -func (elu *EventLogUpdate) SetAddress(s string) *EventLogUpdate { - elu.mutation.SetAddress(s) - return elu -} - -// SetNillableAddress sets the "address" field if the given value is not nil. -func (elu *EventLogUpdate) SetNillableAddress(s *string) *EventLogUpdate { - if s != nil { - elu.SetAddress(*s) - } - return elu -} - -// SetChain sets the "chain" field. -func (elu *EventLogUpdate) SetChain(s string) *EventLogUpdate { - elu.mutation.SetChain(s) - return elu -} - -// SetNillableChain sets the "chain" field if the given value is not nil. -func (elu *EventLogUpdate) SetNillableChain(s *string) *EventLogUpdate { - if s != nil { - elu.SetChain(*s) - } - return elu -} - -// SetIndex sets the "index" field. -func (elu *EventLogUpdate) SetIndex(u uint64) *EventLogUpdate { - elu.mutation.ResetIndex() - elu.mutation.SetIndex(u) - return elu -} - -// SetNillableIndex sets the "index" field if the given value is not nil. -func (elu *EventLogUpdate) SetNillableIndex(u *uint64) *EventLogUpdate { - if u != nil { - elu.SetIndex(*u) - } - return elu -} - -// AddIndex adds u to the "index" field. -func (elu *EventLogUpdate) AddIndex(u int64) *EventLogUpdate { - elu.mutation.AddIndex(u) - return elu -} - -// SetEvent sets the "event" field. -func (elu *EventLogUpdate) SetEvent(s string) *EventLogUpdate { - elu.mutation.SetEvent(s) - return elu -} - -// SetNillableEvent sets the "event" field if the given value is not nil. -func (elu *EventLogUpdate) SetNillableEvent(s *string) *EventLogUpdate { - if s != nil { - elu.SetEvent(*s) - } - return elu -} - -// SetTransaction sets the "transaction" field. -func (elu *EventLogUpdate) SetTransaction(b []byte) *EventLogUpdate { - elu.mutation.SetTransaction(b) - return elu -} - -// SetArgs sets the "args" field. -func (elu *EventLogUpdate) SetArgs(dla []model.EventLogArg) *EventLogUpdate { - elu.mutation.SetArgs(dla) - return elu -} - -// AppendArgs appends dla to the "args" field. -func (elu *EventLogUpdate) AppendArgs(dla []model.EventLogArg) *EventLogUpdate { - elu.mutation.AppendArgs(dla) - return elu -} - -// SetConsensus sets the "consensus" field. -func (elu *EventLogUpdate) SetConsensus(b bool) *EventLogUpdate { - elu.mutation.SetConsensus(b) - return elu -} - -// SetNillableConsensus sets the "consensus" field if the given value is not nil. -func (elu *EventLogUpdate) SetNillableConsensus(b *bool) *EventLogUpdate { - if b != nil { - elu.SetConsensus(*b) - } - return elu -} - -// SetVoted sets the "voted" field. -func (elu *EventLogUpdate) SetVoted(hi *helpers.BigInt) *EventLogUpdate { - elu.mutation.SetVoted(hi) - return elu -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by IDs. -func (elu *EventLogUpdate) AddSignerIDs(ids ...int) *EventLogUpdate { - elu.mutation.AddSignerIDs(ids...) - return elu -} - -// AddSigners adds the "signers" edges to the Signer entity. -func (elu *EventLogUpdate) AddSigners(s ...*Signer) *EventLogUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return elu.AddSignerIDs(ids...) -} - -// Mutation returns the EventLogMutation object of the builder. -func (elu *EventLogUpdate) Mutation() *EventLogMutation { - return elu.mutation -} - -// ClearSigners clears all "signers" edges to the Signer entity. -func (elu *EventLogUpdate) ClearSigners() *EventLogUpdate { - elu.mutation.ClearSigners() - return elu -} - -// RemoveSignerIDs removes the "signers" edge to Signer entities by IDs. -func (elu *EventLogUpdate) RemoveSignerIDs(ids ...int) *EventLogUpdate { - elu.mutation.RemoveSignerIDs(ids...) - return elu -} - -// RemoveSigners removes "signers" edges to Signer entities. -func (elu *EventLogUpdate) RemoveSigners(s ...*Signer) *EventLogUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return elu.RemoveSignerIDs(ids...) -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (elu *EventLogUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, elu.sqlSave, elu.mutation, elu.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (elu *EventLogUpdate) SaveX(ctx context.Context) int { - affected, err := elu.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (elu *EventLogUpdate) Exec(ctx context.Context) error { - _, err := elu.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (elu *EventLogUpdate) ExecX(ctx context.Context) { - if err := elu.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (elu *EventLogUpdate) check() error { - if v, ok := elu.mutation.Signature(); ok { - if err := eventlog.SignatureValidator(v); err != nil { - return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "EventLog.signature": %w`, err)} - } - } - if v, ok := elu.mutation.Transaction(); ok { - if err := eventlog.TransactionValidator(v); err != nil { - return &ValidationError{Name: "transaction", err: fmt.Errorf(`ent: validator failed for field "EventLog.transaction": %w`, err)} - } - } - return nil -} - -func (elu *EventLogUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := elu.check(); err != nil { - return n, err - } - _spec := sqlgraph.NewUpdateSpec(eventlog.Table, eventlog.Columns, sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt)) - if ps := elu.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := elu.mutation.Block(); ok { - _spec.SetField(eventlog.FieldBlock, field.TypeUint64, value) - } - if value, ok := elu.mutation.AddedBlock(); ok { - _spec.AddField(eventlog.FieldBlock, field.TypeUint64, value) - } - if value, ok := elu.mutation.SignersCount(); ok { - _spec.SetField(eventlog.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := elu.mutation.AddedSignersCount(); ok { - _spec.AddField(eventlog.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := elu.mutation.Signature(); ok { - _spec.SetField(eventlog.FieldSignature, field.TypeBytes, value) - } - if value, ok := elu.mutation.Address(); ok { - _spec.SetField(eventlog.FieldAddress, field.TypeString, value) - } - if value, ok := elu.mutation.Chain(); ok { - _spec.SetField(eventlog.FieldChain, field.TypeString, value) - } - if value, ok := elu.mutation.Index(); ok { - _spec.SetField(eventlog.FieldIndex, field.TypeUint64, value) - } - if value, ok := elu.mutation.AddedIndex(); ok { - _spec.AddField(eventlog.FieldIndex, field.TypeUint64, value) - } - if value, ok := elu.mutation.Event(); ok { - _spec.SetField(eventlog.FieldEvent, field.TypeString, value) - } - if value, ok := elu.mutation.Transaction(); ok { - _spec.SetField(eventlog.FieldTransaction, field.TypeBytes, value) - } - if value, ok := elu.mutation.Args(); ok { - _spec.SetField(eventlog.FieldArgs, field.TypeJSON, value) - } - if value, ok := elu.mutation.AppendedArgs(); ok { - _spec.AddModifier(func(u *sql.UpdateBuilder) { - sqljson.Append(u, eventlog.FieldArgs, value) - }) - } - if value, ok := elu.mutation.Consensus(); ok { - _spec.SetField(eventlog.FieldConsensus, field.TypeBool, value) - } - if value, ok := elu.mutation.Voted(); ok { - _spec.SetField(eventlog.FieldVoted, field.TypeUint, value) - } - if elu.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: eventlog.SignersTable, - Columns: eventlog.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := elu.mutation.RemovedSignersIDs(); len(nodes) > 0 && !elu.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: eventlog.SignersTable, - Columns: eventlog.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.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 := elu.mutation.SignersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: eventlog.SignersTable, - Columns: eventlog.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.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, elu.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{eventlog.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - elu.mutation.done = true - return n, nil -} - -// EventLogUpdateOne is the builder for updating a single EventLog entity. -type EventLogUpdateOne struct { - config - fields []string - hooks []Hook - mutation *EventLogMutation -} - -// SetBlock sets the "block" field. -func (eluo *EventLogUpdateOne) SetBlock(u uint64) *EventLogUpdateOne { - eluo.mutation.ResetBlock() - eluo.mutation.SetBlock(u) - return eluo -} - -// SetNillableBlock sets the "block" field if the given value is not nil. -func (eluo *EventLogUpdateOne) SetNillableBlock(u *uint64) *EventLogUpdateOne { - if u != nil { - eluo.SetBlock(*u) - } - return eluo -} - -// AddBlock adds u to the "block" field. -func (eluo *EventLogUpdateOne) AddBlock(u int64) *EventLogUpdateOne { - eluo.mutation.AddBlock(u) - return eluo -} - -// SetSignersCount sets the "signersCount" field. -func (eluo *EventLogUpdateOne) SetSignersCount(u uint64) *EventLogUpdateOne { - eluo.mutation.ResetSignersCount() - eluo.mutation.SetSignersCount(u) - return eluo -} - -// SetNillableSignersCount sets the "signersCount" field if the given value is not nil. -func (eluo *EventLogUpdateOne) SetNillableSignersCount(u *uint64) *EventLogUpdateOne { - if u != nil { - eluo.SetSignersCount(*u) - } - return eluo -} - -// AddSignersCount adds u to the "signersCount" field. -func (eluo *EventLogUpdateOne) AddSignersCount(u int64) *EventLogUpdateOne { - eluo.mutation.AddSignersCount(u) - return eluo -} - -// SetSignature sets the "signature" field. -func (eluo *EventLogUpdateOne) SetSignature(b []byte) *EventLogUpdateOne { - eluo.mutation.SetSignature(b) - return eluo -} - -// SetAddress sets the "address" field. -func (eluo *EventLogUpdateOne) SetAddress(s string) *EventLogUpdateOne { - eluo.mutation.SetAddress(s) - return eluo -} - -// SetNillableAddress sets the "address" field if the given value is not nil. -func (eluo *EventLogUpdateOne) SetNillableAddress(s *string) *EventLogUpdateOne { - if s != nil { - eluo.SetAddress(*s) - } - return eluo -} - -// SetChain sets the "chain" field. -func (eluo *EventLogUpdateOne) SetChain(s string) *EventLogUpdateOne { - eluo.mutation.SetChain(s) - return eluo -} - -// SetNillableChain sets the "chain" field if the given value is not nil. -func (eluo *EventLogUpdateOne) SetNillableChain(s *string) *EventLogUpdateOne { - if s != nil { - eluo.SetChain(*s) - } - return eluo -} - -// SetIndex sets the "index" field. -func (eluo *EventLogUpdateOne) SetIndex(u uint64) *EventLogUpdateOne { - eluo.mutation.ResetIndex() - eluo.mutation.SetIndex(u) - return eluo -} - -// SetNillableIndex sets the "index" field if the given value is not nil. -func (eluo *EventLogUpdateOne) SetNillableIndex(u *uint64) *EventLogUpdateOne { - if u != nil { - eluo.SetIndex(*u) - } - return eluo -} - -// AddIndex adds u to the "index" field. -func (eluo *EventLogUpdateOne) AddIndex(u int64) *EventLogUpdateOne { - eluo.mutation.AddIndex(u) - return eluo -} - -// SetEvent sets the "event" field. -func (eluo *EventLogUpdateOne) SetEvent(s string) *EventLogUpdateOne { - eluo.mutation.SetEvent(s) - return eluo -} - -// SetNillableEvent sets the "event" field if the given value is not nil. -func (eluo *EventLogUpdateOne) SetNillableEvent(s *string) *EventLogUpdateOne { - if s != nil { - eluo.SetEvent(*s) - } - return eluo -} - -// SetTransaction sets the "transaction" field. -func (eluo *EventLogUpdateOne) SetTransaction(b []byte) *EventLogUpdateOne { - eluo.mutation.SetTransaction(b) - return eluo -} - -// SetArgs sets the "args" field. -func (eluo *EventLogUpdateOne) SetArgs(dla []model.EventLogArg) *EventLogUpdateOne { - eluo.mutation.SetArgs(dla) - return eluo -} - -// AppendArgs appends dla to the "args" field. -func (eluo *EventLogUpdateOne) AppendArgs(dla []model.EventLogArg) *EventLogUpdateOne { - eluo.mutation.AppendArgs(dla) - return eluo -} - -// SetConsensus sets the "consensus" field. -func (eluo *EventLogUpdateOne) SetConsensus(b bool) *EventLogUpdateOne { - eluo.mutation.SetConsensus(b) - return eluo -} - -// SetNillableConsensus sets the "consensus" field if the given value is not nil. -func (eluo *EventLogUpdateOne) SetNillableConsensus(b *bool) *EventLogUpdateOne { - if b != nil { - eluo.SetConsensus(*b) - } - return eluo -} - -// SetVoted sets the "voted" field. -func (eluo *EventLogUpdateOne) SetVoted(hi *helpers.BigInt) *EventLogUpdateOne { - eluo.mutation.SetVoted(hi) - return eluo -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by IDs. -func (eluo *EventLogUpdateOne) AddSignerIDs(ids ...int) *EventLogUpdateOne { - eluo.mutation.AddSignerIDs(ids...) - return eluo -} - -// AddSigners adds the "signers" edges to the Signer entity. -func (eluo *EventLogUpdateOne) AddSigners(s ...*Signer) *EventLogUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return eluo.AddSignerIDs(ids...) -} - -// Mutation returns the EventLogMutation object of the builder. -func (eluo *EventLogUpdateOne) Mutation() *EventLogMutation { - return eluo.mutation -} - -// ClearSigners clears all "signers" edges to the Signer entity. -func (eluo *EventLogUpdateOne) ClearSigners() *EventLogUpdateOne { - eluo.mutation.ClearSigners() - return eluo -} - -// RemoveSignerIDs removes the "signers" edge to Signer entities by IDs. -func (eluo *EventLogUpdateOne) RemoveSignerIDs(ids ...int) *EventLogUpdateOne { - eluo.mutation.RemoveSignerIDs(ids...) - return eluo -} - -// RemoveSigners removes "signers" edges to Signer entities. -func (eluo *EventLogUpdateOne) RemoveSigners(s ...*Signer) *EventLogUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID - } - return eluo.RemoveSignerIDs(ids...) -} - -// Where appends a list predicates to the EventLogUpdate builder. -func (eluo *EventLogUpdateOne) Where(ps ...predicate.EventLog) *EventLogUpdateOne { - eluo.mutation.Where(ps...) - return eluo -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (eluo *EventLogUpdateOne) Select(field string, fields ...string) *EventLogUpdateOne { - eluo.fields = append([]string{field}, fields...) - return eluo -} - -// Save executes the query and returns the updated EventLog entity. -func (eluo *EventLogUpdateOne) Save(ctx context.Context) (*EventLog, error) { - return withHooks(ctx, eluo.sqlSave, eluo.mutation, eluo.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (eluo *EventLogUpdateOne) SaveX(ctx context.Context) *EventLog { - node, err := eluo.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (eluo *EventLogUpdateOne) Exec(ctx context.Context) error { - _, err := eluo.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (eluo *EventLogUpdateOne) ExecX(ctx context.Context) { - if err := eluo.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (eluo *EventLogUpdateOne) check() error { - if v, ok := eluo.mutation.Signature(); ok { - if err := eventlog.SignatureValidator(v); err != nil { - return &ValidationError{Name: "signature", err: fmt.Errorf(`ent: validator failed for field "EventLog.signature": %w`, err)} - } - } - if v, ok := eluo.mutation.Transaction(); ok { - if err := eventlog.TransactionValidator(v); err != nil { - return &ValidationError{Name: "transaction", err: fmt.Errorf(`ent: validator failed for field "EventLog.transaction": %w`, err)} - } - } - return nil -} - -func (eluo *EventLogUpdateOne) sqlSave(ctx context.Context) (_node *EventLog, err error) { - if err := eluo.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(eventlog.Table, eventlog.Columns, sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt)) - id, ok := eluo.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EventLog.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := eluo.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, eventlog.FieldID) - for _, f := range fields { - if !eventlog.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != eventlog.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := eluo.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := eluo.mutation.Block(); ok { - _spec.SetField(eventlog.FieldBlock, field.TypeUint64, value) - } - if value, ok := eluo.mutation.AddedBlock(); ok { - _spec.AddField(eventlog.FieldBlock, field.TypeUint64, value) - } - if value, ok := eluo.mutation.SignersCount(); ok { - _spec.SetField(eventlog.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := eluo.mutation.AddedSignersCount(); ok { - _spec.AddField(eventlog.FieldSignersCount, field.TypeUint64, value) - } - if value, ok := eluo.mutation.Signature(); ok { - _spec.SetField(eventlog.FieldSignature, field.TypeBytes, value) - } - if value, ok := eluo.mutation.Address(); ok { - _spec.SetField(eventlog.FieldAddress, field.TypeString, value) - } - if value, ok := eluo.mutation.Chain(); ok { - _spec.SetField(eventlog.FieldChain, field.TypeString, value) - } - if value, ok := eluo.mutation.Index(); ok { - _spec.SetField(eventlog.FieldIndex, field.TypeUint64, value) - } - if value, ok := eluo.mutation.AddedIndex(); ok { - _spec.AddField(eventlog.FieldIndex, field.TypeUint64, value) - } - if value, ok := eluo.mutation.Event(); ok { - _spec.SetField(eventlog.FieldEvent, field.TypeString, value) - } - if value, ok := eluo.mutation.Transaction(); ok { - _spec.SetField(eventlog.FieldTransaction, field.TypeBytes, value) - } - if value, ok := eluo.mutation.Args(); ok { - _spec.SetField(eventlog.FieldArgs, field.TypeJSON, value) - } - if value, ok := eluo.mutation.AppendedArgs(); ok { - _spec.AddModifier(func(u *sql.UpdateBuilder) { - sqljson.Append(u, eventlog.FieldArgs, value) - }) - } - if value, ok := eluo.mutation.Consensus(); ok { - _spec.SetField(eventlog.FieldConsensus, field.TypeBool, value) - } - if value, ok := eluo.mutation.Voted(); ok { - _spec.SetField(eventlog.FieldVoted, field.TypeUint, value) - } - if eluo.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: eventlog.SignersTable, - Columns: eventlog.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := eluo.mutation.RemovedSignersIDs(); len(nodes) > 0 && !eluo.mutation.SignersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: eventlog.SignersTable, - Columns: eventlog.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.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 := eluo.mutation.SignersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: eventlog.SignersTable, - Columns: eventlog.SignersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _node = &EventLog{config: eluo.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, eluo.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{eventlog.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - eluo.mutation.done = true - return _node, nil -} diff --git a/internal/ent/gql_collection.go b/internal/ent/gql_collection.go deleted file mode 100644 index b1a9b00d..00000000 --- a/internal/ent/gql_collection.go +++ /dev/null @@ -1,678 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - - "entgo.io/contrib/entgql" - "entgo.io/ent/dialect/sql" - "github.com/99designs/gqlgen/graphql" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. -func (ap *AssetPriceQuery) CollectFields(ctx context.Context, satisfies ...string) (*AssetPriceQuery, error) { - fc := graphql.GetFieldContext(ctx) - if fc == nil { - return ap, nil - } - if err := ap.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { - return nil, err - } - return ap, nil -} - -func (ap *AssetPriceQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { - path = append([]string(nil), path...) - var ( - unknownSeen bool - fieldSeen = make(map[string]struct{}, len(assetprice.Columns)) - selectedFields = []string{assetprice.FieldID} - ) - for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { - switch field.Name { - case "signers": - var ( - alias = field.Alias - path = append(path, alias) - query = (&SignerClient{config: ap.config}).Query() - ) - if err := query.collectField(ctx, opCtx, field, path, mayAddCondition(satisfies, signerImplementors)...); err != nil { - return err - } - ap.WithNamedSigners(alias, func(wq *SignerQuery) { - *wq = *query - }) - case "block": - if _, ok := fieldSeen[assetprice.FieldBlock]; !ok { - selectedFields = append(selectedFields, assetprice.FieldBlock) - fieldSeen[assetprice.FieldBlock] = struct{}{} - } - case "signerscount": - if _, ok := fieldSeen[assetprice.FieldSignersCount]; !ok { - selectedFields = append(selectedFields, assetprice.FieldSignersCount) - fieldSeen[assetprice.FieldSignersCount] = struct{}{} - } - case "price": - if _, ok := fieldSeen[assetprice.FieldPrice]; !ok { - selectedFields = append(selectedFields, assetprice.FieldPrice) - fieldSeen[assetprice.FieldPrice] = struct{}{} - } - case "signature": - if _, ok := fieldSeen[assetprice.FieldSignature]; !ok { - selectedFields = append(selectedFields, assetprice.FieldSignature) - fieldSeen[assetprice.FieldSignature] = struct{}{} - } - case "asset": - if _, ok := fieldSeen[assetprice.FieldAsset]; !ok { - selectedFields = append(selectedFields, assetprice.FieldAsset) - fieldSeen[assetprice.FieldAsset] = struct{}{} - } - case "chain": - if _, ok := fieldSeen[assetprice.FieldChain]; !ok { - selectedFields = append(selectedFields, assetprice.FieldChain) - fieldSeen[assetprice.FieldChain] = struct{}{} - } - case "pair": - if _, ok := fieldSeen[assetprice.FieldPair]; !ok { - selectedFields = append(selectedFields, assetprice.FieldPair) - fieldSeen[assetprice.FieldPair] = struct{}{} - } - case "consensus": - if _, ok := fieldSeen[assetprice.FieldConsensus]; !ok { - selectedFields = append(selectedFields, assetprice.FieldConsensus) - fieldSeen[assetprice.FieldConsensus] = struct{}{} - } - case "voted": - if _, ok := fieldSeen[assetprice.FieldVoted]; !ok { - selectedFields = append(selectedFields, assetprice.FieldVoted) - fieldSeen[assetprice.FieldVoted] = struct{}{} - } - case "id": - case "__typename": - default: - unknownSeen = true - } - } - if !unknownSeen { - ap.Select(selectedFields...) - } - return nil -} - -type assetpricePaginateArgs struct { - first, last *int - after, before *Cursor - opts []AssetPricePaginateOption -} - -func newAssetPricePaginateArgs(rv map[string]any) *assetpricePaginateArgs { - args := &assetpricePaginateArgs{} - if rv == nil { - return args - } - if v := rv[firstField]; v != nil { - args.first = v.(*int) - } - if v := rv[lastField]; v != nil { - args.last = v.(*int) - } - if v := rv[afterField]; v != nil { - args.after = v.(*Cursor) - } - if v := rv[beforeField]; v != nil { - args.before = v.(*Cursor) - } - if v, ok := rv[orderByField]; ok { - switch v := v.(type) { - case map[string]any: - var ( - err1, err2 error - order = &AssetPriceOrder{Field: &AssetPriceOrderField{}, Direction: entgql.OrderDirectionAsc} - ) - if d, ok := v[directionField]; ok { - err1 = order.Direction.UnmarshalGQL(d) - } - if f, ok := v[fieldField]; ok { - err2 = order.Field.UnmarshalGQL(f) - } - if err1 == nil && err2 == nil { - args.opts = append(args.opts, WithAssetPriceOrder(order)) - } - case *AssetPriceOrder: - if v != nil { - args.opts = append(args.opts, WithAssetPriceOrder(v)) - } - } - } - if v, ok := rv[whereField].(*AssetPriceWhereInput); ok { - args.opts = append(args.opts, WithAssetPriceFilter(v.Filter)) - } - return args -} - -// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. -func (cr *CorrectnessReportQuery) CollectFields(ctx context.Context, satisfies ...string) (*CorrectnessReportQuery, error) { - fc := graphql.GetFieldContext(ctx) - if fc == nil { - return cr, nil - } - if err := cr.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { - return nil, err - } - return cr, nil -} - -func (cr *CorrectnessReportQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { - path = append([]string(nil), path...) - var ( - unknownSeen bool - fieldSeen = make(map[string]struct{}, len(correctnessreport.Columns)) - selectedFields = []string{correctnessreport.FieldID} - ) - for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { - switch field.Name { - case "signers": - var ( - alias = field.Alias - path = append(path, alias) - query = (&SignerClient{config: cr.config}).Query() - ) - if err := query.collectField(ctx, opCtx, field, path, mayAddCondition(satisfies, signerImplementors)...); err != nil { - return err - } - cr.WithNamedSigners(alias, func(wq *SignerQuery) { - *wq = *query - }) - case "signerscount": - if _, ok := fieldSeen[correctnessreport.FieldSignersCount]; !ok { - selectedFields = append(selectedFields, correctnessreport.FieldSignersCount) - fieldSeen[correctnessreport.FieldSignersCount] = struct{}{} - } - case "timestamp": - if _, ok := fieldSeen[correctnessreport.FieldTimestamp]; !ok { - selectedFields = append(selectedFields, correctnessreport.FieldTimestamp) - fieldSeen[correctnessreport.FieldTimestamp] = struct{}{} - } - case "signature": - if _, ok := fieldSeen[correctnessreport.FieldSignature]; !ok { - selectedFields = append(selectedFields, correctnessreport.FieldSignature) - fieldSeen[correctnessreport.FieldSignature] = struct{}{} - } - case "hash": - if _, ok := fieldSeen[correctnessreport.FieldHash]; !ok { - selectedFields = append(selectedFields, correctnessreport.FieldHash) - fieldSeen[correctnessreport.FieldHash] = struct{}{} - } - case "topic": - if _, ok := fieldSeen[correctnessreport.FieldTopic]; !ok { - selectedFields = append(selectedFields, correctnessreport.FieldTopic) - fieldSeen[correctnessreport.FieldTopic] = struct{}{} - } - case "correct": - if _, ok := fieldSeen[correctnessreport.FieldCorrect]; !ok { - selectedFields = append(selectedFields, correctnessreport.FieldCorrect) - fieldSeen[correctnessreport.FieldCorrect] = struct{}{} - } - case "consensus": - if _, ok := fieldSeen[correctnessreport.FieldConsensus]; !ok { - selectedFields = append(selectedFields, correctnessreport.FieldConsensus) - fieldSeen[correctnessreport.FieldConsensus] = struct{}{} - } - case "voted": - if _, ok := fieldSeen[correctnessreport.FieldVoted]; !ok { - selectedFields = append(selectedFields, correctnessreport.FieldVoted) - fieldSeen[correctnessreport.FieldVoted] = struct{}{} - } - case "id": - case "__typename": - default: - unknownSeen = true - } - } - if !unknownSeen { - cr.Select(selectedFields...) - } - return nil -} - -type correctnessreportPaginateArgs struct { - first, last *int - after, before *Cursor - opts []CorrectnessReportPaginateOption -} - -func newCorrectnessReportPaginateArgs(rv map[string]any) *correctnessreportPaginateArgs { - args := &correctnessreportPaginateArgs{} - if rv == nil { - return args - } - if v := rv[firstField]; v != nil { - args.first = v.(*int) - } - if v := rv[lastField]; v != nil { - args.last = v.(*int) - } - if v := rv[afterField]; v != nil { - args.after = v.(*Cursor) - } - if v := rv[beforeField]; v != nil { - args.before = v.(*Cursor) - } - if v, ok := rv[orderByField]; ok { - switch v := v.(type) { - case map[string]any: - var ( - err1, err2 error - order = &CorrectnessReportOrder{Field: &CorrectnessReportOrderField{}, Direction: entgql.OrderDirectionAsc} - ) - if d, ok := v[directionField]; ok { - err1 = order.Direction.UnmarshalGQL(d) - } - if f, ok := v[fieldField]; ok { - err2 = order.Field.UnmarshalGQL(f) - } - if err1 == nil && err2 == nil { - args.opts = append(args.opts, WithCorrectnessReportOrder(order)) - } - case *CorrectnessReportOrder: - if v != nil { - args.opts = append(args.opts, WithCorrectnessReportOrder(v)) - } - } - } - if v, ok := rv[whereField].(*CorrectnessReportWhereInput); ok { - args.opts = append(args.opts, WithCorrectnessReportFilter(v.Filter)) - } - return args -} - -// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. -func (el *EventLogQuery) CollectFields(ctx context.Context, satisfies ...string) (*EventLogQuery, error) { - fc := graphql.GetFieldContext(ctx) - if fc == nil { - return el, nil - } - if err := el.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { - return nil, err - } - return el, nil -} - -func (el *EventLogQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { - path = append([]string(nil), path...) - var ( - unknownSeen bool - fieldSeen = make(map[string]struct{}, len(eventlog.Columns)) - selectedFields = []string{eventlog.FieldID} - ) - for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { - switch field.Name { - case "signers": - var ( - alias = field.Alias - path = append(path, alias) - query = (&SignerClient{config: el.config}).Query() - ) - if err := query.collectField(ctx, opCtx, field, path, mayAddCondition(satisfies, signerImplementors)...); err != nil { - return err - } - el.WithNamedSigners(alias, func(wq *SignerQuery) { - *wq = *query - }) - case "block": - if _, ok := fieldSeen[eventlog.FieldBlock]; !ok { - selectedFields = append(selectedFields, eventlog.FieldBlock) - fieldSeen[eventlog.FieldBlock] = struct{}{} - } - case "signerscount": - if _, ok := fieldSeen[eventlog.FieldSignersCount]; !ok { - selectedFields = append(selectedFields, eventlog.FieldSignersCount) - fieldSeen[eventlog.FieldSignersCount] = struct{}{} - } - case "signature": - if _, ok := fieldSeen[eventlog.FieldSignature]; !ok { - selectedFields = append(selectedFields, eventlog.FieldSignature) - fieldSeen[eventlog.FieldSignature] = struct{}{} - } - case "address": - if _, ok := fieldSeen[eventlog.FieldAddress]; !ok { - selectedFields = append(selectedFields, eventlog.FieldAddress) - fieldSeen[eventlog.FieldAddress] = struct{}{} - } - case "chain": - if _, ok := fieldSeen[eventlog.FieldChain]; !ok { - selectedFields = append(selectedFields, eventlog.FieldChain) - fieldSeen[eventlog.FieldChain] = struct{}{} - } - case "index": - if _, ok := fieldSeen[eventlog.FieldIndex]; !ok { - selectedFields = append(selectedFields, eventlog.FieldIndex) - fieldSeen[eventlog.FieldIndex] = struct{}{} - } - case "event": - if _, ok := fieldSeen[eventlog.FieldEvent]; !ok { - selectedFields = append(selectedFields, eventlog.FieldEvent) - fieldSeen[eventlog.FieldEvent] = struct{}{} - } - case "transaction": - if _, ok := fieldSeen[eventlog.FieldTransaction]; !ok { - selectedFields = append(selectedFields, eventlog.FieldTransaction) - fieldSeen[eventlog.FieldTransaction] = struct{}{} - } - case "args": - if _, ok := fieldSeen[eventlog.FieldArgs]; !ok { - selectedFields = append(selectedFields, eventlog.FieldArgs) - fieldSeen[eventlog.FieldArgs] = struct{}{} - } - case "consensus": - if _, ok := fieldSeen[eventlog.FieldConsensus]; !ok { - selectedFields = append(selectedFields, eventlog.FieldConsensus) - fieldSeen[eventlog.FieldConsensus] = struct{}{} - } - case "voted": - if _, ok := fieldSeen[eventlog.FieldVoted]; !ok { - selectedFields = append(selectedFields, eventlog.FieldVoted) - fieldSeen[eventlog.FieldVoted] = struct{}{} - } - case "id": - case "__typename": - default: - unknownSeen = true - } - } - if !unknownSeen { - el.Select(selectedFields...) - } - return nil -} - -type eventlogPaginateArgs struct { - first, last *int - after, before *Cursor - opts []EventLogPaginateOption -} - -func newEventLogPaginateArgs(rv map[string]any) *eventlogPaginateArgs { - args := &eventlogPaginateArgs{} - if rv == nil { - return args - } - if v := rv[firstField]; v != nil { - args.first = v.(*int) - } - if v := rv[lastField]; v != nil { - args.last = v.(*int) - } - if v := rv[afterField]; v != nil { - args.after = v.(*Cursor) - } - if v := rv[beforeField]; v != nil { - args.before = v.(*Cursor) - } - if v, ok := rv[orderByField]; ok { - switch v := v.(type) { - case map[string]any: - var ( - err1, err2 error - order = &EventLogOrder{Field: &EventLogOrderField{}, Direction: entgql.OrderDirectionAsc} - ) - if d, ok := v[directionField]; ok { - err1 = order.Direction.UnmarshalGQL(d) - } - if f, ok := v[fieldField]; ok { - err2 = order.Field.UnmarshalGQL(f) - } - if err1 == nil && err2 == nil { - args.opts = append(args.opts, WithEventLogOrder(order)) - } - case *EventLogOrder: - if v != nil { - args.opts = append(args.opts, WithEventLogOrder(v)) - } - } - } - if v, ok := rv[whereField].(*EventLogWhereInput); ok { - args.opts = append(args.opts, WithEventLogFilter(v.Filter)) - } - return args -} - -// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. -func (s *SignerQuery) CollectFields(ctx context.Context, satisfies ...string) (*SignerQuery, error) { - fc := graphql.GetFieldContext(ctx) - if fc == nil { - return s, nil - } - if err := s.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { - return nil, err - } - return s, nil -} - -func (s *SignerQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { - path = append([]string(nil), path...) - var ( - unknownSeen bool - fieldSeen = make(map[string]struct{}, len(signer.Columns)) - selectedFields = []string{signer.FieldID} - ) - for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { - switch field.Name { - case "assetprice": - var ( - alias = field.Alias - path = append(path, alias) - query = (&AssetPriceClient{config: s.config}).Query() - ) - if err := query.collectField(ctx, opCtx, field, path, mayAddCondition(satisfies, assetpriceImplementors)...); err != nil { - return err - } - s.WithNamedAssetPrice(alias, func(wq *AssetPriceQuery) { - *wq = *query - }) - case "eventlogs": - var ( - alias = field.Alias - path = append(path, alias) - query = (&EventLogClient{config: s.config}).Query() - ) - if err := query.collectField(ctx, opCtx, field, path, mayAddCondition(satisfies, eventlogImplementors)...); err != nil { - return err - } - s.WithNamedEventLogs(alias, func(wq *EventLogQuery) { - *wq = *query - }) - case "correctnessreport": - var ( - alias = field.Alias - path = append(path, alias) - query = (&CorrectnessReportClient{config: s.config}).Query() - ) - if err := query.collectField(ctx, opCtx, field, path, mayAddCondition(satisfies, correctnessreportImplementors)...); err != nil { - return err - } - s.WithNamedCorrectnessReport(alias, func(wq *CorrectnessReportQuery) { - *wq = *query - }) - case "name": - if _, ok := fieldSeen[signer.FieldName]; !ok { - selectedFields = append(selectedFields, signer.FieldName) - fieldSeen[signer.FieldName] = struct{}{} - } - case "evm": - if _, ok := fieldSeen[signer.FieldEvm]; !ok { - selectedFields = append(selectedFields, signer.FieldEvm) - fieldSeen[signer.FieldEvm] = struct{}{} - } - case "key": - if _, ok := fieldSeen[signer.FieldKey]; !ok { - selectedFields = append(selectedFields, signer.FieldKey) - fieldSeen[signer.FieldKey] = struct{}{} - } - case "shortkey": - if _, ok := fieldSeen[signer.FieldShortkey]; !ok { - selectedFields = append(selectedFields, signer.FieldShortkey) - fieldSeen[signer.FieldShortkey] = struct{}{} - } - case "points": - if _, ok := fieldSeen[signer.FieldPoints]; !ok { - selectedFields = append(selectedFields, signer.FieldPoints) - fieldSeen[signer.FieldPoints] = struct{}{} - } - case "id": - case "__typename": - default: - unknownSeen = true - } - } - if !unknownSeen { - s.Select(selectedFields...) - } - return nil -} - -type signerPaginateArgs struct { - first, last *int - after, before *Cursor - opts []SignerPaginateOption -} - -func newSignerPaginateArgs(rv map[string]any) *signerPaginateArgs { - args := &signerPaginateArgs{} - if rv == nil { - return args - } - if v := rv[firstField]; v != nil { - args.first = v.(*int) - } - if v := rv[lastField]; v != nil { - args.last = v.(*int) - } - if v := rv[afterField]; v != nil { - args.after = v.(*Cursor) - } - if v := rv[beforeField]; v != nil { - args.before = v.(*Cursor) - } - if v, ok := rv[orderByField]; ok { - switch v := v.(type) { - case map[string]any: - var ( - err1, err2 error - order = &SignerOrder{Field: &SignerOrderField{}, Direction: entgql.OrderDirectionAsc} - ) - if d, ok := v[directionField]; ok { - err1 = order.Direction.UnmarshalGQL(d) - } - if f, ok := v[fieldField]; ok { - err2 = order.Field.UnmarshalGQL(f) - } - if err1 == nil && err2 == nil { - args.opts = append(args.opts, WithSignerOrder(order)) - } - case *SignerOrder: - if v != nil { - args.opts = append(args.opts, WithSignerOrder(v)) - } - } - } - if v, ok := rv[whereField].(*SignerWhereInput); ok { - args.opts = append(args.opts, WithSignerFilter(v.Filter)) - } - return args -} - -const ( - afterField = "after" - firstField = "first" - beforeField = "before" - lastField = "last" - orderByField = "orderBy" - directionField = "direction" - fieldField = "field" - whereField = "where" -) - -func fieldArgs(ctx context.Context, whereInput any, path ...string) map[string]any { - field := collectedField(ctx, path...) - if field == nil || field.Arguments == nil { - return nil - } - oc := graphql.GetOperationContext(ctx) - args := field.ArgumentMap(oc.Variables) - return unmarshalArgs(ctx, whereInput, args) -} - -// unmarshalArgs allows extracting the field arguments from their raw representation. -func unmarshalArgs(ctx context.Context, whereInput any, args map[string]any) map[string]any { - for _, k := range []string{firstField, lastField} { - v, ok := args[k] - if !ok { - continue - } - i, err := graphql.UnmarshalInt(v) - if err == nil { - args[k] = &i - } - } - for _, k := range []string{beforeField, afterField} { - v, ok := args[k] - if !ok { - continue - } - c := &Cursor{} - if c.UnmarshalGQL(v) == nil { - args[k] = c - } - } - if v, ok := args[whereField]; ok && whereInput != nil { - if err := graphql.UnmarshalInputFromContext(ctx, v, whereInput); err == nil { - args[whereField] = whereInput - } - } - - return args -} - -func limitRows(partitionBy string, limit int, orderBy ...sql.Querier) func(s *sql.Selector) { - return func(s *sql.Selector) { - d := sql.Dialect(s.Dialect()) - s.SetDistinct(false) - with := d.With("src_query"). - As(s.Clone()). - With("limited_query"). - As( - d.Select("*"). - AppendSelectExprAs( - sql.RowNumber().PartitionBy(partitionBy).OrderExpr(orderBy...), - "row_number", - ). - From(d.Table("src_query")), - ) - t := d.Table("limited_query").As(s.TableName()) - *s = *d.Select(s.UnqualifiedColumns()...). - From(t). - Where(sql.LTE(t.C("row_number"), limit)). - Prefix(with) - } -} - -// mayAddCondition appends another type condition to the satisfies list -// if it does not exist in the list. -func mayAddCondition(satisfies []string, typeCond []string) []string { -Cond: - for _, c := range typeCond { - for _, s := range satisfies { - if c == s { - continue Cond - } - } - satisfies = append(satisfies, c) - } - return satisfies -} diff --git a/internal/ent/gql_edge.go b/internal/ent/gql_edge.go deleted file mode 100644 index a6cb9e8d..00000000 --- a/internal/ent/gql_edge.go +++ /dev/null @@ -1,81 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - - "github.com/99designs/gqlgen/graphql" -) - -func (ap *AssetPrice) Signers(ctx context.Context) (result []*Signer, err error) { - if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { - result, err = ap.NamedSigners(graphql.GetFieldContext(ctx).Field.Alias) - } else { - result, err = ap.Edges.SignersOrErr() - } - if IsNotLoaded(err) { - result, err = ap.QuerySigners().All(ctx) - } - return result, err -} - -func (cr *CorrectnessReport) Signers(ctx context.Context) (result []*Signer, err error) { - if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { - result, err = cr.NamedSigners(graphql.GetFieldContext(ctx).Field.Alias) - } else { - result, err = cr.Edges.SignersOrErr() - } - if IsNotLoaded(err) { - result, err = cr.QuerySigners().All(ctx) - } - return result, err -} - -func (el *EventLog) Signers(ctx context.Context) (result []*Signer, err error) { - if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { - result, err = el.NamedSigners(graphql.GetFieldContext(ctx).Field.Alias) - } else { - result, err = el.Edges.SignersOrErr() - } - if IsNotLoaded(err) { - result, err = el.QuerySigners().All(ctx) - } - return result, err -} - -func (s *Signer) AssetPrice(ctx context.Context) (result []*AssetPrice, err error) { - if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { - result, err = s.NamedAssetPrice(graphql.GetFieldContext(ctx).Field.Alias) - } else { - result, err = s.Edges.AssetPriceOrErr() - } - if IsNotLoaded(err) { - result, err = s.QueryAssetPrice().All(ctx) - } - return result, err -} - -func (s *Signer) EventLogs(ctx context.Context) (result []*EventLog, err error) { - if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { - result, err = s.NamedEventLogs(graphql.GetFieldContext(ctx).Field.Alias) - } else { - result, err = s.Edges.EventLogsOrErr() - } - if IsNotLoaded(err) { - result, err = s.QueryEventLogs().All(ctx) - } - return result, err -} - -func (s *Signer) CorrectnessReport(ctx context.Context) (result []*CorrectnessReport, err error) { - if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { - result, err = s.NamedCorrectnessReport(graphql.GetFieldContext(ctx).Field.Alias) - } else { - result, err = s.Edges.CorrectnessReportOrErr() - } - if IsNotLoaded(err) { - result, err = s.QueryCorrectnessReport().All(ctx) - } - return result, err -} diff --git a/internal/ent/gql_node.go b/internal/ent/gql_node.go deleted file mode 100644 index ac4e7c6a..00000000 --- a/internal/ent/gql_node.go +++ /dev/null @@ -1,348 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "fmt" - "sync" - "sync/atomic" - - "entgo.io/contrib/entgql" - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/schema" - "github.com/99designs/gqlgen/graphql" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/signer" - "github.com/hashicorp/go-multierror" - "golang.org/x/sync/semaphore" -) - -// Noder wraps the basic Node method. -type Noder interface { - IsNode() -} - -var assetpriceImplementors = []string{"AssetPrice", "Node"} - -// IsNode implements the Node interface check for GQLGen. -func (*AssetPrice) IsNode() {} - -var correctnessreportImplementors = []string{"CorrectnessReport", "Node"} - -// IsNode implements the Node interface check for GQLGen. -func (*CorrectnessReport) IsNode() {} - -var eventlogImplementors = []string{"EventLog", "Node"} - -// IsNode implements the Node interface check for GQLGen. -func (*EventLog) IsNode() {} - -var signerImplementors = []string{"Signer", "Node"} - -// IsNode implements the Node interface check for GQLGen. -func (*Signer) IsNode() {} - -var errNodeInvalidID = &NotFoundError{"node"} - -// NodeOption allows configuring the Noder execution using functional options. -type NodeOption func(*nodeOptions) - -// WithNodeType sets the node Type resolver function (i.e. the table to query). -// If was not provided, the table will be derived from the universal-id -// configuration as described in: https://entgo.io/docs/migrate/#universal-ids. -func WithNodeType(f func(context.Context, int) (string, error)) NodeOption { - return func(o *nodeOptions) { - o.nodeType = f - } -} - -// WithFixedNodeType sets the Type of the node to a fixed value. -func WithFixedNodeType(t string) NodeOption { - return WithNodeType(func(context.Context, int) (string, error) { - return t, nil - }) -} - -type nodeOptions struct { - nodeType func(context.Context, int) (string, error) -} - -func (c *Client) newNodeOpts(opts []NodeOption) *nodeOptions { - nopts := &nodeOptions{} - for _, opt := range opts { - opt(nopts) - } - if nopts.nodeType == nil { - nopts.nodeType = func(ctx context.Context, id int) (string, error) { - return c.tables.nodeType(ctx, c.driver, id) - } - } - return nopts -} - -// Noder returns a Node by its id. If the NodeType was not provided, it will -// be derived from the id value according to the universal-id configuration. -// -// c.Noder(ctx, id) -// c.Noder(ctx, id, ent.WithNodeType(typeResolver)) -func (c *Client) Noder(ctx context.Context, id int, opts ...NodeOption) (_ Noder, err error) { - defer func() { - if IsNotFound(err) { - err = multierror.Append(err, entgql.ErrNodeNotFound(id)) - } - }() - table, err := c.newNodeOpts(opts).nodeType(ctx, id) - if err != nil { - return nil, err - } - return c.noder(ctx, table, id) -} - -func (c *Client) noder(ctx context.Context, table string, id int) (Noder, error) { - switch table { - case assetprice.Table: - query := c.AssetPrice.Query(). - Where(assetprice.ID(id)) - query, err := query.CollectFields(ctx, assetpriceImplementors...) - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err - } - return n, nil - case correctnessreport.Table: - query := c.CorrectnessReport.Query(). - Where(correctnessreport.ID(id)) - query, err := query.CollectFields(ctx, correctnessreportImplementors...) - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err - } - return n, nil - case eventlog.Table: - query := c.EventLog.Query(). - Where(eventlog.ID(id)) - query, err := query.CollectFields(ctx, eventlogImplementors...) - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err - } - return n, nil - case signer.Table: - query := c.Signer.Query(). - Where(signer.ID(id)) - query, err := query.CollectFields(ctx, signerImplementors...) - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err - } - return n, nil - default: - return nil, fmt.Errorf("cannot resolve noder from table %q: %w", table, errNodeInvalidID) - } -} - -func (c *Client) Noders(ctx context.Context, ids []int, opts ...NodeOption) ([]Noder, error) { - switch len(ids) { - case 1: - noder, err := c.Noder(ctx, ids[0], opts...) - if err != nil { - return nil, err - } - return []Noder{noder}, nil - case 0: - return []Noder{}, nil - } - - noders := make([]Noder, len(ids)) - errors := make([]error, len(ids)) - tables := make(map[string][]int) - id2idx := make(map[int][]int, len(ids)) - nopts := c.newNodeOpts(opts) - for i, id := range ids { - table, err := nopts.nodeType(ctx, id) - if err != nil { - errors[i] = err - continue - } - tables[table] = append(tables[table], id) - id2idx[id] = append(id2idx[id], i) - } - - for table, ids := range tables { - nodes, err := c.noders(ctx, table, ids) - if err != nil { - for _, id := range ids { - for _, idx := range id2idx[id] { - errors[idx] = err - } - } - } else { - for i, id := range ids { - for _, idx := range id2idx[id] { - noders[idx] = nodes[i] - } - } - } - } - - for i, id := range ids { - if errors[i] == nil { - if noders[i] != nil { - continue - } - errors[i] = entgql.ErrNodeNotFound(id) - } else if IsNotFound(errors[i]) { - errors[i] = multierror.Append(errors[i], entgql.ErrNodeNotFound(id)) - } - ctx := graphql.WithPathContext(ctx, - graphql.NewPathWithIndex(i), - ) - graphql.AddError(ctx, errors[i]) - } - return noders, nil -} - -func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, error) { - noders := make([]Noder, len(ids)) - idmap := make(map[int][]*Noder, len(ids)) - for i, id := range ids { - idmap[id] = append(idmap[id], &noders[i]) - } - switch table { - case assetprice.Table: - query := c.AssetPrice.Query(). - Where(assetprice.IDIn(ids...)) - query, err := query.CollectFields(ctx, assetpriceImplementors...) - if err != nil { - return nil, err - } - nodes, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, node := range nodes { - for _, noder := range idmap[node.ID] { - *noder = node - } - } - case correctnessreport.Table: - query := c.CorrectnessReport.Query(). - Where(correctnessreport.IDIn(ids...)) - query, err := query.CollectFields(ctx, correctnessreportImplementors...) - if err != nil { - return nil, err - } - nodes, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, node := range nodes { - for _, noder := range idmap[node.ID] { - *noder = node - } - } - case eventlog.Table: - query := c.EventLog.Query(). - Where(eventlog.IDIn(ids...)) - query, err := query.CollectFields(ctx, eventlogImplementors...) - if err != nil { - return nil, err - } - nodes, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, node := range nodes { - for _, noder := range idmap[node.ID] { - *noder = node - } - } - case signer.Table: - query := c.Signer.Query(). - Where(signer.IDIn(ids...)) - query, err := query.CollectFields(ctx, signerImplementors...) - if err != nil { - return nil, err - } - nodes, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, node := range nodes { - for _, noder := range idmap[node.ID] { - *noder = node - } - } - default: - return nil, fmt.Errorf("cannot resolve noders from table %q: %w", table, errNodeInvalidID) - } - return noders, nil -} - -type tables struct { - once sync.Once - sem *semaphore.Weighted - value atomic.Value -} - -func (t *tables) nodeType(ctx context.Context, drv dialect.Driver, id int) (string, error) { - tables, err := t.Load(ctx, drv) - if err != nil { - return "", err - } - idx := int(id / (1<<32 - 1)) - if idx < 0 || idx >= len(tables) { - return "", fmt.Errorf("cannot resolve table from id %v: %w", id, errNodeInvalidID) - } - return tables[idx], nil -} - -func (t *tables) Load(ctx context.Context, drv dialect.Driver) ([]string, error) { - if tables := t.value.Load(); tables != nil { - return tables.([]string), nil - } - t.once.Do(func() { t.sem = semaphore.NewWeighted(1) }) - if err := t.sem.Acquire(ctx, 1); err != nil { - return nil, err - } - defer t.sem.Release(1) - if tables := t.value.Load(); tables != nil { - return tables.([]string), nil - } - tables, err := t.load(ctx, drv) - if err == nil { - t.value.Store(tables) - } - return tables, err -} - -func (*tables) load(ctx context.Context, drv dialect.Driver) ([]string, error) { - rows := &sql.Rows{} - query, args := sql.Dialect(drv.Dialect()). - Select("type"). - From(sql.Table(schema.TypeTable)). - OrderBy(sql.Asc("id")). - Query() - if err := drv.Query(ctx, query, args, rows); err != nil { - return nil, err - } - defer rows.Close() - var tables []string - return tables, sql.ScanSlice(rows, &tables) -} diff --git a/internal/ent/gql_pagination.go b/internal/ent/gql_pagination.go deleted file mode 100644 index 73161af9..00000000 --- a/internal/ent/gql_pagination.go +++ /dev/null @@ -1,1282 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "io" - "strconv" - - "entgo.io/contrib/entgql" - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/errcode" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/signer" - "github.com/vektah/gqlparser/v2/gqlerror" -) - -// Common entgql types. -type ( - Cursor = entgql.Cursor[int] - PageInfo = entgql.PageInfo[int] - OrderDirection = entgql.OrderDirection -) - -func orderFunc(o OrderDirection, field string) func(*sql.Selector) { - if o == entgql.OrderDirectionDesc { - return Desc(field) - } - return Asc(field) -} - -const errInvalidPagination = "INVALID_PAGINATION" - -func validateFirstLast(first, last *int) (err *gqlerror.Error) { - switch { - case first != nil && last != nil: - err = &gqlerror.Error{ - Message: "Passing both `first` and `last` to paginate a connection is not supported.", - } - case first != nil && *first < 0: - err = &gqlerror.Error{ - Message: "`first` on a connection cannot be less than zero.", - } - errcode.Set(err, errInvalidPagination) - case last != nil && *last < 0: - err = &gqlerror.Error{ - Message: "`last` on a connection cannot be less than zero.", - } - errcode.Set(err, errInvalidPagination) - } - return err -} - -func collectedField(ctx context.Context, path ...string) *graphql.CollectedField { - fc := graphql.GetFieldContext(ctx) - if fc == nil { - return nil - } - field := fc.Field - oc := graphql.GetOperationContext(ctx) -walk: - for _, name := range path { - for _, f := range graphql.CollectFields(oc, field.Selections, nil) { - if f.Alias == name { - field = f - continue walk - } - } - return nil - } - return &field -} - -func hasCollectedField(ctx context.Context, path ...string) bool { - if graphql.GetFieldContext(ctx) == nil { - return true - } - return collectedField(ctx, path...) != nil -} - -const ( - edgesField = "edges" - nodeField = "node" - pageInfoField = "pageInfo" - totalCountField = "totalCount" -) - -func paginateLimit(first, last *int) int { - var limit int - if first != nil { - limit = *first + 1 - } else if last != nil { - limit = *last + 1 - } - return limit -} - -// AssetPriceEdge is the edge representation of AssetPrice. -type AssetPriceEdge struct { - Node *AssetPrice `json:"node"` - Cursor Cursor `json:"cursor"` -} - -// AssetPriceConnection is the connection containing edges to AssetPrice. -type AssetPriceConnection struct { - Edges []*AssetPriceEdge `json:"edges"` - PageInfo PageInfo `json:"pageInfo"` - TotalCount int `json:"totalCount"` -} - -func (c *AssetPriceConnection) build(nodes []*AssetPrice, pager *assetpricePager, after *Cursor, first *int, before *Cursor, last *int) { - c.PageInfo.HasNextPage = before != nil - c.PageInfo.HasPreviousPage = after != nil - if first != nil && *first+1 == len(nodes) { - c.PageInfo.HasNextPage = true - nodes = nodes[:len(nodes)-1] - } else if last != nil && *last+1 == len(nodes) { - c.PageInfo.HasPreviousPage = true - nodes = nodes[:len(nodes)-1] - } - var nodeAt func(int) *AssetPrice - if last != nil { - n := len(nodes) - 1 - nodeAt = func(i int) *AssetPrice { - return nodes[n-i] - } - } else { - nodeAt = func(i int) *AssetPrice { - return nodes[i] - } - } - c.Edges = make([]*AssetPriceEdge, len(nodes)) - for i := range nodes { - node := nodeAt(i) - c.Edges[i] = &AssetPriceEdge{ - Node: node, - Cursor: pager.toCursor(node), - } - } - if l := len(c.Edges); l > 0 { - c.PageInfo.StartCursor = &c.Edges[0].Cursor - c.PageInfo.EndCursor = &c.Edges[l-1].Cursor - } - if c.TotalCount == 0 { - c.TotalCount = len(nodes) - } -} - -// AssetPricePaginateOption enables pagination customization. -type AssetPricePaginateOption func(*assetpricePager) error - -// WithAssetPriceOrder configures pagination ordering. -func WithAssetPriceOrder(order *AssetPriceOrder) AssetPricePaginateOption { - if order == nil { - order = DefaultAssetPriceOrder - } - o := *order - return func(pager *assetpricePager) error { - if err := o.Direction.Validate(); err != nil { - return err - } - if o.Field == nil { - o.Field = DefaultAssetPriceOrder.Field - } - pager.order = &o - return nil - } -} - -// WithAssetPriceFilter configures pagination filter. -func WithAssetPriceFilter(filter func(*AssetPriceQuery) (*AssetPriceQuery, error)) AssetPricePaginateOption { - return func(pager *assetpricePager) error { - if filter == nil { - return errors.New("AssetPriceQuery filter cannot be nil") - } - pager.filter = filter - return nil - } -} - -type assetpricePager struct { - reverse bool - order *AssetPriceOrder - filter func(*AssetPriceQuery) (*AssetPriceQuery, error) -} - -func newAssetPricePager(opts []AssetPricePaginateOption, reverse bool) (*assetpricePager, error) { - pager := &assetpricePager{reverse: reverse} - for _, opt := range opts { - if err := opt(pager); err != nil { - return nil, err - } - } - if pager.order == nil { - pager.order = DefaultAssetPriceOrder - } - return pager, nil -} - -func (p *assetpricePager) applyFilter(query *AssetPriceQuery) (*AssetPriceQuery, error) { - if p.filter != nil { - return p.filter(query) - } - return query, nil -} - -func (p *assetpricePager) toCursor(ap *AssetPrice) Cursor { - return p.order.Field.toCursor(ap) -} - -func (p *assetpricePager) applyCursors(query *AssetPriceQuery, after, before *Cursor) (*AssetPriceQuery, error) { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - for _, predicate := range entgql.CursorsPredicate(after, before, DefaultAssetPriceOrder.Field.column, p.order.Field.column, direction) { - query = query.Where(predicate) - } - return query, nil -} - -func (p *assetpricePager) applyOrder(query *AssetPriceQuery) *AssetPriceQuery { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) - if p.order.Field != DefaultAssetPriceOrder.Field { - query = query.Order(DefaultAssetPriceOrder.Field.toTerm(direction.OrderTermOption())) - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) - } - return query -} - -func (p *assetpricePager) orderExpr(query *AssetPriceQuery) sql.Querier { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) - } - return sql.ExprFunc(func(b *sql.Builder) { - b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) - if p.order.Field != DefaultAssetPriceOrder.Field { - b.Comma().Ident(DefaultAssetPriceOrder.Field.column).Pad().WriteString(string(direction)) - } - }) -} - -// Paginate executes the query and returns a relay based cursor connection to AssetPrice. -func (ap *AssetPriceQuery) Paginate( - ctx context.Context, after *Cursor, first *int, - before *Cursor, last *int, opts ...AssetPricePaginateOption, -) (*AssetPriceConnection, error) { - if err := validateFirstLast(first, last); err != nil { - return nil, err - } - pager, err := newAssetPricePager(opts, last != nil) - if err != nil { - return nil, err - } - if ap, err = pager.applyFilter(ap); err != nil { - return nil, err - } - conn := &AssetPriceConnection{Edges: []*AssetPriceEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) - if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { - hasPagination := after != nil || first != nil || before != nil || last != nil - if hasPagination || ignoredEdges { - c := ap.Clone() - c.ctx.Fields = nil - if conn.TotalCount, err = c.Count(ctx); err != nil { - return nil, err - } - conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 - conn.PageInfo.HasPreviousPage = last != nil && conn.TotalCount > 0 - } - } - if ignoredEdges || (first != nil && *first == 0) || (last != nil && *last == 0) { - return conn, nil - } - if ap, err = pager.applyCursors(ap, after, before); err != nil { - return nil, err - } - if limit := paginateLimit(first, last); limit != 0 { - ap.Limit(limit) - } - if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := ap.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { - return nil, err - } - } - ap = pager.applyOrder(ap) - nodes, err := ap.All(ctx) - if err != nil { - return nil, err - } - conn.build(nodes, pager, after, first, before, last) - return conn, nil -} - -var ( - // AssetPriceOrderFieldBlock orders AssetPrice by block. - AssetPriceOrderFieldBlock = &AssetPriceOrderField{ - Value: func(ap *AssetPrice) (ent.Value, error) { - return ap.Block, nil - }, - column: assetprice.FieldBlock, - toTerm: assetprice.ByBlock, - toCursor: func(ap *AssetPrice) Cursor { - return Cursor{ - ID: ap.ID, - Value: ap.Block, - } - }, - } -) - -// String implement fmt.Stringer interface. -func (f AssetPriceOrderField) String() string { - var str string - switch f.column { - case AssetPriceOrderFieldBlock.column: - str = "BLOCK" - } - return str -} - -// MarshalGQL implements graphql.Marshaler interface. -func (f AssetPriceOrderField) MarshalGQL(w io.Writer) { - io.WriteString(w, strconv.Quote(f.String())) -} - -// UnmarshalGQL implements graphql.Unmarshaler interface. -func (f *AssetPriceOrderField) UnmarshalGQL(v interface{}) error { - str, ok := v.(string) - if !ok { - return fmt.Errorf("AssetPriceOrderField %T must be a string", v) - } - switch str { - case "BLOCK": - *f = *AssetPriceOrderFieldBlock - default: - return fmt.Errorf("%s is not a valid AssetPriceOrderField", str) - } - return nil -} - -// AssetPriceOrderField defines the ordering field of AssetPrice. -type AssetPriceOrderField struct { - // Value extracts the ordering value from the given AssetPrice. - Value func(*AssetPrice) (ent.Value, error) - column string // field or computed. - toTerm func(...sql.OrderTermOption) assetprice.OrderOption - toCursor func(*AssetPrice) Cursor -} - -// AssetPriceOrder defines the ordering of AssetPrice. -type AssetPriceOrder struct { - Direction OrderDirection `json:"direction"` - Field *AssetPriceOrderField `json:"field"` -} - -// DefaultAssetPriceOrder is the default ordering of AssetPrice. -var DefaultAssetPriceOrder = &AssetPriceOrder{ - Direction: entgql.OrderDirectionAsc, - Field: &AssetPriceOrderField{ - Value: func(ap *AssetPrice) (ent.Value, error) { - return ap.ID, nil - }, - column: assetprice.FieldID, - toTerm: assetprice.ByID, - toCursor: func(ap *AssetPrice) Cursor { - return Cursor{ID: ap.ID} - }, - }, -} - -// ToEdge converts AssetPrice into AssetPriceEdge. -func (ap *AssetPrice) ToEdge(order *AssetPriceOrder) *AssetPriceEdge { - if order == nil { - order = DefaultAssetPriceOrder - } - return &AssetPriceEdge{ - Node: ap, - Cursor: order.Field.toCursor(ap), - } -} - -// CorrectnessReportEdge is the edge representation of CorrectnessReport. -type CorrectnessReportEdge struct { - Node *CorrectnessReport `json:"node"` - Cursor Cursor `json:"cursor"` -} - -// CorrectnessReportConnection is the connection containing edges to CorrectnessReport. -type CorrectnessReportConnection struct { - Edges []*CorrectnessReportEdge `json:"edges"` - PageInfo PageInfo `json:"pageInfo"` - TotalCount int `json:"totalCount"` -} - -func (c *CorrectnessReportConnection) build(nodes []*CorrectnessReport, pager *correctnessreportPager, after *Cursor, first *int, before *Cursor, last *int) { - c.PageInfo.HasNextPage = before != nil - c.PageInfo.HasPreviousPage = after != nil - if first != nil && *first+1 == len(nodes) { - c.PageInfo.HasNextPage = true - nodes = nodes[:len(nodes)-1] - } else if last != nil && *last+1 == len(nodes) { - c.PageInfo.HasPreviousPage = true - nodes = nodes[:len(nodes)-1] - } - var nodeAt func(int) *CorrectnessReport - if last != nil { - n := len(nodes) - 1 - nodeAt = func(i int) *CorrectnessReport { - return nodes[n-i] - } - } else { - nodeAt = func(i int) *CorrectnessReport { - return nodes[i] - } - } - c.Edges = make([]*CorrectnessReportEdge, len(nodes)) - for i := range nodes { - node := nodeAt(i) - c.Edges[i] = &CorrectnessReportEdge{ - Node: node, - Cursor: pager.toCursor(node), - } - } - if l := len(c.Edges); l > 0 { - c.PageInfo.StartCursor = &c.Edges[0].Cursor - c.PageInfo.EndCursor = &c.Edges[l-1].Cursor - } - if c.TotalCount == 0 { - c.TotalCount = len(nodes) - } -} - -// CorrectnessReportPaginateOption enables pagination customization. -type CorrectnessReportPaginateOption func(*correctnessreportPager) error - -// WithCorrectnessReportOrder configures pagination ordering. -func WithCorrectnessReportOrder(order *CorrectnessReportOrder) CorrectnessReportPaginateOption { - if order == nil { - order = DefaultCorrectnessReportOrder - } - o := *order - return func(pager *correctnessreportPager) error { - if err := o.Direction.Validate(); err != nil { - return err - } - if o.Field == nil { - o.Field = DefaultCorrectnessReportOrder.Field - } - pager.order = &o - return nil - } -} - -// WithCorrectnessReportFilter configures pagination filter. -func WithCorrectnessReportFilter(filter func(*CorrectnessReportQuery) (*CorrectnessReportQuery, error)) CorrectnessReportPaginateOption { - return func(pager *correctnessreportPager) error { - if filter == nil { - return errors.New("CorrectnessReportQuery filter cannot be nil") - } - pager.filter = filter - return nil - } -} - -type correctnessreportPager struct { - reverse bool - order *CorrectnessReportOrder - filter func(*CorrectnessReportQuery) (*CorrectnessReportQuery, error) -} - -func newCorrectnessReportPager(opts []CorrectnessReportPaginateOption, reverse bool) (*correctnessreportPager, error) { - pager := &correctnessreportPager{reverse: reverse} - for _, opt := range opts { - if err := opt(pager); err != nil { - return nil, err - } - } - if pager.order == nil { - pager.order = DefaultCorrectnessReportOrder - } - return pager, nil -} - -func (p *correctnessreportPager) applyFilter(query *CorrectnessReportQuery) (*CorrectnessReportQuery, error) { - if p.filter != nil { - return p.filter(query) - } - return query, nil -} - -func (p *correctnessreportPager) toCursor(cr *CorrectnessReport) Cursor { - return p.order.Field.toCursor(cr) -} - -func (p *correctnessreportPager) applyCursors(query *CorrectnessReportQuery, after, before *Cursor) (*CorrectnessReportQuery, error) { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - for _, predicate := range entgql.CursorsPredicate(after, before, DefaultCorrectnessReportOrder.Field.column, p.order.Field.column, direction) { - query = query.Where(predicate) - } - return query, nil -} - -func (p *correctnessreportPager) applyOrder(query *CorrectnessReportQuery) *CorrectnessReportQuery { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) - if p.order.Field != DefaultCorrectnessReportOrder.Field { - query = query.Order(DefaultCorrectnessReportOrder.Field.toTerm(direction.OrderTermOption())) - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) - } - return query -} - -func (p *correctnessreportPager) orderExpr(query *CorrectnessReportQuery) sql.Querier { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) - } - return sql.ExprFunc(func(b *sql.Builder) { - b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) - if p.order.Field != DefaultCorrectnessReportOrder.Field { - b.Comma().Ident(DefaultCorrectnessReportOrder.Field.column).Pad().WriteString(string(direction)) - } - }) -} - -// Paginate executes the query and returns a relay based cursor connection to CorrectnessReport. -func (cr *CorrectnessReportQuery) Paginate( - ctx context.Context, after *Cursor, first *int, - before *Cursor, last *int, opts ...CorrectnessReportPaginateOption, -) (*CorrectnessReportConnection, error) { - if err := validateFirstLast(first, last); err != nil { - return nil, err - } - pager, err := newCorrectnessReportPager(opts, last != nil) - if err != nil { - return nil, err - } - if cr, err = pager.applyFilter(cr); err != nil { - return nil, err - } - conn := &CorrectnessReportConnection{Edges: []*CorrectnessReportEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) - if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { - hasPagination := after != nil || first != nil || before != nil || last != nil - if hasPagination || ignoredEdges { - c := cr.Clone() - c.ctx.Fields = nil - if conn.TotalCount, err = c.Count(ctx); err != nil { - return nil, err - } - conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 - conn.PageInfo.HasPreviousPage = last != nil && conn.TotalCount > 0 - } - } - if ignoredEdges || (first != nil && *first == 0) || (last != nil && *last == 0) { - return conn, nil - } - if cr, err = pager.applyCursors(cr, after, before); err != nil { - return nil, err - } - if limit := paginateLimit(first, last); limit != 0 { - cr.Limit(limit) - } - if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := cr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { - return nil, err - } - } - cr = pager.applyOrder(cr) - nodes, err := cr.All(ctx) - if err != nil { - return nil, err - } - conn.build(nodes, pager, after, first, before, last) - return conn, nil -} - -var ( - // CorrectnessReportOrderFieldTimestamp orders CorrectnessReport by timestamp. - CorrectnessReportOrderFieldTimestamp = &CorrectnessReportOrderField{ - Value: func(cr *CorrectnessReport) (ent.Value, error) { - return cr.Timestamp, nil - }, - column: correctnessreport.FieldTimestamp, - toTerm: correctnessreport.ByTimestamp, - toCursor: func(cr *CorrectnessReport) Cursor { - return Cursor{ - ID: cr.ID, - Value: cr.Timestamp, - } - }, - } -) - -// String implement fmt.Stringer interface. -func (f CorrectnessReportOrderField) String() string { - var str string - switch f.column { - case CorrectnessReportOrderFieldTimestamp.column: - str = "TIMESTAMP" - } - return str -} - -// MarshalGQL implements graphql.Marshaler interface. -func (f CorrectnessReportOrderField) MarshalGQL(w io.Writer) { - io.WriteString(w, strconv.Quote(f.String())) -} - -// UnmarshalGQL implements graphql.Unmarshaler interface. -func (f *CorrectnessReportOrderField) UnmarshalGQL(v interface{}) error { - str, ok := v.(string) - if !ok { - return fmt.Errorf("CorrectnessReportOrderField %T must be a string", v) - } - switch str { - case "TIMESTAMP": - *f = *CorrectnessReportOrderFieldTimestamp - default: - return fmt.Errorf("%s is not a valid CorrectnessReportOrderField", str) - } - return nil -} - -// CorrectnessReportOrderField defines the ordering field of CorrectnessReport. -type CorrectnessReportOrderField struct { - // Value extracts the ordering value from the given CorrectnessReport. - Value func(*CorrectnessReport) (ent.Value, error) - column string // field or computed. - toTerm func(...sql.OrderTermOption) correctnessreport.OrderOption - toCursor func(*CorrectnessReport) Cursor -} - -// CorrectnessReportOrder defines the ordering of CorrectnessReport. -type CorrectnessReportOrder struct { - Direction OrderDirection `json:"direction"` - Field *CorrectnessReportOrderField `json:"field"` -} - -// DefaultCorrectnessReportOrder is the default ordering of CorrectnessReport. -var DefaultCorrectnessReportOrder = &CorrectnessReportOrder{ - Direction: entgql.OrderDirectionAsc, - Field: &CorrectnessReportOrderField{ - Value: func(cr *CorrectnessReport) (ent.Value, error) { - return cr.ID, nil - }, - column: correctnessreport.FieldID, - toTerm: correctnessreport.ByID, - toCursor: func(cr *CorrectnessReport) Cursor { - return Cursor{ID: cr.ID} - }, - }, -} - -// ToEdge converts CorrectnessReport into CorrectnessReportEdge. -func (cr *CorrectnessReport) ToEdge(order *CorrectnessReportOrder) *CorrectnessReportEdge { - if order == nil { - order = DefaultCorrectnessReportOrder - } - return &CorrectnessReportEdge{ - Node: cr, - Cursor: order.Field.toCursor(cr), - } -} - -// EventLogEdge is the edge representation of EventLog. -type EventLogEdge struct { - Node *EventLog `json:"node"` - Cursor Cursor `json:"cursor"` -} - -// EventLogConnection is the connection containing edges to EventLog. -type EventLogConnection struct { - Edges []*EventLogEdge `json:"edges"` - PageInfo PageInfo `json:"pageInfo"` - TotalCount int `json:"totalCount"` -} - -func (c *EventLogConnection) build(nodes []*EventLog, pager *eventlogPager, after *Cursor, first *int, before *Cursor, last *int) { - c.PageInfo.HasNextPage = before != nil - c.PageInfo.HasPreviousPage = after != nil - if first != nil && *first+1 == len(nodes) { - c.PageInfo.HasNextPage = true - nodes = nodes[:len(nodes)-1] - } else if last != nil && *last+1 == len(nodes) { - c.PageInfo.HasPreviousPage = true - nodes = nodes[:len(nodes)-1] - } - var nodeAt func(int) *EventLog - if last != nil { - n := len(nodes) - 1 - nodeAt = func(i int) *EventLog { - return nodes[n-i] - } - } else { - nodeAt = func(i int) *EventLog { - return nodes[i] - } - } - c.Edges = make([]*EventLogEdge, len(nodes)) - for i := range nodes { - node := nodeAt(i) - c.Edges[i] = &EventLogEdge{ - Node: node, - Cursor: pager.toCursor(node), - } - } - if l := len(c.Edges); l > 0 { - c.PageInfo.StartCursor = &c.Edges[0].Cursor - c.PageInfo.EndCursor = &c.Edges[l-1].Cursor - } - if c.TotalCount == 0 { - c.TotalCount = len(nodes) - } -} - -// EventLogPaginateOption enables pagination customization. -type EventLogPaginateOption func(*eventlogPager) error - -// WithEventLogOrder configures pagination ordering. -func WithEventLogOrder(order *EventLogOrder) EventLogPaginateOption { - if order == nil { - order = DefaultEventLogOrder - } - o := *order - return func(pager *eventlogPager) error { - if err := o.Direction.Validate(); err != nil { - return err - } - if o.Field == nil { - o.Field = DefaultEventLogOrder.Field - } - pager.order = &o - return nil - } -} - -// WithEventLogFilter configures pagination filter. -func WithEventLogFilter(filter func(*EventLogQuery) (*EventLogQuery, error)) EventLogPaginateOption { - return func(pager *eventlogPager) error { - if filter == nil { - return errors.New("EventLogQuery filter cannot be nil") - } - pager.filter = filter - return nil - } -} - -type eventlogPager struct { - reverse bool - order *EventLogOrder - filter func(*EventLogQuery) (*EventLogQuery, error) -} - -func newEventLogPager(opts []EventLogPaginateOption, reverse bool) (*eventlogPager, error) { - pager := &eventlogPager{reverse: reverse} - for _, opt := range opts { - if err := opt(pager); err != nil { - return nil, err - } - } - if pager.order == nil { - pager.order = DefaultEventLogOrder - } - return pager, nil -} - -func (p *eventlogPager) applyFilter(query *EventLogQuery) (*EventLogQuery, error) { - if p.filter != nil { - return p.filter(query) - } - return query, nil -} - -func (p *eventlogPager) toCursor(el *EventLog) Cursor { - return p.order.Field.toCursor(el) -} - -func (p *eventlogPager) applyCursors(query *EventLogQuery, after, before *Cursor) (*EventLogQuery, error) { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - for _, predicate := range entgql.CursorsPredicate(after, before, DefaultEventLogOrder.Field.column, p.order.Field.column, direction) { - query = query.Where(predicate) - } - return query, nil -} - -func (p *eventlogPager) applyOrder(query *EventLogQuery) *EventLogQuery { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) - if p.order.Field != DefaultEventLogOrder.Field { - query = query.Order(DefaultEventLogOrder.Field.toTerm(direction.OrderTermOption())) - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) - } - return query -} - -func (p *eventlogPager) orderExpr(query *EventLogQuery) sql.Querier { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) - } - return sql.ExprFunc(func(b *sql.Builder) { - b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) - if p.order.Field != DefaultEventLogOrder.Field { - b.Comma().Ident(DefaultEventLogOrder.Field.column).Pad().WriteString(string(direction)) - } - }) -} - -// Paginate executes the query and returns a relay based cursor connection to EventLog. -func (el *EventLogQuery) Paginate( - ctx context.Context, after *Cursor, first *int, - before *Cursor, last *int, opts ...EventLogPaginateOption, -) (*EventLogConnection, error) { - if err := validateFirstLast(first, last); err != nil { - return nil, err - } - pager, err := newEventLogPager(opts, last != nil) - if err != nil { - return nil, err - } - if el, err = pager.applyFilter(el); err != nil { - return nil, err - } - conn := &EventLogConnection{Edges: []*EventLogEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) - if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { - hasPagination := after != nil || first != nil || before != nil || last != nil - if hasPagination || ignoredEdges { - c := el.Clone() - c.ctx.Fields = nil - if conn.TotalCount, err = c.Count(ctx); err != nil { - return nil, err - } - conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 - conn.PageInfo.HasPreviousPage = last != nil && conn.TotalCount > 0 - } - } - if ignoredEdges || (first != nil && *first == 0) || (last != nil && *last == 0) { - return conn, nil - } - if el, err = pager.applyCursors(el, after, before); err != nil { - return nil, err - } - if limit := paginateLimit(first, last); limit != 0 { - el.Limit(limit) - } - if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := el.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { - return nil, err - } - } - el = pager.applyOrder(el) - nodes, err := el.All(ctx) - if err != nil { - return nil, err - } - conn.build(nodes, pager, after, first, before, last) - return conn, nil -} - -var ( - // EventLogOrderFieldBlock orders EventLog by block. - EventLogOrderFieldBlock = &EventLogOrderField{ - Value: func(el *EventLog) (ent.Value, error) { - return el.Block, nil - }, - column: eventlog.FieldBlock, - toTerm: eventlog.ByBlock, - toCursor: func(el *EventLog) Cursor { - return Cursor{ - ID: el.ID, - Value: el.Block, - } - }, - } -) - -// String implement fmt.Stringer interface. -func (f EventLogOrderField) String() string { - var str string - switch f.column { - case EventLogOrderFieldBlock.column: - str = "BLOCK" - } - return str -} - -// MarshalGQL implements graphql.Marshaler interface. -func (f EventLogOrderField) MarshalGQL(w io.Writer) { - io.WriteString(w, strconv.Quote(f.String())) -} - -// UnmarshalGQL implements graphql.Unmarshaler interface. -func (f *EventLogOrderField) UnmarshalGQL(v interface{}) error { - str, ok := v.(string) - if !ok { - return fmt.Errorf("EventLogOrderField %T must be a string", v) - } - switch str { - case "BLOCK": - *f = *EventLogOrderFieldBlock - default: - return fmt.Errorf("%s is not a valid EventLogOrderField", str) - } - return nil -} - -// EventLogOrderField defines the ordering field of EventLog. -type EventLogOrderField struct { - // Value extracts the ordering value from the given EventLog. - Value func(*EventLog) (ent.Value, error) - column string // field or computed. - toTerm func(...sql.OrderTermOption) eventlog.OrderOption - toCursor func(*EventLog) Cursor -} - -// EventLogOrder defines the ordering of EventLog. -type EventLogOrder struct { - Direction OrderDirection `json:"direction"` - Field *EventLogOrderField `json:"field"` -} - -// DefaultEventLogOrder is the default ordering of EventLog. -var DefaultEventLogOrder = &EventLogOrder{ - Direction: entgql.OrderDirectionAsc, - Field: &EventLogOrderField{ - Value: func(el *EventLog) (ent.Value, error) { - return el.ID, nil - }, - column: eventlog.FieldID, - toTerm: eventlog.ByID, - toCursor: func(el *EventLog) Cursor { - return Cursor{ID: el.ID} - }, - }, -} - -// ToEdge converts EventLog into EventLogEdge. -func (el *EventLog) ToEdge(order *EventLogOrder) *EventLogEdge { - if order == nil { - order = DefaultEventLogOrder - } - return &EventLogEdge{ - Node: el, - Cursor: order.Field.toCursor(el), - } -} - -// SignerEdge is the edge representation of Signer. -type SignerEdge struct { - Node *Signer `json:"node"` - Cursor Cursor `json:"cursor"` -} - -// SignerConnection is the connection containing edges to Signer. -type SignerConnection struct { - Edges []*SignerEdge `json:"edges"` - PageInfo PageInfo `json:"pageInfo"` - TotalCount int `json:"totalCount"` -} - -func (c *SignerConnection) build(nodes []*Signer, pager *signerPager, after *Cursor, first *int, before *Cursor, last *int) { - c.PageInfo.HasNextPage = before != nil - c.PageInfo.HasPreviousPage = after != nil - if first != nil && *first+1 == len(nodes) { - c.PageInfo.HasNextPage = true - nodes = nodes[:len(nodes)-1] - } else if last != nil && *last+1 == len(nodes) { - c.PageInfo.HasPreviousPage = true - nodes = nodes[:len(nodes)-1] - } - var nodeAt func(int) *Signer - if last != nil { - n := len(nodes) - 1 - nodeAt = func(i int) *Signer { - return nodes[n-i] - } - } else { - nodeAt = func(i int) *Signer { - return nodes[i] - } - } - c.Edges = make([]*SignerEdge, len(nodes)) - for i := range nodes { - node := nodeAt(i) - c.Edges[i] = &SignerEdge{ - Node: node, - Cursor: pager.toCursor(node), - } - } - if l := len(c.Edges); l > 0 { - c.PageInfo.StartCursor = &c.Edges[0].Cursor - c.PageInfo.EndCursor = &c.Edges[l-1].Cursor - } - if c.TotalCount == 0 { - c.TotalCount = len(nodes) - } -} - -// SignerPaginateOption enables pagination customization. -type SignerPaginateOption func(*signerPager) error - -// WithSignerOrder configures pagination ordering. -func WithSignerOrder(order *SignerOrder) SignerPaginateOption { - if order == nil { - order = DefaultSignerOrder - } - o := *order - return func(pager *signerPager) error { - if err := o.Direction.Validate(); err != nil { - return err - } - if o.Field == nil { - o.Field = DefaultSignerOrder.Field - } - pager.order = &o - return nil - } -} - -// WithSignerFilter configures pagination filter. -func WithSignerFilter(filter func(*SignerQuery) (*SignerQuery, error)) SignerPaginateOption { - return func(pager *signerPager) error { - if filter == nil { - return errors.New("SignerQuery filter cannot be nil") - } - pager.filter = filter - return nil - } -} - -type signerPager struct { - reverse bool - order *SignerOrder - filter func(*SignerQuery) (*SignerQuery, error) -} - -func newSignerPager(opts []SignerPaginateOption, reverse bool) (*signerPager, error) { - pager := &signerPager{reverse: reverse} - for _, opt := range opts { - if err := opt(pager); err != nil { - return nil, err - } - } - if pager.order == nil { - pager.order = DefaultSignerOrder - } - return pager, nil -} - -func (p *signerPager) applyFilter(query *SignerQuery) (*SignerQuery, error) { - if p.filter != nil { - return p.filter(query) - } - return query, nil -} - -func (p *signerPager) toCursor(s *Signer) Cursor { - return p.order.Field.toCursor(s) -} - -func (p *signerPager) applyCursors(query *SignerQuery, after, before *Cursor) (*SignerQuery, error) { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - for _, predicate := range entgql.CursorsPredicate(after, before, DefaultSignerOrder.Field.column, p.order.Field.column, direction) { - query = query.Where(predicate) - } - return query, nil -} - -func (p *signerPager) applyOrder(query *SignerQuery) *SignerQuery { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) - if p.order.Field != DefaultSignerOrder.Field { - query = query.Order(DefaultSignerOrder.Field.toTerm(direction.OrderTermOption())) - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) - } - return query -} - -func (p *signerPager) orderExpr(query *SignerQuery) sql.Querier { - direction := p.order.Direction - if p.reverse { - direction = direction.Reverse() - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(p.order.Field.column) - } - return sql.ExprFunc(func(b *sql.Builder) { - b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) - if p.order.Field != DefaultSignerOrder.Field { - b.Comma().Ident(DefaultSignerOrder.Field.column).Pad().WriteString(string(direction)) - } - }) -} - -// Paginate executes the query and returns a relay based cursor connection to Signer. -func (s *SignerQuery) Paginate( - ctx context.Context, after *Cursor, first *int, - before *Cursor, last *int, opts ...SignerPaginateOption, -) (*SignerConnection, error) { - if err := validateFirstLast(first, last); err != nil { - return nil, err - } - pager, err := newSignerPager(opts, last != nil) - if err != nil { - return nil, err - } - if s, err = pager.applyFilter(s); err != nil { - return nil, err - } - conn := &SignerConnection{Edges: []*SignerEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) - if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { - hasPagination := after != nil || first != nil || before != nil || last != nil - if hasPagination || ignoredEdges { - c := s.Clone() - c.ctx.Fields = nil - if conn.TotalCount, err = c.Count(ctx); err != nil { - return nil, err - } - conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 - conn.PageInfo.HasPreviousPage = last != nil && conn.TotalCount > 0 - } - } - if ignoredEdges || (first != nil && *first == 0) || (last != nil && *last == 0) { - return conn, nil - } - if s, err = pager.applyCursors(s, after, before); err != nil { - return nil, err - } - if limit := paginateLimit(first, last); limit != 0 { - s.Limit(limit) - } - if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := s.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { - return nil, err - } - } - s = pager.applyOrder(s) - nodes, err := s.All(ctx) - if err != nil { - return nil, err - } - conn.build(nodes, pager, after, first, before, last) - return conn, nil -} - -var ( - // SignerOrderFieldPoints orders Signer by points. - SignerOrderFieldPoints = &SignerOrderField{ - Value: func(s *Signer) (ent.Value, error) { - return s.Points, nil - }, - column: signer.FieldPoints, - toTerm: signer.ByPoints, - toCursor: func(s *Signer) Cursor { - return Cursor{ - ID: s.ID, - Value: s.Points, - } - }, - } -) - -// String implement fmt.Stringer interface. -func (f SignerOrderField) String() string { - var str string - switch f.column { - case SignerOrderFieldPoints.column: - str = "POINTS" - } - return str -} - -// MarshalGQL implements graphql.Marshaler interface. -func (f SignerOrderField) MarshalGQL(w io.Writer) { - io.WriteString(w, strconv.Quote(f.String())) -} - -// UnmarshalGQL implements graphql.Unmarshaler interface. -func (f *SignerOrderField) UnmarshalGQL(v interface{}) error { - str, ok := v.(string) - if !ok { - return fmt.Errorf("SignerOrderField %T must be a string", v) - } - switch str { - case "POINTS": - *f = *SignerOrderFieldPoints - default: - return fmt.Errorf("%s is not a valid SignerOrderField", str) - } - return nil -} - -// SignerOrderField defines the ordering field of Signer. -type SignerOrderField struct { - // Value extracts the ordering value from the given Signer. - Value func(*Signer) (ent.Value, error) - column string // field or computed. - toTerm func(...sql.OrderTermOption) signer.OrderOption - toCursor func(*Signer) Cursor -} - -// SignerOrder defines the ordering of Signer. -type SignerOrder struct { - Direction OrderDirection `json:"direction"` - Field *SignerOrderField `json:"field"` -} - -// DefaultSignerOrder is the default ordering of Signer. -var DefaultSignerOrder = &SignerOrder{ - Direction: entgql.OrderDirectionAsc, - Field: &SignerOrderField{ - Value: func(s *Signer) (ent.Value, error) { - return s.ID, nil - }, - column: signer.FieldID, - toTerm: signer.ByID, - toCursor: func(s *Signer) Cursor { - return Cursor{ID: s.ID} - }, - }, -} - -// ToEdge converts Signer into SignerEdge. -func (s *Signer) ToEdge(order *SignerOrder) *SignerEdge { - if order == nil { - order = DefaultSignerOrder - } - return &SignerEdge{ - Node: s, - Cursor: order.Field.toCursor(s), - } -} diff --git a/internal/ent/gql_transaction.go b/internal/ent/gql_transaction.go deleted file mode 100644 index 96117136..00000000 --- a/internal/ent/gql_transaction.go +++ /dev/null @@ -1,30 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "database/sql/driver" - "errors" -) - -// OpenTx opens a transaction and returns a transactional -// context along with the created transaction. -func (c *Client) OpenTx(ctx context.Context) (context.Context, driver.Tx, error) { - tx, err := c.Tx(ctx) - if err != nil { - return nil, nil, err - } - ctx = NewTxContext(ctx, tx) - ctx = NewContext(ctx, tx.Client()) - return ctx, tx, nil -} - -// OpenTxFromContext open transactions from client stored in context. -func OpenTxFromContext(ctx context.Context) (context.Context, driver.Tx, error) { - client := FromContext(ctx) - if client == nil { - return nil, nil, errors.New("no client attached to context") - } - return client.OpenTx(ctx) -} diff --git a/internal/ent/gql_where_input.go b/internal/ent/gql_where_input.go deleted file mode 100644 index 4977eded..00000000 --- a/internal/ent/gql_where_input.go +++ /dev/null @@ -1,1563 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "errors" - "fmt" - - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// AssetPriceWhereInput represents a where input for filtering AssetPrice queries. -type AssetPriceWhereInput struct { - Predicates []predicate.AssetPrice `json:"-"` - Not *AssetPriceWhereInput `json:"not,omitempty"` - Or []*AssetPriceWhereInput `json:"or,omitempty"` - And []*AssetPriceWhereInput `json:"and,omitempty"` - - // "id" field predicates. - ID *int `json:"id,omitempty"` - IDNEQ *int `json:"idNEQ,omitempty"` - IDIn []int `json:"idIn,omitempty"` - IDNotIn []int `json:"idNotIn,omitempty"` - IDGT *int `json:"idGT,omitempty"` - IDGTE *int `json:"idGTE,omitempty"` - IDLT *int `json:"idLT,omitempty"` - IDLTE *int `json:"idLTE,omitempty"` - - // "block" field predicates. - Block *uint64 `json:"block,omitempty"` - BlockNEQ *uint64 `json:"blockNEQ,omitempty"` - BlockIn []uint64 `json:"blockIn,omitempty"` - BlockNotIn []uint64 `json:"blockNotIn,omitempty"` - BlockGT *uint64 `json:"blockGT,omitempty"` - BlockGTE *uint64 `json:"blockGTE,omitempty"` - BlockLT *uint64 `json:"blockLT,omitempty"` - BlockLTE *uint64 `json:"blockLTE,omitempty"` - - // "signersCount" field predicates. - SignersCount *uint64 `json:"signerscount,omitempty"` - SignersCountNEQ *uint64 `json:"signerscountNEQ,omitempty"` - SignersCountIn []uint64 `json:"signerscountIn,omitempty"` - SignersCountNotIn []uint64 `json:"signerscountNotIn,omitempty"` - SignersCountGT *uint64 `json:"signerscountGT,omitempty"` - SignersCountGTE *uint64 `json:"signerscountGTE,omitempty"` - SignersCountLT *uint64 `json:"signerscountLT,omitempty"` - SignersCountLTE *uint64 `json:"signerscountLTE,omitempty"` - SignersCountIsNil bool `json:"signerscountIsNil,omitempty"` - SignersCountNotNil bool `json:"signerscountNotNil,omitempty"` - - // "price" field predicates. - Price *helpers.BigInt `json:"price,omitempty"` - PriceNEQ *helpers.BigInt `json:"priceNEQ,omitempty"` - PriceIn []*helpers.BigInt `json:"priceIn,omitempty"` - PriceNotIn []*helpers.BigInt `json:"priceNotIn,omitempty"` - PriceGT *helpers.BigInt `json:"priceGT,omitempty"` - PriceGTE *helpers.BigInt `json:"priceGTE,omitempty"` - PriceLT *helpers.BigInt `json:"priceLT,omitempty"` - PriceLTE *helpers.BigInt `json:"priceLTE,omitempty"` - - // "asset" field predicates. - Asset *string `json:"asset,omitempty"` - AssetNEQ *string `json:"assetNEQ,omitempty"` - AssetIn []string `json:"assetIn,omitempty"` - AssetNotIn []string `json:"assetNotIn,omitempty"` - AssetGT *string `json:"assetGT,omitempty"` - AssetGTE *string `json:"assetGTE,omitempty"` - AssetLT *string `json:"assetLT,omitempty"` - AssetLTE *string `json:"assetLTE,omitempty"` - AssetContains *string `json:"assetContains,omitempty"` - AssetHasPrefix *string `json:"assetHasPrefix,omitempty"` - AssetHasSuffix *string `json:"assetHasSuffix,omitempty"` - AssetIsNil bool `json:"assetIsNil,omitempty"` - AssetNotNil bool `json:"assetNotNil,omitempty"` - AssetEqualFold *string `json:"assetEqualFold,omitempty"` - AssetContainsFold *string `json:"assetContainsFold,omitempty"` - - // "chain" field predicates. - Chain *string `json:"chain,omitempty"` - ChainNEQ *string `json:"chainNEQ,omitempty"` - ChainIn []string `json:"chainIn,omitempty"` - ChainNotIn []string `json:"chainNotIn,omitempty"` - ChainGT *string `json:"chainGT,omitempty"` - ChainGTE *string `json:"chainGTE,omitempty"` - ChainLT *string `json:"chainLT,omitempty"` - ChainLTE *string `json:"chainLTE,omitempty"` - ChainContains *string `json:"chainContains,omitempty"` - ChainHasPrefix *string `json:"chainHasPrefix,omitempty"` - ChainHasSuffix *string `json:"chainHasSuffix,omitempty"` - ChainIsNil bool `json:"chainIsNil,omitempty"` - ChainNotNil bool `json:"chainNotNil,omitempty"` - ChainEqualFold *string `json:"chainEqualFold,omitempty"` - ChainContainsFold *string `json:"chainContainsFold,omitempty"` - - // "pair" field predicates. - Pair *string `json:"pair,omitempty"` - PairNEQ *string `json:"pairNEQ,omitempty"` - PairIn []string `json:"pairIn,omitempty"` - PairNotIn []string `json:"pairNotIn,omitempty"` - PairGT *string `json:"pairGT,omitempty"` - PairGTE *string `json:"pairGTE,omitempty"` - PairLT *string `json:"pairLT,omitempty"` - PairLTE *string `json:"pairLTE,omitempty"` - PairContains *string `json:"pairContains,omitempty"` - PairHasPrefix *string `json:"pairHasPrefix,omitempty"` - PairHasSuffix *string `json:"pairHasSuffix,omitempty"` - PairIsNil bool `json:"pairIsNil,omitempty"` - PairNotNil bool `json:"pairNotNil,omitempty"` - PairEqualFold *string `json:"pairEqualFold,omitempty"` - PairContainsFold *string `json:"pairContainsFold,omitempty"` - - // "consensus" field predicates. - Consensus *bool `json:"consensus,omitempty"` - ConsensusNEQ *bool `json:"consensusNEQ,omitempty"` - - // "voted" field predicates. - Voted *helpers.BigInt `json:"voted,omitempty"` - VotedNEQ *helpers.BigInt `json:"votedNEQ,omitempty"` - VotedIn []*helpers.BigInt `json:"votedIn,omitempty"` - VotedNotIn []*helpers.BigInt `json:"votedNotIn,omitempty"` - VotedGT *helpers.BigInt `json:"votedGT,omitempty"` - VotedGTE *helpers.BigInt `json:"votedGTE,omitempty"` - VotedLT *helpers.BigInt `json:"votedLT,omitempty"` - VotedLTE *helpers.BigInt `json:"votedLTE,omitempty"` - - // "signers" edge predicates. - HasSigners *bool `json:"hasSigners,omitempty"` - HasSignersWith []*SignerWhereInput `json:"hasSignersWith,omitempty"` -} - -// AddPredicates adds custom predicates to the where input to be used during the filtering phase. -func (i *AssetPriceWhereInput) AddPredicates(predicates ...predicate.AssetPrice) { - i.Predicates = append(i.Predicates, predicates...) -} - -// Filter applies the AssetPriceWhereInput filter on the AssetPriceQuery builder. -func (i *AssetPriceWhereInput) Filter(q *AssetPriceQuery) (*AssetPriceQuery, error) { - if i == nil { - return q, nil - } - p, err := i.P() - if err != nil { - if err == ErrEmptyAssetPriceWhereInput { - return q, nil - } - return nil, err - } - return q.Where(p), nil -} - -// ErrEmptyAssetPriceWhereInput is returned in case the AssetPriceWhereInput is empty. -var ErrEmptyAssetPriceWhereInput = errors.New("ent: empty predicate AssetPriceWhereInput") - -// P returns a predicate for filtering assetprices. -// An error is returned if the input is empty or invalid. -func (i *AssetPriceWhereInput) P() (predicate.AssetPrice, error) { - var predicates []predicate.AssetPrice - if i.Not != nil { - p, err := i.Not.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'not'", err) - } - predicates = append(predicates, assetprice.Not(p)) - } - switch n := len(i.Or); { - case n == 1: - p, err := i.Or[0].P() - if err != nil { - return nil, fmt.Errorf("%w: field 'or'", err) - } - predicates = append(predicates, p) - case n > 1: - or := make([]predicate.AssetPrice, 0, n) - for _, w := range i.Or { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'or'", err) - } - or = append(or, p) - } - predicates = append(predicates, assetprice.Or(or...)) - } - switch n := len(i.And); { - case n == 1: - p, err := i.And[0].P() - if err != nil { - return nil, fmt.Errorf("%w: field 'and'", err) - } - predicates = append(predicates, p) - case n > 1: - and := make([]predicate.AssetPrice, 0, n) - for _, w := range i.And { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'and'", err) - } - and = append(and, p) - } - predicates = append(predicates, assetprice.And(and...)) - } - predicates = append(predicates, i.Predicates...) - if i.ID != nil { - predicates = append(predicates, assetprice.IDEQ(*i.ID)) - } - if i.IDNEQ != nil { - predicates = append(predicates, assetprice.IDNEQ(*i.IDNEQ)) - } - if len(i.IDIn) > 0 { - predicates = append(predicates, assetprice.IDIn(i.IDIn...)) - } - if len(i.IDNotIn) > 0 { - predicates = append(predicates, assetprice.IDNotIn(i.IDNotIn...)) - } - if i.IDGT != nil { - predicates = append(predicates, assetprice.IDGT(*i.IDGT)) - } - if i.IDGTE != nil { - predicates = append(predicates, assetprice.IDGTE(*i.IDGTE)) - } - if i.IDLT != nil { - predicates = append(predicates, assetprice.IDLT(*i.IDLT)) - } - if i.IDLTE != nil { - predicates = append(predicates, assetprice.IDLTE(*i.IDLTE)) - } - if i.Block != nil { - predicates = append(predicates, assetprice.BlockEQ(*i.Block)) - } - if i.BlockNEQ != nil { - predicates = append(predicates, assetprice.BlockNEQ(*i.BlockNEQ)) - } - if len(i.BlockIn) > 0 { - predicates = append(predicates, assetprice.BlockIn(i.BlockIn...)) - } - if len(i.BlockNotIn) > 0 { - predicates = append(predicates, assetprice.BlockNotIn(i.BlockNotIn...)) - } - if i.BlockGT != nil { - predicates = append(predicates, assetprice.BlockGT(*i.BlockGT)) - } - if i.BlockGTE != nil { - predicates = append(predicates, assetprice.BlockGTE(*i.BlockGTE)) - } - if i.BlockLT != nil { - predicates = append(predicates, assetprice.BlockLT(*i.BlockLT)) - } - if i.BlockLTE != nil { - predicates = append(predicates, assetprice.BlockLTE(*i.BlockLTE)) - } - if i.SignersCount != nil { - predicates = append(predicates, assetprice.SignersCountEQ(*i.SignersCount)) - } - if i.SignersCountNEQ != nil { - predicates = append(predicates, assetprice.SignersCountNEQ(*i.SignersCountNEQ)) - } - if len(i.SignersCountIn) > 0 { - predicates = append(predicates, assetprice.SignersCountIn(i.SignersCountIn...)) - } - if len(i.SignersCountNotIn) > 0 { - predicates = append(predicates, assetprice.SignersCountNotIn(i.SignersCountNotIn...)) - } - if i.SignersCountGT != nil { - predicates = append(predicates, assetprice.SignersCountGT(*i.SignersCountGT)) - } - if i.SignersCountGTE != nil { - predicates = append(predicates, assetprice.SignersCountGTE(*i.SignersCountGTE)) - } - if i.SignersCountLT != nil { - predicates = append(predicates, assetprice.SignersCountLT(*i.SignersCountLT)) - } - if i.SignersCountLTE != nil { - predicates = append(predicates, assetprice.SignersCountLTE(*i.SignersCountLTE)) - } - if i.SignersCountIsNil { - predicates = append(predicates, assetprice.SignersCountIsNil()) - } - if i.SignersCountNotNil { - predicates = append(predicates, assetprice.SignersCountNotNil()) - } - if i.Price != nil { - predicates = append(predicates, assetprice.PriceEQ(i.Price)) - } - if i.PriceNEQ != nil { - predicates = append(predicates, assetprice.PriceNEQ(i.PriceNEQ)) - } - if len(i.PriceIn) > 0 { - predicates = append(predicates, assetprice.PriceIn(i.PriceIn...)) - } - if len(i.PriceNotIn) > 0 { - predicates = append(predicates, assetprice.PriceNotIn(i.PriceNotIn...)) - } - if i.PriceGT != nil { - predicates = append(predicates, assetprice.PriceGT(i.PriceGT)) - } - if i.PriceGTE != nil { - predicates = append(predicates, assetprice.PriceGTE(i.PriceGTE)) - } - if i.PriceLT != nil { - predicates = append(predicates, assetprice.PriceLT(i.PriceLT)) - } - if i.PriceLTE != nil { - predicates = append(predicates, assetprice.PriceLTE(i.PriceLTE)) - } - if i.Asset != nil { - predicates = append(predicates, assetprice.AssetEQ(*i.Asset)) - } - if i.AssetNEQ != nil { - predicates = append(predicates, assetprice.AssetNEQ(*i.AssetNEQ)) - } - if len(i.AssetIn) > 0 { - predicates = append(predicates, assetprice.AssetIn(i.AssetIn...)) - } - if len(i.AssetNotIn) > 0 { - predicates = append(predicates, assetprice.AssetNotIn(i.AssetNotIn...)) - } - if i.AssetGT != nil { - predicates = append(predicates, assetprice.AssetGT(*i.AssetGT)) - } - if i.AssetGTE != nil { - predicates = append(predicates, assetprice.AssetGTE(*i.AssetGTE)) - } - if i.AssetLT != nil { - predicates = append(predicates, assetprice.AssetLT(*i.AssetLT)) - } - if i.AssetLTE != nil { - predicates = append(predicates, assetprice.AssetLTE(*i.AssetLTE)) - } - if i.AssetContains != nil { - predicates = append(predicates, assetprice.AssetContains(*i.AssetContains)) - } - if i.AssetHasPrefix != nil { - predicates = append(predicates, assetprice.AssetHasPrefix(*i.AssetHasPrefix)) - } - if i.AssetHasSuffix != nil { - predicates = append(predicates, assetprice.AssetHasSuffix(*i.AssetHasSuffix)) - } - if i.AssetIsNil { - predicates = append(predicates, assetprice.AssetIsNil()) - } - if i.AssetNotNil { - predicates = append(predicates, assetprice.AssetNotNil()) - } - if i.AssetEqualFold != nil { - predicates = append(predicates, assetprice.AssetEqualFold(*i.AssetEqualFold)) - } - if i.AssetContainsFold != nil { - predicates = append(predicates, assetprice.AssetContainsFold(*i.AssetContainsFold)) - } - if i.Chain != nil { - predicates = append(predicates, assetprice.ChainEQ(*i.Chain)) - } - if i.ChainNEQ != nil { - predicates = append(predicates, assetprice.ChainNEQ(*i.ChainNEQ)) - } - if len(i.ChainIn) > 0 { - predicates = append(predicates, assetprice.ChainIn(i.ChainIn...)) - } - if len(i.ChainNotIn) > 0 { - predicates = append(predicates, assetprice.ChainNotIn(i.ChainNotIn...)) - } - if i.ChainGT != nil { - predicates = append(predicates, assetprice.ChainGT(*i.ChainGT)) - } - if i.ChainGTE != nil { - predicates = append(predicates, assetprice.ChainGTE(*i.ChainGTE)) - } - if i.ChainLT != nil { - predicates = append(predicates, assetprice.ChainLT(*i.ChainLT)) - } - if i.ChainLTE != nil { - predicates = append(predicates, assetprice.ChainLTE(*i.ChainLTE)) - } - if i.ChainContains != nil { - predicates = append(predicates, assetprice.ChainContains(*i.ChainContains)) - } - if i.ChainHasPrefix != nil { - predicates = append(predicates, assetprice.ChainHasPrefix(*i.ChainHasPrefix)) - } - if i.ChainHasSuffix != nil { - predicates = append(predicates, assetprice.ChainHasSuffix(*i.ChainHasSuffix)) - } - if i.ChainIsNil { - predicates = append(predicates, assetprice.ChainIsNil()) - } - if i.ChainNotNil { - predicates = append(predicates, assetprice.ChainNotNil()) - } - if i.ChainEqualFold != nil { - predicates = append(predicates, assetprice.ChainEqualFold(*i.ChainEqualFold)) - } - if i.ChainContainsFold != nil { - predicates = append(predicates, assetprice.ChainContainsFold(*i.ChainContainsFold)) - } - if i.Pair != nil { - predicates = append(predicates, assetprice.PairEQ(*i.Pair)) - } - if i.PairNEQ != nil { - predicates = append(predicates, assetprice.PairNEQ(*i.PairNEQ)) - } - if len(i.PairIn) > 0 { - predicates = append(predicates, assetprice.PairIn(i.PairIn...)) - } - if len(i.PairNotIn) > 0 { - predicates = append(predicates, assetprice.PairNotIn(i.PairNotIn...)) - } - if i.PairGT != nil { - predicates = append(predicates, assetprice.PairGT(*i.PairGT)) - } - if i.PairGTE != nil { - predicates = append(predicates, assetprice.PairGTE(*i.PairGTE)) - } - if i.PairLT != nil { - predicates = append(predicates, assetprice.PairLT(*i.PairLT)) - } - if i.PairLTE != nil { - predicates = append(predicates, assetprice.PairLTE(*i.PairLTE)) - } - if i.PairContains != nil { - predicates = append(predicates, assetprice.PairContains(*i.PairContains)) - } - if i.PairHasPrefix != nil { - predicates = append(predicates, assetprice.PairHasPrefix(*i.PairHasPrefix)) - } - if i.PairHasSuffix != nil { - predicates = append(predicates, assetprice.PairHasSuffix(*i.PairHasSuffix)) - } - if i.PairIsNil { - predicates = append(predicates, assetprice.PairIsNil()) - } - if i.PairNotNil { - predicates = append(predicates, assetprice.PairNotNil()) - } - if i.PairEqualFold != nil { - predicates = append(predicates, assetprice.PairEqualFold(*i.PairEqualFold)) - } - if i.PairContainsFold != nil { - predicates = append(predicates, assetprice.PairContainsFold(*i.PairContainsFold)) - } - if i.Consensus != nil { - predicates = append(predicates, assetprice.ConsensusEQ(*i.Consensus)) - } - if i.ConsensusNEQ != nil { - predicates = append(predicates, assetprice.ConsensusNEQ(*i.ConsensusNEQ)) - } - if i.Voted != nil { - predicates = append(predicates, assetprice.VotedEQ(i.Voted)) - } - if i.VotedNEQ != nil { - predicates = append(predicates, assetprice.VotedNEQ(i.VotedNEQ)) - } - if len(i.VotedIn) > 0 { - predicates = append(predicates, assetprice.VotedIn(i.VotedIn...)) - } - if len(i.VotedNotIn) > 0 { - predicates = append(predicates, assetprice.VotedNotIn(i.VotedNotIn...)) - } - if i.VotedGT != nil { - predicates = append(predicates, assetprice.VotedGT(i.VotedGT)) - } - if i.VotedGTE != nil { - predicates = append(predicates, assetprice.VotedGTE(i.VotedGTE)) - } - if i.VotedLT != nil { - predicates = append(predicates, assetprice.VotedLT(i.VotedLT)) - } - if i.VotedLTE != nil { - predicates = append(predicates, assetprice.VotedLTE(i.VotedLTE)) - } - - if i.HasSigners != nil { - p := assetprice.HasSigners() - if !*i.HasSigners { - p = assetprice.Not(p) - } - predicates = append(predicates, p) - } - if len(i.HasSignersWith) > 0 { - with := make([]predicate.Signer, 0, len(i.HasSignersWith)) - for _, w := range i.HasSignersWith { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'HasSignersWith'", err) - } - with = append(with, p) - } - predicates = append(predicates, assetprice.HasSignersWith(with...)) - } - switch len(predicates) { - case 0: - return nil, ErrEmptyAssetPriceWhereInput - case 1: - return predicates[0], nil - default: - return assetprice.And(predicates...), nil - } -} - -// CorrectnessReportWhereInput represents a where input for filtering CorrectnessReport queries. -type CorrectnessReportWhereInput struct { - Predicates []predicate.CorrectnessReport `json:"-"` - Not *CorrectnessReportWhereInput `json:"not,omitempty"` - Or []*CorrectnessReportWhereInput `json:"or,omitempty"` - And []*CorrectnessReportWhereInput `json:"and,omitempty"` - - // "id" field predicates. - ID *int `json:"id,omitempty"` - IDNEQ *int `json:"idNEQ,omitempty"` - IDIn []int `json:"idIn,omitempty"` - IDNotIn []int `json:"idNotIn,omitempty"` - IDGT *int `json:"idGT,omitempty"` - IDGTE *int `json:"idGTE,omitempty"` - IDLT *int `json:"idLT,omitempty"` - IDLTE *int `json:"idLTE,omitempty"` - - // "signersCount" field predicates. - SignersCount *uint64 `json:"signerscount,omitempty"` - SignersCountNEQ *uint64 `json:"signerscountNEQ,omitempty"` - SignersCountIn []uint64 `json:"signerscountIn,omitempty"` - SignersCountNotIn []uint64 `json:"signerscountNotIn,omitempty"` - SignersCountGT *uint64 `json:"signerscountGT,omitempty"` - SignersCountGTE *uint64 `json:"signerscountGTE,omitempty"` - SignersCountLT *uint64 `json:"signerscountLT,omitempty"` - SignersCountLTE *uint64 `json:"signerscountLTE,omitempty"` - - // "timestamp" field predicates. - Timestamp *uint64 `json:"timestamp,omitempty"` - TimestampNEQ *uint64 `json:"timestampNEQ,omitempty"` - TimestampIn []uint64 `json:"timestampIn,omitempty"` - TimestampNotIn []uint64 `json:"timestampNotIn,omitempty"` - TimestampGT *uint64 `json:"timestampGT,omitempty"` - TimestampGTE *uint64 `json:"timestampGTE,omitempty"` - TimestampLT *uint64 `json:"timestampLT,omitempty"` - TimestampLTE *uint64 `json:"timestampLTE,omitempty"` - - // "correct" field predicates. - Correct *bool `json:"correct,omitempty"` - CorrectNEQ *bool `json:"correctNEQ,omitempty"` - - // "consensus" field predicates. - Consensus *bool `json:"consensus,omitempty"` - ConsensusNEQ *bool `json:"consensusNEQ,omitempty"` - - // "voted" field predicates. - Voted *helpers.BigInt `json:"voted,omitempty"` - VotedNEQ *helpers.BigInt `json:"votedNEQ,omitempty"` - VotedIn []*helpers.BigInt `json:"votedIn,omitempty"` - VotedNotIn []*helpers.BigInt `json:"votedNotIn,omitempty"` - VotedGT *helpers.BigInt `json:"votedGT,omitempty"` - VotedGTE *helpers.BigInt `json:"votedGTE,omitempty"` - VotedLT *helpers.BigInt `json:"votedLT,omitempty"` - VotedLTE *helpers.BigInt `json:"votedLTE,omitempty"` - - // "signers" edge predicates. - HasSigners *bool `json:"hasSigners,omitempty"` - HasSignersWith []*SignerWhereInput `json:"hasSignersWith,omitempty"` -} - -// AddPredicates adds custom predicates to the where input to be used during the filtering phase. -func (i *CorrectnessReportWhereInput) AddPredicates(predicates ...predicate.CorrectnessReport) { - i.Predicates = append(i.Predicates, predicates...) -} - -// Filter applies the CorrectnessReportWhereInput filter on the CorrectnessReportQuery builder. -func (i *CorrectnessReportWhereInput) Filter(q *CorrectnessReportQuery) (*CorrectnessReportQuery, error) { - if i == nil { - return q, nil - } - p, err := i.P() - if err != nil { - if err == ErrEmptyCorrectnessReportWhereInput { - return q, nil - } - return nil, err - } - return q.Where(p), nil -} - -// ErrEmptyCorrectnessReportWhereInput is returned in case the CorrectnessReportWhereInput is empty. -var ErrEmptyCorrectnessReportWhereInput = errors.New("ent: empty predicate CorrectnessReportWhereInput") - -// P returns a predicate for filtering correctnessreports. -// An error is returned if the input is empty or invalid. -func (i *CorrectnessReportWhereInput) P() (predicate.CorrectnessReport, error) { - var predicates []predicate.CorrectnessReport - if i.Not != nil { - p, err := i.Not.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'not'", err) - } - predicates = append(predicates, correctnessreport.Not(p)) - } - switch n := len(i.Or); { - case n == 1: - p, err := i.Or[0].P() - if err != nil { - return nil, fmt.Errorf("%w: field 'or'", err) - } - predicates = append(predicates, p) - case n > 1: - or := make([]predicate.CorrectnessReport, 0, n) - for _, w := range i.Or { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'or'", err) - } - or = append(or, p) - } - predicates = append(predicates, correctnessreport.Or(or...)) - } - switch n := len(i.And); { - case n == 1: - p, err := i.And[0].P() - if err != nil { - return nil, fmt.Errorf("%w: field 'and'", err) - } - predicates = append(predicates, p) - case n > 1: - and := make([]predicate.CorrectnessReport, 0, n) - for _, w := range i.And { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'and'", err) - } - and = append(and, p) - } - predicates = append(predicates, correctnessreport.And(and...)) - } - predicates = append(predicates, i.Predicates...) - if i.ID != nil { - predicates = append(predicates, correctnessreport.IDEQ(*i.ID)) - } - if i.IDNEQ != nil { - predicates = append(predicates, correctnessreport.IDNEQ(*i.IDNEQ)) - } - if len(i.IDIn) > 0 { - predicates = append(predicates, correctnessreport.IDIn(i.IDIn...)) - } - if len(i.IDNotIn) > 0 { - predicates = append(predicates, correctnessreport.IDNotIn(i.IDNotIn...)) - } - if i.IDGT != nil { - predicates = append(predicates, correctnessreport.IDGT(*i.IDGT)) - } - if i.IDGTE != nil { - predicates = append(predicates, correctnessreport.IDGTE(*i.IDGTE)) - } - if i.IDLT != nil { - predicates = append(predicates, correctnessreport.IDLT(*i.IDLT)) - } - if i.IDLTE != nil { - predicates = append(predicates, correctnessreport.IDLTE(*i.IDLTE)) - } - if i.SignersCount != nil { - predicates = append(predicates, correctnessreport.SignersCountEQ(*i.SignersCount)) - } - if i.SignersCountNEQ != nil { - predicates = append(predicates, correctnessreport.SignersCountNEQ(*i.SignersCountNEQ)) - } - if len(i.SignersCountIn) > 0 { - predicates = append(predicates, correctnessreport.SignersCountIn(i.SignersCountIn...)) - } - if len(i.SignersCountNotIn) > 0 { - predicates = append(predicates, correctnessreport.SignersCountNotIn(i.SignersCountNotIn...)) - } - if i.SignersCountGT != nil { - predicates = append(predicates, correctnessreport.SignersCountGT(*i.SignersCountGT)) - } - if i.SignersCountGTE != nil { - predicates = append(predicates, correctnessreport.SignersCountGTE(*i.SignersCountGTE)) - } - if i.SignersCountLT != nil { - predicates = append(predicates, correctnessreport.SignersCountLT(*i.SignersCountLT)) - } - if i.SignersCountLTE != nil { - predicates = append(predicates, correctnessreport.SignersCountLTE(*i.SignersCountLTE)) - } - if i.Timestamp != nil { - predicates = append(predicates, correctnessreport.TimestampEQ(*i.Timestamp)) - } - if i.TimestampNEQ != nil { - predicates = append(predicates, correctnessreport.TimestampNEQ(*i.TimestampNEQ)) - } - if len(i.TimestampIn) > 0 { - predicates = append(predicates, correctnessreport.TimestampIn(i.TimestampIn...)) - } - if len(i.TimestampNotIn) > 0 { - predicates = append(predicates, correctnessreport.TimestampNotIn(i.TimestampNotIn...)) - } - if i.TimestampGT != nil { - predicates = append(predicates, correctnessreport.TimestampGT(*i.TimestampGT)) - } - if i.TimestampGTE != nil { - predicates = append(predicates, correctnessreport.TimestampGTE(*i.TimestampGTE)) - } - if i.TimestampLT != nil { - predicates = append(predicates, correctnessreport.TimestampLT(*i.TimestampLT)) - } - if i.TimestampLTE != nil { - predicates = append(predicates, correctnessreport.TimestampLTE(*i.TimestampLTE)) - } - if i.Correct != nil { - predicates = append(predicates, correctnessreport.CorrectEQ(*i.Correct)) - } - if i.CorrectNEQ != nil { - predicates = append(predicates, correctnessreport.CorrectNEQ(*i.CorrectNEQ)) - } - if i.Consensus != nil { - predicates = append(predicates, correctnessreport.ConsensusEQ(*i.Consensus)) - } - if i.ConsensusNEQ != nil { - predicates = append(predicates, correctnessreport.ConsensusNEQ(*i.ConsensusNEQ)) - } - if i.Voted != nil { - predicates = append(predicates, correctnessreport.VotedEQ(i.Voted)) - } - if i.VotedNEQ != nil { - predicates = append(predicates, correctnessreport.VotedNEQ(i.VotedNEQ)) - } - if len(i.VotedIn) > 0 { - predicates = append(predicates, correctnessreport.VotedIn(i.VotedIn...)) - } - if len(i.VotedNotIn) > 0 { - predicates = append(predicates, correctnessreport.VotedNotIn(i.VotedNotIn...)) - } - if i.VotedGT != nil { - predicates = append(predicates, correctnessreport.VotedGT(i.VotedGT)) - } - if i.VotedGTE != nil { - predicates = append(predicates, correctnessreport.VotedGTE(i.VotedGTE)) - } - if i.VotedLT != nil { - predicates = append(predicates, correctnessreport.VotedLT(i.VotedLT)) - } - if i.VotedLTE != nil { - predicates = append(predicates, correctnessreport.VotedLTE(i.VotedLTE)) - } - - if i.HasSigners != nil { - p := correctnessreport.HasSigners() - if !*i.HasSigners { - p = correctnessreport.Not(p) - } - predicates = append(predicates, p) - } - if len(i.HasSignersWith) > 0 { - with := make([]predicate.Signer, 0, len(i.HasSignersWith)) - for _, w := range i.HasSignersWith { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'HasSignersWith'", err) - } - with = append(with, p) - } - predicates = append(predicates, correctnessreport.HasSignersWith(with...)) - } - switch len(predicates) { - case 0: - return nil, ErrEmptyCorrectnessReportWhereInput - case 1: - return predicates[0], nil - default: - return correctnessreport.And(predicates...), nil - } -} - -// EventLogWhereInput represents a where input for filtering EventLog queries. -type EventLogWhereInput struct { - Predicates []predicate.EventLog `json:"-"` - Not *EventLogWhereInput `json:"not,omitempty"` - Or []*EventLogWhereInput `json:"or,omitempty"` - And []*EventLogWhereInput `json:"and,omitempty"` - - // "id" field predicates. - ID *int `json:"id,omitempty"` - IDNEQ *int `json:"idNEQ,omitempty"` - IDIn []int `json:"idIn,omitempty"` - IDNotIn []int `json:"idNotIn,omitempty"` - IDGT *int `json:"idGT,omitempty"` - IDGTE *int `json:"idGTE,omitempty"` - IDLT *int `json:"idLT,omitempty"` - IDLTE *int `json:"idLTE,omitempty"` - - // "block" field predicates. - Block *uint64 `json:"block,omitempty"` - BlockNEQ *uint64 `json:"blockNEQ,omitempty"` - BlockIn []uint64 `json:"blockIn,omitempty"` - BlockNotIn []uint64 `json:"blockNotIn,omitempty"` - BlockGT *uint64 `json:"blockGT,omitempty"` - BlockGTE *uint64 `json:"blockGTE,omitempty"` - BlockLT *uint64 `json:"blockLT,omitempty"` - BlockLTE *uint64 `json:"blockLTE,omitempty"` - - // "signersCount" field predicates. - SignersCount *uint64 `json:"signerscount,omitempty"` - SignersCountNEQ *uint64 `json:"signerscountNEQ,omitempty"` - SignersCountIn []uint64 `json:"signerscountIn,omitempty"` - SignersCountNotIn []uint64 `json:"signerscountNotIn,omitempty"` - SignersCountGT *uint64 `json:"signerscountGT,omitempty"` - SignersCountGTE *uint64 `json:"signerscountGTE,omitempty"` - SignersCountLT *uint64 `json:"signerscountLT,omitempty"` - SignersCountLTE *uint64 `json:"signerscountLTE,omitempty"` - - // "address" field predicates. - Address *string `json:"address,omitempty"` - AddressNEQ *string `json:"addressNEQ,omitempty"` - AddressIn []string `json:"addressIn,omitempty"` - AddressNotIn []string `json:"addressNotIn,omitempty"` - AddressGT *string `json:"addressGT,omitempty"` - AddressGTE *string `json:"addressGTE,omitempty"` - AddressLT *string `json:"addressLT,omitempty"` - AddressLTE *string `json:"addressLTE,omitempty"` - AddressContains *string `json:"addressContains,omitempty"` - AddressHasPrefix *string `json:"addressHasPrefix,omitempty"` - AddressHasSuffix *string `json:"addressHasSuffix,omitempty"` - AddressEqualFold *string `json:"addressEqualFold,omitempty"` - AddressContainsFold *string `json:"addressContainsFold,omitempty"` - - // "chain" field predicates. - Chain *string `json:"chain,omitempty"` - ChainNEQ *string `json:"chainNEQ,omitempty"` - ChainIn []string `json:"chainIn,omitempty"` - ChainNotIn []string `json:"chainNotIn,omitempty"` - ChainGT *string `json:"chainGT,omitempty"` - ChainGTE *string `json:"chainGTE,omitempty"` - ChainLT *string `json:"chainLT,omitempty"` - ChainLTE *string `json:"chainLTE,omitempty"` - ChainContains *string `json:"chainContains,omitempty"` - ChainHasPrefix *string `json:"chainHasPrefix,omitempty"` - ChainHasSuffix *string `json:"chainHasSuffix,omitempty"` - ChainEqualFold *string `json:"chainEqualFold,omitempty"` - ChainContainsFold *string `json:"chainContainsFold,omitempty"` - - // "index" field predicates. - Index *uint64 `json:"index,omitempty"` - IndexNEQ *uint64 `json:"indexNEQ,omitempty"` - IndexIn []uint64 `json:"indexIn,omitempty"` - IndexNotIn []uint64 `json:"indexNotIn,omitempty"` - IndexGT *uint64 `json:"indexGT,omitempty"` - IndexGTE *uint64 `json:"indexGTE,omitempty"` - IndexLT *uint64 `json:"indexLT,omitempty"` - IndexLTE *uint64 `json:"indexLTE,omitempty"` - - // "event" field predicates. - Event *string `json:"event,omitempty"` - EventNEQ *string `json:"eventNEQ,omitempty"` - EventIn []string `json:"eventIn,omitempty"` - EventNotIn []string `json:"eventNotIn,omitempty"` - EventGT *string `json:"eventGT,omitempty"` - EventGTE *string `json:"eventGTE,omitempty"` - EventLT *string `json:"eventLT,omitempty"` - EventLTE *string `json:"eventLTE,omitempty"` - EventContains *string `json:"eventContains,omitempty"` - EventHasPrefix *string `json:"eventHasPrefix,omitempty"` - EventHasSuffix *string `json:"eventHasSuffix,omitempty"` - EventEqualFold *string `json:"eventEqualFold,omitempty"` - EventContainsFold *string `json:"eventContainsFold,omitempty"` - - // "consensus" field predicates. - Consensus *bool `json:"consensus,omitempty"` - ConsensusNEQ *bool `json:"consensusNEQ,omitempty"` - - // "voted" field predicates. - Voted *helpers.BigInt `json:"voted,omitempty"` - VotedNEQ *helpers.BigInt `json:"votedNEQ,omitempty"` - VotedIn []*helpers.BigInt `json:"votedIn,omitempty"` - VotedNotIn []*helpers.BigInt `json:"votedNotIn,omitempty"` - VotedGT *helpers.BigInt `json:"votedGT,omitempty"` - VotedGTE *helpers.BigInt `json:"votedGTE,omitempty"` - VotedLT *helpers.BigInt `json:"votedLT,omitempty"` - VotedLTE *helpers.BigInt `json:"votedLTE,omitempty"` - - // "signers" edge predicates. - HasSigners *bool `json:"hasSigners,omitempty"` - HasSignersWith []*SignerWhereInput `json:"hasSignersWith,omitempty"` -} - -// AddPredicates adds custom predicates to the where input to be used during the filtering phase. -func (i *EventLogWhereInput) AddPredicates(predicates ...predicate.EventLog) { - i.Predicates = append(i.Predicates, predicates...) -} - -// Filter applies the EventLogWhereInput filter on the EventLogQuery builder. -func (i *EventLogWhereInput) Filter(q *EventLogQuery) (*EventLogQuery, error) { - if i == nil { - return q, nil - } - p, err := i.P() - if err != nil { - if err == ErrEmptyEventLogWhereInput { - return q, nil - } - return nil, err - } - return q.Where(p), nil -} - -// ErrEmptyEventLogWhereInput is returned in case the EventLogWhereInput is empty. -var ErrEmptyEventLogWhereInput = errors.New("ent: empty predicate EventLogWhereInput") - -// P returns a predicate for filtering eventlogs. -// An error is returned if the input is empty or invalid. -func (i *EventLogWhereInput) P() (predicate.EventLog, error) { - var predicates []predicate.EventLog - if i.Not != nil { - p, err := i.Not.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'not'", err) - } - predicates = append(predicates, eventlog.Not(p)) - } - switch n := len(i.Or); { - case n == 1: - p, err := i.Or[0].P() - if err != nil { - return nil, fmt.Errorf("%w: field 'or'", err) - } - predicates = append(predicates, p) - case n > 1: - or := make([]predicate.EventLog, 0, n) - for _, w := range i.Or { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'or'", err) - } - or = append(or, p) - } - predicates = append(predicates, eventlog.Or(or...)) - } - switch n := len(i.And); { - case n == 1: - p, err := i.And[0].P() - if err != nil { - return nil, fmt.Errorf("%w: field 'and'", err) - } - predicates = append(predicates, p) - case n > 1: - and := make([]predicate.EventLog, 0, n) - for _, w := range i.And { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'and'", err) - } - and = append(and, p) - } - predicates = append(predicates, eventlog.And(and...)) - } - predicates = append(predicates, i.Predicates...) - if i.ID != nil { - predicates = append(predicates, eventlog.IDEQ(*i.ID)) - } - if i.IDNEQ != nil { - predicates = append(predicates, eventlog.IDNEQ(*i.IDNEQ)) - } - if len(i.IDIn) > 0 { - predicates = append(predicates, eventlog.IDIn(i.IDIn...)) - } - if len(i.IDNotIn) > 0 { - predicates = append(predicates, eventlog.IDNotIn(i.IDNotIn...)) - } - if i.IDGT != nil { - predicates = append(predicates, eventlog.IDGT(*i.IDGT)) - } - if i.IDGTE != nil { - predicates = append(predicates, eventlog.IDGTE(*i.IDGTE)) - } - if i.IDLT != nil { - predicates = append(predicates, eventlog.IDLT(*i.IDLT)) - } - if i.IDLTE != nil { - predicates = append(predicates, eventlog.IDLTE(*i.IDLTE)) - } - if i.Block != nil { - predicates = append(predicates, eventlog.BlockEQ(*i.Block)) - } - if i.BlockNEQ != nil { - predicates = append(predicates, eventlog.BlockNEQ(*i.BlockNEQ)) - } - if len(i.BlockIn) > 0 { - predicates = append(predicates, eventlog.BlockIn(i.BlockIn...)) - } - if len(i.BlockNotIn) > 0 { - predicates = append(predicates, eventlog.BlockNotIn(i.BlockNotIn...)) - } - if i.BlockGT != nil { - predicates = append(predicates, eventlog.BlockGT(*i.BlockGT)) - } - if i.BlockGTE != nil { - predicates = append(predicates, eventlog.BlockGTE(*i.BlockGTE)) - } - if i.BlockLT != nil { - predicates = append(predicates, eventlog.BlockLT(*i.BlockLT)) - } - if i.BlockLTE != nil { - predicates = append(predicates, eventlog.BlockLTE(*i.BlockLTE)) - } - if i.SignersCount != nil { - predicates = append(predicates, eventlog.SignersCountEQ(*i.SignersCount)) - } - if i.SignersCountNEQ != nil { - predicates = append(predicates, eventlog.SignersCountNEQ(*i.SignersCountNEQ)) - } - if len(i.SignersCountIn) > 0 { - predicates = append(predicates, eventlog.SignersCountIn(i.SignersCountIn...)) - } - if len(i.SignersCountNotIn) > 0 { - predicates = append(predicates, eventlog.SignersCountNotIn(i.SignersCountNotIn...)) - } - if i.SignersCountGT != nil { - predicates = append(predicates, eventlog.SignersCountGT(*i.SignersCountGT)) - } - if i.SignersCountGTE != nil { - predicates = append(predicates, eventlog.SignersCountGTE(*i.SignersCountGTE)) - } - if i.SignersCountLT != nil { - predicates = append(predicates, eventlog.SignersCountLT(*i.SignersCountLT)) - } - if i.SignersCountLTE != nil { - predicates = append(predicates, eventlog.SignersCountLTE(*i.SignersCountLTE)) - } - if i.Address != nil { - predicates = append(predicates, eventlog.AddressEQ(*i.Address)) - } - if i.AddressNEQ != nil { - predicates = append(predicates, eventlog.AddressNEQ(*i.AddressNEQ)) - } - if len(i.AddressIn) > 0 { - predicates = append(predicates, eventlog.AddressIn(i.AddressIn...)) - } - if len(i.AddressNotIn) > 0 { - predicates = append(predicates, eventlog.AddressNotIn(i.AddressNotIn...)) - } - if i.AddressGT != nil { - predicates = append(predicates, eventlog.AddressGT(*i.AddressGT)) - } - if i.AddressGTE != nil { - predicates = append(predicates, eventlog.AddressGTE(*i.AddressGTE)) - } - if i.AddressLT != nil { - predicates = append(predicates, eventlog.AddressLT(*i.AddressLT)) - } - if i.AddressLTE != nil { - predicates = append(predicates, eventlog.AddressLTE(*i.AddressLTE)) - } - if i.AddressContains != nil { - predicates = append(predicates, eventlog.AddressContains(*i.AddressContains)) - } - if i.AddressHasPrefix != nil { - predicates = append(predicates, eventlog.AddressHasPrefix(*i.AddressHasPrefix)) - } - if i.AddressHasSuffix != nil { - predicates = append(predicates, eventlog.AddressHasSuffix(*i.AddressHasSuffix)) - } - if i.AddressEqualFold != nil { - predicates = append(predicates, eventlog.AddressEqualFold(*i.AddressEqualFold)) - } - if i.AddressContainsFold != nil { - predicates = append(predicates, eventlog.AddressContainsFold(*i.AddressContainsFold)) - } - if i.Chain != nil { - predicates = append(predicates, eventlog.ChainEQ(*i.Chain)) - } - if i.ChainNEQ != nil { - predicates = append(predicates, eventlog.ChainNEQ(*i.ChainNEQ)) - } - if len(i.ChainIn) > 0 { - predicates = append(predicates, eventlog.ChainIn(i.ChainIn...)) - } - if len(i.ChainNotIn) > 0 { - predicates = append(predicates, eventlog.ChainNotIn(i.ChainNotIn...)) - } - if i.ChainGT != nil { - predicates = append(predicates, eventlog.ChainGT(*i.ChainGT)) - } - if i.ChainGTE != nil { - predicates = append(predicates, eventlog.ChainGTE(*i.ChainGTE)) - } - if i.ChainLT != nil { - predicates = append(predicates, eventlog.ChainLT(*i.ChainLT)) - } - if i.ChainLTE != nil { - predicates = append(predicates, eventlog.ChainLTE(*i.ChainLTE)) - } - if i.ChainContains != nil { - predicates = append(predicates, eventlog.ChainContains(*i.ChainContains)) - } - if i.ChainHasPrefix != nil { - predicates = append(predicates, eventlog.ChainHasPrefix(*i.ChainHasPrefix)) - } - if i.ChainHasSuffix != nil { - predicates = append(predicates, eventlog.ChainHasSuffix(*i.ChainHasSuffix)) - } - if i.ChainEqualFold != nil { - predicates = append(predicates, eventlog.ChainEqualFold(*i.ChainEqualFold)) - } - if i.ChainContainsFold != nil { - predicates = append(predicates, eventlog.ChainContainsFold(*i.ChainContainsFold)) - } - if i.Index != nil { - predicates = append(predicates, eventlog.IndexEQ(*i.Index)) - } - if i.IndexNEQ != nil { - predicates = append(predicates, eventlog.IndexNEQ(*i.IndexNEQ)) - } - if len(i.IndexIn) > 0 { - predicates = append(predicates, eventlog.IndexIn(i.IndexIn...)) - } - if len(i.IndexNotIn) > 0 { - predicates = append(predicates, eventlog.IndexNotIn(i.IndexNotIn...)) - } - if i.IndexGT != nil { - predicates = append(predicates, eventlog.IndexGT(*i.IndexGT)) - } - if i.IndexGTE != nil { - predicates = append(predicates, eventlog.IndexGTE(*i.IndexGTE)) - } - if i.IndexLT != nil { - predicates = append(predicates, eventlog.IndexLT(*i.IndexLT)) - } - if i.IndexLTE != nil { - predicates = append(predicates, eventlog.IndexLTE(*i.IndexLTE)) - } - if i.Event != nil { - predicates = append(predicates, eventlog.EventEQ(*i.Event)) - } - if i.EventNEQ != nil { - predicates = append(predicates, eventlog.EventNEQ(*i.EventNEQ)) - } - if len(i.EventIn) > 0 { - predicates = append(predicates, eventlog.EventIn(i.EventIn...)) - } - if len(i.EventNotIn) > 0 { - predicates = append(predicates, eventlog.EventNotIn(i.EventNotIn...)) - } - if i.EventGT != nil { - predicates = append(predicates, eventlog.EventGT(*i.EventGT)) - } - if i.EventGTE != nil { - predicates = append(predicates, eventlog.EventGTE(*i.EventGTE)) - } - if i.EventLT != nil { - predicates = append(predicates, eventlog.EventLT(*i.EventLT)) - } - if i.EventLTE != nil { - predicates = append(predicates, eventlog.EventLTE(*i.EventLTE)) - } - if i.EventContains != nil { - predicates = append(predicates, eventlog.EventContains(*i.EventContains)) - } - if i.EventHasPrefix != nil { - predicates = append(predicates, eventlog.EventHasPrefix(*i.EventHasPrefix)) - } - if i.EventHasSuffix != nil { - predicates = append(predicates, eventlog.EventHasSuffix(*i.EventHasSuffix)) - } - if i.EventEqualFold != nil { - predicates = append(predicates, eventlog.EventEqualFold(*i.EventEqualFold)) - } - if i.EventContainsFold != nil { - predicates = append(predicates, eventlog.EventContainsFold(*i.EventContainsFold)) - } - if i.Consensus != nil { - predicates = append(predicates, eventlog.ConsensusEQ(*i.Consensus)) - } - if i.ConsensusNEQ != nil { - predicates = append(predicates, eventlog.ConsensusNEQ(*i.ConsensusNEQ)) - } - if i.Voted != nil { - predicates = append(predicates, eventlog.VotedEQ(i.Voted)) - } - if i.VotedNEQ != nil { - predicates = append(predicates, eventlog.VotedNEQ(i.VotedNEQ)) - } - if len(i.VotedIn) > 0 { - predicates = append(predicates, eventlog.VotedIn(i.VotedIn...)) - } - if len(i.VotedNotIn) > 0 { - predicates = append(predicates, eventlog.VotedNotIn(i.VotedNotIn...)) - } - if i.VotedGT != nil { - predicates = append(predicates, eventlog.VotedGT(i.VotedGT)) - } - if i.VotedGTE != nil { - predicates = append(predicates, eventlog.VotedGTE(i.VotedGTE)) - } - if i.VotedLT != nil { - predicates = append(predicates, eventlog.VotedLT(i.VotedLT)) - } - if i.VotedLTE != nil { - predicates = append(predicates, eventlog.VotedLTE(i.VotedLTE)) - } - - if i.HasSigners != nil { - p := eventlog.HasSigners() - if !*i.HasSigners { - p = eventlog.Not(p) - } - predicates = append(predicates, p) - } - if len(i.HasSignersWith) > 0 { - with := make([]predicate.Signer, 0, len(i.HasSignersWith)) - for _, w := range i.HasSignersWith { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'HasSignersWith'", err) - } - with = append(with, p) - } - predicates = append(predicates, eventlog.HasSignersWith(with...)) - } - switch len(predicates) { - case 0: - return nil, ErrEmptyEventLogWhereInput - case 1: - return predicates[0], nil - default: - return eventlog.And(predicates...), nil - } -} - -// SignerWhereInput represents a where input for filtering Signer queries. -type SignerWhereInput struct { - Predicates []predicate.Signer `json:"-"` - Not *SignerWhereInput `json:"not,omitempty"` - Or []*SignerWhereInput `json:"or,omitempty"` - And []*SignerWhereInput `json:"and,omitempty"` - - // "id" field predicates. - ID *int `json:"id,omitempty"` - IDNEQ *int `json:"idNEQ,omitempty"` - IDIn []int `json:"idIn,omitempty"` - IDNotIn []int `json:"idNotIn,omitempty"` - IDGT *int `json:"idGT,omitempty"` - IDGTE *int `json:"idGTE,omitempty"` - IDLT *int `json:"idLT,omitempty"` - IDLTE *int `json:"idLTE,omitempty"` - - // "name" field predicates. - Name *string `json:"name,omitempty"` - NameNEQ *string `json:"nameNEQ,omitempty"` - NameIn []string `json:"nameIn,omitempty"` - NameNotIn []string `json:"nameNotIn,omitempty"` - NameGT *string `json:"nameGT,omitempty"` - NameGTE *string `json:"nameGTE,omitempty"` - NameLT *string `json:"nameLT,omitempty"` - NameLTE *string `json:"nameLTE,omitempty"` - NameContains *string `json:"nameContains,omitempty"` - NameHasPrefix *string `json:"nameHasPrefix,omitempty"` - NameHasSuffix *string `json:"nameHasSuffix,omitempty"` - NameEqualFold *string `json:"nameEqualFold,omitempty"` - NameContainsFold *string `json:"nameContainsFold,omitempty"` - - // "evm" field predicates. - Evm *string `json:"evm,omitempty"` - EvmNEQ *string `json:"evmNEQ,omitempty"` - EvmIn []string `json:"evmIn,omitempty"` - EvmNotIn []string `json:"evmNotIn,omitempty"` - EvmGT *string `json:"evmGT,omitempty"` - EvmGTE *string `json:"evmGTE,omitempty"` - EvmLT *string `json:"evmLT,omitempty"` - EvmLTE *string `json:"evmLTE,omitempty"` - EvmContains *string `json:"evmContains,omitempty"` - EvmHasPrefix *string `json:"evmHasPrefix,omitempty"` - EvmHasSuffix *string `json:"evmHasSuffix,omitempty"` - EvmIsNil bool `json:"evmIsNil,omitempty"` - EvmNotNil bool `json:"evmNotNil,omitempty"` - EvmEqualFold *string `json:"evmEqualFold,omitempty"` - EvmContainsFold *string `json:"evmContainsFold,omitempty"` - - // "points" field predicates. - Points *int64 `json:"points,omitempty"` - PointsNEQ *int64 `json:"pointsNEQ,omitempty"` - PointsIn []int64 `json:"pointsIn,omitempty"` - PointsNotIn []int64 `json:"pointsNotIn,omitempty"` - PointsGT *int64 `json:"pointsGT,omitempty"` - PointsGTE *int64 `json:"pointsGTE,omitempty"` - PointsLT *int64 `json:"pointsLT,omitempty"` - PointsLTE *int64 `json:"pointsLTE,omitempty"` - - // "assetPrice" edge predicates. - HasAssetPrice *bool `json:"hasAssetPrice,omitempty"` - HasAssetPriceWith []*AssetPriceWhereInput `json:"hasAssetPriceWith,omitempty"` - - // "eventLogs" edge predicates. - HasEventLogs *bool `json:"hasEventLogs,omitempty"` - HasEventLogsWith []*EventLogWhereInput `json:"hasEventLogsWith,omitempty"` - - // "correctnessReport" edge predicates. - HasCorrectnessReport *bool `json:"hasCorrectnessReport,omitempty"` - HasCorrectnessReportWith []*CorrectnessReportWhereInput `json:"hasCorrectnessReportWith,omitempty"` -} - -// AddPredicates adds custom predicates to the where input to be used during the filtering phase. -func (i *SignerWhereInput) AddPredicates(predicates ...predicate.Signer) { - i.Predicates = append(i.Predicates, predicates...) -} - -// Filter applies the SignerWhereInput filter on the SignerQuery builder. -func (i *SignerWhereInput) Filter(q *SignerQuery) (*SignerQuery, error) { - if i == nil { - return q, nil - } - p, err := i.P() - if err != nil { - if err == ErrEmptySignerWhereInput { - return q, nil - } - return nil, err - } - return q.Where(p), nil -} - -// ErrEmptySignerWhereInput is returned in case the SignerWhereInput is empty. -var ErrEmptySignerWhereInput = errors.New("ent: empty predicate SignerWhereInput") - -// P returns a predicate for filtering signers. -// An error is returned if the input is empty or invalid. -func (i *SignerWhereInput) P() (predicate.Signer, error) { - var predicates []predicate.Signer - if i.Not != nil { - p, err := i.Not.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'not'", err) - } - predicates = append(predicates, signer.Not(p)) - } - switch n := len(i.Or); { - case n == 1: - p, err := i.Or[0].P() - if err != nil { - return nil, fmt.Errorf("%w: field 'or'", err) - } - predicates = append(predicates, p) - case n > 1: - or := make([]predicate.Signer, 0, n) - for _, w := range i.Or { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'or'", err) - } - or = append(or, p) - } - predicates = append(predicates, signer.Or(or...)) - } - switch n := len(i.And); { - case n == 1: - p, err := i.And[0].P() - if err != nil { - return nil, fmt.Errorf("%w: field 'and'", err) - } - predicates = append(predicates, p) - case n > 1: - and := make([]predicate.Signer, 0, n) - for _, w := range i.And { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'and'", err) - } - and = append(and, p) - } - predicates = append(predicates, signer.And(and...)) - } - predicates = append(predicates, i.Predicates...) - if i.ID != nil { - predicates = append(predicates, signer.IDEQ(*i.ID)) - } - if i.IDNEQ != nil { - predicates = append(predicates, signer.IDNEQ(*i.IDNEQ)) - } - if len(i.IDIn) > 0 { - predicates = append(predicates, signer.IDIn(i.IDIn...)) - } - if len(i.IDNotIn) > 0 { - predicates = append(predicates, signer.IDNotIn(i.IDNotIn...)) - } - if i.IDGT != nil { - predicates = append(predicates, signer.IDGT(*i.IDGT)) - } - if i.IDGTE != nil { - predicates = append(predicates, signer.IDGTE(*i.IDGTE)) - } - if i.IDLT != nil { - predicates = append(predicates, signer.IDLT(*i.IDLT)) - } - if i.IDLTE != nil { - predicates = append(predicates, signer.IDLTE(*i.IDLTE)) - } - if i.Name != nil { - predicates = append(predicates, signer.NameEQ(*i.Name)) - } - if i.NameNEQ != nil { - predicates = append(predicates, signer.NameNEQ(*i.NameNEQ)) - } - if len(i.NameIn) > 0 { - predicates = append(predicates, signer.NameIn(i.NameIn...)) - } - if len(i.NameNotIn) > 0 { - predicates = append(predicates, signer.NameNotIn(i.NameNotIn...)) - } - if i.NameGT != nil { - predicates = append(predicates, signer.NameGT(*i.NameGT)) - } - if i.NameGTE != nil { - predicates = append(predicates, signer.NameGTE(*i.NameGTE)) - } - if i.NameLT != nil { - predicates = append(predicates, signer.NameLT(*i.NameLT)) - } - if i.NameLTE != nil { - predicates = append(predicates, signer.NameLTE(*i.NameLTE)) - } - if i.NameContains != nil { - predicates = append(predicates, signer.NameContains(*i.NameContains)) - } - if i.NameHasPrefix != nil { - predicates = append(predicates, signer.NameHasPrefix(*i.NameHasPrefix)) - } - if i.NameHasSuffix != nil { - predicates = append(predicates, signer.NameHasSuffix(*i.NameHasSuffix)) - } - if i.NameEqualFold != nil { - predicates = append(predicates, signer.NameEqualFold(*i.NameEqualFold)) - } - if i.NameContainsFold != nil { - predicates = append(predicates, signer.NameContainsFold(*i.NameContainsFold)) - } - if i.Evm != nil { - predicates = append(predicates, signer.EvmEQ(*i.Evm)) - } - if i.EvmNEQ != nil { - predicates = append(predicates, signer.EvmNEQ(*i.EvmNEQ)) - } - if len(i.EvmIn) > 0 { - predicates = append(predicates, signer.EvmIn(i.EvmIn...)) - } - if len(i.EvmNotIn) > 0 { - predicates = append(predicates, signer.EvmNotIn(i.EvmNotIn...)) - } - if i.EvmGT != nil { - predicates = append(predicates, signer.EvmGT(*i.EvmGT)) - } - if i.EvmGTE != nil { - predicates = append(predicates, signer.EvmGTE(*i.EvmGTE)) - } - if i.EvmLT != nil { - predicates = append(predicates, signer.EvmLT(*i.EvmLT)) - } - if i.EvmLTE != nil { - predicates = append(predicates, signer.EvmLTE(*i.EvmLTE)) - } - if i.EvmContains != nil { - predicates = append(predicates, signer.EvmContains(*i.EvmContains)) - } - if i.EvmHasPrefix != nil { - predicates = append(predicates, signer.EvmHasPrefix(*i.EvmHasPrefix)) - } - if i.EvmHasSuffix != nil { - predicates = append(predicates, signer.EvmHasSuffix(*i.EvmHasSuffix)) - } - if i.EvmIsNil { - predicates = append(predicates, signer.EvmIsNil()) - } - if i.EvmNotNil { - predicates = append(predicates, signer.EvmNotNil()) - } - if i.EvmEqualFold != nil { - predicates = append(predicates, signer.EvmEqualFold(*i.EvmEqualFold)) - } - if i.EvmContainsFold != nil { - predicates = append(predicates, signer.EvmContainsFold(*i.EvmContainsFold)) - } - if i.Points != nil { - predicates = append(predicates, signer.PointsEQ(*i.Points)) - } - if i.PointsNEQ != nil { - predicates = append(predicates, signer.PointsNEQ(*i.PointsNEQ)) - } - if len(i.PointsIn) > 0 { - predicates = append(predicates, signer.PointsIn(i.PointsIn...)) - } - if len(i.PointsNotIn) > 0 { - predicates = append(predicates, signer.PointsNotIn(i.PointsNotIn...)) - } - if i.PointsGT != nil { - predicates = append(predicates, signer.PointsGT(*i.PointsGT)) - } - if i.PointsGTE != nil { - predicates = append(predicates, signer.PointsGTE(*i.PointsGTE)) - } - if i.PointsLT != nil { - predicates = append(predicates, signer.PointsLT(*i.PointsLT)) - } - if i.PointsLTE != nil { - predicates = append(predicates, signer.PointsLTE(*i.PointsLTE)) - } - - if i.HasAssetPrice != nil { - p := signer.HasAssetPrice() - if !*i.HasAssetPrice { - p = signer.Not(p) - } - predicates = append(predicates, p) - } - if len(i.HasAssetPriceWith) > 0 { - with := make([]predicate.AssetPrice, 0, len(i.HasAssetPriceWith)) - for _, w := range i.HasAssetPriceWith { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'HasAssetPriceWith'", err) - } - with = append(with, p) - } - predicates = append(predicates, signer.HasAssetPriceWith(with...)) - } - if i.HasEventLogs != nil { - p := signer.HasEventLogs() - if !*i.HasEventLogs { - p = signer.Not(p) - } - predicates = append(predicates, p) - } - if len(i.HasEventLogsWith) > 0 { - with := make([]predicate.EventLog, 0, len(i.HasEventLogsWith)) - for _, w := range i.HasEventLogsWith { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'HasEventLogsWith'", err) - } - with = append(with, p) - } - predicates = append(predicates, signer.HasEventLogsWith(with...)) - } - if i.HasCorrectnessReport != nil { - p := signer.HasCorrectnessReport() - if !*i.HasCorrectnessReport { - p = signer.Not(p) - } - predicates = append(predicates, p) - } - if len(i.HasCorrectnessReportWith) > 0 { - with := make([]predicate.CorrectnessReport, 0, len(i.HasCorrectnessReportWith)) - for _, w := range i.HasCorrectnessReportWith { - p, err := w.P() - if err != nil { - return nil, fmt.Errorf("%w: field 'HasCorrectnessReportWith'", err) - } - with = append(with, p) - } - predicates = append(predicates, signer.HasCorrectnessReportWith(with...)) - } - switch len(predicates) { - case 0: - return nil, ErrEmptySignerWhereInput - case 1: - return predicates[0], nil - default: - return signer.And(predicates...), nil - } -} diff --git a/internal/ent/helpers/bigint.go b/internal/ent/helpers/bigint.go deleted file mode 100644 index 4510de16..00000000 --- a/internal/ent/helpers/bigint.go +++ /dev/null @@ -1,34 +0,0 @@ -package helpers - -import ( - "database/sql" - "database/sql/driver" - "fmt" - "math/big" -) - -type BigInt struct { - big.Int -} - -const ( - BaseOfNumbers = 10 -) - -func (b *BigInt) Scan(src any) error { - var i sql.NullString - if err := i.Scan(src); err != nil { - return err - } - if !i.Valid { - return nil - } - if _, ok := b.Int.SetString(i.String, BaseOfNumbers); ok { - return nil - } - return fmt.Errorf("could not scan type %T with value %v into BigInt", src, src) -} - -func (b *BigInt) Value() (driver.Value, error) { - return b.String(), nil -} diff --git a/internal/ent/hook/hook.go b/internal/ent/hook/hook.go deleted file mode 100644 index cd8a4b49..00000000 --- a/internal/ent/hook/hook.go +++ /dev/null @@ -1,235 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package hook - -import ( - "context" - "fmt" - - "github.com/TimeleapLabs/unchained/internal/ent" -) - -// The AssetPriceFunc type is an adapter to allow the use of ordinary -// function as AssetPrice mutator. -type AssetPriceFunc func(context.Context, *ent.AssetPriceMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f AssetPriceFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.AssetPriceMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AssetPriceMutation", m) -} - -// The CorrectnessReportFunc type is an adapter to allow the use of ordinary -// function as CorrectnessReport mutator. -type CorrectnessReportFunc func(context.Context, *ent.CorrectnessReportMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f CorrectnessReportFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.CorrectnessReportMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.CorrectnessReportMutation", m) -} - -// The EventLogFunc type is an adapter to allow the use of ordinary -// function as EventLog mutator. -type EventLogFunc func(context.Context, *ent.EventLogMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f EventLogFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.EventLogMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EventLogMutation", m) -} - -// The SignerFunc type is an adapter to allow the use of ordinary -// function as Signer mutator. -type SignerFunc func(context.Context, *ent.SignerMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f SignerFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.SignerMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SignerMutation", 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/internal/ent/migrate/migrate.go b/internal/ent/migrate/migrate.go deleted file mode 100644 index 1956a6bf..00000000 --- a/internal/ent/migrate/migrate.go +++ /dev/null @@ -1,64 +0,0 @@ -// 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/internal/ent/migrate/schema.go b/internal/ent/migrate/schema.go deleted file mode 100644 index 0ae7b317..00000000 --- a/internal/ent/migrate/schema.go +++ /dev/null @@ -1,226 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package migrate - -import ( - "entgo.io/ent/dialect/sql/schema" - "entgo.io/ent/schema/field" -) - -var ( - // AssetPricesColumns holds the columns for the "asset_prices" table. - AssetPricesColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, - {Name: "block", Type: field.TypeUint64}, - {Name: "signers_count", Type: field.TypeUint64, Nullable: true}, - {Name: "price", Type: field.TypeUint, SchemaType: map[string]string{"postgres": "numeric(78, 0)", "sqlite3": "numeric(78, 0)"}}, - {Name: "signature", Type: field.TypeBytes, Size: 48}, - {Name: "asset", Type: field.TypeString, Nullable: true}, - {Name: "chain", Type: field.TypeString, Nullable: true}, - {Name: "pair", Type: field.TypeString, Nullable: true}, - {Name: "consensus", Type: field.TypeBool, Default: false}, - {Name: "voted", Type: field.TypeUint, SchemaType: map[string]string{"postgres": "numeric(78, 0)", "sqlite3": "numeric(78, 0)"}}, - } - // AssetPricesTable holds the schema information for the "asset_prices" table. - AssetPricesTable = &schema.Table{ - Name: "asset_prices", - Columns: AssetPricesColumns, - PrimaryKey: []*schema.Column{AssetPricesColumns[0]}, - Indexes: []*schema.Index{ - { - Name: "assetprice_block_chain_asset_pair", - Unique: true, - Columns: []*schema.Column{AssetPricesColumns[1], AssetPricesColumns[6], AssetPricesColumns[5], AssetPricesColumns[7]}, - }, - { - Name: "assetprice_block_chain_asset_pair_price_consensus", - Unique: false, - Columns: []*schema.Column{AssetPricesColumns[1], AssetPricesColumns[6], AssetPricesColumns[5], AssetPricesColumns[7], AssetPricesColumns[3], AssetPricesColumns[8]}, - }, - }, - } - // CorrectnessReportsColumns holds the columns for the "correctness_reports" table. - CorrectnessReportsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, - {Name: "signers_count", Type: field.TypeUint64}, - {Name: "timestamp", Type: field.TypeUint64}, - {Name: "signature", Type: field.TypeBytes, Size: 48}, - {Name: "hash", Type: field.TypeBytes, Size: 64}, - {Name: "topic", Type: field.TypeBytes, Size: 64}, - {Name: "correct", Type: field.TypeBool}, - {Name: "consensus", Type: field.TypeBool, Default: false}, - {Name: "voted", Type: field.TypeUint, SchemaType: map[string]string{"postgres": "numeric(78, 0)", "sqlite3": "numeric(78, 0)"}}, - } - // CorrectnessReportsTable holds the schema information for the "correctness_reports" table. - CorrectnessReportsTable = &schema.Table{ - Name: "correctness_reports", - Columns: CorrectnessReportsColumns, - PrimaryKey: []*schema.Column{CorrectnessReportsColumns[0]}, - Indexes: []*schema.Index{ - { - Name: "correctnessreport_topic_hash", - Unique: true, - Columns: []*schema.Column{CorrectnessReportsColumns[5], CorrectnessReportsColumns[4]}, - }, - { - Name: "correctnessreport_topic_timestamp_hash", - Unique: false, - Columns: []*schema.Column{CorrectnessReportsColumns[5], CorrectnessReportsColumns[2], CorrectnessReportsColumns[4]}, - }, - }, - } - // EventLogsColumns holds the columns for the "event_logs" table. - EventLogsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, - {Name: "block", Type: field.TypeUint64}, - {Name: "signers_count", Type: field.TypeUint64}, - {Name: "signature", Type: field.TypeBytes, Size: 48}, - {Name: "address", Type: field.TypeString}, - {Name: "chain", Type: field.TypeString}, - {Name: "index", Type: field.TypeUint64}, - {Name: "event", Type: field.TypeString}, - {Name: "transaction", Type: field.TypeBytes, Size: 32}, - {Name: "args", Type: field.TypeJSON}, - {Name: "consensus", Type: field.TypeBool, Default: false}, - {Name: "voted", Type: field.TypeUint, SchemaType: map[string]string{"postgres": "numeric(78, 0)", "sqlite3": "numeric(78, 0)"}}, - } - // EventLogsTable holds the schema information for the "event_logs" table. - EventLogsTable = &schema.Table{ - Name: "event_logs", - Columns: EventLogsColumns, - PrimaryKey: []*schema.Column{EventLogsColumns[0]}, - Indexes: []*schema.Index{ - { - Name: "eventlog_block_transaction_index", - Unique: true, - Columns: []*schema.Column{EventLogsColumns[1], EventLogsColumns[8], EventLogsColumns[6]}, - }, - { - Name: "eventlog_block_address_event_consensus", - Unique: false, - Columns: []*schema.Column{EventLogsColumns[1], EventLogsColumns[4], EventLogsColumns[7], EventLogsColumns[10]}, - }, - }, - } - // SignersColumns holds the columns for the "signers" table. - SignersColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, - {Name: "name", Type: field.TypeString}, - {Name: "evm", Type: field.TypeString, Nullable: true}, - {Name: "key", Type: field.TypeBytes, Unique: true, Size: 96}, - {Name: "shortkey", Type: field.TypeBytes, Unique: true, Size: 96}, - {Name: "points", Type: field.TypeInt64}, - } - // SignersTable holds the schema information for the "signers" table. - SignersTable = &schema.Table{ - Name: "signers", - Columns: SignersColumns, - PrimaryKey: []*schema.Column{SignersColumns[0]}, - Indexes: []*schema.Index{ - { - Name: "signer_key", - Unique: true, - Columns: []*schema.Column{SignersColumns[3]}, - }, - { - Name: "signer_shortkey", - Unique: true, - Columns: []*schema.Column{SignersColumns[4]}, - }, - }, - } - // AssetPriceSignersColumns holds the columns for the "asset_price_signers" table. - AssetPriceSignersColumns = []*schema.Column{ - {Name: "asset_price_id", Type: field.TypeInt}, - {Name: "signer_id", Type: field.TypeInt}, - } - // AssetPriceSignersTable holds the schema information for the "asset_price_signers" table. - AssetPriceSignersTable = &schema.Table{ - Name: "asset_price_signers", - Columns: AssetPriceSignersColumns, - PrimaryKey: []*schema.Column{AssetPriceSignersColumns[0], AssetPriceSignersColumns[1]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "asset_price_signers_asset_price_id", - Columns: []*schema.Column{AssetPriceSignersColumns[0]}, - RefColumns: []*schema.Column{AssetPricesColumns[0]}, - OnDelete: schema.Cascade, - }, - { - Symbol: "asset_price_signers_signer_id", - Columns: []*schema.Column{AssetPriceSignersColumns[1]}, - RefColumns: []*schema.Column{SignersColumns[0]}, - OnDelete: schema.Cascade, - }, - }, - } - // CorrectnessReportSignersColumns holds the columns for the "correctness_report_signers" table. - CorrectnessReportSignersColumns = []*schema.Column{ - {Name: "correctness_report_id", Type: field.TypeInt}, - {Name: "signer_id", Type: field.TypeInt}, - } - // CorrectnessReportSignersTable holds the schema information for the "correctness_report_signers" table. - CorrectnessReportSignersTable = &schema.Table{ - Name: "correctness_report_signers", - Columns: CorrectnessReportSignersColumns, - PrimaryKey: []*schema.Column{CorrectnessReportSignersColumns[0], CorrectnessReportSignersColumns[1]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "correctness_report_signers_correctness_report_id", - Columns: []*schema.Column{CorrectnessReportSignersColumns[0]}, - RefColumns: []*schema.Column{CorrectnessReportsColumns[0]}, - OnDelete: schema.Cascade, - }, - { - Symbol: "correctness_report_signers_signer_id", - Columns: []*schema.Column{CorrectnessReportSignersColumns[1]}, - RefColumns: []*schema.Column{SignersColumns[0]}, - OnDelete: schema.Cascade, - }, - }, - } - // EventLogSignersColumns holds the columns for the "event_log_signers" table. - EventLogSignersColumns = []*schema.Column{ - {Name: "event_log_id", Type: field.TypeInt}, - {Name: "signer_id", Type: field.TypeInt}, - } - // EventLogSignersTable holds the schema information for the "event_log_signers" table. - EventLogSignersTable = &schema.Table{ - Name: "event_log_signers", - Columns: EventLogSignersColumns, - PrimaryKey: []*schema.Column{EventLogSignersColumns[0], EventLogSignersColumns[1]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "event_log_signers_event_log_id", - Columns: []*schema.Column{EventLogSignersColumns[0]}, - RefColumns: []*schema.Column{EventLogsColumns[0]}, - OnDelete: schema.Cascade, - }, - { - Symbol: "event_log_signers_signer_id", - Columns: []*schema.Column{EventLogSignersColumns[1]}, - RefColumns: []*schema.Column{SignersColumns[0]}, - OnDelete: schema.Cascade, - }, - }, - } - // Tables holds all the tables in the schema. - Tables = []*schema.Table{ - AssetPricesTable, - CorrectnessReportsTable, - EventLogsTable, - SignersTable, - AssetPriceSignersTable, - CorrectnessReportSignersTable, - EventLogSignersTable, - } -) - -func init() { - AssetPriceSignersTable.ForeignKeys[0].RefTable = AssetPricesTable - AssetPriceSignersTable.ForeignKeys[1].RefTable = SignersTable - CorrectnessReportSignersTable.ForeignKeys[0].RefTable = CorrectnessReportsTable - CorrectnessReportSignersTable.ForeignKeys[1].RefTable = SignersTable - EventLogSignersTable.ForeignKeys[0].RefTable = EventLogsTable - EventLogSignersTable.ForeignKeys[1].RefTable = SignersTable -} diff --git a/internal/ent/mutation.go b/internal/ent/mutation.go deleted file mode 100644 index ddcde87d..00000000 --- a/internal/ent/mutation.go +++ /dev/null @@ -1,3837 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "github.com/TimeleapLabs/unchained/internal/model" - "sync" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -const ( - // Operation types. - OpCreate = ent.OpCreate - OpDelete = ent.OpDelete - OpDeleteOne = ent.OpDeleteOne - OpUpdate = ent.OpUpdate - OpUpdateOne = ent.OpUpdateOne - - // Node types. - TypeAssetPrice = "AssetPrice" - TypeCorrectnessReport = "CorrectnessReport" - TypeEventLog = "EventLog" - TypeSigner = "Signer" -) - -// AssetPriceMutation represents an operation that mutates the AssetPrice nodes in the graph. -type AssetPriceMutation struct { - config - op Op - typ string - id *int - block *uint64 - addblock *int64 - signersCount *uint64 - addsignersCount *int64 - price **helpers.BigInt - signature *[]byte - asset *string - chain *string - pair *string - consensus *bool - voted **helpers.BigInt - clearedFields map[string]struct{} - signers map[int]struct{} - removedsigners map[int]struct{} - clearedsigners bool - done bool - oldValue func(context.Context) (*AssetPrice, error) - predicates []predicate.AssetPrice -} - -var _ ent.Mutation = (*AssetPriceMutation)(nil) - -// assetpriceOption allows management of the mutation configuration using functional options. -type assetpriceOption func(*AssetPriceMutation) - -// newAssetPriceMutation creates new mutation for the AssetPrice entity. -func newAssetPriceMutation(c config, op Op, opts ...assetpriceOption) *AssetPriceMutation { - m := &AssetPriceMutation{ - config: c, - op: op, - typ: TypeAssetPrice, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withAssetPriceID sets the ID field of the mutation. -func withAssetPriceID(id int) assetpriceOption { - return func(m *AssetPriceMutation) { - var ( - err error - once sync.Once - value *AssetPrice - ) - m.oldValue = func(ctx context.Context) (*AssetPrice, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().AssetPrice.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withAssetPrice sets the old AssetPrice of the mutation. -func withAssetPrice(node *AssetPrice) assetpriceOption { - return func(m *AssetPriceMutation) { - m.oldValue = func(context.Context) (*AssetPrice, 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 AssetPriceMutation) 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 AssetPriceMutation) 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 *AssetPriceMutation) 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 *AssetPriceMutation) 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().AssetPrice.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetBlock sets the "block" field. -func (m *AssetPriceMutation) SetBlock(u uint64) { - m.block = &u - m.addblock = nil -} - -// Block returns the value of the "block" field in the mutation. -func (m *AssetPriceMutation) Block() (r uint64, exists bool) { - v := m.block - if v == nil { - return - } - return *v, true -} - -// OldBlock returns the old "block" field's value of the AssetPrice entity. -// If the AssetPrice 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 *AssetPriceMutation) OldBlock(ctx context.Context) (v uint64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBlock is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBlock requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldBlock: %w", err) - } - return oldValue.Block, nil -} - -// AddBlock adds u to the "block" field. -func (m *AssetPriceMutation) AddBlock(u int64) { - if m.addblock != nil { - *m.addblock += u - } else { - m.addblock = &u - } -} - -// AddedBlock returns the value that was added to the "block" field in this mutation. -func (m *AssetPriceMutation) AddedBlock() (r int64, exists bool) { - v := m.addblock - if v == nil { - return - } - return *v, true -} - -// ResetBlock resets all changes to the "block" field. -func (m *AssetPriceMutation) ResetBlock() { - m.block = nil - m.addblock = nil -} - -// SetSignersCount sets the "signersCount" field. -func (m *AssetPriceMutation) SetSignersCount(u uint64) { - m.signersCount = &u - m.addsignersCount = nil -} - -// SignersCount returns the value of the "signersCount" field in the mutation. -func (m *AssetPriceMutation) SignersCount() (r uint64, exists bool) { - v := m.signersCount - if v == nil { - return - } - return *v, true -} - -// OldSignersCount returns the old "signersCount" field's value of the AssetPrice entity. -// If the AssetPrice 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 *AssetPriceMutation) OldSignersCount(ctx context.Context) (v *uint64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSignersCount is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSignersCount requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSignersCount: %w", err) - } - return oldValue.SignersCount, nil -} - -// AddSignersCount adds u to the "signersCount" field. -func (m *AssetPriceMutation) AddSignersCount(u int64) { - if m.addsignersCount != nil { - *m.addsignersCount += u - } else { - m.addsignersCount = &u - } -} - -// AddedSignersCount returns the value that was added to the "signersCount" field in this mutation. -func (m *AssetPriceMutation) AddedSignersCount() (r int64, exists bool) { - v := m.addsignersCount - if v == nil { - return - } - return *v, true -} - -// ClearSignersCount clears the value of the "signersCount" field. -func (m *AssetPriceMutation) ClearSignersCount() { - m.signersCount = nil - m.addsignersCount = nil - m.clearedFields[assetprice.FieldSignersCount] = struct{}{} -} - -// SignersCountCleared returns if the "signersCount" field was cleared in this mutation. -func (m *AssetPriceMutation) SignersCountCleared() bool { - _, ok := m.clearedFields[assetprice.FieldSignersCount] - return ok -} - -// ResetSignersCount resets all changes to the "signersCount" field. -func (m *AssetPriceMutation) ResetSignersCount() { - m.signersCount = nil - m.addsignersCount = nil - delete(m.clearedFields, assetprice.FieldSignersCount) -} - -// SetPrice sets the "price" field. -func (m *AssetPriceMutation) SetPrice(hi *helpers.BigInt) { - m.price = &hi -} - -// Price returns the value of the "price" field in the mutation. -func (m *AssetPriceMutation) Price() (r *helpers.BigInt, exists bool) { - v := m.price - if v == nil { - return - } - return *v, true -} - -// OldPrice returns the old "price" field's value of the AssetPrice entity. -// If the AssetPrice 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 *AssetPriceMutation) OldPrice(ctx context.Context) (v *helpers.BigInt, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPrice is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPrice requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPrice: %w", err) - } - return oldValue.Price, nil -} - -// ResetPrice resets all changes to the "price" field. -func (m *AssetPriceMutation) ResetPrice() { - m.price = nil -} - -// SetSignature sets the "signature" field. -func (m *AssetPriceMutation) SetSignature(b []byte) { - m.signature = &b -} - -// Signature returns the value of the "signature" field in the mutation. -func (m *AssetPriceMutation) Signature() (r []byte, exists bool) { - v := m.signature - if v == nil { - return - } - return *v, true -} - -// OldSignature returns the old "signature" field's value of the AssetPrice entity. -// If the AssetPrice 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 *AssetPriceMutation) OldSignature(ctx context.Context) (v []byte, 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 *AssetPriceMutation) ResetSignature() { - m.signature = nil -} - -// SetAsset sets the "asset" field. -func (m *AssetPriceMutation) SetAsset(s string) { - m.asset = &s -} - -// Asset returns the value of the "asset" field in the mutation. -func (m *AssetPriceMutation) Asset() (r string, exists bool) { - v := m.asset - if v == nil { - return - } - return *v, true -} - -// OldAsset returns the old "asset" field's value of the AssetPrice entity. -// If the AssetPrice 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 *AssetPriceMutation) OldAsset(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAsset is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAsset requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldAsset: %w", err) - } - return oldValue.Asset, nil -} - -// ClearAsset clears the value of the "asset" field. -func (m *AssetPriceMutation) ClearAsset() { - m.asset = nil - m.clearedFields[assetprice.FieldAsset] = struct{}{} -} - -// AssetCleared returns if the "asset" field was cleared in this mutation. -func (m *AssetPriceMutation) AssetCleared() bool { - _, ok := m.clearedFields[assetprice.FieldAsset] - return ok -} - -// ResetAsset resets all changes to the "asset" field. -func (m *AssetPriceMutation) ResetAsset() { - m.asset = nil - delete(m.clearedFields, assetprice.FieldAsset) -} - -// SetChain sets the "chain" field. -func (m *AssetPriceMutation) SetChain(s string) { - m.chain = &s -} - -// Chain returns the value of the "chain" field in the mutation. -func (m *AssetPriceMutation) Chain() (r string, exists bool) { - v := m.chain - if v == nil { - return - } - return *v, true -} - -// OldChain returns the old "chain" field's value of the AssetPrice entity. -// If the AssetPrice 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 *AssetPriceMutation) OldChain(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldChain is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldChain requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldChain: %w", err) - } - return oldValue.Chain, nil -} - -// ClearChain clears the value of the "chain" field. -func (m *AssetPriceMutation) ClearChain() { - m.chain = nil - m.clearedFields[assetprice.FieldChain] = struct{}{} -} - -// ChainCleared returns if the "chain" field was cleared in this mutation. -func (m *AssetPriceMutation) ChainCleared() bool { - _, ok := m.clearedFields[assetprice.FieldChain] - return ok -} - -// ResetChain resets all changes to the "chain" field. -func (m *AssetPriceMutation) ResetChain() { - m.chain = nil - delete(m.clearedFields, assetprice.FieldChain) -} - -// SetPair sets the "pair" field. -func (m *AssetPriceMutation) SetPair(s string) { - m.pair = &s -} - -// Pair returns the value of the "pair" field in the mutation. -func (m *AssetPriceMutation) Pair() (r string, exists bool) { - v := m.pair - if v == nil { - return - } - return *v, true -} - -// OldPair returns the old "pair" field's value of the AssetPrice entity. -// If the AssetPrice 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 *AssetPriceMutation) OldPair(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPair is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPair requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPair: %w", err) - } - return oldValue.Pair, nil -} - -// ClearPair clears the value of the "pair" field. -func (m *AssetPriceMutation) ClearPair() { - m.pair = nil - m.clearedFields[assetprice.FieldPair] = struct{}{} -} - -// PairCleared returns if the "pair" field was cleared in this mutation. -func (m *AssetPriceMutation) PairCleared() bool { - _, ok := m.clearedFields[assetprice.FieldPair] - return ok -} - -// ResetPair resets all changes to the "pair" field. -func (m *AssetPriceMutation) ResetPair() { - m.pair = nil - delete(m.clearedFields, assetprice.FieldPair) -} - -// SetConsensus sets the "consensus" field. -func (m *AssetPriceMutation) SetConsensus(b bool) { - m.consensus = &b -} - -// Consensus returns the value of the "consensus" field in the mutation. -func (m *AssetPriceMutation) Consensus() (r bool, exists bool) { - v := m.consensus - if v == nil { - return - } - return *v, true -} - -// OldConsensus returns the old "consensus" field's value of the AssetPrice entity. -// If the AssetPrice 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 *AssetPriceMutation) OldConsensus(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldConsensus is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldConsensus requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldConsensus: %w", err) - } - return oldValue.Consensus, nil -} - -// ResetConsensus resets all changes to the "consensus" field. -func (m *AssetPriceMutation) ResetConsensus() { - m.consensus = nil -} - -// SetVoted sets the "voted" field. -func (m *AssetPriceMutation) SetVoted(hi *helpers.BigInt) { - m.voted = &hi -} - -// Voted returns the value of the "voted" field in the mutation. -func (m *AssetPriceMutation) Voted() (r *helpers.BigInt, exists bool) { - v := m.voted - if v == nil { - return - } - return *v, true -} - -// OldVoted returns the old "voted" field's value of the AssetPrice entity. -// If the AssetPrice 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 *AssetPriceMutation) OldVoted(ctx context.Context) (v *helpers.BigInt, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVoted is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVoted requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldVoted: %w", err) - } - return oldValue.Voted, nil -} - -// ResetVoted resets all changes to the "voted" field. -func (m *AssetPriceMutation) ResetVoted() { - m.voted = nil -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by ids. -func (m *AssetPriceMutation) AddSignerIDs(ids ...int) { - if m.signers == nil { - m.signers = make(map[int]struct{}) - } - for i := range ids { - m.signers[ids[i]] = struct{}{} - } -} - -// ClearSigners clears the "signers" edge to the Signer entity. -func (m *AssetPriceMutation) ClearSigners() { - m.clearedsigners = true -} - -// SignersCleared reports if the "signers" edge to the Signer entity was cleared. -func (m *AssetPriceMutation) SignersCleared() bool { - return m.clearedsigners -} - -// RemoveSignerIDs removes the "signers" edge to the Signer entity by IDs. -func (m *AssetPriceMutation) RemoveSignerIDs(ids ...int) { - if m.removedsigners == nil { - m.removedsigners = make(map[int]struct{}) - } - for i := range ids { - delete(m.signers, ids[i]) - m.removedsigners[ids[i]] = struct{}{} - } -} - -// RemovedSigners returns the removed IDs of the "signers" edge to the Signer entity. -func (m *AssetPriceMutation) RemovedSignersIDs() (ids []int) { - for id := range m.removedsigners { - ids = append(ids, id) - } - return -} - -// SignersIDs returns the "signers" edge IDs in the mutation. -func (m *AssetPriceMutation) SignersIDs() (ids []int) { - for id := range m.signers { - ids = append(ids, id) - } - return -} - -// ResetSigners resets all changes to the "signers" edge. -func (m *AssetPriceMutation) ResetSigners() { - m.signers = nil - m.clearedsigners = false - m.removedsigners = nil -} - -// Where appends a list predicates to the AssetPriceMutation builder. -func (m *AssetPriceMutation) Where(ps ...predicate.AssetPrice) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the AssetPriceMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *AssetPriceMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.AssetPrice, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *AssetPriceMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *AssetPriceMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (AssetPrice). -func (m *AssetPriceMutation) 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 *AssetPriceMutation) Fields() []string { - fields := make([]string, 0, 9) - if m.block != nil { - fields = append(fields, assetprice.FieldBlock) - } - if m.signersCount != nil { - fields = append(fields, assetprice.FieldSignersCount) - } - if m.price != nil { - fields = append(fields, assetprice.FieldPrice) - } - if m.signature != nil { - fields = append(fields, assetprice.FieldSignature) - } - if m.asset != nil { - fields = append(fields, assetprice.FieldAsset) - } - if m.chain != nil { - fields = append(fields, assetprice.FieldChain) - } - if m.pair != nil { - fields = append(fields, assetprice.FieldPair) - } - if m.consensus != nil { - fields = append(fields, assetprice.FieldConsensus) - } - if m.voted != nil { - fields = append(fields, assetprice.FieldVoted) - } - 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 *AssetPriceMutation) Field(name string) (ent.Value, bool) { - switch name { - case assetprice.FieldBlock: - return m.Block() - case assetprice.FieldSignersCount: - return m.SignersCount() - case assetprice.FieldPrice: - return m.Price() - case assetprice.FieldSignature: - return m.Signature() - case assetprice.FieldAsset: - return m.Asset() - case assetprice.FieldChain: - return m.Chain() - case assetprice.FieldPair: - return m.Pair() - case assetprice.FieldConsensus: - return m.Consensus() - case assetprice.FieldVoted: - return m.Voted() - } - 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 *AssetPriceMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case assetprice.FieldBlock: - return m.OldBlock(ctx) - case assetprice.FieldSignersCount: - return m.OldSignersCount(ctx) - case assetprice.FieldPrice: - return m.OldPrice(ctx) - case assetprice.FieldSignature: - return m.OldSignature(ctx) - case assetprice.FieldAsset: - return m.OldAsset(ctx) - case assetprice.FieldChain: - return m.OldChain(ctx) - case assetprice.FieldPair: - return m.OldPair(ctx) - case assetprice.FieldConsensus: - return m.OldConsensus(ctx) - case assetprice.FieldVoted: - return m.OldVoted(ctx) - } - return nil, fmt.Errorf("unknown AssetPrice 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 *AssetPriceMutation) SetField(name string, value ent.Value) error { - switch name { - case assetprice.FieldBlock: - v, ok := value.(uint64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetBlock(v) - return nil - case assetprice.FieldSignersCount: - v, ok := value.(uint64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSignersCount(v) - return nil - case assetprice.FieldPrice: - v, ok := value.(*helpers.BigInt) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPrice(v) - return nil - case assetprice.FieldSignature: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSignature(v) - return nil - case assetprice.FieldAsset: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAsset(v) - return nil - case assetprice.FieldChain: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetChain(v) - return nil - case assetprice.FieldPair: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPair(v) - return nil - case assetprice.FieldConsensus: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetConsensus(v) - return nil - case assetprice.FieldVoted: - v, ok := value.(*helpers.BigInt) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetVoted(v) - return nil - } - return fmt.Errorf("unknown AssetPrice field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *AssetPriceMutation) AddedFields() []string { - var fields []string - if m.addblock != nil { - fields = append(fields, assetprice.FieldBlock) - } - if m.addsignersCount != nil { - fields = append(fields, assetprice.FieldSignersCount) - } - 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 *AssetPriceMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case assetprice.FieldBlock: - return m.AddedBlock() - case assetprice.FieldSignersCount: - return m.AddedSignersCount() - } - 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 *AssetPriceMutation) AddField(name string, value ent.Value) error { - switch name { - case assetprice.FieldBlock: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddBlock(v) - return nil - case assetprice.FieldSignersCount: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddSignersCount(v) - return nil - } - return fmt.Errorf("unknown AssetPrice numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *AssetPriceMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(assetprice.FieldSignersCount) { - fields = append(fields, assetprice.FieldSignersCount) - } - if m.FieldCleared(assetprice.FieldAsset) { - fields = append(fields, assetprice.FieldAsset) - } - if m.FieldCleared(assetprice.FieldChain) { - fields = append(fields, assetprice.FieldChain) - } - if m.FieldCleared(assetprice.FieldPair) { - fields = append(fields, assetprice.FieldPair) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *AssetPriceMutation) 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 *AssetPriceMutation) ClearField(name string) error { - switch name { - case assetprice.FieldSignersCount: - m.ClearSignersCount() - return nil - case assetprice.FieldAsset: - m.ClearAsset() - return nil - case assetprice.FieldChain: - m.ClearChain() - return nil - case assetprice.FieldPair: - m.ClearPair() - return nil - } - return fmt.Errorf("unknown AssetPrice 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 *AssetPriceMutation) ResetField(name string) error { - switch name { - case assetprice.FieldBlock: - m.ResetBlock() - return nil - case assetprice.FieldSignersCount: - m.ResetSignersCount() - return nil - case assetprice.FieldPrice: - m.ResetPrice() - return nil - case assetprice.FieldSignature: - m.ResetSignature() - return nil - case assetprice.FieldAsset: - m.ResetAsset() - return nil - case assetprice.FieldChain: - m.ResetChain() - return nil - case assetprice.FieldPair: - m.ResetPair() - return nil - case assetprice.FieldConsensus: - m.ResetConsensus() - return nil - case assetprice.FieldVoted: - m.ResetVoted() - return nil - } - return fmt.Errorf("unknown AssetPrice field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *AssetPriceMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.signers != nil { - edges = append(edges, assetprice.EdgeSigners) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *AssetPriceMutation) AddedIDs(name string) []ent.Value { - switch name { - case assetprice.EdgeSigners: - ids := make([]ent.Value, 0, len(m.signers)) - for id := range m.signers { - ids = append(ids, id) - } - return ids - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *AssetPriceMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) - if m.removedsigners != nil { - edges = append(edges, assetprice.EdgeSigners) - } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *AssetPriceMutation) RemovedIDs(name string) []ent.Value { - switch name { - case assetprice.EdgeSigners: - ids := make([]ent.Value, 0, len(m.removedsigners)) - for id := range m.removedsigners { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *AssetPriceMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.clearedsigners { - edges = append(edges, assetprice.EdgeSigners) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *AssetPriceMutation) EdgeCleared(name string) bool { - switch name { - case assetprice.EdgeSigners: - return m.clearedsigners - } - 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 *AssetPriceMutation) ClearEdge(name string) error { - switch name { - } - return fmt.Errorf("unknown AssetPrice 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 *AssetPriceMutation) ResetEdge(name string) error { - switch name { - case assetprice.EdgeSigners: - m.ResetSigners() - return nil - } - return fmt.Errorf("unknown AssetPrice edge %s", name) -} - -// CorrectnessReportMutation represents an operation that mutates the CorrectnessReport nodes in the graph. -type CorrectnessReportMutation struct { - config - op Op - typ string - id *int - signersCount *uint64 - addsignersCount *int64 - timestamp *uint64 - addtimestamp *int64 - signature *[]byte - hash *[]byte - topic *[]byte - correct *bool - consensus *bool - voted **helpers.BigInt - clearedFields map[string]struct{} - signers map[int]struct{} - removedsigners map[int]struct{} - clearedsigners bool - done bool - oldValue func(context.Context) (*CorrectnessReport, error) - predicates []predicate.CorrectnessReport -} - -var _ ent.Mutation = (*CorrectnessReportMutation)(nil) - -// correctnessreportOption allows management of the mutation configuration using functional options. -type correctnessreportOption func(*CorrectnessReportMutation) - -// newCorrectnessReportMutation creates new mutation for the CorrectnessReport entity. -func newCorrectnessReportMutation(c config, op Op, opts ...correctnessreportOption) *CorrectnessReportMutation { - m := &CorrectnessReportMutation{ - config: c, - op: op, - typ: TypeCorrectnessReport, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withCorrectnessReportID sets the ID field of the mutation. -func withCorrectnessReportID(id int) correctnessreportOption { - return func(m *CorrectnessReportMutation) { - var ( - err error - once sync.Once - value *CorrectnessReport - ) - m.oldValue = func(ctx context.Context) (*CorrectnessReport, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().CorrectnessReport.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withCorrectnessReport sets the old CorrectnessReport of the mutation. -func withCorrectnessReport(node *CorrectnessReport) correctnessreportOption { - return func(m *CorrectnessReportMutation) { - m.oldValue = func(context.Context) (*CorrectnessReport, 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 CorrectnessReportMutation) 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 CorrectnessReportMutation) 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 *CorrectnessReportMutation) 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 *CorrectnessReportMutation) 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().CorrectnessReport.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetSignersCount sets the "signersCount" field. -func (m *CorrectnessReportMutation) SetSignersCount(u uint64) { - m.signersCount = &u - m.addsignersCount = nil -} - -// SignersCount returns the value of the "signersCount" field in the mutation. -func (m *CorrectnessReportMutation) SignersCount() (r uint64, exists bool) { - v := m.signersCount - if v == nil { - return - } - return *v, true -} - -// OldSignersCount returns the old "signersCount" field's value of the CorrectnessReport entity. -// If the CorrectnessReport 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 *CorrectnessReportMutation) OldSignersCount(ctx context.Context) (v uint64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSignersCount is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSignersCount requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSignersCount: %w", err) - } - return oldValue.SignersCount, nil -} - -// AddSignersCount adds u to the "signersCount" field. -func (m *CorrectnessReportMutation) AddSignersCount(u int64) { - if m.addsignersCount != nil { - *m.addsignersCount += u - } else { - m.addsignersCount = &u - } -} - -// AddedSignersCount returns the value that was added to the "signersCount" field in this mutation. -func (m *CorrectnessReportMutation) AddedSignersCount() (r int64, exists bool) { - v := m.addsignersCount - if v == nil { - return - } - return *v, true -} - -// ResetSignersCount resets all changes to the "signersCount" field. -func (m *CorrectnessReportMutation) ResetSignersCount() { - m.signersCount = nil - m.addsignersCount = nil -} - -// SetTimestamp sets the "timestamp" field. -func (m *CorrectnessReportMutation) SetTimestamp(u uint64) { - m.timestamp = &u - m.addtimestamp = nil -} - -// Timestamp returns the value of the "timestamp" field in the mutation. -func (m *CorrectnessReportMutation) Timestamp() (r uint64, exists bool) { - v := m.timestamp - if v == nil { - return - } - return *v, true -} - -// OldTimestamp returns the old "timestamp" field's value of the CorrectnessReport entity. -// If the CorrectnessReport 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 *CorrectnessReportMutation) OldTimestamp(ctx context.Context) (v uint64, 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 u to the "timestamp" field. -func (m *CorrectnessReportMutation) AddTimestamp(u int64) { - if m.addtimestamp != nil { - *m.addtimestamp += u - } else { - m.addtimestamp = &u - } -} - -// AddedTimestamp returns the value that was added to the "timestamp" field in this mutation. -func (m *CorrectnessReportMutation) AddedTimestamp() (r int64, exists bool) { - v := m.addtimestamp - if v == nil { - return - } - return *v, true -} - -// ResetTimestamp resets all changes to the "timestamp" field. -func (m *CorrectnessReportMutation) ResetTimestamp() { - m.timestamp = nil - m.addtimestamp = nil -} - -// SetSignature sets the "signature" field. -func (m *CorrectnessReportMutation) SetSignature(b []byte) { - m.signature = &b -} - -// Signature returns the value of the "signature" field in the mutation. -func (m *CorrectnessReportMutation) Signature() (r []byte, exists bool) { - v := m.signature - if v == nil { - return - } - return *v, true -} - -// OldSignature returns the old "signature" field's value of the CorrectnessReport entity. -// If the CorrectnessReport 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 *CorrectnessReportMutation) OldSignature(ctx context.Context) (v []byte, 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 *CorrectnessReportMutation) ResetSignature() { - m.signature = nil -} - -// SetHash sets the "hash" field. -func (m *CorrectnessReportMutation) SetHash(b []byte) { - m.hash = &b -} - -// Hash returns the value of the "hash" field in the mutation. -func (m *CorrectnessReportMutation) Hash() (r []byte, exists bool) { - v := m.hash - if v == nil { - return - } - return *v, true -} - -// OldHash returns the old "hash" field's value of the CorrectnessReport entity. -// If the CorrectnessReport 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 *CorrectnessReportMutation) OldHash(ctx context.Context) (v []byte, 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 *CorrectnessReportMutation) ResetHash() { - m.hash = nil -} - -// SetTopic sets the "topic" field. -func (m *CorrectnessReportMutation) SetTopic(b []byte) { - m.topic = &b -} - -// Topic returns the value of the "topic" field in the mutation. -func (m *CorrectnessReportMutation) Topic() (r []byte, exists bool) { - v := m.topic - if v == nil { - return - } - return *v, true -} - -// OldTopic returns the old "topic" field's value of the CorrectnessReport entity. -// If the CorrectnessReport 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 *CorrectnessReportMutation) OldTopic(ctx context.Context) (v []byte, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTopic is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTopic requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTopic: %w", err) - } - return oldValue.Topic, nil -} - -// ResetTopic resets all changes to the "topic" field. -func (m *CorrectnessReportMutation) ResetTopic() { - m.topic = nil -} - -// SetCorrect sets the "correct" field. -func (m *CorrectnessReportMutation) SetCorrect(b bool) { - m.correct = &b -} - -// Correct returns the value of the "correct" field in the mutation. -func (m *CorrectnessReportMutation) Correct() (r bool, exists bool) { - v := m.correct - if v == nil { - return - } - return *v, true -} - -// OldCorrect returns the old "correct" field's value of the CorrectnessReport entity. -// If the CorrectnessReport 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 *CorrectnessReportMutation) OldCorrect(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCorrect is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCorrect requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCorrect: %w", err) - } - return oldValue.Correct, nil -} - -// ResetCorrect resets all changes to the "correct" field. -func (m *CorrectnessReportMutation) ResetCorrect() { - m.correct = nil -} - -// SetConsensus sets the "consensus" field. -func (m *CorrectnessReportMutation) SetConsensus(b bool) { - m.consensus = &b -} - -// Consensus returns the value of the "consensus" field in the mutation. -func (m *CorrectnessReportMutation) Consensus() (r bool, exists bool) { - v := m.consensus - if v == nil { - return - } - return *v, true -} - -// OldConsensus returns the old "consensus" field's value of the CorrectnessReport entity. -// If the CorrectnessReport 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 *CorrectnessReportMutation) OldConsensus(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldConsensus is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldConsensus requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldConsensus: %w", err) - } - return oldValue.Consensus, nil -} - -// ResetConsensus resets all changes to the "consensus" field. -func (m *CorrectnessReportMutation) ResetConsensus() { - m.consensus = nil -} - -// SetVoted sets the "voted" field. -func (m *CorrectnessReportMutation) SetVoted(hi *helpers.BigInt) { - m.voted = &hi -} - -// Voted returns the value of the "voted" field in the mutation. -func (m *CorrectnessReportMutation) Voted() (r *helpers.BigInt, exists bool) { - v := m.voted - if v == nil { - return - } - return *v, true -} - -// OldVoted returns the old "voted" field's value of the CorrectnessReport entity. -// If the CorrectnessReport 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 *CorrectnessReportMutation) OldVoted(ctx context.Context) (v *helpers.BigInt, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVoted is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVoted requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldVoted: %w", err) - } - return oldValue.Voted, nil -} - -// ResetVoted resets all changes to the "voted" field. -func (m *CorrectnessReportMutation) ResetVoted() { - m.voted = nil -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by ids. -func (m *CorrectnessReportMutation) AddSignerIDs(ids ...int) { - if m.signers == nil { - m.signers = make(map[int]struct{}) - } - for i := range ids { - m.signers[ids[i]] = struct{}{} - } -} - -// ClearSigners clears the "signers" edge to the Signer entity. -func (m *CorrectnessReportMutation) ClearSigners() { - m.clearedsigners = true -} - -// SignersCleared reports if the "signers" edge to the Signer entity was cleared. -func (m *CorrectnessReportMutation) SignersCleared() bool { - return m.clearedsigners -} - -// RemoveSignerIDs removes the "signers" edge to the Signer entity by IDs. -func (m *CorrectnessReportMutation) RemoveSignerIDs(ids ...int) { - if m.removedsigners == nil { - m.removedsigners = make(map[int]struct{}) - } - for i := range ids { - delete(m.signers, ids[i]) - m.removedsigners[ids[i]] = struct{}{} - } -} - -// RemovedSigners returns the removed IDs of the "signers" edge to the Signer entity. -func (m *CorrectnessReportMutation) RemovedSignersIDs() (ids []int) { - for id := range m.removedsigners { - ids = append(ids, id) - } - return -} - -// SignersIDs returns the "signers" edge IDs in the mutation. -func (m *CorrectnessReportMutation) SignersIDs() (ids []int) { - for id := range m.signers { - ids = append(ids, id) - } - return -} - -// ResetSigners resets all changes to the "signers" edge. -func (m *CorrectnessReportMutation) ResetSigners() { - m.signers = nil - m.clearedsigners = false - m.removedsigners = nil -} - -// Where appends a list predicates to the CorrectnessReportMutation builder. -func (m *CorrectnessReportMutation) Where(ps ...predicate.CorrectnessReport) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the CorrectnessReportMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *CorrectnessReportMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.CorrectnessReport, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *CorrectnessReportMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *CorrectnessReportMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (CorrectnessReport). -func (m *CorrectnessReportMutation) 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 *CorrectnessReportMutation) Fields() []string { - fields := make([]string, 0, 8) - if m.signersCount != nil { - fields = append(fields, correctnessreport.FieldSignersCount) - } - if m.timestamp != nil { - fields = append(fields, correctnessreport.FieldTimestamp) - } - if m.signature != nil { - fields = append(fields, correctnessreport.FieldSignature) - } - if m.hash != nil { - fields = append(fields, correctnessreport.FieldHash) - } - if m.topic != nil { - fields = append(fields, correctnessreport.FieldTopic) - } - if m.correct != nil { - fields = append(fields, correctnessreport.FieldCorrect) - } - if m.consensus != nil { - fields = append(fields, correctnessreport.FieldConsensus) - } - if m.voted != nil { - fields = append(fields, correctnessreport.FieldVoted) - } - 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 *CorrectnessReportMutation) Field(name string) (ent.Value, bool) { - switch name { - case correctnessreport.FieldSignersCount: - return m.SignersCount() - case correctnessreport.FieldTimestamp: - return m.Timestamp() - case correctnessreport.FieldSignature: - return m.Signature() - case correctnessreport.FieldHash: - return m.Hash() - case correctnessreport.FieldTopic: - return m.Topic() - case correctnessreport.FieldCorrect: - return m.Correct() - case correctnessreport.FieldConsensus: - return m.Consensus() - case correctnessreport.FieldVoted: - return m.Voted() - } - 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 *CorrectnessReportMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case correctnessreport.FieldSignersCount: - return m.OldSignersCount(ctx) - case correctnessreport.FieldTimestamp: - return m.OldTimestamp(ctx) - case correctnessreport.FieldSignature: - return m.OldSignature(ctx) - case correctnessreport.FieldHash: - return m.OldHash(ctx) - case correctnessreport.FieldTopic: - return m.OldTopic(ctx) - case correctnessreport.FieldCorrect: - return m.OldCorrect(ctx) - case correctnessreport.FieldConsensus: - return m.OldConsensus(ctx) - case correctnessreport.FieldVoted: - return m.OldVoted(ctx) - } - return nil, fmt.Errorf("unknown CorrectnessReport 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 *CorrectnessReportMutation) SetField(name string, value ent.Value) error { - switch name { - case correctnessreport.FieldSignersCount: - v, ok := value.(uint64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSignersCount(v) - return nil - case correctnessreport.FieldTimestamp: - v, ok := value.(uint64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTimestamp(v) - return nil - case correctnessreport.FieldSignature: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSignature(v) - return nil - case correctnessreport.FieldHash: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetHash(v) - return nil - case correctnessreport.FieldTopic: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTopic(v) - return nil - case correctnessreport.FieldCorrect: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCorrect(v) - return nil - case correctnessreport.FieldConsensus: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetConsensus(v) - return nil - case correctnessreport.FieldVoted: - v, ok := value.(*helpers.BigInt) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetVoted(v) - return nil - } - return fmt.Errorf("unknown CorrectnessReport field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *CorrectnessReportMutation) AddedFields() []string { - var fields []string - if m.addsignersCount != nil { - fields = append(fields, correctnessreport.FieldSignersCount) - } - if m.addtimestamp != nil { - fields = append(fields, correctnessreport.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 *CorrectnessReportMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case correctnessreport.FieldSignersCount: - return m.AddedSignersCount() - case correctnessreport.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 *CorrectnessReportMutation) AddField(name string, value ent.Value) error { - switch name { - case correctnessreport.FieldSignersCount: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddSignersCount(v) - return nil - case correctnessreport.FieldTimestamp: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddTimestamp(v) - return nil - } - return fmt.Errorf("unknown CorrectnessReport numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *CorrectnessReportMutation) ClearedFields() []string { - return nil -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *CorrectnessReportMutation) 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 *CorrectnessReportMutation) ClearField(name string) error { - return fmt.Errorf("unknown CorrectnessReport 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 *CorrectnessReportMutation) ResetField(name string) error { - switch name { - case correctnessreport.FieldSignersCount: - m.ResetSignersCount() - return nil - case correctnessreport.FieldTimestamp: - m.ResetTimestamp() - return nil - case correctnessreport.FieldSignature: - m.ResetSignature() - return nil - case correctnessreport.FieldHash: - m.ResetHash() - return nil - case correctnessreport.FieldTopic: - m.ResetTopic() - return nil - case correctnessreport.FieldCorrect: - m.ResetCorrect() - return nil - case correctnessreport.FieldConsensus: - m.ResetConsensus() - return nil - case correctnessreport.FieldVoted: - m.ResetVoted() - return nil - } - return fmt.Errorf("unknown CorrectnessReport field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *CorrectnessReportMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.signers != nil { - edges = append(edges, correctnessreport.EdgeSigners) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *CorrectnessReportMutation) AddedIDs(name string) []ent.Value { - switch name { - case correctnessreport.EdgeSigners: - ids := make([]ent.Value, 0, len(m.signers)) - for id := range m.signers { - ids = append(ids, id) - } - return ids - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *CorrectnessReportMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) - if m.removedsigners != nil { - edges = append(edges, correctnessreport.EdgeSigners) - } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *CorrectnessReportMutation) RemovedIDs(name string) []ent.Value { - switch name { - case correctnessreport.EdgeSigners: - ids := make([]ent.Value, 0, len(m.removedsigners)) - for id := range m.removedsigners { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *CorrectnessReportMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.clearedsigners { - edges = append(edges, correctnessreport.EdgeSigners) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *CorrectnessReportMutation) EdgeCleared(name string) bool { - switch name { - case correctnessreport.EdgeSigners: - return m.clearedsigners - } - 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 *CorrectnessReportMutation) ClearEdge(name string) error { - switch name { - } - return fmt.Errorf("unknown CorrectnessReport 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 *CorrectnessReportMutation) ResetEdge(name string) error { - switch name { - case correctnessreport.EdgeSigners: - m.ResetSigners() - return nil - } - return fmt.Errorf("unknown CorrectnessReport edge %s", name) -} - -// EventLogMutation represents an operation that mutates the EventLog nodes in the graph. -type EventLogMutation struct { - config - op Op - typ string - id *int - block *uint64 - addblock *int64 - signersCount *uint64 - addsignersCount *int64 - signature *[]byte - address *string - chain *string - index *uint64 - addindex *int64 - event *string - transaction *[]byte - args *[]model.EventLogArg - appendargs []model.EventLogArg - consensus *bool - voted **helpers.BigInt - clearedFields map[string]struct{} - signers map[int]struct{} - removedsigners map[int]struct{} - clearedsigners bool - done bool - oldValue func(context.Context) (*EventLog, error) - predicates []predicate.EventLog -} - -var _ ent.Mutation = (*EventLogMutation)(nil) - -// eventlogOption allows management of the mutation configuration using functional options. -type eventlogOption func(*EventLogMutation) - -// newEventLogMutation creates new mutation for the EventLog entity. -func newEventLogMutation(c config, op Op, opts ...eventlogOption) *EventLogMutation { - m := &EventLogMutation{ - config: c, - op: op, - typ: TypeEventLog, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withEventLogID sets the ID field of the mutation. -func withEventLogID(id int) eventlogOption { - return func(m *EventLogMutation) { - var ( - err error - once sync.Once - value *EventLog - ) - m.oldValue = func(ctx context.Context) (*EventLog, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().EventLog.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withEventLog sets the old EventLog of the mutation. -func withEventLog(node *EventLog) eventlogOption { - return func(m *EventLogMutation) { - m.oldValue = func(context.Context) (*EventLog, 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 EventLogMutation) 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 EventLogMutation) 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 *EventLogMutation) 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 *EventLogMutation) 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().EventLog.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetBlock sets the "block" field. -func (m *EventLogMutation) SetBlock(u uint64) { - m.block = &u - m.addblock = nil -} - -// Block returns the value of the "block" field in the mutation. -func (m *EventLogMutation) Block() (r uint64, exists bool) { - v := m.block - if v == nil { - return - } - return *v, true -} - -// OldBlock returns the old "block" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldBlock(ctx context.Context) (v uint64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBlock is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBlock requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldBlock: %w", err) - } - return oldValue.Block, nil -} - -// AddBlock adds u to the "block" field. -func (m *EventLogMutation) AddBlock(u int64) { - if m.addblock != nil { - *m.addblock += u - } else { - m.addblock = &u - } -} - -// AddedBlock returns the value that was added to the "block" field in this mutation. -func (m *EventLogMutation) AddedBlock() (r int64, exists bool) { - v := m.addblock - if v == nil { - return - } - return *v, true -} - -// ResetBlock resets all changes to the "block" field. -func (m *EventLogMutation) ResetBlock() { - m.block = nil - m.addblock = nil -} - -// SetSignersCount sets the "signersCount" field. -func (m *EventLogMutation) SetSignersCount(u uint64) { - m.signersCount = &u - m.addsignersCount = nil -} - -// SignersCount returns the value of the "signersCount" field in the mutation. -func (m *EventLogMutation) SignersCount() (r uint64, exists bool) { - v := m.signersCount - if v == nil { - return - } - return *v, true -} - -// OldSignersCount returns the old "signersCount" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldSignersCount(ctx context.Context) (v uint64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSignersCount is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSignersCount requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSignersCount: %w", err) - } - return oldValue.SignersCount, nil -} - -// AddSignersCount adds u to the "signersCount" field. -func (m *EventLogMutation) AddSignersCount(u int64) { - if m.addsignersCount != nil { - *m.addsignersCount += u - } else { - m.addsignersCount = &u - } -} - -// AddedSignersCount returns the value that was added to the "signersCount" field in this mutation. -func (m *EventLogMutation) AddedSignersCount() (r int64, exists bool) { - v := m.addsignersCount - if v == nil { - return - } - return *v, true -} - -// ResetSignersCount resets all changes to the "signersCount" field. -func (m *EventLogMutation) ResetSignersCount() { - m.signersCount = nil - m.addsignersCount = nil -} - -// SetSignature sets the "signature" field. -func (m *EventLogMutation) SetSignature(b []byte) { - m.signature = &b -} - -// Signature returns the value of the "signature" field in the mutation. -func (m *EventLogMutation) Signature() (r []byte, exists bool) { - v := m.signature - if v == nil { - return - } - return *v, true -} - -// OldSignature returns the old "signature" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldSignature(ctx context.Context) (v []byte, 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 *EventLogMutation) ResetSignature() { - m.signature = nil -} - -// SetAddress sets the "address" field. -func (m *EventLogMutation) SetAddress(s string) { - m.address = &s -} - -// Address returns the value of the "address" field in the mutation. -func (m *EventLogMutation) Address() (r string, exists bool) { - v := m.address - if v == nil { - return - } - return *v, true -} - -// OldAddress returns the old "address" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldAddress(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAddress is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAddress requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldAddress: %w", err) - } - return oldValue.Address, nil -} - -// ResetAddress resets all changes to the "address" field. -func (m *EventLogMutation) ResetAddress() { - m.address = nil -} - -// SetChain sets the "chain" field. -func (m *EventLogMutation) SetChain(s string) { - m.chain = &s -} - -// Chain returns the value of the "chain" field in the mutation. -func (m *EventLogMutation) Chain() (r string, exists bool) { - v := m.chain - if v == nil { - return - } - return *v, true -} - -// OldChain returns the old "chain" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldChain(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldChain is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldChain requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldChain: %w", err) - } - return oldValue.Chain, nil -} - -// ResetChain resets all changes to the "chain" field. -func (m *EventLogMutation) ResetChain() { - m.chain = nil -} - -// SetIndex sets the "index" field. -func (m *EventLogMutation) SetIndex(u uint64) { - m.index = &u - m.addindex = nil -} - -// Index returns the value of the "index" field in the mutation. -func (m *EventLogMutation) Index() (r uint64, exists bool) { - v := m.index - if v == nil { - return - } - return *v, true -} - -// OldIndex returns the old "index" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldIndex(ctx context.Context) (v uint64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIndex is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIndex requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldIndex: %w", err) - } - return oldValue.Index, nil -} - -// AddIndex adds u to the "index" field. -func (m *EventLogMutation) AddIndex(u int64) { - if m.addindex != nil { - *m.addindex += u - } else { - m.addindex = &u - } -} - -// AddedIndex returns the value that was added to the "index" field in this mutation. -func (m *EventLogMutation) AddedIndex() (r int64, exists bool) { - v := m.addindex - if v == nil { - return - } - return *v, true -} - -// ResetIndex resets all changes to the "index" field. -func (m *EventLogMutation) ResetIndex() { - m.index = nil - m.addindex = nil -} - -// SetEvent sets the "event" field. -func (m *EventLogMutation) SetEvent(s string) { - m.event = &s -} - -// Event returns the value of the "event" field in the mutation. -func (m *EventLogMutation) Event() (r string, exists bool) { - v := m.event - if v == nil { - return - } - return *v, true -} - -// OldEvent returns the old "event" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldEvent(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEvent is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEvent requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldEvent: %w", err) - } - return oldValue.Event, nil -} - -// ResetEvent resets all changes to the "event" field. -func (m *EventLogMutation) ResetEvent() { - m.event = nil -} - -// SetTransaction sets the "transaction" field. -func (m *EventLogMutation) SetTransaction(b []byte) { - m.transaction = &b -} - -// Transaction returns the value of the "transaction" field in the mutation. -func (m *EventLogMutation) Transaction() (r []byte, exists bool) { - v := m.transaction - if v == nil { - return - } - return *v, true -} - -// OldTransaction returns the old "transaction" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldTransaction(ctx context.Context) (v []byte, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTransaction is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTransaction requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTransaction: %w", err) - } - return oldValue.Transaction, nil -} - -// ResetTransaction resets all changes to the "transaction" field. -func (m *EventLogMutation) ResetTransaction() { - m.transaction = nil -} - -// SetArgs sets the "args" field. -func (m *EventLogMutation) SetArgs(dla []model.EventLogArg) { - m.args = &dla - m.appendargs = nil -} - -// Args returns the value of the "args" field in the mutation. -func (m *EventLogMutation) Args() (r []model.EventLogArg, exists bool) { - v := m.args - if v == nil { - return - } - return *v, true -} - -// OldArgs returns the old "args" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldArgs(ctx context.Context) (v []model.EventLogArg, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldArgs is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldArgs requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldArgs: %w", err) - } - return oldValue.Args, nil -} - -// AppendArgs adds dla to the "args" field. -func (m *EventLogMutation) AppendArgs(dla []model.EventLogArg) { - m.appendargs = append(m.appendargs, dla...) -} - -// AppendedArgs returns the list of values that were appended to the "args" field in this mutation. -func (m *EventLogMutation) AppendedArgs() ([]model.EventLogArg, bool) { - if len(m.appendargs) == 0 { - return nil, false - } - return m.appendargs, true -} - -// ResetArgs resets all changes to the "args" field. -func (m *EventLogMutation) ResetArgs() { - m.args = nil - m.appendargs = nil -} - -// SetConsensus sets the "consensus" field. -func (m *EventLogMutation) SetConsensus(b bool) { - m.consensus = &b -} - -// Consensus returns the value of the "consensus" field in the mutation. -func (m *EventLogMutation) Consensus() (r bool, exists bool) { - v := m.consensus - if v == nil { - return - } - return *v, true -} - -// OldConsensus returns the old "consensus" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldConsensus(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldConsensus is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldConsensus requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldConsensus: %w", err) - } - return oldValue.Consensus, nil -} - -// ResetConsensus resets all changes to the "consensus" field. -func (m *EventLogMutation) ResetConsensus() { - m.consensus = nil -} - -// SetVoted sets the "voted" field. -func (m *EventLogMutation) SetVoted(hi *helpers.BigInt) { - m.voted = &hi -} - -// Voted returns the value of the "voted" field in the mutation. -func (m *EventLogMutation) Voted() (r *helpers.BigInt, exists bool) { - v := m.voted - if v == nil { - return - } - return *v, true -} - -// OldVoted returns the old "voted" field's value of the EventLog entity. -// If the EventLog 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 *EventLogMutation) OldVoted(ctx context.Context) (v *helpers.BigInt, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVoted is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVoted requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldVoted: %w", err) - } - return oldValue.Voted, nil -} - -// ResetVoted resets all changes to the "voted" field. -func (m *EventLogMutation) ResetVoted() { - m.voted = nil -} - -// AddSignerIDs adds the "signers" edge to the Signer entity by ids. -func (m *EventLogMutation) AddSignerIDs(ids ...int) { - if m.signers == nil { - m.signers = make(map[int]struct{}) - } - for i := range ids { - m.signers[ids[i]] = struct{}{} - } -} - -// ClearSigners clears the "signers" edge to the Signer entity. -func (m *EventLogMutation) ClearSigners() { - m.clearedsigners = true -} - -// SignersCleared reports if the "signers" edge to the Signer entity was cleared. -func (m *EventLogMutation) SignersCleared() bool { - return m.clearedsigners -} - -// RemoveSignerIDs removes the "signers" edge to the Signer entity by IDs. -func (m *EventLogMutation) RemoveSignerIDs(ids ...int) { - if m.removedsigners == nil { - m.removedsigners = make(map[int]struct{}) - } - for i := range ids { - delete(m.signers, ids[i]) - m.removedsigners[ids[i]] = struct{}{} - } -} - -// RemovedSigners returns the removed IDs of the "signers" edge to the Signer entity. -func (m *EventLogMutation) RemovedSignersIDs() (ids []int) { - for id := range m.removedsigners { - ids = append(ids, id) - } - return -} - -// SignersIDs returns the "signers" edge IDs in the mutation. -func (m *EventLogMutation) SignersIDs() (ids []int) { - for id := range m.signers { - ids = append(ids, id) - } - return -} - -// ResetSigners resets all changes to the "signers" edge. -func (m *EventLogMutation) ResetSigners() { - m.signers = nil - m.clearedsigners = false - m.removedsigners = nil -} - -// Where appends a list predicates to the EventLogMutation builder. -func (m *EventLogMutation) Where(ps ...predicate.EventLog) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the EventLogMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *EventLogMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.EventLog, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *EventLogMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *EventLogMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (EventLog). -func (m *EventLogMutation) 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 *EventLogMutation) Fields() []string { - fields := make([]string, 0, 11) - if m.block != nil { - fields = append(fields, eventlog.FieldBlock) - } - if m.signersCount != nil { - fields = append(fields, eventlog.FieldSignersCount) - } - if m.signature != nil { - fields = append(fields, eventlog.FieldSignature) - } - if m.address != nil { - fields = append(fields, eventlog.FieldAddress) - } - if m.chain != nil { - fields = append(fields, eventlog.FieldChain) - } - if m.index != nil { - fields = append(fields, eventlog.FieldIndex) - } - if m.event != nil { - fields = append(fields, eventlog.FieldEvent) - } - if m.transaction != nil { - fields = append(fields, eventlog.FieldTransaction) - } - if m.args != nil { - fields = append(fields, eventlog.FieldArgs) - } - if m.consensus != nil { - fields = append(fields, eventlog.FieldConsensus) - } - if m.voted != nil { - fields = append(fields, eventlog.FieldVoted) - } - 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 *EventLogMutation) Field(name string) (ent.Value, bool) { - switch name { - case eventlog.FieldBlock: - return m.Block() - case eventlog.FieldSignersCount: - return m.SignersCount() - case eventlog.FieldSignature: - return m.Signature() - case eventlog.FieldAddress: - return m.Address() - case eventlog.FieldChain: - return m.Chain() - case eventlog.FieldIndex: - return m.Index() - case eventlog.FieldEvent: - return m.Event() - case eventlog.FieldTransaction: - return m.Transaction() - case eventlog.FieldArgs: - return m.Args() - case eventlog.FieldConsensus: - return m.Consensus() - case eventlog.FieldVoted: - return m.Voted() - } - 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 *EventLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case eventlog.FieldBlock: - return m.OldBlock(ctx) - case eventlog.FieldSignersCount: - return m.OldSignersCount(ctx) - case eventlog.FieldSignature: - return m.OldSignature(ctx) - case eventlog.FieldAddress: - return m.OldAddress(ctx) - case eventlog.FieldChain: - return m.OldChain(ctx) - case eventlog.FieldIndex: - return m.OldIndex(ctx) - case eventlog.FieldEvent: - return m.OldEvent(ctx) - case eventlog.FieldTransaction: - return m.OldTransaction(ctx) - case eventlog.FieldArgs: - return m.OldArgs(ctx) - case eventlog.FieldConsensus: - return m.OldConsensus(ctx) - case eventlog.FieldVoted: - return m.OldVoted(ctx) - } - return nil, fmt.Errorf("unknown EventLog 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 *EventLogMutation) SetField(name string, value ent.Value) error { - switch name { - case eventlog.FieldBlock: - v, ok := value.(uint64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetBlock(v) - return nil - case eventlog.FieldSignersCount: - v, ok := value.(uint64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSignersCount(v) - return nil - case eventlog.FieldSignature: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSignature(v) - return nil - case eventlog.FieldAddress: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAddress(v) - return nil - case eventlog.FieldChain: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetChain(v) - return nil - case eventlog.FieldIndex: - v, ok := value.(uint64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetIndex(v) - return nil - case eventlog.FieldEvent: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetEvent(v) - return nil - case eventlog.FieldTransaction: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTransaction(v) - return nil - case eventlog.FieldArgs: - v, ok := value.([]model.EventLogArg) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetArgs(v) - return nil - case eventlog.FieldConsensus: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetConsensus(v) - return nil - case eventlog.FieldVoted: - v, ok := value.(*helpers.BigInt) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetVoted(v) - return nil - } - return fmt.Errorf("unknown EventLog field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *EventLogMutation) AddedFields() []string { - var fields []string - if m.addblock != nil { - fields = append(fields, eventlog.FieldBlock) - } - if m.addsignersCount != nil { - fields = append(fields, eventlog.FieldSignersCount) - } - if m.addindex != nil { - fields = append(fields, eventlog.FieldIndex) - } - 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 *EventLogMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case eventlog.FieldBlock: - return m.AddedBlock() - case eventlog.FieldSignersCount: - return m.AddedSignersCount() - case eventlog.FieldIndex: - return m.AddedIndex() - } - 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 *EventLogMutation) AddField(name string, value ent.Value) error { - switch name { - case eventlog.FieldBlock: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddBlock(v) - return nil - case eventlog.FieldSignersCount: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddSignersCount(v) - return nil - case eventlog.FieldIndex: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddIndex(v) - return nil - } - return fmt.Errorf("unknown EventLog numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *EventLogMutation) ClearedFields() []string { - return nil -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *EventLogMutation) 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 *EventLogMutation) ClearField(name string) error { - return fmt.Errorf("unknown EventLog 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 *EventLogMutation) ResetField(name string) error { - switch name { - case eventlog.FieldBlock: - m.ResetBlock() - return nil - case eventlog.FieldSignersCount: - m.ResetSignersCount() - return nil - case eventlog.FieldSignature: - m.ResetSignature() - return nil - case eventlog.FieldAddress: - m.ResetAddress() - return nil - case eventlog.FieldChain: - m.ResetChain() - return nil - case eventlog.FieldIndex: - m.ResetIndex() - return nil - case eventlog.FieldEvent: - m.ResetEvent() - return nil - case eventlog.FieldTransaction: - m.ResetTransaction() - return nil - case eventlog.FieldArgs: - m.ResetArgs() - return nil - case eventlog.FieldConsensus: - m.ResetConsensus() - return nil - case eventlog.FieldVoted: - m.ResetVoted() - return nil - } - return fmt.Errorf("unknown EventLog field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *EventLogMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.signers != nil { - edges = append(edges, eventlog.EdgeSigners) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *EventLogMutation) AddedIDs(name string) []ent.Value { - switch name { - case eventlog.EdgeSigners: - ids := make([]ent.Value, 0, len(m.signers)) - for id := range m.signers { - ids = append(ids, id) - } - return ids - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *EventLogMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) - if m.removedsigners != nil { - edges = append(edges, eventlog.EdgeSigners) - } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *EventLogMutation) RemovedIDs(name string) []ent.Value { - switch name { - case eventlog.EdgeSigners: - ids := make([]ent.Value, 0, len(m.removedsigners)) - for id := range m.removedsigners { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *EventLogMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.clearedsigners { - edges = append(edges, eventlog.EdgeSigners) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *EventLogMutation) EdgeCleared(name string) bool { - switch name { - case eventlog.EdgeSigners: - return m.clearedsigners - } - 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 *EventLogMutation) ClearEdge(name string) error { - switch name { - } - return fmt.Errorf("unknown EventLog 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 *EventLogMutation) ResetEdge(name string) error { - switch name { - case eventlog.EdgeSigners: - m.ResetSigners() - return nil - } - return fmt.Errorf("unknown EventLog edge %s", name) -} - -// SignerMutation represents an operation that mutates the Signer nodes in the graph. -type SignerMutation struct { - config - op Op - typ string - id *int - name *string - evm *string - key *[]byte - shortkey *[]byte - points *int64 - addpoints *int64 - clearedFields map[string]struct{} - assetPrice map[int]struct{} - removedassetPrice map[int]struct{} - clearedassetPrice bool - eventLogs map[int]struct{} - removedeventLogs map[int]struct{} - clearedeventLogs bool - correctnessReport map[int]struct{} - removedcorrectnessReport map[int]struct{} - clearedcorrectnessReport bool - done bool - oldValue func(context.Context) (*Signer, error) - predicates []predicate.Signer -} - -var _ ent.Mutation = (*SignerMutation)(nil) - -// signerOption allows management of the mutation configuration using functional options. -type signerOption func(*SignerMutation) - -// newSignerMutation creates new mutation for the Signer entity. -func newSignerMutation(c config, op Op, opts ...signerOption) *SignerMutation { - m := &SignerMutation{ - config: c, - op: op, - typ: TypeSigner, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withSignerID sets the ID field of the mutation. -func withSignerID(id int) signerOption { - return func(m *SignerMutation) { - var ( - err error - once sync.Once - value *Signer - ) - m.oldValue = func(ctx context.Context) (*Signer, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().Signer.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withSigner sets the old Signer of the mutation. -func withSigner(node *Signer) signerOption { - return func(m *SignerMutation) { - m.oldValue = func(context.Context) (*Signer, 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 SignerMutation) 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 SignerMutation) 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 *SignerMutation) 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 *SignerMutation) 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().Signer.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetName sets the "name" field. -func (m *SignerMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *SignerMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return - } - return *v, true -} - -// OldName returns the old "name" field's value of the Signer entity. -// If the Signer 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 *SignerMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *SignerMutation) ResetName() { - m.name = nil -} - -// SetEvm sets the "evm" field. -func (m *SignerMutation) SetEvm(s string) { - m.evm = &s -} - -// Evm returns the value of the "evm" field in the mutation. -func (m *SignerMutation) Evm() (r string, exists bool) { - v := m.evm - if v == nil { - return - } - return *v, true -} - -// OldEvm returns the old "evm" field's value of the Signer entity. -// If the Signer 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 *SignerMutation) OldEvm(ctx context.Context) (v *string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEvm is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEvm requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldEvm: %w", err) - } - return oldValue.Evm, nil -} - -// ClearEvm clears the value of the "evm" field. -func (m *SignerMutation) ClearEvm() { - m.evm = nil - m.clearedFields[signer.FieldEvm] = struct{}{} -} - -// EvmCleared returns if the "evm" field was cleared in this mutation. -func (m *SignerMutation) EvmCleared() bool { - _, ok := m.clearedFields[signer.FieldEvm] - return ok -} - -// ResetEvm resets all changes to the "evm" field. -func (m *SignerMutation) ResetEvm() { - m.evm = nil - delete(m.clearedFields, signer.FieldEvm) -} - -// SetKey sets the "key" field. -func (m *SignerMutation) SetKey(b []byte) { - m.key = &b -} - -// Key returns the value of the "key" field in the mutation. -func (m *SignerMutation) Key() (r []byte, exists bool) { - v := m.key - if v == nil { - return - } - return *v, true -} - -// OldKey returns the old "key" field's value of the Signer entity. -// If the Signer 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 *SignerMutation) OldKey(ctx context.Context) (v []byte, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldKey is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldKey requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldKey: %w", err) - } - return oldValue.Key, nil -} - -// ResetKey resets all changes to the "key" field. -func (m *SignerMutation) ResetKey() { - m.key = nil -} - -// SetShortkey sets the "shortkey" field. -func (m *SignerMutation) SetShortkey(b []byte) { - m.shortkey = &b -} - -// Shortkey returns the value of the "shortkey" field in the mutation. -func (m *SignerMutation) Shortkey() (r []byte, exists bool) { - v := m.shortkey - if v == nil { - return - } - return *v, true -} - -// OldShortkey returns the old "shortkey" field's value of the Signer entity. -// If the Signer 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 *SignerMutation) OldShortkey(ctx context.Context) (v []byte, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldShortkey is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldShortkey requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldShortkey: %w", err) - } - return oldValue.Shortkey, nil -} - -// ResetShortkey resets all changes to the "shortkey" field. -func (m *SignerMutation) ResetShortkey() { - m.shortkey = nil -} - -// SetPoints sets the "points" field. -func (m *SignerMutation) SetPoints(i int64) { - m.points = &i - m.addpoints = nil -} - -// Points returns the value of the "points" field in the mutation. -func (m *SignerMutation) Points() (r int64, exists bool) { - v := m.points - if v == nil { - return - } - return *v, true -} - -// OldPoints returns the old "points" field's value of the Signer entity. -// If the Signer 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 *SignerMutation) OldPoints(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPoints is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPoints requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPoints: %w", err) - } - return oldValue.Points, nil -} - -// AddPoints adds i to the "points" field. -func (m *SignerMutation) AddPoints(i int64) { - if m.addpoints != nil { - *m.addpoints += i - } else { - m.addpoints = &i - } -} - -// AddedPoints returns the value that was added to the "points" field in this mutation. -func (m *SignerMutation) AddedPoints() (r int64, exists bool) { - v := m.addpoints - if v == nil { - return - } - return *v, true -} - -// ResetPoints resets all changes to the "points" field. -func (m *SignerMutation) ResetPoints() { - m.points = nil - m.addpoints = nil -} - -// AddAssetPriceIDs adds the "assetPrice" edge to the AssetPrice entity by ids. -func (m *SignerMutation) AddAssetPriceIDs(ids ...int) { - if m.assetPrice == nil { - m.assetPrice = make(map[int]struct{}) - } - for i := range ids { - m.assetPrice[ids[i]] = struct{}{} - } -} - -// ClearAssetPrice clears the "assetPrice" edge to the AssetPrice entity. -func (m *SignerMutation) ClearAssetPrice() { - m.clearedassetPrice = true -} - -// AssetPriceCleared reports if the "assetPrice" edge to the AssetPrice entity was cleared. -func (m *SignerMutation) AssetPriceCleared() bool { - return m.clearedassetPrice -} - -// RemoveAssetPriceIDs removes the "assetPrice" edge to the AssetPrice entity by IDs. -func (m *SignerMutation) RemoveAssetPriceIDs(ids ...int) { - if m.removedassetPrice == nil { - m.removedassetPrice = make(map[int]struct{}) - } - for i := range ids { - delete(m.assetPrice, ids[i]) - m.removedassetPrice[ids[i]] = struct{}{} - } -} - -// RemovedAssetPrice returns the removed IDs of the "assetPrice" edge to the AssetPrice entity. -func (m *SignerMutation) RemovedAssetPriceIDs() (ids []int) { - for id := range m.removedassetPrice { - ids = append(ids, id) - } - return -} - -// AssetPriceIDs returns the "assetPrice" edge IDs in the mutation. -func (m *SignerMutation) AssetPriceIDs() (ids []int) { - for id := range m.assetPrice { - ids = append(ids, id) - } - return -} - -// ResetAssetPrice resets all changes to the "assetPrice" edge. -func (m *SignerMutation) ResetAssetPrice() { - m.assetPrice = nil - m.clearedassetPrice = false - m.removedassetPrice = nil -} - -// AddEventLogIDs adds the "eventLogs" edge to the EventLog entity by ids. -func (m *SignerMutation) AddEventLogIDs(ids ...int) { - if m.eventLogs == nil { - m.eventLogs = make(map[int]struct{}) - } - for i := range ids { - m.eventLogs[ids[i]] = struct{}{} - } -} - -// ClearEventLogs clears the "eventLogs" edge to the EventLog entity. -func (m *SignerMutation) ClearEventLogs() { - m.clearedeventLogs = true -} - -// EventLogsCleared reports if the "eventLogs" edge to the EventLog entity was cleared. -func (m *SignerMutation) EventLogsCleared() bool { - return m.clearedeventLogs -} - -// RemoveEventLogIDs removes the "eventLogs" edge to the EventLog entity by IDs. -func (m *SignerMutation) RemoveEventLogIDs(ids ...int) { - if m.removedeventLogs == nil { - m.removedeventLogs = make(map[int]struct{}) - } - for i := range ids { - delete(m.eventLogs, ids[i]) - m.removedeventLogs[ids[i]] = struct{}{} - } -} - -// RemovedEventLogs returns the removed IDs of the "eventLogs" edge to the EventLog entity. -func (m *SignerMutation) RemovedEventLogsIDs() (ids []int) { - for id := range m.removedeventLogs { - ids = append(ids, id) - } - return -} - -// EventLogsIDs returns the "eventLogs" edge IDs in the mutation. -func (m *SignerMutation) EventLogsIDs() (ids []int) { - for id := range m.eventLogs { - ids = append(ids, id) - } - return -} - -// ResetEventLogs resets all changes to the "eventLogs" edge. -func (m *SignerMutation) ResetEventLogs() { - m.eventLogs = nil - m.clearedeventLogs = false - m.removedeventLogs = nil -} - -// AddCorrectnessReportIDs adds the "correctnessReport" edge to the CorrectnessReport entity by ids. -func (m *SignerMutation) AddCorrectnessReportIDs(ids ...int) { - if m.correctnessReport == nil { - m.correctnessReport = make(map[int]struct{}) - } - for i := range ids { - m.correctnessReport[ids[i]] = struct{}{} - } -} - -// ClearCorrectnessReport clears the "correctnessReport" edge to the CorrectnessReport entity. -func (m *SignerMutation) ClearCorrectnessReport() { - m.clearedcorrectnessReport = true -} - -// CorrectnessReportCleared reports if the "correctnessReport" edge to the CorrectnessReport entity was cleared. -func (m *SignerMutation) CorrectnessReportCleared() bool { - return m.clearedcorrectnessReport -} - -// RemoveCorrectnessReportIDs removes the "correctnessReport" edge to the CorrectnessReport entity by IDs. -func (m *SignerMutation) RemoveCorrectnessReportIDs(ids ...int) { - if m.removedcorrectnessReport == nil { - m.removedcorrectnessReport = make(map[int]struct{}) - } - for i := range ids { - delete(m.correctnessReport, ids[i]) - m.removedcorrectnessReport[ids[i]] = struct{}{} - } -} - -// RemovedCorrectnessReport returns the removed IDs of the "correctnessReport" edge to the CorrectnessReport entity. -func (m *SignerMutation) RemovedCorrectnessReportIDs() (ids []int) { - for id := range m.removedcorrectnessReport { - ids = append(ids, id) - } - return -} - -// CorrectnessReportIDs returns the "correctnessReport" edge IDs in the mutation. -func (m *SignerMutation) CorrectnessReportIDs() (ids []int) { - for id := range m.correctnessReport { - ids = append(ids, id) - } - return -} - -// ResetCorrectnessReport resets all changes to the "correctnessReport" edge. -func (m *SignerMutation) ResetCorrectnessReport() { - m.correctnessReport = nil - m.clearedcorrectnessReport = false - m.removedcorrectnessReport = nil -} - -// Where appends a list predicates to the SignerMutation builder. -func (m *SignerMutation) Where(ps ...predicate.Signer) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the SignerMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *SignerMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Signer, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *SignerMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *SignerMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (Signer). -func (m *SignerMutation) 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 *SignerMutation) Fields() []string { - fields := make([]string, 0, 5) - if m.name != nil { - fields = append(fields, signer.FieldName) - } - if m.evm != nil { - fields = append(fields, signer.FieldEvm) - } - if m.key != nil { - fields = append(fields, signer.FieldKey) - } - if m.shortkey != nil { - fields = append(fields, signer.FieldShortkey) - } - if m.points != nil { - fields = append(fields, signer.FieldPoints) - } - 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 *SignerMutation) Field(name string) (ent.Value, bool) { - switch name { - case signer.FieldName: - return m.Name() - case signer.FieldEvm: - return m.Evm() - case signer.FieldKey: - return m.Key() - case signer.FieldShortkey: - return m.Shortkey() - case signer.FieldPoints: - return m.Points() - } - 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 *SignerMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case signer.FieldName: - return m.OldName(ctx) - case signer.FieldEvm: - return m.OldEvm(ctx) - case signer.FieldKey: - return m.OldKey(ctx) - case signer.FieldShortkey: - return m.OldShortkey(ctx) - case signer.FieldPoints: - return m.OldPoints(ctx) - } - return nil, fmt.Errorf("unknown Signer 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 *SignerMutation) SetField(name string, value ent.Value) error { - switch name { - case signer.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case signer.FieldEvm: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetEvm(v) - return nil - case signer.FieldKey: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetKey(v) - return nil - case signer.FieldShortkey: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetShortkey(v) - return nil - case signer.FieldPoints: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPoints(v) - return nil - } - return fmt.Errorf("unknown Signer field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *SignerMutation) AddedFields() []string { - var fields []string - if m.addpoints != nil { - fields = append(fields, signer.FieldPoints) - } - 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 *SignerMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case signer.FieldPoints: - return m.AddedPoints() - } - 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 *SignerMutation) AddField(name string, value ent.Value) error { - switch name { - case signer.FieldPoints: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddPoints(v) - return nil - } - return fmt.Errorf("unknown Signer numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *SignerMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(signer.FieldEvm) { - fields = append(fields, signer.FieldEvm) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *SignerMutation) 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 *SignerMutation) ClearField(name string) error { - switch name { - case signer.FieldEvm: - m.ClearEvm() - return nil - } - return fmt.Errorf("unknown Signer 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 *SignerMutation) ResetField(name string) error { - switch name { - case signer.FieldName: - m.ResetName() - return nil - case signer.FieldEvm: - m.ResetEvm() - return nil - case signer.FieldKey: - m.ResetKey() - return nil - case signer.FieldShortkey: - m.ResetShortkey() - return nil - case signer.FieldPoints: - m.ResetPoints() - return nil - } - return fmt.Errorf("unknown Signer field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *SignerMutation) AddedEdges() []string { - edges := make([]string, 0, 3) - if m.assetPrice != nil { - edges = append(edges, signer.EdgeAssetPrice) - } - if m.eventLogs != nil { - edges = append(edges, signer.EdgeEventLogs) - } - if m.correctnessReport != nil { - edges = append(edges, signer.EdgeCorrectnessReport) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *SignerMutation) AddedIDs(name string) []ent.Value { - switch name { - case signer.EdgeAssetPrice: - ids := make([]ent.Value, 0, len(m.assetPrice)) - for id := range m.assetPrice { - ids = append(ids, id) - } - return ids - case signer.EdgeEventLogs: - ids := make([]ent.Value, 0, len(m.eventLogs)) - for id := range m.eventLogs { - ids = append(ids, id) - } - return ids - case signer.EdgeCorrectnessReport: - ids := make([]ent.Value, 0, len(m.correctnessReport)) - for id := range m.correctnessReport { - ids = append(ids, id) - } - return ids - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *SignerMutation) RemovedEdges() []string { - edges := make([]string, 0, 3) - if m.removedassetPrice != nil { - edges = append(edges, signer.EdgeAssetPrice) - } - if m.removedeventLogs != nil { - edges = append(edges, signer.EdgeEventLogs) - } - if m.removedcorrectnessReport != nil { - edges = append(edges, signer.EdgeCorrectnessReport) - } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *SignerMutation) RemovedIDs(name string) []ent.Value { - switch name { - case signer.EdgeAssetPrice: - ids := make([]ent.Value, 0, len(m.removedassetPrice)) - for id := range m.removedassetPrice { - ids = append(ids, id) - } - return ids - case signer.EdgeEventLogs: - ids := make([]ent.Value, 0, len(m.removedeventLogs)) - for id := range m.removedeventLogs { - ids = append(ids, id) - } - return ids - case signer.EdgeCorrectnessReport: - ids := make([]ent.Value, 0, len(m.removedcorrectnessReport)) - for id := range m.removedcorrectnessReport { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *SignerMutation) ClearedEdges() []string { - edges := make([]string, 0, 3) - if m.clearedassetPrice { - edges = append(edges, signer.EdgeAssetPrice) - } - if m.clearedeventLogs { - edges = append(edges, signer.EdgeEventLogs) - } - if m.clearedcorrectnessReport { - edges = append(edges, signer.EdgeCorrectnessReport) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *SignerMutation) EdgeCleared(name string) bool { - switch name { - case signer.EdgeAssetPrice: - return m.clearedassetPrice - case signer.EdgeEventLogs: - return m.clearedeventLogs - case signer.EdgeCorrectnessReport: - return m.clearedcorrectnessReport - } - 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 *SignerMutation) ClearEdge(name string) error { - switch name { - } - return fmt.Errorf("unknown Signer 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 *SignerMutation) ResetEdge(name string) error { - switch name { - case signer.EdgeAssetPrice: - m.ResetAssetPrice() - return nil - case signer.EdgeEventLogs: - m.ResetEventLogs() - return nil - case signer.EdgeCorrectnessReport: - m.ResetCorrectnessReport() - return nil - } - return fmt.Errorf("unknown Signer edge %s", name) -} diff --git a/internal/ent/predicate/predicate.go b/internal/ent/predicate/predicate.go deleted file mode 100644 index e42f1360..00000000 --- a/internal/ent/predicate/predicate.go +++ /dev/null @@ -1,19 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package predicate - -import ( - "entgo.io/ent/dialect/sql" -) - -// AssetPrice is the predicate function for assetprice builders. -type AssetPrice func(*sql.Selector) - -// CorrectnessReport is the predicate function for correctnessreport builders. -type CorrectnessReport func(*sql.Selector) - -// EventLog is the predicate function for eventlog builders. -type EventLog func(*sql.Selector) - -// Signer is the predicate function for signer builders. -type Signer func(*sql.Selector) diff --git a/internal/ent/runtime.go b/internal/ent/runtime.go deleted file mode 100644 index 3880c15d..00000000 --- a/internal/ent/runtime.go +++ /dev/null @@ -1,101 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/schema" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// 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() { - assetpriceFields := schema.AssetPrice{}.Fields() - _ = assetpriceFields - // assetpriceDescSignature is the schema descriptor for signature field. - assetpriceDescSignature := assetpriceFields[3].Descriptor() - // assetprice.SignatureValidator is a validator for the "signature" field. It is called by the builders before save. - assetprice.SignatureValidator = assetpriceDescSignature.Validators[0].(func([]byte) error) - // assetpriceDescConsensus is the schema descriptor for consensus field. - assetpriceDescConsensus := assetpriceFields[7].Descriptor() - // assetprice.DefaultConsensus holds the default value on creation for the consensus field. - assetprice.DefaultConsensus = assetpriceDescConsensus.Default.(bool) - correctnessreportFields := schema.CorrectnessReport{}.Fields() - _ = correctnessreportFields - // correctnessreportDescSignature is the schema descriptor for signature field. - correctnessreportDescSignature := correctnessreportFields[2].Descriptor() - // correctnessreport.SignatureValidator is a validator for the "signature" field. It is called by the builders before save. - correctnessreport.SignatureValidator = correctnessreportDescSignature.Validators[0].(func([]byte) error) - // correctnessreportDescHash is the schema descriptor for hash field. - correctnessreportDescHash := correctnessreportFields[3].Descriptor() - // correctnessreport.HashValidator is a validator for the "hash" field. It is called by the builders before save. - correctnessreport.HashValidator = correctnessreportDescHash.Validators[0].(func([]byte) error) - // correctnessreportDescTopic is the schema descriptor for topic field. - correctnessreportDescTopic := correctnessreportFields[4].Descriptor() - // correctnessreport.TopicValidator is a validator for the "topic" field. It is called by the builders before save. - correctnessreport.TopicValidator = correctnessreportDescTopic.Validators[0].(func([]byte) error) - // correctnessreportDescConsensus is the schema descriptor for consensus field. - correctnessreportDescConsensus := correctnessreportFields[6].Descriptor() - // correctnessreport.DefaultConsensus holds the default value on creation for the consensus field. - correctnessreport.DefaultConsensus = correctnessreportDescConsensus.Default.(bool) - eventlogFields := schema.EventLog{}.Fields() - _ = eventlogFields - // eventlogDescSignature is the schema descriptor for signature field. - eventlogDescSignature := eventlogFields[2].Descriptor() - // eventlog.SignatureValidator is a validator for the "signature" field. It is called by the builders before save. - eventlog.SignatureValidator = eventlogDescSignature.Validators[0].(func([]byte) error) - // eventlogDescTransaction is the schema descriptor for transaction field. - eventlogDescTransaction := eventlogFields[7].Descriptor() - // eventlog.TransactionValidator is a validator for the "transaction" field. It is called by the builders before save. - eventlog.TransactionValidator = eventlogDescTransaction.Validators[0].(func([]byte) error) - // eventlogDescConsensus is the schema descriptor for consensus field. - eventlogDescConsensus := eventlogFields[9].Descriptor() - // eventlog.DefaultConsensus holds the default value on creation for the consensus field. - eventlog.DefaultConsensus = eventlogDescConsensus.Default.(bool) - signerFields := schema.Signer{}.Fields() - _ = signerFields - // signerDescName is the schema descriptor for name field. - signerDescName := signerFields[0].Descriptor() - // signer.NameValidator is a validator for the "name" field. It is called by the builders before save. - signer.NameValidator = signerDescName.Validators[0].(func(string) error) - // signerDescKey is the schema descriptor for key field. - signerDescKey := signerFields[2].Descriptor() - // signer.KeyValidator is a validator for the "key" field. It is called by the builders before save. - signer.KeyValidator = func() func([]byte) error { - validators := signerDescKey.Validators - fns := [...]func([]byte) error{ - validators[0].(func([]byte) error), - validators[1].(func([]byte) error), - } - return func(key []byte) error { - for _, fn := range fns { - if err := fn(key); err != nil { - return err - } - } - return nil - } - }() - // signerDescShortkey is the schema descriptor for shortkey field. - signerDescShortkey := signerFields[3].Descriptor() - // signer.ShortkeyValidator is a validator for the "shortkey" field. It is called by the builders before save. - signer.ShortkeyValidator = func() func([]byte) error { - validators := signerDescShortkey.Validators - fns := [...]func([]byte) error{ - validators[0].(func([]byte) error), - validators[1].(func([]byte) error), - } - return func(shortkey []byte) error { - for _, fn := range fns { - if err := fn(shortkey); err != nil { - return err - } - } - return nil - } - }() -} diff --git a/internal/ent/runtime/runtime.go b/internal/ent/runtime/runtime.go deleted file mode 100644 index 075ef70c..00000000 --- a/internal/ent/runtime/runtime.go +++ /dev/null @@ -1,10 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package runtime - -// The schema-stitching logic is generated in github.com/TimeleapLabs/unchained/internal/ent/runtime.go - -const ( - Version = "v0.13.1" // Version of ent codegen. - Sum = "h1:uD8QwN1h6SNphdCCzmkMN3feSUzNnVvV/WIkHKMbzOE=" // Sum of ent codegen. -) diff --git a/internal/ent/schema/assetprice.go b/internal/ent/schema/assetprice.go deleted file mode 100644 index c6aa6a1c..00000000 --- a/internal/ent/schema/assetprice.go +++ /dev/null @@ -1,77 +0,0 @@ -package schema - -import ( - "entgo.io/contrib/entgql" - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "entgo.io/ent/schema/index" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" -) - -// DataSet holds the schema definition for the DataSet entity. -type AssetPrice struct { - ent.Schema -} - -// Fields of the DataSet. -func (AssetPrice) Fields() []ent.Field { - return []ent.Field{ - field.Uint64("block"). - Annotations( - entgql.Type("Uint"), - entgql.OrderField("BLOCK"), - ), - field.Uint64("signersCount").Nillable().Optional(). - Annotations(entgql.Type("Uint")), - field.Uint("price"). - GoType(new(helpers.BigInt)). - SchemaType(map[string]string{ - // Uint256 - dialect.SQLite: "numeric(78, 0)", - dialect.Postgres: "numeric(78, 0)", - }). - Annotations(entgql.Type("Uint")), - field.Bytes("signature"). - MaxLen(SignatureMaxLen). - Annotations(entgql.Type("Bytes")), - field.String("asset").Optional(), - field.String("chain").Optional(), - field.String("pair").Optional(), - field.Bool("consensus").Default(false). - Annotations(entgql.Type("Boolean")), - field.Uint("voted"). - GoType(new(helpers.BigInt)). - SchemaType(map[string]string{ - // Uint256 - dialect.SQLite: "numeric(78, 0)", - dialect.Postgres: "numeric(78, 0)", - }). - Annotations(entgql.Type("Uint")), - } -} - -// Edges of the DataSet. -func (AssetPrice) Edges() []ent.Edge { - return []ent.Edge{ - // TODO: Make these required on next migrate - edge.To("signers", Signer.Type).Required(), - } -} - -// Edges of the DataSet. -func (AssetPrice) Indexes() []ent.Index { - return []ent.Index{ - index.Fields("block", "chain", "asset", "pair").Unique(), - index.Fields("block", "chain", "asset", "pair", "price", "consensus"), - } -} - -func (AssetPrice) Annotations() []schema.Annotation { - return []schema.Annotation{ - entgql.RelayConnection(), - entgql.QueryField(), - } -} diff --git a/internal/ent/schema/correctness.go b/internal/ent/schema/correctness.go deleted file mode 100644 index 74c5d00f..00000000 --- a/internal/ent/schema/correctness.go +++ /dev/null @@ -1,75 +0,0 @@ -package schema - -import ( - "entgo.io/contrib/entgql" - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "entgo.io/ent/schema/index" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" -) - -// DataSet holds the schema definition for the DataSet entity. -type CorrectnessReport struct { - ent.Schema -} - -const ( - SignatureMaxLen = 48 - HashMaxLen = 64 -) - -// Fields of the DataSet. -func (CorrectnessReport) Fields() []ent.Field { - return []ent.Field{ - field.Uint64("signersCount"). - Annotations(entgql.Type("Uint")), - field.Uint64("timestamp"). - Annotations(entgql.OrderField("TIMESTAMP")). - Annotations(entgql.Type("Uint")), - field.Bytes("signature"). - MaxLen(SignatureMaxLen). - Annotations(entgql.Type("Bytes")), - field.Bytes("hash"). - MaxLen(HashMaxLen). - Annotations(entgql.Type("Bytes")), - field.Bytes("topic"). - MaxLen(HashMaxLen). - Annotations(entgql.Type("Bytes")), - field.Bool("correct"), - field.Bool("consensus").Default(false). - Annotations(entgql.Type("Boolean")), - field.Uint("voted"). - GoType(new(helpers.BigInt)). - SchemaType(map[string]string{ - // Uint256 - dialect.SQLite: "numeric(78, 0)", - dialect.Postgres: "numeric(78, 0)", - }). - Annotations(entgql.Type("Uint")), - } -} - -// Edges of the DataSet. -func (CorrectnessReport) Edges() []ent.Edge { - return []ent.Edge{ - edge.To("signers", Signer.Type).Required(), - } -} - -// Edges of the DataSet. -func (CorrectnessReport) Indexes() []ent.Index { - return []ent.Index{ - index.Fields("topic", "hash").Unique(), - index.Fields("topic", "timestamp", "hash"), - } -} - -func (CorrectnessReport) Annotations() []schema.Annotation { - return []schema.Annotation{ - entgql.RelayConnection(), - entgql.QueryField(), - } -} diff --git a/internal/ent/schema/eventlog.go b/internal/ent/schema/eventlog.go deleted file mode 100644 index cb1d7f4f..00000000 --- a/internal/ent/schema/eventlog.go +++ /dev/null @@ -1,80 +0,0 @@ -package schema - -import ( - "entgo.io/contrib/entgql" - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "entgo.io/ent/schema/index" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/model" -) - -// DataSet holds the schema definition for the DataSet entity. -type EventLog struct { - ent.Schema -} - -const ( - TransactionMaxLen = 32 -) - -// Fields of the DataSet. -func (EventLog) Fields() []ent.Field { - return []ent.Field{ - field.Uint64("block"). - Annotations( - entgql.Type("Uint"), - entgql.OrderField("BLOCK"), - ), - field.Uint64("signersCount"). - Annotations(entgql.Type("Uint")), - field.Bytes("signature"). - MaxLen(SignatureMaxLen). - Annotations(entgql.Type("Bytes")), - field.String("address"), - field.String("chain"), - field.Uint64("index"). - Annotations(entgql.Type("Uint")), - field.String("event"), - field.Bytes("transaction"). - MaxLen(TransactionMaxLen). - Annotations(entgql.Type("Bytes")), - field.JSON("args", []model.EventLogArg{}), - field.Bool("consensus").Default(false). - Annotations(entgql.Type("Boolean")), - field.Uint("voted"). - GoType(new(helpers.BigInt)). - SchemaType(map[string]string{ - // Uint256 - dialect.SQLite: "numeric(78, 0)", - dialect.Postgres: "numeric(78, 0)", - }). - Annotations(entgql.Type("Uint")), - } -} - -// Edges of the DataSet. -func (EventLog) Edges() []ent.Edge { - return []ent.Edge{ - // TODO: Make these required on next migrate - edge.To("signers", Signer.Type).Required(), - } -} - -// Edges of the DataSet. -func (EventLog) Indexes() []ent.Index { - return []ent.Index{ - index.Fields("block", "transaction", "index").Unique(), - index.Fields("block", "address", "event", "consensus"), - } -} - -func (EventLog) Annotations() []schema.Annotation { - return []schema.Annotation{ - entgql.RelayConnection(), - entgql.QueryField(), - } -} diff --git a/internal/ent/schema/signer.go b/internal/ent/schema/signer.go deleted file mode 100644 index 8344289d..00000000 --- a/internal/ent/schema/signer.go +++ /dev/null @@ -1,68 +0,0 @@ -package schema - -import ( - "entgo.io/contrib/entgql" - "entgo.io/ent" - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "entgo.io/ent/schema/index" -) - -// DataSet holds the schema definition for the DataSet entity. -type Signer struct { - ent.Schema -} - -const ( - KeyMaxLen = 96 -) - -// Fields of the DataSet. -func (Signer) Fields() []ent.Field { - return []ent.Field{ - field.String("name"). - NotEmpty(), - field.String("evm"). - Nillable(). - Optional(), - field.Bytes("key"). - MaxLen(KeyMaxLen). - Unique(). - NotEmpty(). - Annotations(entgql.Type("Bytes")), - field.Bytes("shortkey"). - MaxLen(KeyMaxLen). - Unique(). - NotEmpty(). - Annotations(entgql.Type("Bytes")), - field.Int64("points"). - Annotations(entgql.OrderField("POINTS")), - } -} - -// Edges of the DataSet. -func (Signer) Edges() []ent.Edge { - return []ent.Edge{ - edge.From("assetPrice", AssetPrice.Type).Ref("signers"), - edge.From("eventLogs", EventLog.Type).Ref("signers"), - edge.From("correctnessReport", CorrectnessReport.Type).Ref("signers"), - } -} - -// Indexes of the DataSet. -func (Signer) Indexes() []ent.Index { - return []ent.Index{ - index.Fields("key"). - Unique(), - index.Fields("shortkey"). - Unique(), - } -} - -func (Signer) Annotations() []schema.Annotation { - return []schema.Annotation{ - entgql.RelayConnection(), - entgql.QueryField(), - } -} diff --git a/internal/ent/signer.go b/internal/ent/signer.go deleted file mode 100644 index 9e88f167..00000000 --- a/internal/ent/signer.go +++ /dev/null @@ -1,288 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "fmt" - "strings" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// Signer is the model entity for the Signer schema. -type Signer struct { - config `json:"-"` - // ID of the ent. - ID int `json:"id,omitempty"` - // Name holds the value of the "name" field. - Name string `json:"name,omitempty"` - // Evm holds the value of the "evm" field. - Evm *string `json:"evm,omitempty"` - // Key holds the value of the "key" field. - Key []byte `json:"key,omitempty"` - // Shortkey holds the value of the "shortkey" field. - Shortkey []byte `json:"shortkey,omitempty"` - // Points holds the value of the "points" field. - Points int64 `json:"points,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the SignerQuery when eager-loading is set. - Edges SignerEdges `json:"edges"` - selectValues sql.SelectValues -} - -// SignerEdges holds the relations/edges for other nodes in the graph. -type SignerEdges struct { - // AssetPrice holds the value of the assetPrice edge. - AssetPrice []*AssetPrice `json:"assetPrice,omitempty"` - // EventLogs holds the value of the eventLogs edge. - EventLogs []*EventLog `json:"eventLogs,omitempty"` - // CorrectnessReport holds the value of the correctnessReport edge. - CorrectnessReport []*CorrectnessReport `json:"correctnessReport,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [3]bool - // totalCount holds the count of the edges above. - totalCount [3]map[string]int - - namedAssetPrice map[string][]*AssetPrice - namedEventLogs map[string][]*EventLog - namedCorrectnessReport map[string][]*CorrectnessReport -} - -// AssetPriceOrErr returns the AssetPrice value or an error if the edge -// was not loaded in eager-loading. -func (e SignerEdges) AssetPriceOrErr() ([]*AssetPrice, error) { - if e.loadedTypes[0] { - return e.AssetPrice, nil - } - return nil, &NotLoadedError{edge: "assetPrice"} -} - -// EventLogsOrErr returns the EventLogs value or an error if the edge -// was not loaded in eager-loading. -func (e SignerEdges) EventLogsOrErr() ([]*EventLog, error) { - if e.loadedTypes[1] { - return e.EventLogs, nil - } - return nil, &NotLoadedError{edge: "eventLogs"} -} - -// CorrectnessReportOrErr returns the CorrectnessReport value or an error if the edge -// was not loaded in eager-loading. -func (e SignerEdges) CorrectnessReportOrErr() ([]*CorrectnessReport, error) { - if e.loadedTypes[2] { - return e.CorrectnessReport, nil - } - return nil, &NotLoadedError{edge: "correctnessReport"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*Signer) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case signer.FieldKey, signer.FieldShortkey: - values[i] = new([]byte) - case signer.FieldID, signer.FieldPoints: - values[i] = new(sql.NullInt64) - case signer.FieldName, signer.FieldEvm: - 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 Signer fields. -func (s *Signer) 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 signer.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) - } - s.ID = int(value.Int64) - case signer.FieldName: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field name", values[i]) - } else if value.Valid { - s.Name = value.String - } - case signer.FieldEvm: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field evm", values[i]) - } else if value.Valid { - s.Evm = new(string) - *s.Evm = value.String - } - case signer.FieldKey: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field key", values[i]) - } else if value != nil { - s.Key = *value - } - case signer.FieldShortkey: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field shortkey", values[i]) - } else if value != nil { - s.Shortkey = *value - } - case signer.FieldPoints: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field points", values[i]) - } else if value.Valid { - s.Points = value.Int64 - } - default: - s.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the Signer. -// This includes values selected through modifiers, order, etc. -func (s *Signer) Value(name string) (ent.Value, error) { - return s.selectValues.Get(name) -} - -// QueryAssetPrice queries the "assetPrice" edge of the Signer entity. -func (s *Signer) QueryAssetPrice() *AssetPriceQuery { - return NewSignerClient(s.config).QueryAssetPrice(s) -} - -// QueryEventLogs queries the "eventLogs" edge of the Signer entity. -func (s *Signer) QueryEventLogs() *EventLogQuery { - return NewSignerClient(s.config).QueryEventLogs(s) -} - -// QueryCorrectnessReport queries the "correctnessReport" edge of the Signer entity. -func (s *Signer) QueryCorrectnessReport() *CorrectnessReportQuery { - return NewSignerClient(s.config).QueryCorrectnessReport(s) -} - -// Update returns a builder for updating this Signer. -// Note that you need to call Signer.Unwrap() before calling this method if this Signer -// was returned from a transaction, and the transaction was committed or rolled back. -func (s *Signer) Update() *SignerUpdateOne { - return NewSignerClient(s.config).UpdateOne(s) -} - -// Unwrap unwraps the Signer 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 (s *Signer) Unwrap() *Signer { - _tx, ok := s.config.driver.(*txDriver) - if !ok { - panic("ent: Signer is not a transactional entity") - } - s.config.driver = _tx.drv - return s -} - -// String implements the fmt.Stringer. -func (s *Signer) String() string { - var builder strings.Builder - builder.WriteString("Signer(") - builder.WriteString(fmt.Sprintf("id=%v, ", s.ID)) - builder.WriteString("name=") - builder.WriteString(s.Name) - builder.WriteString(", ") - if v := s.Evm; v != nil { - builder.WriteString("evm=") - builder.WriteString(*v) - } - builder.WriteString(", ") - builder.WriteString("key=") - builder.WriteString(fmt.Sprintf("%v", s.Key)) - builder.WriteString(", ") - builder.WriteString("shortkey=") - builder.WriteString(fmt.Sprintf("%v", s.Shortkey)) - builder.WriteString(", ") - builder.WriteString("points=") - builder.WriteString(fmt.Sprintf("%v", s.Points)) - builder.WriteByte(')') - return builder.String() -} - -// NamedAssetPrice returns the AssetPrice named value or an error if the edge was not -// loaded in eager-loading with this name. -func (s *Signer) NamedAssetPrice(name string) ([]*AssetPrice, error) { - if s.Edges.namedAssetPrice == nil { - return nil, &NotLoadedError{edge: name} - } - nodes, ok := s.Edges.namedAssetPrice[name] - if !ok { - return nil, &NotLoadedError{edge: name} - } - return nodes, nil -} - -func (s *Signer) appendNamedAssetPrice(name string, edges ...*AssetPrice) { - if s.Edges.namedAssetPrice == nil { - s.Edges.namedAssetPrice = make(map[string][]*AssetPrice) - } - if len(edges) == 0 { - s.Edges.namedAssetPrice[name] = []*AssetPrice{} - } else { - s.Edges.namedAssetPrice[name] = append(s.Edges.namedAssetPrice[name], edges...) - } -} - -// NamedEventLogs returns the EventLogs named value or an error if the edge was not -// loaded in eager-loading with this name. -func (s *Signer) NamedEventLogs(name string) ([]*EventLog, error) { - if s.Edges.namedEventLogs == nil { - return nil, &NotLoadedError{edge: name} - } - nodes, ok := s.Edges.namedEventLogs[name] - if !ok { - return nil, &NotLoadedError{edge: name} - } - return nodes, nil -} - -func (s *Signer) appendNamedEventLogs(name string, edges ...*EventLog) { - if s.Edges.namedEventLogs == nil { - s.Edges.namedEventLogs = make(map[string][]*EventLog) - } - if len(edges) == 0 { - s.Edges.namedEventLogs[name] = []*EventLog{} - } else { - s.Edges.namedEventLogs[name] = append(s.Edges.namedEventLogs[name], edges...) - } -} - -// NamedCorrectnessReport returns the CorrectnessReport named value or an error if the edge was not -// loaded in eager-loading with this name. -func (s *Signer) NamedCorrectnessReport(name string) ([]*CorrectnessReport, error) { - if s.Edges.namedCorrectnessReport == nil { - return nil, &NotLoadedError{edge: name} - } - nodes, ok := s.Edges.namedCorrectnessReport[name] - if !ok { - return nil, &NotLoadedError{edge: name} - } - return nodes, nil -} - -func (s *Signer) appendNamedCorrectnessReport(name string, edges ...*CorrectnessReport) { - if s.Edges.namedCorrectnessReport == nil { - s.Edges.namedCorrectnessReport = make(map[string][]*CorrectnessReport) - } - if len(edges) == 0 { - s.Edges.namedCorrectnessReport[name] = []*CorrectnessReport{} - } else { - s.Edges.namedCorrectnessReport[name] = append(s.Edges.namedCorrectnessReport[name], edges...) - } -} - -// Signers is a parsable slice of Signer. -type Signers []*Signer diff --git a/internal/ent/signer/signer.go b/internal/ent/signer/signer.go deleted file mode 100644 index 66e88841..00000000 --- a/internal/ent/signer/signer.go +++ /dev/null @@ -1,175 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package signer - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the signer type in the database. - Label = "signer" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldName holds the string denoting the name field in the database. - FieldName = "name" - // FieldEvm holds the string denoting the evm field in the database. - FieldEvm = "evm" - // FieldKey holds the string denoting the key field in the database. - FieldKey = "key" - // FieldShortkey holds the string denoting the shortkey field in the database. - FieldShortkey = "shortkey" - // FieldPoints holds the string denoting the points field in the database. - FieldPoints = "points" - // EdgeAssetPrice holds the string denoting the assetprice edge name in mutations. - EdgeAssetPrice = "assetPrice" - // EdgeEventLogs holds the string denoting the eventlogs edge name in mutations. - EdgeEventLogs = "eventLogs" - // EdgeCorrectnessReport holds the string denoting the correctnessreport edge name in mutations. - EdgeCorrectnessReport = "correctnessReport" - // Table holds the table name of the signer in the database. - Table = "signers" - // AssetPriceTable is the table that holds the assetPrice relation/edge. The primary key declared below. - AssetPriceTable = "asset_price_signers" - // AssetPriceInverseTable is the table name for the AssetPrice entity. - // It exists in this package in order to avoid circular dependency with the "assetprice" package. - AssetPriceInverseTable = "asset_prices" - // EventLogsTable is the table that holds the eventLogs relation/edge. The primary key declared below. - EventLogsTable = "event_log_signers" - // EventLogsInverseTable is the table name for the EventLog entity. - // It exists in this package in order to avoid circular dependency with the "eventlog" package. - EventLogsInverseTable = "event_logs" - // CorrectnessReportTable is the table that holds the correctnessReport relation/edge. The primary key declared below. - CorrectnessReportTable = "correctness_report_signers" - // CorrectnessReportInverseTable is the table name for the CorrectnessReport entity. - // It exists in this package in order to avoid circular dependency with the "correctnessreport" package. - CorrectnessReportInverseTable = "correctness_reports" -) - -// Columns holds all SQL columns for signer fields. -var Columns = []string{ - FieldID, - FieldName, - FieldEvm, - FieldKey, - FieldShortkey, - FieldPoints, -} - -var ( - // AssetPricePrimaryKey and AssetPriceColumn2 are the table columns denoting the - // primary key for the assetPrice relation (M2M). - AssetPricePrimaryKey = []string{"asset_price_id", "signer_id"} - // EventLogsPrimaryKey and EventLogsColumn2 are the table columns denoting the - // primary key for the eventLogs relation (M2M). - EventLogsPrimaryKey = []string{"event_log_id", "signer_id"} - // CorrectnessReportPrimaryKey and CorrectnessReportColumn2 are the table columns denoting the - // primary key for the correctnessReport relation (M2M). - CorrectnessReportPrimaryKey = []string{"correctness_report_id", "signer_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 -} - -var ( - // NameValidator is a validator for the "name" field. It is called by the builders before save. - NameValidator func(string) error - // KeyValidator is a validator for the "key" field. It is called by the builders before save. - KeyValidator func([]byte) error - // ShortkeyValidator is a validator for the "shortkey" field. It is called by the builders before save. - ShortkeyValidator func([]byte) error -) - -// OrderOption defines the ordering options for the Signer 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() -} - -// ByName orders the results by the name field. -func ByName(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldName, opts...).ToFunc() -} - -// ByEvm orders the results by the evm field. -func ByEvm(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldEvm, opts...).ToFunc() -} - -// ByPoints orders the results by the points field. -func ByPoints(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPoints, opts...).ToFunc() -} - -// ByAssetPriceCount orders the results by assetPrice count. -func ByAssetPriceCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newAssetPriceStep(), opts...) - } -} - -// ByAssetPrice orders the results by assetPrice terms. -func ByAssetPrice(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newAssetPriceStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByEventLogsCount orders the results by eventLogs count. -func ByEventLogsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newEventLogsStep(), opts...) - } -} - -// ByEventLogs orders the results by eventLogs terms. -func ByEventLogs(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newEventLogsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByCorrectnessReportCount orders the results by correctnessReport count. -func ByCorrectnessReportCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newCorrectnessReportStep(), opts...) - } -} - -// ByCorrectnessReport orders the results by correctnessReport terms. -func ByCorrectnessReport(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newCorrectnessReportStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newAssetPriceStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(AssetPriceInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, AssetPriceTable, AssetPricePrimaryKey...), - ) -} -func newEventLogsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(EventLogsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, EventLogsTable, EventLogsPrimaryKey...), - ) -} -func newCorrectnessReportStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(CorrectnessReportInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, CorrectnessReportTable, CorrectnessReportPrimaryKey...), - ) -} diff --git a/internal/ent/signer/where.go b/internal/ent/signer/where.go deleted file mode 100644 index 8e83872b..00000000 --- a/internal/ent/signer/where.go +++ /dev/null @@ -1,423 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package signer - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.Signer { - return predicate.Signer(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.Signer { - return predicate.Signer(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.Signer { - return predicate.Signer(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.Signer { - return predicate.Signer(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.Signer { - return predicate.Signer(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.Signer { - return predicate.Signer(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.Signer { - return predicate.Signer(sql.FieldLTE(FieldID, id)) -} - -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldName, v)) -} - -// Evm applies equality check predicate on the "evm" field. It's identical to EvmEQ. -func Evm(v string) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldEvm, v)) -} - -// Key applies equality check predicate on the "key" field. It's identical to KeyEQ. -func Key(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldKey, v)) -} - -// Shortkey applies equality check predicate on the "shortkey" field. It's identical to ShortkeyEQ. -func Shortkey(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldShortkey, v)) -} - -// Points applies equality check predicate on the "points" field. It's identical to PointsEQ. -func Points(v int64) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldPoints, v)) -} - -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldName, v)) -} - -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.Signer { - return predicate.Signer(sql.FieldNEQ(FieldName, v)) -} - -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.Signer { - return predicate.Signer(sql.FieldIn(FieldName, vs...)) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.Signer { - return predicate.Signer(sql.FieldNotIn(FieldName, vs...)) -} - -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.Signer { - return predicate.Signer(sql.FieldGT(FieldName, v)) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.Signer { - return predicate.Signer(sql.FieldGTE(FieldName, v)) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.Signer { - return predicate.Signer(sql.FieldLT(FieldName, v)) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.Signer { - return predicate.Signer(sql.FieldLTE(FieldName, v)) -} - -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.Signer { - return predicate.Signer(sql.FieldContains(FieldName, v)) -} - -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.Signer { - return predicate.Signer(sql.FieldHasPrefix(FieldName, v)) -} - -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.Signer { - return predicate.Signer(sql.FieldHasSuffix(FieldName, v)) -} - -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.Signer { - return predicate.Signer(sql.FieldEqualFold(FieldName, v)) -} - -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.Signer { - return predicate.Signer(sql.FieldContainsFold(FieldName, v)) -} - -// EvmEQ applies the EQ predicate on the "evm" field. -func EvmEQ(v string) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldEvm, v)) -} - -// EvmNEQ applies the NEQ predicate on the "evm" field. -func EvmNEQ(v string) predicate.Signer { - return predicate.Signer(sql.FieldNEQ(FieldEvm, v)) -} - -// EvmIn applies the In predicate on the "evm" field. -func EvmIn(vs ...string) predicate.Signer { - return predicate.Signer(sql.FieldIn(FieldEvm, vs...)) -} - -// EvmNotIn applies the NotIn predicate on the "evm" field. -func EvmNotIn(vs ...string) predicate.Signer { - return predicate.Signer(sql.FieldNotIn(FieldEvm, vs...)) -} - -// EvmGT applies the GT predicate on the "evm" field. -func EvmGT(v string) predicate.Signer { - return predicate.Signer(sql.FieldGT(FieldEvm, v)) -} - -// EvmGTE applies the GTE predicate on the "evm" field. -func EvmGTE(v string) predicate.Signer { - return predicate.Signer(sql.FieldGTE(FieldEvm, v)) -} - -// EvmLT applies the LT predicate on the "evm" field. -func EvmLT(v string) predicate.Signer { - return predicate.Signer(sql.FieldLT(FieldEvm, v)) -} - -// EvmLTE applies the LTE predicate on the "evm" field. -func EvmLTE(v string) predicate.Signer { - return predicate.Signer(sql.FieldLTE(FieldEvm, v)) -} - -// EvmContains applies the Contains predicate on the "evm" field. -func EvmContains(v string) predicate.Signer { - return predicate.Signer(sql.FieldContains(FieldEvm, v)) -} - -// EvmHasPrefix applies the HasPrefix predicate on the "evm" field. -func EvmHasPrefix(v string) predicate.Signer { - return predicate.Signer(sql.FieldHasPrefix(FieldEvm, v)) -} - -// EvmHasSuffix applies the HasSuffix predicate on the "evm" field. -func EvmHasSuffix(v string) predicate.Signer { - return predicate.Signer(sql.FieldHasSuffix(FieldEvm, v)) -} - -// EvmIsNil applies the IsNil predicate on the "evm" field. -func EvmIsNil() predicate.Signer { - return predicate.Signer(sql.FieldIsNull(FieldEvm)) -} - -// EvmNotNil applies the NotNil predicate on the "evm" field. -func EvmNotNil() predicate.Signer { - return predicate.Signer(sql.FieldNotNull(FieldEvm)) -} - -// EvmEqualFold applies the EqualFold predicate on the "evm" field. -func EvmEqualFold(v string) predicate.Signer { - return predicate.Signer(sql.FieldEqualFold(FieldEvm, v)) -} - -// EvmContainsFold applies the ContainsFold predicate on the "evm" field. -func EvmContainsFold(v string) predicate.Signer { - return predicate.Signer(sql.FieldContainsFold(FieldEvm, v)) -} - -// KeyEQ applies the EQ predicate on the "key" field. -func KeyEQ(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldKey, v)) -} - -// KeyNEQ applies the NEQ predicate on the "key" field. -func KeyNEQ(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldNEQ(FieldKey, v)) -} - -// KeyIn applies the In predicate on the "key" field. -func KeyIn(vs ...[]byte) predicate.Signer { - return predicate.Signer(sql.FieldIn(FieldKey, vs...)) -} - -// KeyNotIn applies the NotIn predicate on the "key" field. -func KeyNotIn(vs ...[]byte) predicate.Signer { - return predicate.Signer(sql.FieldNotIn(FieldKey, vs...)) -} - -// KeyGT applies the GT predicate on the "key" field. -func KeyGT(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldGT(FieldKey, v)) -} - -// KeyGTE applies the GTE predicate on the "key" field. -func KeyGTE(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldGTE(FieldKey, v)) -} - -// KeyLT applies the LT predicate on the "key" field. -func KeyLT(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldLT(FieldKey, v)) -} - -// KeyLTE applies the LTE predicate on the "key" field. -func KeyLTE(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldLTE(FieldKey, v)) -} - -// ShortkeyEQ applies the EQ predicate on the "shortkey" field. -func ShortkeyEQ(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldShortkey, v)) -} - -// ShortkeyNEQ applies the NEQ predicate on the "shortkey" field. -func ShortkeyNEQ(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldNEQ(FieldShortkey, v)) -} - -// ShortkeyIn applies the In predicate on the "shortkey" field. -func ShortkeyIn(vs ...[]byte) predicate.Signer { - return predicate.Signer(sql.FieldIn(FieldShortkey, vs...)) -} - -// ShortkeyNotIn applies the NotIn predicate on the "shortkey" field. -func ShortkeyNotIn(vs ...[]byte) predicate.Signer { - return predicate.Signer(sql.FieldNotIn(FieldShortkey, vs...)) -} - -// ShortkeyGT applies the GT predicate on the "shortkey" field. -func ShortkeyGT(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldGT(FieldShortkey, v)) -} - -// ShortkeyGTE applies the GTE predicate on the "shortkey" field. -func ShortkeyGTE(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldGTE(FieldShortkey, v)) -} - -// ShortkeyLT applies the LT predicate on the "shortkey" field. -func ShortkeyLT(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldLT(FieldShortkey, v)) -} - -// ShortkeyLTE applies the LTE predicate on the "shortkey" field. -func ShortkeyLTE(v []byte) predicate.Signer { - return predicate.Signer(sql.FieldLTE(FieldShortkey, v)) -} - -// PointsEQ applies the EQ predicate on the "points" field. -func PointsEQ(v int64) predicate.Signer { - return predicate.Signer(sql.FieldEQ(FieldPoints, v)) -} - -// PointsNEQ applies the NEQ predicate on the "points" field. -func PointsNEQ(v int64) predicate.Signer { - return predicate.Signer(sql.FieldNEQ(FieldPoints, v)) -} - -// PointsIn applies the In predicate on the "points" field. -func PointsIn(vs ...int64) predicate.Signer { - return predicate.Signer(sql.FieldIn(FieldPoints, vs...)) -} - -// PointsNotIn applies the NotIn predicate on the "points" field. -func PointsNotIn(vs ...int64) predicate.Signer { - return predicate.Signer(sql.FieldNotIn(FieldPoints, vs...)) -} - -// PointsGT applies the GT predicate on the "points" field. -func PointsGT(v int64) predicate.Signer { - return predicate.Signer(sql.FieldGT(FieldPoints, v)) -} - -// PointsGTE applies the GTE predicate on the "points" field. -func PointsGTE(v int64) predicate.Signer { - return predicate.Signer(sql.FieldGTE(FieldPoints, v)) -} - -// PointsLT applies the LT predicate on the "points" field. -func PointsLT(v int64) predicate.Signer { - return predicate.Signer(sql.FieldLT(FieldPoints, v)) -} - -// PointsLTE applies the LTE predicate on the "points" field. -func PointsLTE(v int64) predicate.Signer { - return predicate.Signer(sql.FieldLTE(FieldPoints, v)) -} - -// HasAssetPrice applies the HasEdge predicate on the "assetPrice" edge. -func HasAssetPrice() predicate.Signer { - return predicate.Signer(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, AssetPriceTable, AssetPricePrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasAssetPriceWith applies the HasEdge predicate on the "assetPrice" edge with a given conditions (other predicates). -func HasAssetPriceWith(preds ...predicate.AssetPrice) predicate.Signer { - return predicate.Signer(func(s *sql.Selector) { - step := newAssetPriceStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasEventLogs applies the HasEdge predicate on the "eventLogs" edge. -func HasEventLogs() predicate.Signer { - return predicate.Signer(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, EventLogsTable, EventLogsPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasEventLogsWith applies the HasEdge predicate on the "eventLogs" edge with a given conditions (other predicates). -func HasEventLogsWith(preds ...predicate.EventLog) predicate.Signer { - return predicate.Signer(func(s *sql.Selector) { - step := newEventLogsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasCorrectnessReport applies the HasEdge predicate on the "correctnessReport" edge. -func HasCorrectnessReport() predicate.Signer { - return predicate.Signer(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, CorrectnessReportTable, CorrectnessReportPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasCorrectnessReportWith applies the HasEdge predicate on the "correctnessReport" edge with a given conditions (other predicates). -func HasCorrectnessReportWith(preds ...predicate.CorrectnessReport) predicate.Signer { - return predicate.Signer(func(s *sql.Selector) { - step := newCorrectnessReportStep() - 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.Signer) predicate.Signer { - return predicate.Signer(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.Signer) predicate.Signer { - return predicate.Signer(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.Signer) predicate.Signer { - return predicate.Signer(sql.NotPredicates(p)) -} diff --git a/internal/ent/signer_create.go b/internal/ent/signer_create.go deleted file mode 100644 index 170ff05f..00000000 --- a/internal/ent/signer_create.go +++ /dev/null @@ -1,822 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// SignerCreate is the builder for creating a Signer entity. -type SignerCreate struct { - config - mutation *SignerMutation - hooks []Hook - conflict []sql.ConflictOption -} - -// SetName sets the "name" field. -func (sc *SignerCreate) SetName(s string) *SignerCreate { - sc.mutation.SetName(s) - return sc -} - -// SetEvm sets the "evm" field. -func (sc *SignerCreate) SetEvm(s string) *SignerCreate { - sc.mutation.SetEvm(s) - return sc -} - -// SetNillableEvm sets the "evm" field if the given value is not nil. -func (sc *SignerCreate) SetNillableEvm(s *string) *SignerCreate { - if s != nil { - sc.SetEvm(*s) - } - return sc -} - -// SetKey sets the "key" field. -func (sc *SignerCreate) SetKey(b []byte) *SignerCreate { - sc.mutation.SetKey(b) - return sc -} - -// SetShortkey sets the "shortkey" field. -func (sc *SignerCreate) SetShortkey(b []byte) *SignerCreate { - sc.mutation.SetShortkey(b) - return sc -} - -// SetPoints sets the "points" field. -func (sc *SignerCreate) SetPoints(i int64) *SignerCreate { - sc.mutation.SetPoints(i) - return sc -} - -// AddAssetPriceIDs adds the "assetPrice" edge to the AssetPrice entity by IDs. -func (sc *SignerCreate) AddAssetPriceIDs(ids ...int) *SignerCreate { - sc.mutation.AddAssetPriceIDs(ids...) - return sc -} - -// AddAssetPrice adds the "assetPrice" edges to the AssetPrice entity. -func (sc *SignerCreate) AddAssetPrice(a ...*AssetPrice) *SignerCreate { - ids := make([]int, len(a)) - for i := range a { - ids[i] = a[i].ID - } - return sc.AddAssetPriceIDs(ids...) -} - -// AddEventLogIDs adds the "eventLogs" edge to the EventLog entity by IDs. -func (sc *SignerCreate) AddEventLogIDs(ids ...int) *SignerCreate { - sc.mutation.AddEventLogIDs(ids...) - return sc -} - -// AddEventLogs adds the "eventLogs" edges to the EventLog entity. -func (sc *SignerCreate) AddEventLogs(e ...*EventLog) *SignerCreate { - ids := make([]int, len(e)) - for i := range e { - ids[i] = e[i].ID - } - return sc.AddEventLogIDs(ids...) -} - -// AddCorrectnessReportIDs adds the "correctnessReport" edge to the CorrectnessReport entity by IDs. -func (sc *SignerCreate) AddCorrectnessReportIDs(ids ...int) *SignerCreate { - sc.mutation.AddCorrectnessReportIDs(ids...) - return sc -} - -// AddCorrectnessReport adds the "correctnessReport" edges to the CorrectnessReport entity. -func (sc *SignerCreate) AddCorrectnessReport(c ...*CorrectnessReport) *SignerCreate { - ids := make([]int, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return sc.AddCorrectnessReportIDs(ids...) -} - -// Mutation returns the SignerMutation object of the builder. -func (sc *SignerCreate) Mutation() *SignerMutation { - return sc.mutation -} - -// Save creates the Signer in the database. -func (sc *SignerCreate) Save(ctx context.Context) (*Signer, error) { - return withHooks(ctx, sc.sqlSave, sc.mutation, sc.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (sc *SignerCreate) SaveX(ctx context.Context) *Signer { - v, err := sc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (sc *SignerCreate) Exec(ctx context.Context) error { - _, err := sc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (sc *SignerCreate) ExecX(ctx context.Context) { - if err := sc.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (sc *SignerCreate) check() error { - if _, ok := sc.mutation.Name(); !ok { - return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Signer.name"`)} - } - if v, ok := sc.mutation.Name(); ok { - if err := signer.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Signer.name": %w`, err)} - } - } - if _, ok := sc.mutation.Key(); !ok { - return &ValidationError{Name: "key", err: errors.New(`ent: missing required field "Signer.key"`)} - } - if v, ok := sc.mutation.Key(); ok { - if err := signer.KeyValidator(v); err != nil { - return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "Signer.key": %w`, err)} - } - } - if _, ok := sc.mutation.Shortkey(); !ok { - return &ValidationError{Name: "shortkey", err: errors.New(`ent: missing required field "Signer.shortkey"`)} - } - if v, ok := sc.mutation.Shortkey(); ok { - if err := signer.ShortkeyValidator(v); err != nil { - return &ValidationError{Name: "shortkey", err: fmt.Errorf(`ent: validator failed for field "Signer.shortkey": %w`, err)} - } - } - if _, ok := sc.mutation.Points(); !ok { - return &ValidationError{Name: "points", err: errors.New(`ent: missing required field "Signer.points"`)} - } - return nil -} - -func (sc *SignerCreate) sqlSave(ctx context.Context) (*Signer, error) { - if err := sc.check(); err != nil { - return nil, err - } - _node, _spec := sc.createSpec() - if err := sqlgraph.CreateNode(ctx, sc.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) - sc.mutation.id = &_node.ID - sc.mutation.done = true - return _node, nil -} - -func (sc *SignerCreate) createSpec() (*Signer, *sqlgraph.CreateSpec) { - var ( - _node = &Signer{config: sc.config} - _spec = sqlgraph.NewCreateSpec(signer.Table, sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt)) - ) - _spec.OnConflict = sc.conflict - if value, ok := sc.mutation.Name(); ok { - _spec.SetField(signer.FieldName, field.TypeString, value) - _node.Name = value - } - if value, ok := sc.mutation.Evm(); ok { - _spec.SetField(signer.FieldEvm, field.TypeString, value) - _node.Evm = &value - } - if value, ok := sc.mutation.Key(); ok { - _spec.SetField(signer.FieldKey, field.TypeBytes, value) - _node.Key = value - } - if value, ok := sc.mutation.Shortkey(); ok { - _spec.SetField(signer.FieldShortkey, field.TypeBytes, value) - _node.Shortkey = value - } - if value, ok := sc.mutation.Points(); ok { - _spec.SetField(signer.FieldPoints, field.TypeInt64, value) - _node.Points = value - } - if nodes := sc.mutation.AssetPriceIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.AssetPriceTable, - Columns: signer.AssetPricePrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := sc.mutation.EventLogsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.EventLogsTable, - Columns: signer.EventLogsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := sc.mutation.CorrectnessReportIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.CorrectnessReportTable, - Columns: signer.CorrectnessReportPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(correctnessreport.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.Signer.Create(). -// SetName(v). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.SignerUpsert) { -// SetName(v+v). -// }). -// Exec(ctx) -func (sc *SignerCreate) OnConflict(opts ...sql.ConflictOption) *SignerUpsertOne { - sc.conflict = opts - return &SignerUpsertOne{ - create: sc, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.Signer.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (sc *SignerCreate) OnConflictColumns(columns ...string) *SignerUpsertOne { - sc.conflict = append(sc.conflict, sql.ConflictColumns(columns...)) - return &SignerUpsertOne{ - create: sc, - } -} - -type ( - // SignerUpsertOne is the builder for "upsert"-ing - // one Signer node. - SignerUpsertOne struct { - create *SignerCreate - } - - // SignerUpsert is the "OnConflict" setter. - SignerUpsert struct { - *sql.UpdateSet - } -) - -// SetName sets the "name" field. -func (u *SignerUpsert) SetName(v string) *SignerUpsert { - u.Set(signer.FieldName, v) - return u -} - -// UpdateName sets the "name" field to the value that was provided on create. -func (u *SignerUpsert) UpdateName() *SignerUpsert { - u.SetExcluded(signer.FieldName) - return u -} - -// SetEvm sets the "evm" field. -func (u *SignerUpsert) SetEvm(v string) *SignerUpsert { - u.Set(signer.FieldEvm, v) - return u -} - -// UpdateEvm sets the "evm" field to the value that was provided on create. -func (u *SignerUpsert) UpdateEvm() *SignerUpsert { - u.SetExcluded(signer.FieldEvm) - return u -} - -// ClearEvm clears the value of the "evm" field. -func (u *SignerUpsert) ClearEvm() *SignerUpsert { - u.SetNull(signer.FieldEvm) - return u -} - -// SetKey sets the "key" field. -func (u *SignerUpsert) SetKey(v []byte) *SignerUpsert { - u.Set(signer.FieldKey, v) - return u -} - -// UpdateKey sets the "key" field to the value that was provided on create. -func (u *SignerUpsert) UpdateKey() *SignerUpsert { - u.SetExcluded(signer.FieldKey) - return u -} - -// SetShortkey sets the "shortkey" field. -func (u *SignerUpsert) SetShortkey(v []byte) *SignerUpsert { - u.Set(signer.FieldShortkey, v) - return u -} - -// UpdateShortkey sets the "shortkey" field to the value that was provided on create. -func (u *SignerUpsert) UpdateShortkey() *SignerUpsert { - u.SetExcluded(signer.FieldShortkey) - return u -} - -// SetPoints sets the "points" field. -func (u *SignerUpsert) SetPoints(v int64) *SignerUpsert { - u.Set(signer.FieldPoints, v) - return u -} - -// UpdatePoints sets the "points" field to the value that was provided on create. -func (u *SignerUpsert) UpdatePoints() *SignerUpsert { - u.SetExcluded(signer.FieldPoints) - return u -} - -// AddPoints adds v to the "points" field. -func (u *SignerUpsert) AddPoints(v int64) *SignerUpsert { - u.Add(signer.FieldPoints, v) - return u -} - -// UpdateNewValues updates the mutable fields using the new values that were set on create. -// Using this option is equivalent to using: -// -// client.Signer.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *SignerUpsertOne) UpdateNewValues() *SignerUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.Signer.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *SignerUpsertOne) Ignore() *SignerUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *SignerUpsertOne) DoNothing() *SignerUpsertOne { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the SignerCreate.OnConflict -// documentation for more info. -func (u *SignerUpsertOne) Update(set func(*SignerUpsert)) *SignerUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&SignerUpsert{UpdateSet: update}) - })) - return u -} - -// SetName sets the "name" field. -func (u *SignerUpsertOne) SetName(v string) *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.SetName(v) - }) -} - -// UpdateName sets the "name" field to the value that was provided on create. -func (u *SignerUpsertOne) UpdateName() *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.UpdateName() - }) -} - -// SetEvm sets the "evm" field. -func (u *SignerUpsertOne) SetEvm(v string) *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.SetEvm(v) - }) -} - -// UpdateEvm sets the "evm" field to the value that was provided on create. -func (u *SignerUpsertOne) UpdateEvm() *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.UpdateEvm() - }) -} - -// ClearEvm clears the value of the "evm" field. -func (u *SignerUpsertOne) ClearEvm() *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.ClearEvm() - }) -} - -// SetKey sets the "key" field. -func (u *SignerUpsertOne) SetKey(v []byte) *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.SetKey(v) - }) -} - -// UpdateKey sets the "key" field to the value that was provided on create. -func (u *SignerUpsertOne) UpdateKey() *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.UpdateKey() - }) -} - -// SetShortkey sets the "shortkey" field. -func (u *SignerUpsertOne) SetShortkey(v []byte) *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.SetShortkey(v) - }) -} - -// UpdateShortkey sets the "shortkey" field to the value that was provided on create. -func (u *SignerUpsertOne) UpdateShortkey() *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.UpdateShortkey() - }) -} - -// SetPoints sets the "points" field. -func (u *SignerUpsertOne) SetPoints(v int64) *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.SetPoints(v) - }) -} - -// AddPoints adds v to the "points" field. -func (u *SignerUpsertOne) AddPoints(v int64) *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.AddPoints(v) - }) -} - -// UpdatePoints sets the "points" field to the value that was provided on create. -func (u *SignerUpsertOne) UpdatePoints() *SignerUpsertOne { - return u.Update(func(s *SignerUpsert) { - s.UpdatePoints() - }) -} - -// Exec executes the query. -func (u *SignerUpsertOne) Exec(ctx context.Context) error { - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for SignerCreate.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *SignerUpsertOne) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} - -// Exec executes the UPSERT query and returns the inserted/updated ID. -func (u *SignerUpsertOne) ID(ctx context.Context) (id int, err error) { - node, err := u.create.Save(ctx) - if err != nil { - return id, err - } - return node.ID, nil -} - -// IDX is like ID, but panics if an error occurs. -func (u *SignerUpsertOne) IDX(ctx context.Context) int { - id, err := u.ID(ctx) - if err != nil { - panic(err) - } - return id -} - -// SignerCreateBulk is the builder for creating many Signer entities in bulk. -type SignerCreateBulk struct { - config - err error - builders []*SignerCreate - conflict []sql.ConflictOption -} - -// Save creates the Signer entities in the database. -func (scb *SignerCreateBulk) Save(ctx context.Context) ([]*Signer, error) { - if scb.err != nil { - return nil, scb.err - } - specs := make([]*sqlgraph.CreateSpec, len(scb.builders)) - nodes := make([]*Signer, len(scb.builders)) - mutators := make([]Mutator, len(scb.builders)) - for i := range scb.builders { - func(i int, root context.Context) { - builder := scb.builders[i] - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*SignerMutation) - 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, scb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - spec.OnConflict = scb.conflict - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, scb.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, scb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (scb *SignerCreateBulk) SaveX(ctx context.Context) []*Signer { - v, err := scb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (scb *SignerCreateBulk) Exec(ctx context.Context) error { - _, err := scb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (scb *SignerCreateBulk) ExecX(ctx context.Context) { - if err := scb.Exec(ctx); err != nil { - panic(err) - } -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.Signer.CreateBulk(builders...). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.SignerUpsert) { -// SetName(v+v). -// }). -// Exec(ctx) -func (scb *SignerCreateBulk) OnConflict(opts ...sql.ConflictOption) *SignerUpsertBulk { - scb.conflict = opts - return &SignerUpsertBulk{ - create: scb, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.Signer.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (scb *SignerCreateBulk) OnConflictColumns(columns ...string) *SignerUpsertBulk { - scb.conflict = append(scb.conflict, sql.ConflictColumns(columns...)) - return &SignerUpsertBulk{ - create: scb, - } -} - -// SignerUpsertBulk is the builder for "upsert"-ing -// a bulk of Signer nodes. -type SignerUpsertBulk struct { - create *SignerCreateBulk -} - -// UpdateNewValues updates the mutable fields using the new values that -// were set on create. Using this option is equivalent to using: -// -// client.Signer.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *SignerUpsertBulk) UpdateNewValues() *SignerUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.Signer.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *SignerUpsertBulk) Ignore() *SignerUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *SignerUpsertBulk) DoNothing() *SignerUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the SignerCreateBulk.OnConflict -// documentation for more info. -func (u *SignerUpsertBulk) Update(set func(*SignerUpsert)) *SignerUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&SignerUpsert{UpdateSet: update}) - })) - return u -} - -// SetName sets the "name" field. -func (u *SignerUpsertBulk) SetName(v string) *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.SetName(v) - }) -} - -// UpdateName sets the "name" field to the value that was provided on create. -func (u *SignerUpsertBulk) UpdateName() *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.UpdateName() - }) -} - -// SetEvm sets the "evm" field. -func (u *SignerUpsertBulk) SetEvm(v string) *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.SetEvm(v) - }) -} - -// UpdateEvm sets the "evm" field to the value that was provided on create. -func (u *SignerUpsertBulk) UpdateEvm() *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.UpdateEvm() - }) -} - -// ClearEvm clears the value of the "evm" field. -func (u *SignerUpsertBulk) ClearEvm() *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.ClearEvm() - }) -} - -// SetKey sets the "key" field. -func (u *SignerUpsertBulk) SetKey(v []byte) *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.SetKey(v) - }) -} - -// UpdateKey sets the "key" field to the value that was provided on create. -func (u *SignerUpsertBulk) UpdateKey() *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.UpdateKey() - }) -} - -// SetShortkey sets the "shortkey" field. -func (u *SignerUpsertBulk) SetShortkey(v []byte) *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.SetShortkey(v) - }) -} - -// UpdateShortkey sets the "shortkey" field to the value that was provided on create. -func (u *SignerUpsertBulk) UpdateShortkey() *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.UpdateShortkey() - }) -} - -// SetPoints sets the "points" field. -func (u *SignerUpsertBulk) SetPoints(v int64) *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.SetPoints(v) - }) -} - -// AddPoints adds v to the "points" field. -func (u *SignerUpsertBulk) AddPoints(v int64) *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.AddPoints(v) - }) -} - -// UpdatePoints sets the "points" field to the value that was provided on create. -func (u *SignerUpsertBulk) UpdatePoints() *SignerUpsertBulk { - return u.Update(func(s *SignerUpsert) { - s.UpdatePoints() - }) -} - -// Exec executes the query. -func (u *SignerUpsertBulk) Exec(ctx context.Context) error { - if u.create.err != nil { - return u.create.err - } - for i, b := range u.create.builders { - if len(b.conflict) != 0 { - return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the SignerCreateBulk instead", i) - } - } - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for SignerCreateBulk.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *SignerUpsertBulk) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/ent/signer_delete.go b/internal/ent/signer_delete.go deleted file mode 100644 index e6d724ba..00000000 --- a/internal/ent/signer_delete.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// SignerDelete is the builder for deleting a Signer entity. -type SignerDelete struct { - config - hooks []Hook - mutation *SignerMutation -} - -// Where appends a list predicates to the SignerDelete builder. -func (sd *SignerDelete) Where(ps ...predicate.Signer) *SignerDelete { - sd.mutation.Where(ps...) - return sd -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (sd *SignerDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, sd.sqlExec, sd.mutation, sd.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (sd *SignerDelete) ExecX(ctx context.Context) int { - n, err := sd.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (sd *SignerDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(signer.Table, sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt)) - if ps := sd.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, sd.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - sd.mutation.done = true - return affected, err -} - -// SignerDeleteOne is the builder for deleting a single Signer entity. -type SignerDeleteOne struct { - sd *SignerDelete -} - -// Where appends a list predicates to the SignerDelete builder. -func (sdo *SignerDeleteOne) Where(ps ...predicate.Signer) *SignerDeleteOne { - sdo.sd.mutation.Where(ps...) - return sdo -} - -// Exec executes the deletion query. -func (sdo *SignerDeleteOne) Exec(ctx context.Context) error { - n, err := sdo.sd.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{signer.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (sdo *SignerDeleteOne) ExecX(ctx context.Context) { - if err := sdo.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/ent/signer_query.go b/internal/ent/signer_query.go deleted file mode 100644 index d189a69d..00000000 --- a/internal/ent/signer_query.go +++ /dev/null @@ -1,927 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "database/sql/driver" - "fmt" - "math" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// SignerQuery is the builder for querying Signer entities. -type SignerQuery struct { - config - ctx *QueryContext - order []signer.OrderOption - inters []Interceptor - predicates []predicate.Signer - withAssetPrice *AssetPriceQuery - withEventLogs *EventLogQuery - withCorrectnessReport *CorrectnessReportQuery - modifiers []func(*sql.Selector) - loadTotal []func(context.Context, []*Signer) error - withNamedAssetPrice map[string]*AssetPriceQuery - withNamedEventLogs map[string]*EventLogQuery - withNamedCorrectnessReport map[string]*CorrectnessReportQuery - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the SignerQuery builder. -func (sq *SignerQuery) Where(ps ...predicate.Signer) *SignerQuery { - sq.predicates = append(sq.predicates, ps...) - return sq -} - -// Limit the number of records to be returned by this query. -func (sq *SignerQuery) Limit(limit int) *SignerQuery { - sq.ctx.Limit = &limit - return sq -} - -// Offset to start from. -func (sq *SignerQuery) Offset(offset int) *SignerQuery { - sq.ctx.Offset = &offset - return sq -} - -// 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 (sq *SignerQuery) Unique(unique bool) *SignerQuery { - sq.ctx.Unique = &unique - return sq -} - -// Order specifies how the records should be ordered. -func (sq *SignerQuery) Order(o ...signer.OrderOption) *SignerQuery { - sq.order = append(sq.order, o...) - return sq -} - -// QueryAssetPrice chains the current query on the "assetPrice" edge. -func (sq *SignerQuery) QueryAssetPrice() *AssetPriceQuery { - query := (&AssetPriceClient{config: sq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := sq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := sq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(signer.Table, signer.FieldID, selector), - sqlgraph.To(assetprice.Table, assetprice.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, signer.AssetPriceTable, signer.AssetPricePrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryEventLogs chains the current query on the "eventLogs" edge. -func (sq *SignerQuery) QueryEventLogs() *EventLogQuery { - query := (&EventLogClient{config: sq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := sq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := sq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(signer.Table, signer.FieldID, selector), - sqlgraph.To(eventlog.Table, eventlog.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, signer.EventLogsTable, signer.EventLogsPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryCorrectnessReport chains the current query on the "correctnessReport" edge. -func (sq *SignerQuery) QueryCorrectnessReport() *CorrectnessReportQuery { - query := (&CorrectnessReportClient{config: sq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := sq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := sq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(signer.Table, signer.FieldID, selector), - sqlgraph.To(correctnessreport.Table, correctnessreport.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, signer.CorrectnessReportTable, signer.CorrectnessReportPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first Signer entity from the query. -// Returns a *NotFoundError when no Signer was found. -func (sq *SignerQuery) First(ctx context.Context) (*Signer, error) { - nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First")) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{signer.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (sq *SignerQuery) FirstX(ctx context.Context) *Signer { - node, err := sq.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first Signer ID from the query. -// Returns a *NotFoundError when no Signer ID was found. -func (sq *SignerQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, "FirstID")); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{signer.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (sq *SignerQuery) FirstIDX(ctx context.Context) int { - id, err := sq.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single Signer entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one Signer entity is found. -// Returns a *NotFoundError when no Signer entities are found. -func (sq *SignerQuery) Only(ctx context.Context) (*Signer, error) { - nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, "Only")) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{signer.Label} - default: - return nil, &NotSingularError{signer.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (sq *SignerQuery) OnlyX(ctx context.Context) *Signer { - node, err := sq.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only Signer ID in the query. -// Returns a *NotSingularError when more than one Signer ID is found. -// Returns a *NotFoundError when no entities are found. -func (sq *SignerQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, "OnlyID")); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{signer.Label} - default: - err = &NotSingularError{signer.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (sq *SignerQuery) OnlyIDX(ctx context.Context) int { - id, err := sq.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of Signers. -func (sq *SignerQuery) All(ctx context.Context) ([]*Signer, error) { - ctx = setContextOp(ctx, sq.ctx, "All") - if err := sq.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*Signer, *SignerQuery]() - return withInterceptors[[]*Signer](ctx, sq, qr, sq.inters) -} - -// AllX is like All, but panics if an error occurs. -func (sq *SignerQuery) AllX(ctx context.Context) []*Signer { - nodes, err := sq.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of Signer IDs. -func (sq *SignerQuery) IDs(ctx context.Context) (ids []int, err error) { - if sq.ctx.Unique == nil && sq.path != nil { - sq.Unique(true) - } - ctx = setContextOp(ctx, sq.ctx, "IDs") - if err = sq.Select(signer.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (sq *SignerQuery) IDsX(ctx context.Context) []int { - ids, err := sq.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (sq *SignerQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, sq.ctx, "Count") - if err := sq.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, sq, querierCount[*SignerQuery](), sq.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (sq *SignerQuery) CountX(ctx context.Context) int { - count, err := sq.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (sq *SignerQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, sq.ctx, "Exist") - switch _, err := sq.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 (sq *SignerQuery) ExistX(ctx context.Context) bool { - exist, err := sq.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the SignerQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (sq *SignerQuery) Clone() *SignerQuery { - if sq == nil { - return nil - } - return &SignerQuery{ - config: sq.config, - ctx: sq.ctx.Clone(), - order: append([]signer.OrderOption{}, sq.order...), - inters: append([]Interceptor{}, sq.inters...), - predicates: append([]predicate.Signer{}, sq.predicates...), - withAssetPrice: sq.withAssetPrice.Clone(), - withEventLogs: sq.withEventLogs.Clone(), - withCorrectnessReport: sq.withCorrectnessReport.Clone(), - // clone intermediate query. - sql: sq.sql.Clone(), - path: sq.path, - } -} - -// WithAssetPrice tells the query-builder to eager-load the nodes that are connected to -// the "assetPrice" edge. The optional arguments are used to configure the query builder of the edge. -func (sq *SignerQuery) WithAssetPrice(opts ...func(*AssetPriceQuery)) *SignerQuery { - query := (&AssetPriceClient{config: sq.config}).Query() - for _, opt := range opts { - opt(query) - } - sq.withAssetPrice = query - return sq -} - -// WithEventLogs tells the query-builder to eager-load the nodes that are connected to -// the "eventLogs" edge. The optional arguments are used to configure the query builder of the edge. -func (sq *SignerQuery) WithEventLogs(opts ...func(*EventLogQuery)) *SignerQuery { - query := (&EventLogClient{config: sq.config}).Query() - for _, opt := range opts { - opt(query) - } - sq.withEventLogs = query - return sq -} - -// WithCorrectnessReport tells the query-builder to eager-load the nodes that are connected to -// the "correctnessReport" edge. The optional arguments are used to configure the query builder of the edge. -func (sq *SignerQuery) WithCorrectnessReport(opts ...func(*CorrectnessReportQuery)) *SignerQuery { - query := (&CorrectnessReportClient{config: sq.config}).Query() - for _, opt := range opts { - opt(query) - } - sq.withCorrectnessReport = query - return sq -} - -// 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 { -// Name string `json:"name,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.Signer.Query(). -// GroupBy(signer.FieldName). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (sq *SignerQuery) GroupBy(field string, fields ...string) *SignerGroupBy { - sq.ctx.Fields = append([]string{field}, fields...) - grbuild := &SignerGroupBy{build: sq} - grbuild.flds = &sq.ctx.Fields - grbuild.label = signer.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 { -// Name string `json:"name,omitempty"` -// } -// -// client.Signer.Query(). -// Select(signer.FieldName). -// Scan(ctx, &v) -func (sq *SignerQuery) Select(fields ...string) *SignerSelect { - sq.ctx.Fields = append(sq.ctx.Fields, fields...) - sbuild := &SignerSelect{SignerQuery: sq} - sbuild.label = signer.Label - sbuild.flds, sbuild.scan = &sq.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a SignerSelect configured with the given aggregations. -func (sq *SignerQuery) Aggregate(fns ...AggregateFunc) *SignerSelect { - return sq.Select().Aggregate(fns...) -} - -func (sq *SignerQuery) prepareQuery(ctx context.Context) error { - for _, inter := range sq.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, sq); err != nil { - return err - } - } - } - for _, f := range sq.ctx.Fields { - if !signer.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if sq.path != nil { - prev, err := sq.path(ctx) - if err != nil { - return err - } - sq.sql = prev - } - return nil -} - -func (sq *SignerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Signer, error) { - var ( - nodes = []*Signer{} - _spec = sq.querySpec() - loadedTypes = [3]bool{ - sq.withAssetPrice != nil, - sq.withEventLogs != nil, - sq.withCorrectnessReport != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*Signer).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &Signer{config: sq.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(sq.modifiers) > 0 { - _spec.Modifiers = sq.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, sq.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := sq.withAssetPrice; query != nil { - if err := sq.loadAssetPrice(ctx, query, nodes, - func(n *Signer) { n.Edges.AssetPrice = []*AssetPrice{} }, - func(n *Signer, e *AssetPrice) { n.Edges.AssetPrice = append(n.Edges.AssetPrice, e) }); err != nil { - return nil, err - } - } - if query := sq.withEventLogs; query != nil { - if err := sq.loadEventLogs(ctx, query, nodes, - func(n *Signer) { n.Edges.EventLogs = []*EventLog{} }, - func(n *Signer, e *EventLog) { n.Edges.EventLogs = append(n.Edges.EventLogs, e) }); err != nil { - return nil, err - } - } - if query := sq.withCorrectnessReport; query != nil { - if err := sq.loadCorrectnessReport(ctx, query, nodes, - func(n *Signer) { n.Edges.CorrectnessReport = []*CorrectnessReport{} }, - func(n *Signer, e *CorrectnessReport) { - n.Edges.CorrectnessReport = append(n.Edges.CorrectnessReport, e) - }); err != nil { - return nil, err - } - } - for name, query := range sq.withNamedAssetPrice { - if err := sq.loadAssetPrice(ctx, query, nodes, - func(n *Signer) { n.appendNamedAssetPrice(name) }, - func(n *Signer, e *AssetPrice) { n.appendNamedAssetPrice(name, e) }); err != nil { - return nil, err - } - } - for name, query := range sq.withNamedEventLogs { - if err := sq.loadEventLogs(ctx, query, nodes, - func(n *Signer) { n.appendNamedEventLogs(name) }, - func(n *Signer, e *EventLog) { n.appendNamedEventLogs(name, e) }); err != nil { - return nil, err - } - } - for name, query := range sq.withNamedCorrectnessReport { - if err := sq.loadCorrectnessReport(ctx, query, nodes, - func(n *Signer) { n.appendNamedCorrectnessReport(name) }, - func(n *Signer, e *CorrectnessReport) { n.appendNamedCorrectnessReport(name, e) }); err != nil { - return nil, err - } - } - for i := range sq.loadTotal { - if err := sq.loadTotal[i](ctx, nodes); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (sq *SignerQuery) loadAssetPrice(ctx context.Context, query *AssetPriceQuery, nodes []*Signer, init func(*Signer), assign func(*Signer, *AssetPrice)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int]*Signer) - nids := make(map[int]map[*Signer]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(signer.AssetPriceTable) - s.Join(joinT).On(s.C(assetprice.FieldID), joinT.C(signer.AssetPricePrimaryKey[0])) - s.Where(sql.InValues(joinT.C(signer.AssetPricePrimaryKey[1]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(signer.AssetPricePrimaryKey[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[*Signer]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*AssetPrice](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 "assetPrice" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} -func (sq *SignerQuery) loadEventLogs(ctx context.Context, query *EventLogQuery, nodes []*Signer, init func(*Signer), assign func(*Signer, *EventLog)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int]*Signer) - nids := make(map[int]map[*Signer]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(signer.EventLogsTable) - s.Join(joinT).On(s.C(eventlog.FieldID), joinT.C(signer.EventLogsPrimaryKey[0])) - s.Where(sql.InValues(joinT.C(signer.EventLogsPrimaryKey[1]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(signer.EventLogsPrimaryKey[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[*Signer]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*EventLog](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 "eventLogs" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} -func (sq *SignerQuery) loadCorrectnessReport(ctx context.Context, query *CorrectnessReportQuery, nodes []*Signer, init func(*Signer), assign func(*Signer, *CorrectnessReport)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int]*Signer) - nids := make(map[int]map[*Signer]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(signer.CorrectnessReportTable) - s.Join(joinT).On(s.C(correctnessreport.FieldID), joinT.C(signer.CorrectnessReportPrimaryKey[0])) - s.Where(sql.InValues(joinT.C(signer.CorrectnessReportPrimaryKey[1]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(signer.CorrectnessReportPrimaryKey[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[*Signer]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*CorrectnessReport](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 "correctnessReport" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} - -func (sq *SignerQuery) sqlCount(ctx context.Context) (int, error) { - _spec := sq.querySpec() - if len(sq.modifiers) > 0 { - _spec.Modifiers = sq.modifiers - } - _spec.Node.Columns = sq.ctx.Fields - if len(sq.ctx.Fields) > 0 { - _spec.Unique = sq.ctx.Unique != nil && *sq.ctx.Unique - } - return sqlgraph.CountNodes(ctx, sq.driver, _spec) -} - -func (sq *SignerQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(signer.Table, signer.Columns, sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt)) - _spec.From = sq.sql - if unique := sq.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if sq.path != nil { - _spec.Unique = true - } - if fields := sq.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, signer.FieldID) - for i := range fields { - if fields[i] != signer.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := sq.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := sq.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := sq.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := sq.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (sq *SignerQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(sq.driver.Dialect()) - t1 := builder.Table(signer.Table) - columns := sq.ctx.Fields - if len(columns) == 0 { - columns = signer.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if sq.sql != nil { - selector = sq.sql - selector.Select(selector.Columns(columns...)...) - } - if sq.ctx.Unique != nil && *sq.ctx.Unique { - selector.Distinct() - } - for _, p := range sq.predicates { - p(selector) - } - for _, p := range sq.order { - p(selector) - } - if offset := sq.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 := sq.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// WithNamedAssetPrice tells the query-builder to eager-load the nodes that are connected to the "assetPrice" -// edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (sq *SignerQuery) WithNamedAssetPrice(name string, opts ...func(*AssetPriceQuery)) *SignerQuery { - query := (&AssetPriceClient{config: sq.config}).Query() - for _, opt := range opts { - opt(query) - } - if sq.withNamedAssetPrice == nil { - sq.withNamedAssetPrice = make(map[string]*AssetPriceQuery) - } - sq.withNamedAssetPrice[name] = query - return sq -} - -// WithNamedEventLogs tells the query-builder to eager-load the nodes that are connected to the "eventLogs" -// edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (sq *SignerQuery) WithNamedEventLogs(name string, opts ...func(*EventLogQuery)) *SignerQuery { - query := (&EventLogClient{config: sq.config}).Query() - for _, opt := range opts { - opt(query) - } - if sq.withNamedEventLogs == nil { - sq.withNamedEventLogs = make(map[string]*EventLogQuery) - } - sq.withNamedEventLogs[name] = query - return sq -} - -// WithNamedCorrectnessReport tells the query-builder to eager-load the nodes that are connected to the "correctnessReport" -// edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (sq *SignerQuery) WithNamedCorrectnessReport(name string, opts ...func(*CorrectnessReportQuery)) *SignerQuery { - query := (&CorrectnessReportClient{config: sq.config}).Query() - for _, opt := range opts { - opt(query) - } - if sq.withNamedCorrectnessReport == nil { - sq.withNamedCorrectnessReport = make(map[string]*CorrectnessReportQuery) - } - sq.withNamedCorrectnessReport[name] = query - return sq -} - -// SignerGroupBy is the group-by builder for Signer entities. -type SignerGroupBy struct { - selector - build *SignerQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (sgb *SignerGroupBy) Aggregate(fns ...AggregateFunc) *SignerGroupBy { - sgb.fns = append(sgb.fns, fns...) - return sgb -} - -// Scan applies the selector query and scans the result into the given value. -func (sgb *SignerGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, sgb.build.ctx, "GroupBy") - if err := sgb.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*SignerQuery, *SignerGroupBy](ctx, sgb.build, sgb, sgb.build.inters, v) -} - -func (sgb *SignerGroupBy) sqlScan(ctx context.Context, root *SignerQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(sgb.fns)) - for _, fn := range sgb.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*sgb.flds)+len(sgb.fns)) - for _, f := range *sgb.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*sgb.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := sgb.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// SignerSelect is the builder for selecting fields of Signer entities. -type SignerSelect struct { - *SignerQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (ss *SignerSelect) Aggregate(fns ...AggregateFunc) *SignerSelect { - ss.fns = append(ss.fns, fns...) - return ss -} - -// Scan applies the selector query and scans the result into the given value. -func (ss *SignerSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ss.ctx, "Select") - if err := ss.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*SignerQuery, *SignerSelect](ctx, ss.SignerQuery, ss, ss.inters, v) -} - -func (ss *SignerSelect) sqlScan(ctx context.Context, root *SignerQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(ss.fns)) - for _, fn := range ss.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*ss.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 := ss.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} diff --git a/internal/ent/signer_update.go b/internal/ent/signer_update.go deleted file mode 100644 index 3c48ffb2..00000000 --- a/internal/ent/signer_update.go +++ /dev/null @@ -1,886 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" - "github.com/TimeleapLabs/unchained/internal/ent/predicate" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// SignerUpdate is the builder for updating Signer entities. -type SignerUpdate struct { - config - hooks []Hook - mutation *SignerMutation -} - -// Where appends a list predicates to the SignerUpdate builder. -func (su *SignerUpdate) Where(ps ...predicate.Signer) *SignerUpdate { - su.mutation.Where(ps...) - return su -} - -// SetName sets the "name" field. -func (su *SignerUpdate) SetName(s string) *SignerUpdate { - su.mutation.SetName(s) - return su -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (su *SignerUpdate) SetNillableName(s *string) *SignerUpdate { - if s != nil { - su.SetName(*s) - } - return su -} - -// SetEvm sets the "evm" field. -func (su *SignerUpdate) SetEvm(s string) *SignerUpdate { - su.mutation.SetEvm(s) - return su -} - -// SetNillableEvm sets the "evm" field if the given value is not nil. -func (su *SignerUpdate) SetNillableEvm(s *string) *SignerUpdate { - if s != nil { - su.SetEvm(*s) - } - return su -} - -// ClearEvm clears the value of the "evm" field. -func (su *SignerUpdate) ClearEvm() *SignerUpdate { - su.mutation.ClearEvm() - return su -} - -// SetKey sets the "key" field. -func (su *SignerUpdate) SetKey(b []byte) *SignerUpdate { - su.mutation.SetKey(b) - return su -} - -// SetShortkey sets the "shortkey" field. -func (su *SignerUpdate) SetShortkey(b []byte) *SignerUpdate { - su.mutation.SetShortkey(b) - return su -} - -// SetPoints sets the "points" field. -func (su *SignerUpdate) SetPoints(i int64) *SignerUpdate { - su.mutation.ResetPoints() - su.mutation.SetPoints(i) - return su -} - -// SetNillablePoints sets the "points" field if the given value is not nil. -func (su *SignerUpdate) SetNillablePoints(i *int64) *SignerUpdate { - if i != nil { - su.SetPoints(*i) - } - return su -} - -// AddPoints adds i to the "points" field. -func (su *SignerUpdate) AddPoints(i int64) *SignerUpdate { - su.mutation.AddPoints(i) - return su -} - -// AddAssetPriceIDs adds the "assetPrice" edge to the AssetPrice entity by IDs. -func (su *SignerUpdate) AddAssetPriceIDs(ids ...int) *SignerUpdate { - su.mutation.AddAssetPriceIDs(ids...) - return su -} - -// AddAssetPrice adds the "assetPrice" edges to the AssetPrice entity. -func (su *SignerUpdate) AddAssetPrice(a ...*AssetPrice) *SignerUpdate { - ids := make([]int, len(a)) - for i := range a { - ids[i] = a[i].ID - } - return su.AddAssetPriceIDs(ids...) -} - -// AddEventLogIDs adds the "eventLogs" edge to the EventLog entity by IDs. -func (su *SignerUpdate) AddEventLogIDs(ids ...int) *SignerUpdate { - su.mutation.AddEventLogIDs(ids...) - return su -} - -// AddEventLogs adds the "eventLogs" edges to the EventLog entity. -func (su *SignerUpdate) AddEventLogs(e ...*EventLog) *SignerUpdate { - ids := make([]int, len(e)) - for i := range e { - ids[i] = e[i].ID - } - return su.AddEventLogIDs(ids...) -} - -// AddCorrectnessReportIDs adds the "correctnessReport" edge to the CorrectnessReport entity by IDs. -func (su *SignerUpdate) AddCorrectnessReportIDs(ids ...int) *SignerUpdate { - su.mutation.AddCorrectnessReportIDs(ids...) - return su -} - -// AddCorrectnessReport adds the "correctnessReport" edges to the CorrectnessReport entity. -func (su *SignerUpdate) AddCorrectnessReport(c ...*CorrectnessReport) *SignerUpdate { - ids := make([]int, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return su.AddCorrectnessReportIDs(ids...) -} - -// Mutation returns the SignerMutation object of the builder. -func (su *SignerUpdate) Mutation() *SignerMutation { - return su.mutation -} - -// ClearAssetPrice clears all "assetPrice" edges to the AssetPrice entity. -func (su *SignerUpdate) ClearAssetPrice() *SignerUpdate { - su.mutation.ClearAssetPrice() - return su -} - -// RemoveAssetPriceIDs removes the "assetPrice" edge to AssetPrice entities by IDs. -func (su *SignerUpdate) RemoveAssetPriceIDs(ids ...int) *SignerUpdate { - su.mutation.RemoveAssetPriceIDs(ids...) - return su -} - -// RemoveAssetPrice removes "assetPrice" edges to AssetPrice entities. -func (su *SignerUpdate) RemoveAssetPrice(a ...*AssetPrice) *SignerUpdate { - ids := make([]int, len(a)) - for i := range a { - ids[i] = a[i].ID - } - return su.RemoveAssetPriceIDs(ids...) -} - -// ClearEventLogs clears all "eventLogs" edges to the EventLog entity. -func (su *SignerUpdate) ClearEventLogs() *SignerUpdate { - su.mutation.ClearEventLogs() - return su -} - -// RemoveEventLogIDs removes the "eventLogs" edge to EventLog entities by IDs. -func (su *SignerUpdate) RemoveEventLogIDs(ids ...int) *SignerUpdate { - su.mutation.RemoveEventLogIDs(ids...) - return su -} - -// RemoveEventLogs removes "eventLogs" edges to EventLog entities. -func (su *SignerUpdate) RemoveEventLogs(e ...*EventLog) *SignerUpdate { - ids := make([]int, len(e)) - for i := range e { - ids[i] = e[i].ID - } - return su.RemoveEventLogIDs(ids...) -} - -// ClearCorrectnessReport clears all "correctnessReport" edges to the CorrectnessReport entity. -func (su *SignerUpdate) ClearCorrectnessReport() *SignerUpdate { - su.mutation.ClearCorrectnessReport() - return su -} - -// RemoveCorrectnessReportIDs removes the "correctnessReport" edge to CorrectnessReport entities by IDs. -func (su *SignerUpdate) RemoveCorrectnessReportIDs(ids ...int) *SignerUpdate { - su.mutation.RemoveCorrectnessReportIDs(ids...) - return su -} - -// RemoveCorrectnessReport removes "correctnessReport" edges to CorrectnessReport entities. -func (su *SignerUpdate) RemoveCorrectnessReport(c ...*CorrectnessReport) *SignerUpdate { - ids := make([]int, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return su.RemoveCorrectnessReportIDs(ids...) -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (su *SignerUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, su.sqlSave, su.mutation, su.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (su *SignerUpdate) SaveX(ctx context.Context) int { - affected, err := su.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (su *SignerUpdate) Exec(ctx context.Context) error { - _, err := su.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (su *SignerUpdate) ExecX(ctx context.Context) { - if err := su.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (su *SignerUpdate) check() error { - if v, ok := su.mutation.Name(); ok { - if err := signer.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Signer.name": %w`, err)} - } - } - if v, ok := su.mutation.Key(); ok { - if err := signer.KeyValidator(v); err != nil { - return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "Signer.key": %w`, err)} - } - } - if v, ok := su.mutation.Shortkey(); ok { - if err := signer.ShortkeyValidator(v); err != nil { - return &ValidationError{Name: "shortkey", err: fmt.Errorf(`ent: validator failed for field "Signer.shortkey": %w`, err)} - } - } - return nil -} - -func (su *SignerUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := su.check(); err != nil { - return n, err - } - _spec := sqlgraph.NewUpdateSpec(signer.Table, signer.Columns, sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt)) - if ps := su.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := su.mutation.Name(); ok { - _spec.SetField(signer.FieldName, field.TypeString, value) - } - if value, ok := su.mutation.Evm(); ok { - _spec.SetField(signer.FieldEvm, field.TypeString, value) - } - if su.mutation.EvmCleared() { - _spec.ClearField(signer.FieldEvm, field.TypeString) - } - if value, ok := su.mutation.Key(); ok { - _spec.SetField(signer.FieldKey, field.TypeBytes, value) - } - if value, ok := su.mutation.Shortkey(); ok { - _spec.SetField(signer.FieldShortkey, field.TypeBytes, value) - } - if value, ok := su.mutation.Points(); ok { - _spec.SetField(signer.FieldPoints, field.TypeInt64, value) - } - if value, ok := su.mutation.AddedPoints(); ok { - _spec.AddField(signer.FieldPoints, field.TypeInt64, value) - } - if su.mutation.AssetPriceCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.AssetPriceTable, - Columns: signer.AssetPricePrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := su.mutation.RemovedAssetPriceIDs(); len(nodes) > 0 && !su.mutation.AssetPriceCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.AssetPriceTable, - Columns: signer.AssetPricePrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(assetprice.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 := su.mutation.AssetPriceIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.AssetPriceTable, - Columns: signer.AssetPricePrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if su.mutation.EventLogsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.EventLogsTable, - Columns: signer.EventLogsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := su.mutation.RemovedEventLogsIDs(); len(nodes) > 0 && !su.mutation.EventLogsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.EventLogsTable, - Columns: signer.EventLogsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(eventlog.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 := su.mutation.EventLogsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.EventLogsTable, - Columns: signer.EventLogsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if su.mutation.CorrectnessReportCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.CorrectnessReportTable, - Columns: signer.CorrectnessReportPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(correctnessreport.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := su.mutation.RemovedCorrectnessReportIDs(); len(nodes) > 0 && !su.mutation.CorrectnessReportCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.CorrectnessReportTable, - Columns: signer.CorrectnessReportPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(correctnessreport.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 := su.mutation.CorrectnessReportIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.CorrectnessReportTable, - Columns: signer.CorrectnessReportPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(correctnessreport.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, su.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{signer.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - su.mutation.done = true - return n, nil -} - -// SignerUpdateOne is the builder for updating a single Signer entity. -type SignerUpdateOne struct { - config - fields []string - hooks []Hook - mutation *SignerMutation -} - -// SetName sets the "name" field. -func (suo *SignerUpdateOne) SetName(s string) *SignerUpdateOne { - suo.mutation.SetName(s) - return suo -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (suo *SignerUpdateOne) SetNillableName(s *string) *SignerUpdateOne { - if s != nil { - suo.SetName(*s) - } - return suo -} - -// SetEvm sets the "evm" field. -func (suo *SignerUpdateOne) SetEvm(s string) *SignerUpdateOne { - suo.mutation.SetEvm(s) - return suo -} - -// SetNillableEvm sets the "evm" field if the given value is not nil. -func (suo *SignerUpdateOne) SetNillableEvm(s *string) *SignerUpdateOne { - if s != nil { - suo.SetEvm(*s) - } - return suo -} - -// ClearEvm clears the value of the "evm" field. -func (suo *SignerUpdateOne) ClearEvm() *SignerUpdateOne { - suo.mutation.ClearEvm() - return suo -} - -// SetKey sets the "key" field. -func (suo *SignerUpdateOne) SetKey(b []byte) *SignerUpdateOne { - suo.mutation.SetKey(b) - return suo -} - -// SetShortkey sets the "shortkey" field. -func (suo *SignerUpdateOne) SetShortkey(b []byte) *SignerUpdateOne { - suo.mutation.SetShortkey(b) - return suo -} - -// SetPoints sets the "points" field. -func (suo *SignerUpdateOne) SetPoints(i int64) *SignerUpdateOne { - suo.mutation.ResetPoints() - suo.mutation.SetPoints(i) - return suo -} - -// SetNillablePoints sets the "points" field if the given value is not nil. -func (suo *SignerUpdateOne) SetNillablePoints(i *int64) *SignerUpdateOne { - if i != nil { - suo.SetPoints(*i) - } - return suo -} - -// AddPoints adds i to the "points" field. -func (suo *SignerUpdateOne) AddPoints(i int64) *SignerUpdateOne { - suo.mutation.AddPoints(i) - return suo -} - -// AddAssetPriceIDs adds the "assetPrice" edge to the AssetPrice entity by IDs. -func (suo *SignerUpdateOne) AddAssetPriceIDs(ids ...int) *SignerUpdateOne { - suo.mutation.AddAssetPriceIDs(ids...) - return suo -} - -// AddAssetPrice adds the "assetPrice" edges to the AssetPrice entity. -func (suo *SignerUpdateOne) AddAssetPrice(a ...*AssetPrice) *SignerUpdateOne { - ids := make([]int, len(a)) - for i := range a { - ids[i] = a[i].ID - } - return suo.AddAssetPriceIDs(ids...) -} - -// AddEventLogIDs adds the "eventLogs" edge to the EventLog entity by IDs. -func (suo *SignerUpdateOne) AddEventLogIDs(ids ...int) *SignerUpdateOne { - suo.mutation.AddEventLogIDs(ids...) - return suo -} - -// AddEventLogs adds the "eventLogs" edges to the EventLog entity. -func (suo *SignerUpdateOne) AddEventLogs(e ...*EventLog) *SignerUpdateOne { - ids := make([]int, len(e)) - for i := range e { - ids[i] = e[i].ID - } - return suo.AddEventLogIDs(ids...) -} - -// AddCorrectnessReportIDs adds the "correctnessReport" edge to the CorrectnessReport entity by IDs. -func (suo *SignerUpdateOne) AddCorrectnessReportIDs(ids ...int) *SignerUpdateOne { - suo.mutation.AddCorrectnessReportIDs(ids...) - return suo -} - -// AddCorrectnessReport adds the "correctnessReport" edges to the CorrectnessReport entity. -func (suo *SignerUpdateOne) AddCorrectnessReport(c ...*CorrectnessReport) *SignerUpdateOne { - ids := make([]int, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return suo.AddCorrectnessReportIDs(ids...) -} - -// Mutation returns the SignerMutation object of the builder. -func (suo *SignerUpdateOne) Mutation() *SignerMutation { - return suo.mutation -} - -// ClearAssetPrice clears all "assetPrice" edges to the AssetPrice entity. -func (suo *SignerUpdateOne) ClearAssetPrice() *SignerUpdateOne { - suo.mutation.ClearAssetPrice() - return suo -} - -// RemoveAssetPriceIDs removes the "assetPrice" edge to AssetPrice entities by IDs. -func (suo *SignerUpdateOne) RemoveAssetPriceIDs(ids ...int) *SignerUpdateOne { - suo.mutation.RemoveAssetPriceIDs(ids...) - return suo -} - -// RemoveAssetPrice removes "assetPrice" edges to AssetPrice entities. -func (suo *SignerUpdateOne) RemoveAssetPrice(a ...*AssetPrice) *SignerUpdateOne { - ids := make([]int, len(a)) - for i := range a { - ids[i] = a[i].ID - } - return suo.RemoveAssetPriceIDs(ids...) -} - -// ClearEventLogs clears all "eventLogs" edges to the EventLog entity. -func (suo *SignerUpdateOne) ClearEventLogs() *SignerUpdateOne { - suo.mutation.ClearEventLogs() - return suo -} - -// RemoveEventLogIDs removes the "eventLogs" edge to EventLog entities by IDs. -func (suo *SignerUpdateOne) RemoveEventLogIDs(ids ...int) *SignerUpdateOne { - suo.mutation.RemoveEventLogIDs(ids...) - return suo -} - -// RemoveEventLogs removes "eventLogs" edges to EventLog entities. -func (suo *SignerUpdateOne) RemoveEventLogs(e ...*EventLog) *SignerUpdateOne { - ids := make([]int, len(e)) - for i := range e { - ids[i] = e[i].ID - } - return suo.RemoveEventLogIDs(ids...) -} - -// ClearCorrectnessReport clears all "correctnessReport" edges to the CorrectnessReport entity. -func (suo *SignerUpdateOne) ClearCorrectnessReport() *SignerUpdateOne { - suo.mutation.ClearCorrectnessReport() - return suo -} - -// RemoveCorrectnessReportIDs removes the "correctnessReport" edge to CorrectnessReport entities by IDs. -func (suo *SignerUpdateOne) RemoveCorrectnessReportIDs(ids ...int) *SignerUpdateOne { - suo.mutation.RemoveCorrectnessReportIDs(ids...) - return suo -} - -// RemoveCorrectnessReport removes "correctnessReport" edges to CorrectnessReport entities. -func (suo *SignerUpdateOne) RemoveCorrectnessReport(c ...*CorrectnessReport) *SignerUpdateOne { - ids := make([]int, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return suo.RemoveCorrectnessReportIDs(ids...) -} - -// Where appends a list predicates to the SignerUpdate builder. -func (suo *SignerUpdateOne) Where(ps ...predicate.Signer) *SignerUpdateOne { - suo.mutation.Where(ps...) - return suo -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (suo *SignerUpdateOne) Select(field string, fields ...string) *SignerUpdateOne { - suo.fields = append([]string{field}, fields...) - return suo -} - -// Save executes the query and returns the updated Signer entity. -func (suo *SignerUpdateOne) Save(ctx context.Context) (*Signer, error) { - return withHooks(ctx, suo.sqlSave, suo.mutation, suo.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (suo *SignerUpdateOne) SaveX(ctx context.Context) *Signer { - node, err := suo.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (suo *SignerUpdateOne) Exec(ctx context.Context) error { - _, err := suo.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (suo *SignerUpdateOne) ExecX(ctx context.Context) { - if err := suo.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (suo *SignerUpdateOne) check() error { - if v, ok := suo.mutation.Name(); ok { - if err := signer.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Signer.name": %w`, err)} - } - } - if v, ok := suo.mutation.Key(); ok { - if err := signer.KeyValidator(v); err != nil { - return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "Signer.key": %w`, err)} - } - } - if v, ok := suo.mutation.Shortkey(); ok { - if err := signer.ShortkeyValidator(v); err != nil { - return &ValidationError{Name: "shortkey", err: fmt.Errorf(`ent: validator failed for field "Signer.shortkey": %w`, err)} - } - } - return nil -} - -func (suo *SignerUpdateOne) sqlSave(ctx context.Context) (_node *Signer, err error) { - if err := suo.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(signer.Table, signer.Columns, sqlgraph.NewFieldSpec(signer.FieldID, field.TypeInt)) - id, ok := suo.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Signer.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := suo.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, signer.FieldID) - for _, f := range fields { - if !signer.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != signer.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := suo.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := suo.mutation.Name(); ok { - _spec.SetField(signer.FieldName, field.TypeString, value) - } - if value, ok := suo.mutation.Evm(); ok { - _spec.SetField(signer.FieldEvm, field.TypeString, value) - } - if suo.mutation.EvmCleared() { - _spec.ClearField(signer.FieldEvm, field.TypeString) - } - if value, ok := suo.mutation.Key(); ok { - _spec.SetField(signer.FieldKey, field.TypeBytes, value) - } - if value, ok := suo.mutation.Shortkey(); ok { - _spec.SetField(signer.FieldShortkey, field.TypeBytes, value) - } - if value, ok := suo.mutation.Points(); ok { - _spec.SetField(signer.FieldPoints, field.TypeInt64, value) - } - if value, ok := suo.mutation.AddedPoints(); ok { - _spec.AddField(signer.FieldPoints, field.TypeInt64, value) - } - if suo.mutation.AssetPriceCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.AssetPriceTable, - Columns: signer.AssetPricePrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := suo.mutation.RemovedAssetPriceIDs(); len(nodes) > 0 && !suo.mutation.AssetPriceCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.AssetPriceTable, - Columns: signer.AssetPricePrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(assetprice.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 := suo.mutation.AssetPriceIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.AssetPriceTable, - Columns: signer.AssetPricePrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(assetprice.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if suo.mutation.EventLogsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.EventLogsTable, - Columns: signer.EventLogsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := suo.mutation.RemovedEventLogsIDs(); len(nodes) > 0 && !suo.mutation.EventLogsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.EventLogsTable, - Columns: signer.EventLogsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(eventlog.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 := suo.mutation.EventLogsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.EventLogsTable, - Columns: signer.EventLogsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(eventlog.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if suo.mutation.CorrectnessReportCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.CorrectnessReportTable, - Columns: signer.CorrectnessReportPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(correctnessreport.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := suo.mutation.RemovedCorrectnessReportIDs(); len(nodes) > 0 && !suo.mutation.CorrectnessReportCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.CorrectnessReportTable, - Columns: signer.CorrectnessReportPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(correctnessreport.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 := suo.mutation.CorrectnessReportIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: signer.CorrectnessReportTable, - Columns: signer.CorrectnessReportPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(correctnessreport.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _node = &Signer{config: suo.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{signer.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - suo.mutation.done = true - return _node, nil -} diff --git a/internal/ent/tx.go b/internal/ent/tx.go deleted file mode 100644 index 23c3301d..00000000 --- a/internal/ent/tx.go +++ /dev/null @@ -1,219 +0,0 @@ -// 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 - // AssetPrice is the client for interacting with the AssetPrice builders. - AssetPrice *AssetPriceClient - // CorrectnessReport is the client for interacting with the CorrectnessReport builders. - CorrectnessReport *CorrectnessReportClient - // EventLog is the client for interacting with the EventLog builders. - EventLog *EventLogClient - // Signer is the client for interacting with the Signer builders. - Signer *SignerClient - - // 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.AssetPrice = NewAssetPriceClient(tx.config) - tx.CorrectnessReport = NewCorrectnessReportClient(tx.config) - tx.EventLog = NewEventLogClient(tx.config) - tx.Signer = NewSignerClient(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: AssetPrice.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/internal/generate.go b/internal/generate.go index a37be673..4c8d5812 100644 --- a/internal/generate.go +++ b/internal/generate.go @@ -1,4 +1,3 @@ package main -//go:generate go run ./ent/entc.go //go:generate go run github.com/99designs/gqlgen diff --git a/internal/model/assetprice.go b/internal/model/assetprice.go index b609566d..19222a49 100644 --- a/internal/model/assetprice.go +++ b/internal/model/assetprice.go @@ -1,6 +1,10 @@ package model -import "math/big" +import ( + "bytes" + "encoding/gob" + "math/big" +) type AssetPrice struct { Pair string @@ -13,4 +17,14 @@ type AssetPrice struct { Consensus bool Voted big.Int SignerIDs []int + Signers []Signer +} + +func (a AssetPrice) Hash() []byte { + var b bytes.Buffer + err := gob.NewEncoder(&b).Encode(a) + if err != nil { + return nil + } + return b.Bytes() } diff --git a/internal/model/correctness.go b/internal/model/correctness.go index e119f97b..ba8be0f2 100644 --- a/internal/model/correctness.go +++ b/internal/model/correctness.go @@ -11,51 +11,6 @@ import ( sia "github.com/pouya-eghbali/go-sia/v2/pkg" ) -type CorrectnessReportPacket struct { - Correctness - Signature [48]byte -} - -func (c *CorrectnessReportPacket) Sia() sia.Sia { - return sia.New(). - EmbedBytes(c.Correctness.Sia().Bytes()). - AddByteArray8(c.Signature[:]) -} - -func (c *CorrectnessReportPacket) FromBytes(payload []byte) *CorrectnessReportPacket { - siaMessage := sia.NewFromBytes(payload) - - c.Correctness.FromSia(siaMessage) - copy(c.Signature[:], siaMessage.ReadByteArray8()) - - return c -} - -////// - -type BroadcastCorrectnessPacket struct { - Info Correctness - Signature [48]byte - Signer Signer -} - -func (b *BroadcastCorrectnessPacket) Sia() sia.Sia { - return sia.New(). - EmbedBytes(b.Info.Sia().Bytes()). - AddByteArray8(b.Signature[:]). - EmbedBytes(b.Signer.Sia().Bytes()) -} - -func (b *BroadcastCorrectnessPacket) FromBytes(payload []byte) *BroadcastCorrectnessPacket { - siaMessage := sia.NewFromBytes(payload) - - b.Info.FromSia(siaMessage) - copy(b.Signature[:], siaMessage.ReadByteArray8()) - b.Signer.FromSia(siaMessage) - - return b -} - type Correctness struct { SignersCount uint64 Signature []byte @@ -66,6 +21,8 @@ type Correctness struct { Hash []byte Topic [64]byte Correct bool + + Signers []Signer } func (c *Correctness) Sia() sia.Sia { @@ -90,12 +47,12 @@ func (c *Correctness) FromSia(sia sia.Sia) *Correctness { return c } -func (c *Correctness) Bls() (bls12381.G1Affine, error) { +func (c *Correctness) Bls() bls12381.G1Affine { hash, err := bls.Hash(c.Sia().Bytes()) if err != nil { utils.Logger.Error("Can't hash bls: %v", err) - return bls12381.G1Affine{}, err + return bls12381.G1Affine{} } - return hash, err + return hash } diff --git a/internal/model/dataframe.go b/internal/model/dataframe.go new file mode 100644 index 00000000..d49d3c26 --- /dev/null +++ b/internal/model/dataframe.go @@ -0,0 +1,9 @@ +package model + +import "time" + +type DataFrame struct { + Hash []byte `bson:"hash" json:"hash"` + Timestamp time.Time `bson:"timestamp" json:"timestamp"` + Data interface{} `bson:"data" gorm:"embedded" json:"data"` +} diff --git a/internal/model/logs.go b/internal/model/logs.go index 2d845702..f68ae5a4 100644 --- a/internal/model/logs.go +++ b/internal/model/logs.go @@ -2,9 +2,9 @@ package model import ( "encoding/json" + "math/big" "github.com/TimeleapLabs/unchained/internal/crypto/bls" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" "github.com/TimeleapLabs/unchained/internal/utils" bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" @@ -12,48 +12,6 @@ import ( sia "github.com/pouya-eghbali/go-sia/v2/pkg" ) -type EventLogReportPacket struct { - EventLog - Signature [48]byte -} - -func (e *EventLogReportPacket) Sia() sia.Sia { - return sia.New(). - EmbedBytes(e.EventLog.Sia().Bytes()). - AddByteArray8(e.Signature[:]) -} - -func (e *EventLogReportPacket) FromBytes(payload []byte) *EventLogReportPacket { - siaMessage := sia.NewFromBytes(payload) - e.EventLog.FromSia(siaMessage) - copy(e.Signature[:], siaMessage.ReadByteArray8()) - - return e -} - -type BroadcastEventPacket struct { - Info EventLog - Signature [48]byte - Signer Signer -} - -func (b *BroadcastEventPacket) Sia() sia.Sia { - return sia.New(). - EmbedBytes(b.Info.Sia().Bytes()). - AddByteArray8(b.Signature[:]). - EmbedBytes(b.Signer.Sia().Bytes()) -} - -func (b *BroadcastEventPacket) FromBytes(payload []byte) *BroadcastEventPacket { - siaMessage := sia.NewFromBytes(payload) - - b.Info.FromSia(siaMessage) - copy(b.Signature[:], siaMessage.ReadByteArray8()) - b.Signer.FromSia(siaMessage) - - return b -} - type EventLogArg struct { Name string `json:"Name"` Type string `json:"Type"` @@ -72,8 +30,9 @@ type EventLog struct { Consensus bool SignersCount uint64 SignerIDs []int + Signers []Signer Signature []byte - Voted *helpers.BigInt + Voted *big.Int } func (e *EventLog) Sia() sia.Sia { diff --git a/internal/model/price.go b/internal/model/price.go deleted file mode 100644 index 2422daf2..00000000 --- a/internal/model/price.go +++ /dev/null @@ -1,28 +0,0 @@ -package model - -import ( - sia "github.com/pouya-eghbali/go-sia/v2/pkg" -) - -type PriceReportPacket struct { - PriceInfo PriceInfo - Signature [48]byte -} - -func (p *PriceReportPacket) Sia() sia.Sia { - return sia.New(). - EmbedBytes(p.PriceInfo.Sia().Bytes()). - AddByteArray8(p.Signature[:]) -} - -func (p *PriceReportPacket) FromBytes(payload []byte) *PriceReportPacket { - siaMessage := sia.NewFromBytes(payload) - return p.FromSia(siaMessage) -} - -func (p *PriceReportPacket) FromSia(sia sia.Sia) *PriceReportPacket { - p.PriceInfo.FromSia(sia) - copy(p.Signature[:], sia.ReadByteArray8()) - - return p -} diff --git a/internal/model/proof.go b/internal/model/proof.go new file mode 100644 index 00000000..d69cd8e7 --- /dev/null +++ b/internal/model/proof.go @@ -0,0 +1,11 @@ +package model + +import "time" + +type Proof struct { + Hash []byte `bson:"hash" json:"hash"` + Timestamp time.Time `bson:"timestamp" json:"timestamp"` + Signature [48]byte `bson:"signature" json:"signature"` + Signers []Signer `bson:"signers" json:"signers"` + // list of signers (relations in Postgres, and an array in Mongo) +} diff --git a/internal/model/bls.go b/internal/model/signer.go similarity index 54% rename from internal/model/bls.go rename to internal/model/signer.go index ebbf554a..bd7d0606 100644 --- a/internal/model/bls.go +++ b/internal/model/signer.go @@ -1,7 +1,6 @@ package model import ( - bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" sia "github.com/pouya-eghbali/go-sia/v2/pkg" ) @@ -12,34 +11,6 @@ type Signer struct { ShortPublicKey [48]byte } -type Signature struct { - Signature bls12381.G1Affine - Signer Signer -} - -func (s *Signature) Sia() sia.Sia { - return sia.New(). - AddByteArray8(s.Signature.Marshal()). - EmbedBytes(s.Signer.Sia().Bytes()) -} - -func (s *Signature) FromBytes(payload []byte) *Signature { - siaMessage := sia.NewFromBytes(payload) - return s.FromSia(siaMessage) -} - -func (s *Signature) FromSia(sia sia.Sia) *Signature { - err := s.Signature.Unmarshal(sia.ReadByteArray8()) - - if err != nil { - s.Signature = bls12381.G1Affine{} - } - - s.Signer.FromSia(sia) - - return s -} - func (s *Signer) Sia() sia.Sia { return sia.New(). AddString8(s.Name). diff --git a/internal/model/uniswap.go b/internal/model/uniswap.go deleted file mode 100644 index 9b37c6e8..00000000 --- a/internal/model/uniswap.go +++ /dev/null @@ -1,115 +0,0 @@ -package model - -import ( - "math/big" - - "github.com/TimeleapLabs/unchained/internal/crypto/bls" - "github.com/TimeleapLabs/unchained/internal/utils" - - bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" - - sia "github.com/pouya-eghbali/go-sia/v2/pkg" -) - -type TokenKey struct { - Name string - Pair string - Chain string - Delta int64 - Invert bool - Cross string -} - -func (t *TokenKey) Sia() sia.Sia { - return sia.New(). - AddString8(t.Name). - AddString8(t.Pair). - AddString8(t.Chain). - AddInt64(t.Delta). - AddBool(t.Invert). - AddString8(t.Cross) -} - -func (t *TokenKey) FromSia(sia sia.Sia) *TokenKey { - t.Name = sia.ReadString8() - t.Pair = sia.ReadString8() - t.Chain = sia.ReadString8() - t.Delta = sia.ReadInt64() - t.Invert = sia.ReadBool() - t.Cross = sia.ReadString8() - - return t -} - -type AssetKey struct { - Token TokenKey - Block uint64 -} - -func (a *AssetKey) Sia() sia.Sia { - return sia.New(). - EmbedBytes(a.Token.Sia().Bytes()). - AddUInt64(a.Block) -} - -func (a *AssetKey) FromSia(sia sia.Sia) *AssetKey { - a.Token.FromSia(sia) - a.Block = sia.ReadUInt64() - - return a -} - -type PriceInfo struct { - Asset AssetKey - Price big.Int -} - -func (p *PriceInfo) Sia() sia.Sia { - return sia.New(). - EmbedBytes(p.Asset.Sia().Bytes()). - AddBigInt(&p.Price) -} - -func (p *PriceInfo) FromBytes(payload []byte) *PriceInfo { - siaMessage := sia.NewFromBytes(payload) - return p.FromSia(siaMessage) -} - -func (p *PriceInfo) FromSia(sia sia.Sia) *PriceInfo { - p.Asset.FromSia(sia) - p.Price = *sia.ReadBigInt() - - return p -} - -func (p *PriceInfo) Bls() (bls12381.G1Affine, error) { - hash, err := bls.Hash(p.Sia().Bytes()) - if err != nil { - utils.Logger.With("err", err).Error("Can't hash bls") - return bls12381.G1Affine{}, err - } - - return hash, err -} - -type BroadcastPricePacket struct { - Info PriceInfo - Signature [48]byte - Signer Signer -} - -func (b *BroadcastPricePacket) Sia() sia.Sia { - return sia.New(). - EmbedBytes(b.Info.Sia().Bytes()). - AddByteArray8(b.Signature[:]). - EmbedBytes(b.Signer.Sia().Bytes()) -} - -func (b *BroadcastPricePacket) FromBytes(payload []byte) *BroadcastPricePacket { - siaMessage := sia.NewFromBytes(payload) - b.Info.FromSia(siaMessage) - copy(b.Signature[:], siaMessage.ReadByteArray8()) - b.Signer.FromSia(siaMessage) - - return b -} diff --git a/internal/repository/postgres/assetprice.go b/internal/repository/postgres/assetprice.go index 441a898d..f1570fbc 100644 --- a/internal/repository/postgres/assetprice.go +++ b/internal/repository/postgres/assetprice.go @@ -2,11 +2,11 @@ package postgres import ( "context" + "time" + + "gorm.io/gorm/clause" "github.com/TimeleapLabs/unchained/internal/consts" - "github.com/TimeleapLabs/unchained/internal/ent" - "github.com/TimeleapLabs/unchained/internal/ent/assetprice" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" "github.com/TimeleapLabs/unchained/internal/transport/database" @@ -20,21 +20,17 @@ type AssetPriceRepo struct { func (a AssetPriceRepo) Upsert(ctx context.Context, data model.AssetPrice) error { err := a.client. GetConnection(). - AssetPrice. - Create(). - SetPair(data.Pair). - SetAsset(data.Name). - SetChain(data.Chain). - SetBlock(data.Block). - SetPrice(&helpers.BigInt{Int: data.Price}). - SetSignersCount(data.SignersCount). - SetSignature(data.Signature). - SetConsensus(data.Consensus). - SetVoted(&helpers.BigInt{Int: data.Voted}). - AddSignerIDs(data.SignerIDs...). - OnConflictColumns("block", "chain", "asset", "pair"). - UpdateNewValues(). - Exec(ctx) + WithContext(ctx). + Table("asset_price"). + Clauses(clause.OnConflict{ + Columns: []clause.Column{{Name: "block"}, {Name: "chain"}, {Name: "asset"}, {Name: "pair"}}, + UpdateAll: true, + }). + Create(&model.DataFrame{ + Hash: data.Hash(), + Timestamp: time.Now(), + Data: data, + }) if err != nil { utils.Logger.With("err", err).Error("Cant upsert asset price record in database") @@ -44,19 +40,18 @@ func (a AssetPriceRepo) Upsert(ctx context.Context, data model.AssetPrice) error return nil } -func (a AssetPriceRepo) Find(ctx context.Context, block uint64, chain string, name string, pair string) ([]*ent.AssetPrice, error) { - currentRecords, err := a.client. +func (a AssetPriceRepo) Find(ctx context.Context, block uint64, chain string, name string, pair string) ([]model.AssetPrice, error) { + currentRecords := []model.AssetPrice{} + err := a.client. GetConnection(). - AssetPrice. - Query(). - Where( - assetprice.Block(block), - assetprice.Chain(chain), - assetprice.Asset(name), - assetprice.Pair(pair), - ). - WithSigners(). - All(ctx) + WithContext(ctx). + Table("asset_price"). + Where("block", block). + Where("chain", chain). + Where("name", name). + Where("pair", pair). + Preload("Signer"). + Find(¤tRecords) if err != nil { utils.Logger.With("err", err).Error("Cant fetch asset price records from database") diff --git a/internal/repository/postgres/correctness.go b/internal/repository/postgres/correctness.go index c4095362..48f9d862 100644 --- a/internal/repository/postgres/correctness.go +++ b/internal/repository/postgres/correctness.go @@ -2,32 +2,30 @@ package postgres import ( "context" + "time" "github.com/TimeleapLabs/unchained/internal/consts" - "github.com/TimeleapLabs/unchained/internal/ent" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" "github.com/TimeleapLabs/unchained/internal/transport/database" "github.com/TimeleapLabs/unchained/internal/utils" + "gorm.io/gorm/clause" ) type CorrectnessRepo struct { client database.Database } -func (c CorrectnessRepo) Find(ctx context.Context, hash []byte, topic []byte, timestamp uint64) ([]*ent.CorrectnessReport, error) { - currentRecords, err := c.client. +func (c CorrectnessRepo) Find(ctx context.Context, hash []byte, topic []byte, timestamp uint64) ([]model.Correctness, error) { + currentRecords := []model.Correctness{} + err := c.client. GetConnection(). - CorrectnessReport. - Query(). - Where(correctnessreport.And( - correctnessreport.Hash(hash), - correctnessreport.Topic(topic), - correctnessreport.Timestamp(timestamp), - )). - All(ctx) + WithContext(ctx). + Table("correctness"). + Where("hash", hash). + Where("topic", topic). + Where("timestamp", timestamp). + Find(¤tRecords) if err != nil { utils.Logger.With("err", err).Error("Cant fetch correctness reports from database") @@ -38,22 +36,22 @@ func (c CorrectnessRepo) Find(ctx context.Context, hash []byte, topic []byte, ti } func (c CorrectnessRepo) Upsert(ctx context.Context, data model.Correctness) error { + dataBls := data.Bls() + dataBlsHash := (&dataBls).Marshal() + err := c.client. GetConnection(). - CorrectnessReport. - Create(). - SetCorrect(data.Correct). - SetSignersCount(data.SignersCount). - SetSignature(data.Signature). - SetHash(data.Hash). - SetTimestamp(data.Timestamp). - SetTopic(data.Topic[:]). - SetConsensus(data.Consensus). - SetVoted(&helpers.BigInt{Int: data.Voted}). - AddSignerIDs(data.SignerIDs...). - OnConflictColumns("topic", "hash"). - UpdateNewValues(). - Exec(ctx) + WithContext(ctx). + Table("correctness"). + Clauses(clause.OnConflict{ + Columns: []clause.Column{{Name: "topic"}, {Name: "hash"}}, + UpdateAll: true, + }). + Create(&model.DataFrame{ + Hash: dataBlsHash, + Timestamp: time.Now(), + Data: data, + }) if err != nil { utils.Logger.With("err", err).Error("Cant upsert correctness report in database") diff --git a/internal/repository/postgres/eventlog.go b/internal/repository/postgres/eventlog.go index 74477c91..09aa565e 100644 --- a/internal/repository/postgres/eventlog.go +++ b/internal/repository/postgres/eventlog.go @@ -2,10 +2,11 @@ package postgres import ( "context" + "time" + + "gorm.io/gorm/clause" "github.com/TimeleapLabs/unchained/internal/consts" - "github.com/TimeleapLabs/unchained/internal/ent" - "github.com/TimeleapLabs/unchained/internal/ent/eventlog" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" "github.com/TimeleapLabs/unchained/internal/transport/database" @@ -16,18 +17,17 @@ type EventLogRepo struct { client database.Database } -func (r EventLogRepo) Find(ctx context.Context, block uint64, hash []byte, index uint64) ([]*ent.EventLog, error) { - currentRecords, err := r.client. +func (r EventLogRepo) Find(ctx context.Context, block uint64, hash []byte, index uint64) ([]model.EventLog, error) { + currentRecords := []model.EventLog{} + err := r.client. GetConnection(). - EventLog. - Query(). - Where( - eventlog.Block(block), - eventlog.TransactionEQ(hash), - eventlog.IndexEQ(index), - ). - WithSigners(). - All(ctx) + WithContext(ctx). + Table("event_log"). + Where("block", block). + Where("transaction", hash). + Where("index", index). + Preload("Signers"). + Find(¤tRecords) if err != nil { utils.Logger.With("err", err).Error("Cant fetch event log records from database") @@ -40,23 +40,17 @@ func (r EventLogRepo) Find(ctx context.Context, block uint64, hash []byte, index func (r EventLogRepo) Upsert(ctx context.Context, data model.EventLog) error { err := r.client. GetConnection(). - EventLog. - Create(). - SetBlock(data.Block). - SetChain(data.Chain). - SetAddress(data.Address). - SetEvent(data.Event). - SetIndex(data.LogIndex). - SetTransaction(data.TxHash[:]). - SetSignersCount(data.SignersCount). - SetSignature(data.Signature). - SetArgs(data.Args). - SetConsensus(data.Consensus). - SetVoted(data.Voted). - AddSignerIDs(data.SignerIDs...). - OnConflictColumns("block", "transaction", "index"). - UpdateNewValues(). - Exec(ctx) + WithContext(ctx). + Table("event_log"). + Clauses(clause.OnConflict{ + Columns: []clause.Column{{Name: "block"}, {Name: "transaction"}, {Name: "index"}}, + UpdateAll: true, + }). + Create(&model.DataFrame{ + Hash: nil, + Timestamp: time.Now(), + Data: data, + }) if err != nil { utils.Logger.With("err", err).Error("Cant upsert event log record to database") diff --git a/internal/repository/postgres/signer.go b/internal/repository/postgres/signer.go index 3ba2b270..26eb8a57 100644 --- a/internal/repository/postgres/signer.go +++ b/internal/repository/postgres/signer.go @@ -3,9 +3,10 @@ package postgres import ( "context" + "gorm.io/gorm" + "gorm.io/gorm/clause" + "github.com/TimeleapLabs/unchained/internal/consts" - "github.com/TimeleapLabs/unchained/internal/ent" - "github.com/TimeleapLabs/unchained/internal/ent/signer" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" "github.com/TimeleapLabs/unchained/internal/transport/database" @@ -19,22 +20,22 @@ type signerRepo struct { func (s signerRepo) CreateSigners(ctx context.Context, signers []model.Signer) error { err := s.client. GetConnection(). - Signer.MapCreateBulk(signers, func(sc *ent.SignerCreate, i int) { - signer := signers[i] - sc.SetName(signer.Name). - SetEvm(signer.EvmAddress). - SetKey(signer.PublicKey[:]). - SetShortkey(signer.ShortPublicKey[:]). - SetPoints(0) - }). - OnConflictColumns("shortkey"). - UpdateName(). - UpdateEvm(). - UpdateKey(). - Update(func(su *ent.SignerUpsert) { - su.AddPoints(1) + WithContext(ctx). + Table("signer"). + Clauses(clause.OnConflict{ + Columns: []clause.Column{{Name: "shortkey"}}, + DoUpdates: clause.Assignments(map[string]interface{}{ + "name": "name", + "evm": "evm", + "key": "key", + "point": gorm.Expr("signer.point + 1"), + }), }). - Exec(ctx) + CreateInBatches(&signers, 100) + + // Update(func(su *ent.SignerUpsert) { + // su.AddPoints(1) + // }). if err != nil { utils.Logger.With("err", err).Error("Cant create signers in database") @@ -45,19 +46,22 @@ func (s signerRepo) CreateSigners(ctx context.Context, signers []model.Signer) e } func (s signerRepo) GetSingerIDsByKeys(ctx context.Context, keys [][]byte) ([]int, error) { - signerIDs, err := s.client. + ids := []int{} + + err := s.client. GetConnection(). - Signer. - Query(). - Where(signer.KeyIn(keys...)). - IDs(ctx) + WithContext(ctx). + Table("signer"). + Select("id"). + Where("data.key in ?", keys). + Find(&ids) if err != nil { utils.Logger.With("err", err).Error("Cant fetch signer IDs from database") return []int{}, consts.ErrInternalError } - return signerIDs, nil + return ids, nil } func NewSigner(client database.Database) repository.Signer { diff --git a/internal/repository/repository.go b/internal/repository/repository.go index 0948dc57..732593c9 100644 --- a/internal/repository/repository.go +++ b/internal/repository/repository.go @@ -3,13 +3,12 @@ package repository import ( "context" - "github.com/TimeleapLabs/unchained/internal/ent" "github.com/TimeleapLabs/unchained/internal/model" ) // EvenetLog interface represents the methods that can be used to interact with the EventLog table in the database. type EventLog interface { - Find(ctx context.Context, block uint64, hash []byte, index uint64) ([]*ent.EventLog, error) + Find(ctx context.Context, block uint64, hash []byte, index uint64) ([]model.EventLog, error) Upsert(ctx context.Context, data model.EventLog) error } @@ -21,13 +20,13 @@ type Signer interface { // AssetPrice interface represents the methods that can be used to interact with the AssetPrice table in the database. type AssetPrice interface { - Find(ctx context.Context, block uint64, chain string, name string, pair string) ([]*ent.AssetPrice, error) + Find(ctx context.Context, block uint64, chain string, name string, pair string) ([]model.AssetPrice, error) Upsert(ctx context.Context, data model.AssetPrice) error } // CorrectnessReport interface represents the methods that can be used to interact with the CorrectnessReport table in the database. type CorrectnessReport interface { - Find(ctx context.Context, hash []byte, topic []byte, timestamp uint64) ([]*ent.CorrectnessReport, error) + Find(ctx context.Context, hash []byte, topic []byte, timestamp uint64) ([]model.Correctness, error) Upsert(ctx context.Context, data model.Correctness) error } diff --git a/internal/service/correctness/correctness.go b/internal/service/correctness/correctness.go index b9ad53bd..802337ba 100644 --- a/internal/service/correctness/correctness.go +++ b/internal/service/correctness/correctness.go @@ -14,12 +14,10 @@ import ( "github.com/TimeleapLabs/unchained/internal/service/pos" "github.com/TimeleapLabs/unchained/internal/utils/address" - "github.com/TimeleapLabs/unchained/internal/service/evmlog" "github.com/puzpuzpuz/xsync/v3" "github.com/TimeleapLabs/unchained/internal/config" "github.com/TimeleapLabs/unchained/internal/crypto/bls" - "github.com/TimeleapLabs/unchained/internal/ent" "github.com/TimeleapLabs/unchained/internal/utils" bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" lru "github.com/hashicorp/golang-lru/v2" @@ -37,7 +35,7 @@ type SaveSignatureArgs struct { } type Service interface { - IsNewSigner(signature model.Signature, records []*ent.CorrectnessReport) bool + IsNewSigner(signature Signature, records []model.Correctness) bool RecordSignature( ctx context.Context, signature bls12381.G1Affine, signer model.Signer, hash bls12381.G1Affine, info model.Correctness, debounce bool, ) error @@ -49,7 +47,7 @@ type service struct { signerRepo repository.Signer correctnessRepo repository.CorrectnessReport - signatureCache *lru.Cache[bls12381.G1Affine, []model.Signature] + signatureCache *lru.Cache[bls12381.G1Affine, []Signature] consensus *lru.Cache[Key, xsync.MapOf[bls12381.G1Affine, big.Int]] DebouncedSaveSignatures func(key bls12381.G1Affine, arg SaveSignatureArgs) @@ -58,11 +56,11 @@ type service struct { } // IsNewSigner checks if the signer's pub key is in the records signers or not. -func (s *service) IsNewSigner(signature model.Signature, records []*ent.CorrectnessReport) bool { +func (s *service) IsNewSigner(signature Signature, records []model.Correctness) bool { // TODO: This isn't efficient, we should use a map for _, record := range records { - for _, signer := range record.Edges.Signers { - if signature.Signer.PublicKey == [96]byte(signer.Key) { + for _, signer := range record.Signers { + if signature.Signer.PublicKey == signer.PublicKey { return false } } @@ -88,7 +86,7 @@ func (s *service) RecordSignature( signatures, ok := s.signatureCache.Get(hash) if !ok { - signatures = make([]model.Signature, 0) + signatures = make([]Signature, 0) } // Check for duplicates @@ -98,7 +96,7 @@ func (s *service) RecordSignature( } } - packed := model.Signature{ + packed := Signature{ Signature: signature, Signer: signer, } @@ -178,7 +176,7 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er } currentRecords, err := s.correctnessRepo.Find(ctx, args.Info.Hash, args.Info.Topic[:], args.Info.Timestamp) - if err != nil && !ent.IsNotFound(err) { + if err != nil { return err } @@ -255,7 +253,7 @@ func (s *service) init() { s.DebouncedSaveSignatures = utils.Debounce[bls12381.G1Affine, SaveSignatureArgs](5*time.Second, s.SaveSignatures) s.signatureMutex = new(sync.Mutex) s.supportedTopics = make(map[[64]byte]bool) - s.signatureCache, err = lru.New[bls12381.G1Affine, []model.Signature](LruSize) + s.signatureCache, err = lru.New[bls12381.G1Affine, []Signature](LruSize) if err != nil { panic(err) @@ -279,7 +277,7 @@ func New( } var err error - c.consensus, err = lru.New[Key, xsync.MapOf[bls12381.G1Affine, big.Int]](evmlog.LruSize) + c.consensus, err = lru.New[Key, xsync.MapOf[bls12381.G1Affine, big.Int]](LruSize) if err != nil { utils.Logger. Error("Failed to create correctness consensus cache.") diff --git a/internal/service/correctness/correctness_test.go b/internal/service/correctness/correctness_test.go index ca5462ba..a70024d1 100644 --- a/internal/service/correctness/correctness_test.go +++ b/internal/service/correctness/correctness_test.go @@ -3,7 +3,6 @@ package correctness import ( "testing" - "github.com/TimeleapLabs/unchained/internal/ent" "github.com/TimeleapLabs/unchained/internal/model" postgresRepo "github.com/TimeleapLabs/unchained/internal/repository/postgres" "github.com/TimeleapLabs/unchained/internal/service/pos" @@ -13,12 +12,12 @@ import ( ) var ( - SignerOne = model.Signature{ + SignerOne = Signature{ Signer: model.Signer{ PublicKey: [96]byte{1, 2, 3}, }, } - SignerTwo = model.Signature{ + SignerTwo = Signature{ Signer: model.Signer{ PublicKey: [96]byte{3, 2, 1}, }, @@ -43,7 +42,7 @@ func (s *CorrectnessTestSuite) SetupTest() { func (s *CorrectnessTestSuite) TestIsNewSigner() { s.Run("Check if new signer with empty values", func() { - isSigner := s.service.IsNewSigner(model.Signature{}, []*ent.CorrectnessReport{}) + isSigner := s.service.IsNewSigner(Signature{}, []model.Correctness{}) assert.False(s.T(), isSigner) }) @@ -55,16 +54,16 @@ func (s *CorrectnessTestSuite) TestIsNewSigner() { isSigner := s.service.IsNewSigner( SignerOne, - []*ent.CorrectnessReport{ - { - Edges: ent.CorrectnessReportEdges{ - Signers: []*ent.Signer{ - { - Key: signers, - }, - }, - }, - }, + []model.Correctness{ + //{ + // Edges: ent.CorrectnessReportEdges{ + // Signers: []*ent.Signer{ + // { + // Key: signers, + // }, + // }, + // }, + // }, }, ) assert.True(s.T(), isSigner) @@ -78,15 +77,15 @@ func (s *CorrectnessTestSuite) TestIsNewSigner() { isSigner := s.service.IsNewSigner( SignerTwo, - []*ent.CorrectnessReport{ + []model.Correctness{ { - Edges: ent.CorrectnessReportEdges{ - Signers: []*ent.Signer{ - { - Key: signers, - }, - }, - }, + //Edges: ent.CorrectnessReportEdges{ + // Signers: []*ent.Signer{ + // { + // Key: signers, + // }, + // }, + // }, }, }, ) diff --git a/internal/service/correctness/types.go b/internal/service/correctness/types.go index 1170f6b6..bc73fa07 100644 --- a/internal/service/correctness/types.go +++ b/internal/service/correctness/types.go @@ -1,7 +1,41 @@ package correctness +import ( + "github.com/TimeleapLabs/unchained/internal/model" + bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" + sia "github.com/pouya-eghbali/go-sia/v2/pkg" +) + type Key struct { Hash string Topic string Correct bool } + +type Signature struct { + Signature bls12381.G1Affine + Signer model.Signer +} + +func (s *Signature) Sia() sia.Sia { + return sia.New(). + AddByteArray8(s.Signature.Marshal()). + EmbedBytes(s.Signer.Sia().Bytes()) +} + +func (s *Signature) FromBytes(payload []byte) *Signature { + siaMessage := sia.NewFromBytes(payload) + return s.FromSia(siaMessage) +} + +func (s *Signature) FromSia(sia sia.Sia) *Signature { + err := s.Signature.Unmarshal(sia.ReadByteArray8()) + + if err != nil { + s.Signature = bls12381.G1Affine{} + } + + s.Signer.FromSia(sia) + + return s +} diff --git a/internal/service/evmlog/evmlog.go b/internal/service/evmlog/evmlog.go index b96d1bfb..273a684f 100644 --- a/internal/service/evmlog/evmlog.go +++ b/internal/service/evmlog/evmlog.go @@ -9,6 +9,9 @@ import ( "sync" "time" + "github.com/TimeleapLabs/unchained/internal/service/correctness" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" + "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" @@ -19,8 +22,6 @@ import ( "github.com/TimeleapLabs/unchained/internal/config" "github.com/TimeleapLabs/unchained/internal/crypto/bls" - "github.com/TimeleapLabs/unchained/internal/ent" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" "github.com/TimeleapLabs/unchained/internal/transport/client/conn" "github.com/TimeleapLabs/unchained/internal/utils" bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" @@ -57,7 +58,7 @@ type service struct { persistence *Badger consensus *lru.Cache[EventKey, map[bls12381.G1Affine]big.Int] - signatureCache *lru.Cache[bls12381.G1Affine, []model.Signature] + signatureCache *lru.Cache[bls12381.G1Affine, []correctness.Signature] DebouncedSaveSignatures func(key bls12381.G1Affine, arg SaveSignatureArgs) signatureMutex *sync.Mutex supportedEvents map[SupportKey]bool @@ -87,7 +88,7 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er var keys [][]byte currentRecords, err := s.eventLogRepo.Find(ctx, args.Info.Block, args.Info.TxHash[:], args.Info.LogIndex) - if err != nil && !ent.IsNotFound(err) { + if err != nil { return err } @@ -175,7 +176,7 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er args.Info.SignerIDs = signerIDs args.Info.Consensus = args.Consensus args.Info.Signature = signatureBytes[:] - args.Info.Voted = &helpers.BigInt{Int: *args.Voted} + args.Info.Voted = args.Voted err = s.eventLogRepo.Upsert(ctx, args.Info) if err != nil { @@ -188,7 +189,7 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er func (s *service) SendPriceReport(signature bls12381.G1Affine, event model.EventLog) { compressedSignature := signature.Bytes() - priceReport := model.EventLogReportPacket{ + priceReport := packet.EventLogReportPacket{ EventLog: event, Signature: compressedSignature, } @@ -219,7 +220,7 @@ func New( s.DebouncedSaveSignatures = utils.Debounce[bls12381.G1Affine, SaveSignatureArgs](5*time.Second, s.SaveSignatures) var err error - s.signatureCache, err = lru.New[bls12381.G1Affine, []model.Signature](LruSize) + s.signatureCache, err = lru.New[bls12381.G1Affine, []correctness.Signature](LruSize) if err != nil { panic(err) } diff --git a/internal/service/evmlog/helper.go b/internal/service/evmlog/helper.go index 3d9b18d0..dda1f396 100644 --- a/internal/service/evmlog/helper.go +++ b/internal/service/evmlog/helper.go @@ -1,14 +1,14 @@ package evmlog import ( - "github.com/TimeleapLabs/unchained/internal/ent" "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/service/correctness" ) -func isNewSigner(signature model.Signature, records []*ent.EventLog) bool { +func isNewSigner(signature correctness.Signature, records []model.EventLog) bool { for _, record := range records { - for _, signer := range record.Edges.Signers { - if signature.Signer.PublicKey == [96]byte(signer.Key) { + for _, signer := range record.Signers { + if signature.Signer.PublicKey == signer.PublicKey { return false } } diff --git a/internal/service/evmlog/record.go b/internal/service/evmlog/record.go index 646f1453..01e98741 100644 --- a/internal/service/evmlog/record.go +++ b/internal/service/evmlog/record.go @@ -4,6 +4,8 @@ import ( "context" "math/big" + "github.com/TimeleapLabs/unchained/internal/service/correctness" + "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/utils" @@ -88,7 +90,7 @@ func (s *service) RecordSignature( cached, _ := s.signatureCache.Get(hash) - packed := model.Signature{ + packed := correctness.Signature{ Signature: signature, Signer: signer, } diff --git a/internal/service/uniswap/helper.go b/internal/service/uniswap/helper.go index ce63a731..9688238f 100644 --- a/internal/service/uniswap/helper.go +++ b/internal/service/uniswap/helper.go @@ -1,14 +1,14 @@ package uniswap import ( - "github.com/TimeleapLabs/unchained/internal/ent" "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/service/correctness" ) -func IsNewSigner(signature model.Signature, records []*ent.AssetPrice) bool { +func IsNewSigner(signature correctness.Signature, records []model.AssetPrice) bool { for _, record := range records { - for _, signer := range record.Edges.Signers { - if signature.Signer.PublicKey == [96]byte(signer.Key) { + for _, signer := range record.Signers { + if signature.Signer.PublicKey == signer.PublicKey { return false } } diff --git a/internal/service/uniswap/process.go b/internal/service/uniswap/process.go index 0e2a3af9..c7bac60f 100644 --- a/internal/service/uniswap/process.go +++ b/internal/service/uniswap/process.go @@ -3,8 +3,9 @@ package uniswap import ( "context" + "github.com/TimeleapLabs/unchained/internal/service/uniswap/types" + "github.com/TimeleapLabs/unchained/internal/config" - "github.com/TimeleapLabs/unchained/internal/model" ) func (s *service) ProcessBlocks(ctx context.Context, chain string) error { @@ -14,7 +15,7 @@ func (s *service) ProcessBlocks(ctx context.Context, chain string) error { return err } - for _, token := range model.NewTokensFromCfg(config.App.Plugins.Uniswap.Tokens) { + for _, token := range types.NewTokensFromCfg(config.App.Plugins.Uniswap.Tokens) { if token.Chain != chain { continue } diff --git a/internal/service/uniswap/record.go b/internal/service/uniswap/record.go index 54707062..8d81ecf8 100644 --- a/internal/service/uniswap/record.go +++ b/internal/service/uniswap/record.go @@ -5,6 +5,8 @@ import ( "fmt" "math/big" + "github.com/TimeleapLabs/unchained/internal/service/uniswap/types" + "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/utils" @@ -17,7 +19,7 @@ import ( // TODO: This needs to work with different datasets // TODO: Can we turn this into a library func? func (s *service) RecordSignature( - ctx context.Context, signature bls12381.G1Affine, signer model.Signer, hash bls12381.G1Affine, info model.PriceInfo, debounce bool, historical bool, + ctx context.Context, signature bls12381.G1Affine, signer model.Signer, hash bls12381.G1Affine, info types.PriceInfo, debounce bool, historical bool, ) error { if supported := s.SupportedTokens[info.Asset.Token]; !supported { utils.Logger. diff --git a/internal/service/uniswap/types/assetkey.go b/internal/service/uniswap/types/assetkey.go new file mode 100644 index 00000000..19407873 --- /dev/null +++ b/internal/service/uniswap/types/assetkey.go @@ -0,0 +1,21 @@ +package types + +import sia "github.com/pouya-eghbali/go-sia/v2/pkg" + +type AssetKey struct { + Token TokenKey + Block uint64 +} + +func (a *AssetKey) Sia() sia.Sia { + return sia.New(). + EmbedBytes(a.Token.Sia().Bytes()). + AddUInt64(a.Block) +} + +func (a *AssetKey) FromSia(sia sia.Sia) *AssetKey { + a.Token.FromSia(sia) + a.Block = sia.ReadUInt64() + + return a +} diff --git a/internal/service/uniswap/types/priceinfo.go b/internal/service/uniswap/types/priceinfo.go new file mode 100644 index 00000000..08171803 --- /dev/null +++ b/internal/service/uniswap/types/priceinfo.go @@ -0,0 +1,43 @@ +package types + +import ( + "math/big" + + "github.com/TimeleapLabs/unchained/internal/crypto/bls" + "github.com/TimeleapLabs/unchained/internal/utils" + bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" + sia "github.com/pouya-eghbali/go-sia/v2/pkg" +) + +type PriceInfo struct { + Asset AssetKey + Price big.Int +} + +func (p *PriceInfo) Sia() sia.Sia { + return sia.New(). + EmbedBytes(p.Asset.Sia().Bytes()). + AddBigInt(&p.Price) +} + +func (p *PriceInfo) FromBytes(payload []byte) *PriceInfo { + siaMessage := sia.NewFromBytes(payload) + return p.FromSia(siaMessage) +} + +func (p *PriceInfo) FromSia(sia sia.Sia) *PriceInfo { + p.Asset.FromSia(sia) + p.Price = *sia.ReadBigInt() + + return p +} + +func (p *PriceInfo) Bls() (bls12381.G1Affine, error) { + hash, err := bls.Hash(p.Sia().Bytes()) + if err != nil { + utils.Logger.With("err", err).Error("Can't hash bls") + return bls12381.G1Affine{}, err + } + + return hash, err +} diff --git a/internal/model/token.go b/internal/service/uniswap/types/token.go similarity index 98% rename from internal/model/token.go rename to internal/service/uniswap/types/token.go index d1300119..48ab8e2e 100644 --- a/internal/model/token.go +++ b/internal/service/uniswap/types/token.go @@ -1,4 +1,4 @@ -package model +package types import "github.com/TimeleapLabs/unchained/internal/config" diff --git a/internal/service/uniswap/types/tokenkey.go b/internal/service/uniswap/types/tokenkey.go new file mode 100644 index 00000000..6593bf62 --- /dev/null +++ b/internal/service/uniswap/types/tokenkey.go @@ -0,0 +1,33 @@ +package types + +import sia "github.com/pouya-eghbali/go-sia/v2/pkg" + +type TokenKey struct { + Name string + Pair string + Chain string + Delta int64 + Invert bool + Cross string +} + +func (t *TokenKey) Sia() sia.Sia { + return sia.New(). + AddString8(t.Name). + AddString8(t.Pair). + AddString8(t.Chain). + AddInt64(t.Delta). + AddBool(t.Invert). + AddString8(t.Cross) +} + +func (t *TokenKey) FromSia(sia sia.Sia) *TokenKey { + t.Name = sia.ReadString8() + t.Pair = sia.ReadString8() + t.Chain = sia.ReadString8() + t.Delta = sia.ReadInt64() + t.Invert = sia.ReadBool() + t.Cross = sia.ReadString8() + + return t +} diff --git a/internal/service/uniswap/uniswap.go b/internal/service/uniswap/uniswap.go index 1bbdc6da..ae909411 100644 --- a/internal/service/uniswap/uniswap.go +++ b/internal/service/uniswap/uniswap.go @@ -9,6 +9,10 @@ import ( "sync" "time" + "github.com/TimeleapLabs/unchained/internal/service/correctness" + "github.com/TimeleapLabs/unchained/internal/service/uniswap/types" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" + "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/repository" @@ -19,7 +23,6 @@ import ( "github.com/TimeleapLabs/unchained/internal/crypto" "github.com/TimeleapLabs/unchained/internal/crypto/bls" "github.com/TimeleapLabs/unchained/internal/crypto/ethereum" - "github.com/TimeleapLabs/unchained/internal/ent" "github.com/TimeleapLabs/unchained/internal/service/evmlog" "github.com/TimeleapLabs/unchained/internal/transport/client/conn" "github.com/TimeleapLabs/unchained/internal/utils" @@ -37,7 +40,7 @@ const ( SizeOfPriceCacheLru = 128 ) -var DebouncedSaveSignatures func(key model.AssetKey, arg SaveSignatureArgs) +var DebouncedSaveSignatures func(key types.AssetKey, arg SaveSignatureArgs) type Service interface { checkAndCacheSignature( @@ -47,10 +50,10 @@ type Service interface { saveSignatures(ctx context.Context, args SaveSignatureArgs) error GetBlockNumber(ctx context.Context, network string) (*uint64, error) GetPriceAtBlockFromPair(network string, blockNumber uint64, pairAddr string, decimalDif int64, inverse bool) (*big.Int, error) - SyncBlocks(ctx context.Context, token model.Token, key model.TokenKey, latest uint64) error - TokenKey(token model.Token) *model.TokenKey + SyncBlocks(ctx context.Context, token types.Token, key types.TokenKey, latest uint64) error + TokenKey(token types.Token) *types.TokenKey RecordSignature( - ctx context.Context, signature bls12381.G1Affine, signer model.Signer, hash bls12381.G1Affine, info model.PriceInfo, debounce bool, historical bool, + ctx context.Context, signature bls12381.G1Affine, signer model.Signer, hash bls12381.G1Affine, info types.PriceInfo, debounce bool, historical bool, ) error ProcessBlocks(ctx context.Context, chain string) error } @@ -61,18 +64,18 @@ type service struct { signerRepo repository.Signer assetPriceRepo repository.AssetPrice - consensus *lru.Cache[model.AssetKey, xsync.MapOf[bls12381.G1Affine, big.Int]] - signatureCache *lru.Cache[bls12381.G1Affine, []model.Signature] - SupportedTokens map[model.TokenKey]bool + consensus *lru.Cache[types.AssetKey, xsync.MapOf[bls12381.G1Affine, big.Int]] + signatureCache *lru.Cache[bls12381.G1Affine, []correctness.Signature] + SupportedTokens map[types.TokenKey]bool signatureMutex sync.Mutex twoOneNineTwo big.Int tenEighteen big.Int tenEighteenF big.Float - LastBlock xsync.MapOf[model.TokenKey, uint64] + LastBlock xsync.MapOf[types.TokenKey, uint64] PriceCache map[string]*lru.Cache[uint64, big.Int] crossPrices map[string]big.Int - crossTokens map[string]model.TokenKey + crossTokens map[string]types.TokenKey LastPrice big.Int } @@ -85,7 +88,7 @@ func (s *service) checkAndCacheSignature( cached, _ := s.signatureCache.Get(hash) - packed := model.Signature{ + packed := correctness.Signature{ Signature: signature, Signer: signer, } @@ -107,7 +110,7 @@ func (s *service) checkAndCacheSignature( } type SaveSignatureArgs struct { - Info model.PriceInfo + Info types.PriceInfo Hash bls12381.G1Affine Consensus bool Voted *big.Int @@ -137,7 +140,7 @@ func (s *service) saveSignatures(ctx context.Context, args SaveSignatureArgs) er args.Info.Asset.Block, args.Info.Asset.Token.Chain, args.Info.Asset.Token.Name, args.Info.Asset.Token.Pair, ) - if err != nil && !ent.IsNotFound(err) { + if err != nil { return err } @@ -163,7 +166,6 @@ func (s *service) saveSignatures(ctx context.Context, args SaveSignatureArgs) er } signerIDs, err := s.signerRepo.GetSingerIDsByKeys(ctx, keys) - if err != nil { utils.Logger. With("Block", args.Info.Asset.Block). @@ -177,7 +179,6 @@ func (s *service) saveSignatures(ctx context.Context, args SaveSignatureArgs) er for _, record := range currentRecords { if record.Price.Cmp(&args.Info.Price) == 0 { currentAggregate, err := bls.RecoverSignature([48]byte(record.Signature)) - if err != nil { utils.Logger. With("Block", args.Info.Asset.Block). @@ -290,7 +291,7 @@ func (s *service) priceFromSqrtX96(sqrtPriceX96 *big.Int, decimalDif int64, inve return &price } -func (s *service) syncBlock(ctx context.Context, token model.Token, caser cases.Caser, key *model.TokenKey, blockInx uint64) error { +func (s *service) syncBlock(ctx context.Context, token types.Token, caser cases.Caser, key *types.TokenKey, blockInx uint64) error { lastSynced, ok := s.LastBlock.Load(*key) if ok && blockInx <= lastSynced { @@ -347,9 +348,9 @@ func (s *service) syncBlock(ctx context.Context, token model.Token, caser cases. key = s.TokenKey(token) - priceInfo := model.PriceInfo{ + priceInfo := types.PriceInfo{ Price: *price, - Asset: model.AssetKey{ + Asset: types.AssetKey{ Block: blockInx, Token: *key, }, @@ -359,7 +360,7 @@ func (s *service) syncBlock(ctx context.Context, token model.Token, caser cases. if token.Send && !conn.IsClosed { compressedSignature := signature.Bytes() - priceReport := model.PriceReportPacket{ + priceReport := packet.PriceReportPacket{ PriceInfo: priceInfo, Signature: compressedSignature, } @@ -388,7 +389,7 @@ func (s *service) syncBlock(ctx context.Context, token model.Token, caser cases. return nil } -func (s *service) SyncBlocks(ctx context.Context, token model.Token, key model.TokenKey, latest uint64) error { +func (s *service) SyncBlocks(ctx context.Context, token types.Token, key types.TokenKey, latest uint64) error { block, ok := s.LastBlock.Load(key) if !ok { return consts.ErrCantLoadLastBlock @@ -406,21 +407,21 @@ func (s *service) SyncBlocks(ctx context.Context, token model.Token, key model.T return nil } -func (s *service) TokenKey(token model.Token) *model.TokenKey { - var cross []model.TokenKey +func (s *service) TokenKey(token types.Token) *types.TokenKey { + var cross []types.TokenKey for _, id := range token.Cross { cross = append(cross, s.crossTokens[id]) } - toHash := new(sia.ArraySia[model.TokenKey]). - AddArray8(cross, func(s *sia.ArraySia[model.TokenKey], item model.TokenKey) { + toHash := new(sia.ArraySia[types.TokenKey]). + AddArray8(cross, func(s *sia.ArraySia[types.TokenKey], item types.TokenKey) { s.EmbedBytes(item.Sia().Bytes()) }).Bytes() hash := utils.Shake(toHash) - key := model.TokenKey{ + key := types.TokenKey{ Name: strings.ToLower(token.Name), Pair: strings.ToLower(token.Pair), Chain: strings.ToLower(token.Chain), @@ -446,15 +447,15 @@ func New( consensus: nil, signatureCache: nil, - SupportedTokens: map[model.TokenKey]bool{}, + SupportedTokens: map[types.TokenKey]bool{}, signatureMutex: sync.Mutex{}, - LastBlock: *xsync.NewMapOf[model.TokenKey, uint64](), + LastBlock: *xsync.NewMapOf[types.TokenKey, uint64](), PriceCache: map[string]*lru.Cache[uint64, big.Int]{}, crossPrices: map[string]big.Int{}, - crossTokens: map[string]model.TokenKey{}, + crossTokens: map[string]types.TokenKey{}, } - DebouncedSaveSignatures = utils.Debounce[model.AssetKey, SaveSignatureArgs](5*time.Second, s.saveSignatures) + DebouncedSaveSignatures = utils.Debounce[types.AssetKey, SaveSignatureArgs](5*time.Second, s.saveSignatures) s.twoOneNineTwo.Exp(big.NewInt(2), big.NewInt(192), nil) s.tenEighteen.Exp(big.NewInt(10), big.NewInt(18), nil) @@ -462,7 +463,7 @@ func New( if config.App.Plugins.Uniswap != nil { for _, t := range config.App.Plugins.Uniswap.Tokens { - token := model.NewTokenFromCfg(t) + token := types.NewTokenFromCfg(t) key := s.TokenKey(token) s.SupportedTokens[*key] = true @@ -470,7 +471,7 @@ func New( } for _, t := range config.App.Plugins.Uniswap.Tokens { - token := model.NewTokenFromCfg(t) + token := types.NewTokenFromCfg(t) var err error s.PriceCache[strings.ToLower(token.Pair)], err = lru.New[uint64, big.Int](SizeOfPriceCacheLru) @@ -481,14 +482,14 @@ func New( } var err error - s.signatureCache, err = lru.New[bls12381.G1Affine, []model.Signature](evmlog.LruSize) + s.signatureCache, err = lru.New[bls12381.G1Affine, []correctness.Signature](evmlog.LruSize) if err != nil { utils.Logger.Error("Failed to create token price signature cache.") os.Exit(1) } // TODO: This is vulnerable to flood attacks - s.consensus, err = lru.New[model.AssetKey, xsync.MapOf[bls12381.G1Affine, big.Int]](evmlog.LruSize) + s.consensus, err = lru.New[types.AssetKey, xsync.MapOf[bls12381.G1Affine, big.Int]](evmlog.LruSize) if err != nil { utils.Logger.Error("Failed to create token price consensus cache.") os.Exit(1) diff --git a/internal/transport/client/handler/challenge.go b/internal/transport/client/handler/challenge.go index 88bbbb9a..d42f08e5 100644 --- a/internal/transport/client/handler/challenge.go +++ b/internal/transport/client/handler/challenge.go @@ -2,11 +2,11 @@ package handler import ( "github.com/TimeleapLabs/unchained/internal/crypto" - "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" ) func (h *consumer) Challenge(message []byte) []byte { - challenge := new(model.ChallengePacket).FromBytes(message) + challenge := new(packet.ChallengePacket).FromBytes(message) signature, _ := crypto.Identity.Bls.Sign(challenge.Random[:]) challenge.Signature = signature.Bytes() @@ -15,7 +15,7 @@ func (h *consumer) Challenge(message []byte) []byte { } func (w worker) Challenge(message []byte) []byte { - challenge := new(model.ChallengePacket).FromBytes(message) + challenge := new(packet.ChallengePacket).FromBytes(message) signature, _ := crypto.Identity.Bls.Sign(challenge.Random[:]) challenge.Signature = signature.Bytes() diff --git a/internal/transport/client/handler/correctness.go b/internal/transport/client/handler/correctness.go index 50486e1a..fdd3c0b0 100644 --- a/internal/transport/client/handler/correctness.go +++ b/internal/transport/client/handler/correctness.go @@ -3,18 +3,16 @@ package handler import ( "context" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" + "github.com/TimeleapLabs/unchained/internal/crypto/bls" - "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/utils" ) func (h *consumer) CorrectnessReport(ctx context.Context, message []byte) { - packet := new(model.BroadcastCorrectnessPacket).FromBytes(message) + packet := new(packet.BroadcastCorrectnessPacket).FromBytes(message) - correctnessHash, err := packet.Info.Bls() - if err != nil { - return - } + correctnessHash := packet.Info.Bls() signature, err := bls.RecoverSignature(packet.Signature) if err != nil { diff --git a/internal/transport/client/handler/event.go b/internal/transport/client/handler/event.go index a33f9f16..c8c48417 100644 --- a/internal/transport/client/handler/event.go +++ b/internal/transport/client/handler/event.go @@ -3,13 +3,14 @@ package handler import ( "context" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" + "github.com/TimeleapLabs/unchained/internal/crypto/bls" - "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/utils" ) func (h *consumer) EventLog(ctx context.Context, message []byte) { - packet := new(model.BroadcastEventPacket).FromBytes(message) + packet := new(packet.BroadcastEventPacket).FromBytes(message) eventLogHash, err := packet.Info.Bls() if err != nil { diff --git a/internal/transport/client/handler/price.go b/internal/transport/client/handler/price.go index 09b34a33..10531d8f 100644 --- a/internal/transport/client/handler/price.go +++ b/internal/transport/client/handler/price.go @@ -3,13 +3,14 @@ package handler import ( "context" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" + "github.com/TimeleapLabs/unchained/internal/crypto/bls" - "github.com/TimeleapLabs/unchained/internal/model" "github.com/TimeleapLabs/unchained/internal/utils" ) func (h *consumer) PriceReport(ctx context.Context, message []byte) { - packet := new(model.BroadcastPricePacket).FromBytes(message) + packet := new(packet.BroadcastPricePacket).FromBytes(message) priceInfoHash, err := packet.Info.Bls() if err != nil { diff --git a/internal/transport/database/database.go b/internal/transport/database/database.go index 39ded2c0..db17af8b 100644 --- a/internal/transport/database/database.go +++ b/internal/transport/database/database.go @@ -3,10 +3,10 @@ package database import ( "context" - "github.com/TimeleapLabs/unchained/internal/ent" + "gorm.io/gorm" ) type Database interface { - GetConnection() *ent.Client + GetConnection() *gorm.DB HealthCheck(ctx context.Context) bool } diff --git a/internal/transport/database/mock/postgres_mock.go b/internal/transport/database/mock/postgres_mock.go index 367bf0ef..5827cd5b 100644 --- a/internal/transport/database/mock/postgres_mock.go +++ b/internal/transport/database/mock/postgres_mock.go @@ -4,7 +4,10 @@ import ( "context" "testing" - "github.com/TimeleapLabs/unchained/internal/ent" + "gorm.io/driver/postgres" + "gorm.io/gorm" + "gorm.io/gorm/logger" + "github.com/TimeleapLabs/unchained/internal/transport/database" "github.com/peterldowns/pgtestdb" @@ -12,10 +15,10 @@ import ( type mockConnection struct { t *testing.T - db *ent.Client + db *gorm.DB } -func (m *mockConnection) GetConnection() *ent.Client { +func (m *mockConnection) GetConnection() *gorm.DB { if m.db != nil { return m.db } @@ -34,7 +37,13 @@ func (m *mockConnection) GetConnection() *ent.Client { ) var err error - m.db, err = ent.Open("postgres", "postgresql://postgres:password@127.0.0.1:5433/unchained?sslmode=disable") + m.db, err = gorm.Open( + postgres.Open("postgresql://postgres:password@127.0.0.1:5433/unchained?sslmode=disable"), + &gorm.Config{ + Logger: logger.Default.LogMode(logger.Warn), + TranslateError: true, + }, + ) if err != nil { panic(err) } diff --git a/internal/transport/database/postgres/postgres.go b/internal/transport/database/postgres/postgres.go index 40784bd2..b641b326 100644 --- a/internal/transport/database/postgres/postgres.go +++ b/internal/transport/database/postgres/postgres.go @@ -4,24 +4,38 @@ import ( "context" "github.com/TimeleapLabs/unchained/internal/config" - "github.com/TimeleapLabs/unchained/internal/ent" "github.com/TimeleapLabs/unchained/internal/transport/database" "github.com/TimeleapLabs/unchained/internal/utils" - // these imports are required for ent to work with postgres. - _ "github.com/jackc/pgx/v5/stdlib" - _ "github.com/lib/pq" + "gorm.io/driver/postgres" + "gorm.io/gorm" + "gorm.io/gorm/logger" ) type connection struct { - db *ent.Client + db *gorm.DB } func (c *connection) HealthCheck(_ context.Context) bool { + if c.db != nil { + return false + } + conn, err := c.db.DB() + if err != nil { + utils.Logger.With("Error", err).Error("Failed to get DB connection") + return false + } + + err = conn.Ping() + if err != nil { + utils.Logger.With("Error", err).Error("Failed to ping DB") + return false + } + return true } -func (c *connection) GetConnection() *ent.Client { +func (c *connection) GetConnection() *gorm.DB { if c.db != nil { return c.db } @@ -34,17 +48,30 @@ func (c *connection) GetConnection() *ent.Client { utils.Logger.Info("Connecting to DB") - c.db, err = ent.Open("postgres", config.App.Postgres.URL) - + c.db, err = gorm.Open( + postgres.Open(config.App.Postgres.URL), + &gorm.Config{ + Logger: logger.Default.LogMode(logger.Warn), + TranslateError: true, + }, + ) if err != nil { - utils.Logger.With("err", err).Error("failed opening connection to postgres") + panic(err) } - if err = c.db.Schema.Create(context.Background()); err != nil { - utils.Logger.With("err", err).Error("failed creating schema resources") + return c.db +} + +func (c *connection) Migrate() { + if c.db == nil { + c.GetConnection() } - return c.db + err := c.db.AutoMigrate() + + if err != nil { + utils.Logger.With("Error", err).Error("Failed to migrate DB") + } } func New() database.Database { diff --git a/internal/transport/server/gql/args.graphql b/internal/transport/server/gql/args.graphql deleted file mode 100644 index b38a3c14..00000000 --- a/internal/transport/server/gql/args.graphql +++ /dev/null @@ -1,7 +0,0 @@ -scalar BigInt -scalar Bytes - -type EventLogArg { - name: String! - value: String! -} diff --git a/internal/transport/server/gql/args.resolvers.go b/internal/transport/server/gql/args.resolvers.go deleted file mode 100644 index 014d802d..00000000 --- a/internal/transport/server/gql/args.resolvers.go +++ /dev/null @@ -1,39 +0,0 @@ -package gql - -// This file will be automatically regenerated based on the schema, any resolver implementations -// will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.45 - -import ( - "context" - "fmt" - "github.com/TimeleapLabs/unchained/internal/model" - "strings" - - "github.com/TimeleapLabs/unchained/internal/transport/server/gql/generated" -) - -// Value is the resolver for the value field. -func (r *eventLogArgResolver) Value(ctx context.Context, obj *model.EventLogArg) (string, error) { - switch { - case strings.HasPrefix(obj.Type, "uint"), strings.HasPrefix(obj.Type, "int"): - return obj.Value.(string), nil - - case obj.Type == "bool": - return fmt.Sprintf("%t", obj.Value), nil - - case obj.Type == "string": - return obj.Value.(string), nil - - case obj.Type == "address": - return obj.Value.(string), nil - - default: - return "", fmt.Errorf("unsupported type: %s", obj.Type) - } -} - -// EventLogArg returns generated.EventLogArgResolver implementation. -func (r *Resolver) EventLogArg() generated.EventLogArgResolver { return &eventLogArgResolver{r} } - -type eventLogArgResolver struct{ *Resolver } diff --git a/internal/transport/server/gql/extensions.graphql b/internal/transport/server/gql/extensions.graphql deleted file mode 100644 index ac87aa64..00000000 --- a/internal/transport/server/gql/extensions.graphql +++ /dev/null @@ -1,8 +0,0 @@ -extend input SignerWhereInput { - key: String -} - -extend input CorrectnessReportWhereInput { - topic: String - hash: String -} diff --git a/internal/transport/server/gql/extensions.resolvers.go b/internal/transport/server/gql/extensions.resolvers.go deleted file mode 100644 index 4ef548d2..00000000 --- a/internal/transport/server/gql/extensions.resolvers.go +++ /dev/null @@ -1,65 +0,0 @@ -package gql - -// This file will be automatically regenerated based on the schema, any resolver implementations -// will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.45 - -import ( - "context" - "encoding/hex" - - "github.com/TimeleapLabs/unchained/internal/ent" - "github.com/TimeleapLabs/unchained/internal/ent/correctnessreport" - "github.com/TimeleapLabs/unchained/internal/ent/signer" -) - -// Topic is the resolver for the topic field. -func (r *correctnessReportWhereInputResolver) Topic(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *string) error { - if obj == nil || data == nil { - return nil - } - - bytes, err := hex.DecodeString(*data) - - if err != nil { - return err - } - - obj.AddPredicates(correctnessreport.TopicEQ(bytes)) - - return nil -} - -// Hash is the resolver for the hash field. -func (r *correctnessReportWhereInputResolver) Hash(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *string) error { - if obj == nil || data == nil { - return nil - } - - bytes, err := hex.DecodeString(*data) - - if err != nil { - return err - } - - obj.AddPredicates(correctnessreport.HashEQ(bytes)) - - return nil -} - -// Key is the resolver for the key field. -func (r *signerWhereInputResolver) Key(ctx context.Context, obj *ent.SignerWhereInput, data *string) error { - if obj == nil || data == nil { - return nil - } - - bytes, err := hex.DecodeString(*data) - - if err != nil { - return err - } - - obj.AddPredicates(signer.KeyEQ(bytes)) - - return nil -} diff --git a/internal/transport/server/gql/generated/args.generated.go b/internal/transport/server/gql/generated/args.generated.go deleted file mode 100644 index 62e0fe21..00000000 --- a/internal/transport/server/gql/generated/args.generated.go +++ /dev/null @@ -1,279 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package generated - -import ( - "context" - "errors" - "github.com/TimeleapLabs/unchained/internal/model" - "strconv" - "sync" - "sync/atomic" - - "github.com/99designs/gqlgen/graphql" - "github.com/TimeleapLabs/unchained/internal/transport/server/gql/types" - "github.com/vektah/gqlparser/v2/ast" -) - -// region ************************** generated!.gotpl ************************** - -type EventLogArgResolver interface { - Value(ctx context.Context, obj *model.EventLogArg) (string, error) -} - -// endregion ************************** generated!.gotpl ************************** - -// region ***************************** args.gotpl ***************************** - -// endregion ***************************** args.gotpl ***************************** - -// region ************************** directives.gotpl ************************** - -// endregion ************************** directives.gotpl ************************** - -// region **************************** field.gotpl ***************************** - -func (ec *executionContext) _EventLogArg_name(ctx context.Context, field graphql.CollectedField, obj *model.EventLogArg) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLogArg_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLogArg_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLogArg", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLogArg_value(ctx context.Context, field graphql.CollectedField, obj *model.EventLogArg) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLogArg_value(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.EventLogArg().Value(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLogArg_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLogArg", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** - -// endregion **************************** input.gotpl ***************************** - -// region ************************** interface.gotpl *************************** - -// endregion ************************** interface.gotpl *************************** - -// region **************************** object.gotpl **************************** - -var eventLogArgImplementors = []string{"EventLogArg"} - -func (ec *executionContext) _EventLogArg(ctx context.Context, sel ast.SelectionSet, obj *model.EventLogArg) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, eventLogArgImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("EventLogArg") - case "name": - out.Values[i] = ec._EventLogArg_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "value": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._EventLogArg_value(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -// endregion **************************** object.gotpl **************************** - -// region ***************************** type.gotpl ***************************** - -func (ec *executionContext) unmarshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx context.Context, v interface{}) (types.Bytes, error) { - var res types.Bytes - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx context.Context, sel ast.SelectionSet, v types.Bytes) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return v -} - -func (ec *executionContext) marshalNEventLogArg2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋdatasetsᚐEventLogArg(ctx context.Context, sel ast.SelectionSet, v model.EventLogArg) graphql.Marshaler { - return ec._EventLogArg(ctx, sel, &v) -} - -func (ec *executionContext) marshalNEventLogArg2ᚕgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋdatasetsᚐEventLogArgᚄ(ctx context.Context, sel ast.SelectionSet, v []model.EventLogArg) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNEventLogArg2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋdatasetsᚐEventLogArg(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -// endregion ***************************** type.gotpl ***************************** diff --git a/internal/transport/server/gql/generated/prelude.generated.go b/internal/transport/server/gql/generated/prelude.generated.go deleted file mode 100644 index 4ed6110b..00000000 --- a/internal/transport/server/gql/generated/prelude.generated.go +++ /dev/null @@ -1,2969 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package generated - -import ( - "context" - "errors" - "fmt" - "strconv" - "sync" - "sync/atomic" - - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/introspection" - "github.com/vektah/gqlparser/v2/ast" -) - -// region ************************** generated!.gotpl ************************** - -// endregion ************************** generated!.gotpl ************************** - -// region ***************************** args.gotpl ***************************** - -func (ec *executionContext) dir_defer_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 *bool - if tmp, ok := rawArgs["if"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("if")) - arg0, err = ec.unmarshalOBoolean2ᚖbool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["if"] = arg0 - var arg1 *string - if tmp, ok := rawArgs["label"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("label")) - arg1, err = ec.unmarshalOString2ᚖstring(ctx, tmp) - if err != nil { - return nil, err - } - } - args["label"] = arg1 - return args, nil -} - -func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) - arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil -} - -func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) - arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil -} - -// endregion ***************************** args.gotpl ***************************** - -// region ************************** directives.gotpl ************************** - -// endregion ************************** directives.gotpl ************************** - -// region **************************** field.gotpl ***************************** - -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_locations(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Locations, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]string) - fc.Result = res - return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type __DirectiveLocation does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_args(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsRepeatable, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Directive", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__EnumValue", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_args(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - fc.Result = res - return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_type(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Field", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_type(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__InputValue", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_types(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Types(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_queryType(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_mutationType(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Schema_directives(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.Directive) - fc.Result = res - return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Schema", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___Directive_name(ctx, field) - case "description": - return ec.fieldContext___Directive_description(ctx, field) - case "locations": - return ec.fieldContext___Directive_locations(ctx, field) - case "args": - return ec.fieldContext___Directive_args(ctx, field) - case "isRepeatable": - return ec.fieldContext___Directive_isRepeatable(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_kind(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalN__TypeKind2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type __TypeKind does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_description(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_fields(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Field) - fc.Result = res - return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___Field_name(ctx, field) - case "description": - return ec.fieldContext___Field_description(ctx, field) - case "args": - return ec.fieldContext___Field_args(ctx, field) - case "type": - return ec.fieldContext___Field_type(ctx, field) - case "isDeprecated": - return ec.fieldContext___Field_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___Field_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_interfaces(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_enumValues(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.EnumValue) - fc.Result = res - return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___EnumValue_name(ctx, field) - case "description": - return ec.fieldContext___EnumValue_description(ctx, field) - case "isDeprecated": - return ec.fieldContext___EnumValue_isDeprecated(ctx, field) - case "deprecationReason": - return ec.fieldContext___EnumValue_deprecationReason(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_inputFields(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - fc.Result = res - return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext___InputValue_name(ctx, field) - case "description": - return ec.fieldContext___InputValue_description(ctx, field) - case "type": - return ec.fieldContext___InputValue_type(ctx, field) - case "defaultValue": - return ec.fieldContext___InputValue_defaultValue(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_ofType(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { - fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SpecifiedByURL(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "__Type", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** - -// endregion **************************** input.gotpl ***************************** - -// region ************************** interface.gotpl *************************** - -// endregion ************************** interface.gotpl *************************** - -// region **************************** object.gotpl **************************** - -var __DirectiveImplementors = []string{"__Directive"} - -func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Directive") - case "name": - out.Values[i] = ec.___Directive_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "description": - out.Values[i] = ec.___Directive_description(ctx, field, obj) - case "locations": - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "isRepeatable": - out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var __EnumValueImplementors = []string{"__EnumValue"} - -func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__EnumValue") - case "name": - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "description": - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - case "isDeprecated": - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var __FieldImplementors = []string{"__Field"} - -func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Field") - case "name": - out.Values[i] = ec.___Field_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "description": - out.Values[i] = ec.___Field_description(ctx, field, obj) - case "args": - out.Values[i] = ec.___Field_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var __InputValueImplementors = []string{"__InputValue"} - -func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__InputValue") - case "name": - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "description": - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - case "type": - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var __SchemaImplementors = []string{"__Schema"} - -func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Schema") - case "description": - out.Values[i] = ec.___Schema_description(ctx, field, obj) - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "mutationType": - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - case "subscriptionType": - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - case "directives": - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var __TypeImplementors = []string{"__Type"} - -func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Type") - case "kind": - out.Values[i] = ec.___Type_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "name": - out.Values[i] = ec.___Type_name(ctx, field, obj) - case "description": - out.Values[i] = ec.___Type_description(ctx, field, obj) - case "fields": - out.Values[i] = ec.___Type_fields(ctx, field, obj) - case "interfaces": - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - case "possibleTypes": - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - case "enumValues": - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - case "inputFields": - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - case "ofType": - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - case "specifiedByURL": - out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -// endregion **************************** object.gotpl **************************** - -// region ***************************** type.gotpl ***************************** - -func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { - res, err := graphql.UnmarshalBoolean(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) (int, error) { - res, err := graphql.UnmarshalIntID(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - res := graphql.MarshalIntID(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalNID2ᚕintᚄ(ctx context.Context, v interface{}) ([]int, error) { - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]int, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNID2int(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalNID2ᚕintᚄ(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalNID2int(ctx, sel, v[i]) - } - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { - res, err := graphql.UnmarshalInt(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - res := graphql.MarshalInt(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalNInt2int64(ctx context.Context, v interface{}) (int64, error) { - res, err := graphql.UnmarshalInt64(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNInt2int64(ctx context.Context, sel ast.SelectionSet, v int64) graphql.Marshaler { - res := graphql.MarshalInt64(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - -func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec.___Type(ctx, sel, v) -} - -func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { - res, err := graphql.UnmarshalBoolean(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) - return res -} - -func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalBoolean(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalBoolean(*v) - return res -} - -func (ec *executionContext) unmarshalOID2ᚕintᚄ(ctx context.Context, v interface{}) ([]int, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]int, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNID2int(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalOID2ᚕintᚄ(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalNID2int(ctx, sel, v[i]) - } - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalOID2ᚖint(ctx context.Context, v interface{}) (*int, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalIntID(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOID2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalIntID(*v) - return res -} - -func (ec *executionContext) unmarshalOInt2ᚕint64ᚄ(ctx context.Context, v interface{}) ([]int64, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]int64, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNInt2int64(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalOInt2ᚕint64ᚄ(ctx context.Context, sel ast.SelectionSet, v []int64) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalNInt2int64(ctx, sel, v[i]) - } - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalInt(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalInt(*v) - return res -} - -func (ec *executionContext) unmarshalOInt2ᚖint64(ctx context.Context, v interface{}) (*int64, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalInt64(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOInt2ᚖint64(ctx context.Context, sel ast.SelectionSet, v *int64) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalInt64(*v) - return res -} - -func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - return res -} - -func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNString2string(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalOString2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalNString2string(ctx, sel, v[i]) - } - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalString(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalString(*v) - return res -} - -func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Schema(ctx, sel, v) -} - -func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Type(ctx, sel, v) -} - -// endregion ***************************** type.gotpl ***************************** diff --git a/internal/transport/server/gql/generated/root_.generated.go b/internal/transport/server/gql/generated/root_.generated.go deleted file mode 100644 index 7a6e02ff..00000000 --- a/internal/transport/server/gql/generated/root_.generated.go +++ /dev/null @@ -1,1712 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package generated - -import ( - "bytes" - "context" - "errors" - "sync/atomic" - - "entgo.io/contrib/entgql" - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/introspection" - "github.com/TimeleapLabs/unchained/internal/ent" - gqlparser "github.com/vektah/gqlparser/v2" - "github.com/vektah/gqlparser/v2/ast" -) - -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - schema: cfg.Schema, - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Schema *ast.Schema - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - AssetPrice() AssetPriceResolver - CorrectnessReport() CorrectnessReportResolver - EventLog() EventLogResolver - EventLogArg() EventLogArgResolver - Query() QueryResolver - Signer() SignerResolver - AssetPriceWhereInput() AssetPriceWhereInputResolver - CorrectnessReportWhereInput() CorrectnessReportWhereInputResolver - EventLogWhereInput() EventLogWhereInputResolver - SignerWhereInput() SignerWhereInputResolver -} - -type DirectiveRoot struct { -} - -type ComplexityRoot struct { - AssetPrice struct { - Asset func(childComplexity int) int - Block func(childComplexity int) int - Chain func(childComplexity int) int - Consensus func(childComplexity int) int - ID func(childComplexity int) int - Pair func(childComplexity int) int - Price func(childComplexity int) int - Signature func(childComplexity int) int - Signers func(childComplexity int) int - SignersCount func(childComplexity int) int - Voted func(childComplexity int) int - } - - AssetPriceConnection struct { - Edges func(childComplexity int) int - PageInfo func(childComplexity int) int - TotalCount func(childComplexity int) int - } - - AssetPriceEdge struct { - Cursor func(childComplexity int) int - Node func(childComplexity int) int - } - - CorrectnessReport struct { - Consensus func(childComplexity int) int - Correct func(childComplexity int) int - Hash func(childComplexity int) int - ID func(childComplexity int) int - Signature func(childComplexity int) int - Signers func(childComplexity int) int - SignersCount func(childComplexity int) int - Timestamp func(childComplexity int) int - Topic func(childComplexity int) int - Voted func(childComplexity int) int - } - - CorrectnessReportConnection struct { - Edges func(childComplexity int) int - PageInfo func(childComplexity int) int - TotalCount func(childComplexity int) int - } - - CorrectnessReportEdge struct { - Cursor func(childComplexity int) int - Node func(childComplexity int) int - } - - EventLog struct { - Address func(childComplexity int) int - Args func(childComplexity int) int - Block func(childComplexity int) int - Chain func(childComplexity int) int - Consensus func(childComplexity int) int - Event func(childComplexity int) int - ID func(childComplexity int) int - Index func(childComplexity int) int - Signature func(childComplexity int) int - Signers func(childComplexity int) int - SignersCount func(childComplexity int) int - Transaction func(childComplexity int) int - Voted func(childComplexity int) int - } - - EventLogArg struct { - Name func(childComplexity int) int - Value func(childComplexity int) int - } - - EventLogConnection struct { - Edges func(childComplexity int) int - PageInfo func(childComplexity int) int - TotalCount func(childComplexity int) int - } - - EventLogEdge struct { - Cursor func(childComplexity int) int - Node func(childComplexity int) int - } - - PageInfo struct { - EndCursor func(childComplexity int) int - HasNextPage func(childComplexity int) int - HasPreviousPage func(childComplexity int) int - StartCursor func(childComplexity int) int - } - - Query struct { - AssetPrices func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.AssetPriceOrder, where *ent.AssetPriceWhereInput) int - CorrectnessReports func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.CorrectnessReportOrder, where *ent.CorrectnessReportWhereInput) int - EventLogs func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.EventLogOrder, where *ent.EventLogWhereInput) int - Node func(childComplexity int, id int) int - Nodes func(childComplexity int, ids []int) int - Signers func(childComplexity int, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.SignerOrder, where *ent.SignerWhereInput) int - } - - Signer struct { - AssetPrice func(childComplexity int) int - CorrectnessReport func(childComplexity int) int - EventLogs func(childComplexity int) int - Evm func(childComplexity int) int - ID func(childComplexity int) int - Key func(childComplexity int) int - Name func(childComplexity int) int - Points func(childComplexity int) int - Shortkey func(childComplexity int) int - } - - SignerConnection struct { - Edges func(childComplexity int) int - PageInfo func(childComplexity int) int - TotalCount func(childComplexity int) int - } - - SignerEdge struct { - Cursor func(childComplexity int) int - Node func(childComplexity int) int - } -} - -type executableSchema struct { - schema *ast.Schema - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} - -func (e *executableSchema) Schema() *ast.Schema { - if e.schema != nil { - return e.schema - } - return parsedSchema -} - -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - ec := executionContext{nil, e, 0, 0, nil} - _ = ec - switch typeName + "." + field { - - case "AssetPrice.asset": - if e.complexity.AssetPrice.Asset == nil { - break - } - - return e.complexity.AssetPrice.Asset(childComplexity), true - - case "AssetPrice.block": - if e.complexity.AssetPrice.Block == nil { - break - } - - return e.complexity.AssetPrice.Block(childComplexity), true - - case "AssetPrice.chain": - if e.complexity.AssetPrice.Chain == nil { - break - } - - return e.complexity.AssetPrice.Chain(childComplexity), true - - case "AssetPrice.consensus": - if e.complexity.AssetPrice.Consensus == nil { - break - } - - return e.complexity.AssetPrice.Consensus(childComplexity), true - - case "AssetPrice.id": - if e.complexity.AssetPrice.ID == nil { - break - } - - return e.complexity.AssetPrice.ID(childComplexity), true - - case "AssetPrice.pair": - if e.complexity.AssetPrice.Pair == nil { - break - } - - return e.complexity.AssetPrice.Pair(childComplexity), true - - case "AssetPrice.price": - if e.complexity.AssetPrice.Price == nil { - break - } - - return e.complexity.AssetPrice.Price(childComplexity), true - - case "AssetPrice.signature": - if e.complexity.AssetPrice.Signature == nil { - break - } - - return e.complexity.AssetPrice.Signature(childComplexity), true - - case "AssetPrice.signers": - if e.complexity.AssetPrice.Signers == nil { - break - } - - return e.complexity.AssetPrice.Signers(childComplexity), true - - case "AssetPrice.signerscount": - if e.complexity.AssetPrice.SignersCount == nil { - break - } - - return e.complexity.AssetPrice.SignersCount(childComplexity), true - - case "AssetPrice.voted": - if e.complexity.AssetPrice.Voted == nil { - break - } - - return e.complexity.AssetPrice.Voted(childComplexity), true - - case "AssetPriceConnection.edges": - if e.complexity.AssetPriceConnection.Edges == nil { - break - } - - return e.complexity.AssetPriceConnection.Edges(childComplexity), true - - case "AssetPriceConnection.pageInfo": - if e.complexity.AssetPriceConnection.PageInfo == nil { - break - } - - return e.complexity.AssetPriceConnection.PageInfo(childComplexity), true - - case "AssetPriceConnection.totalCount": - if e.complexity.AssetPriceConnection.TotalCount == nil { - break - } - - return e.complexity.AssetPriceConnection.TotalCount(childComplexity), true - - case "AssetPriceEdge.cursor": - if e.complexity.AssetPriceEdge.Cursor == nil { - break - } - - return e.complexity.AssetPriceEdge.Cursor(childComplexity), true - - case "AssetPriceEdge.node": - if e.complexity.AssetPriceEdge.Node == nil { - break - } - - return e.complexity.AssetPriceEdge.Node(childComplexity), true - - case "CorrectnessReport.consensus": - if e.complexity.CorrectnessReport.Consensus == nil { - break - } - - return e.complexity.CorrectnessReport.Consensus(childComplexity), true - - case "CorrectnessReport.correct": - if e.complexity.CorrectnessReport.Correct == nil { - break - } - - return e.complexity.CorrectnessReport.Correct(childComplexity), true - - case "CorrectnessReport.hash": - if e.complexity.CorrectnessReport.Hash == nil { - break - } - - return e.complexity.CorrectnessReport.Hash(childComplexity), true - - case "CorrectnessReport.id": - if e.complexity.CorrectnessReport.ID == nil { - break - } - - return e.complexity.CorrectnessReport.ID(childComplexity), true - - case "CorrectnessReport.signature": - if e.complexity.CorrectnessReport.Signature == nil { - break - } - - return e.complexity.CorrectnessReport.Signature(childComplexity), true - - case "CorrectnessReport.signers": - if e.complexity.CorrectnessReport.Signers == nil { - break - } - - return e.complexity.CorrectnessReport.Signers(childComplexity), true - - case "CorrectnessReport.signerscount": - if e.complexity.CorrectnessReport.SignersCount == nil { - break - } - - return e.complexity.CorrectnessReport.SignersCount(childComplexity), true - - case "CorrectnessReport.timestamp": - if e.complexity.CorrectnessReport.Timestamp == nil { - break - } - - return e.complexity.CorrectnessReport.Timestamp(childComplexity), true - - case "CorrectnessReport.topic": - if e.complexity.CorrectnessReport.Topic == nil { - break - } - - return e.complexity.CorrectnessReport.Topic(childComplexity), true - - case "CorrectnessReport.voted": - if e.complexity.CorrectnessReport.Voted == nil { - break - } - - return e.complexity.CorrectnessReport.Voted(childComplexity), true - - case "CorrectnessReportConnection.edges": - if e.complexity.CorrectnessReportConnection.Edges == nil { - break - } - - return e.complexity.CorrectnessReportConnection.Edges(childComplexity), true - - case "CorrectnessReportConnection.pageInfo": - if e.complexity.CorrectnessReportConnection.PageInfo == nil { - break - } - - return e.complexity.CorrectnessReportConnection.PageInfo(childComplexity), true - - case "CorrectnessReportConnection.totalCount": - if e.complexity.CorrectnessReportConnection.TotalCount == nil { - break - } - - return e.complexity.CorrectnessReportConnection.TotalCount(childComplexity), true - - case "CorrectnessReportEdge.cursor": - if e.complexity.CorrectnessReportEdge.Cursor == nil { - break - } - - return e.complexity.CorrectnessReportEdge.Cursor(childComplexity), true - - case "CorrectnessReportEdge.node": - if e.complexity.CorrectnessReportEdge.Node == nil { - break - } - - return e.complexity.CorrectnessReportEdge.Node(childComplexity), true - - case "EventLog.address": - if e.complexity.EventLog.Address == nil { - break - } - - return e.complexity.EventLog.Address(childComplexity), true - - case "EventLog.args": - if e.complexity.EventLog.Args == nil { - break - } - - return e.complexity.EventLog.Args(childComplexity), true - - case "EventLog.block": - if e.complexity.EventLog.Block == nil { - break - } - - return e.complexity.EventLog.Block(childComplexity), true - - case "EventLog.chain": - if e.complexity.EventLog.Chain == nil { - break - } - - return e.complexity.EventLog.Chain(childComplexity), true - - case "EventLog.consensus": - if e.complexity.EventLog.Consensus == nil { - break - } - - return e.complexity.EventLog.Consensus(childComplexity), true - - case "EventLog.event": - if e.complexity.EventLog.Event == nil { - break - } - - return e.complexity.EventLog.Event(childComplexity), true - - case "EventLog.id": - if e.complexity.EventLog.ID == nil { - break - } - - return e.complexity.EventLog.ID(childComplexity), true - - case "EventLog.index": - if e.complexity.EventLog.Index == nil { - break - } - - return e.complexity.EventLog.Index(childComplexity), true - - case "EventLog.signature": - if e.complexity.EventLog.Signature == nil { - break - } - - return e.complexity.EventLog.Signature(childComplexity), true - - case "EventLog.signers": - if e.complexity.EventLog.Signers == nil { - break - } - - return e.complexity.EventLog.Signers(childComplexity), true - - case "EventLog.signerscount": - if e.complexity.EventLog.SignersCount == nil { - break - } - - return e.complexity.EventLog.SignersCount(childComplexity), true - - case "EventLog.transaction": - if e.complexity.EventLog.Transaction == nil { - break - } - - return e.complexity.EventLog.Transaction(childComplexity), true - - case "EventLog.voted": - if e.complexity.EventLog.Voted == nil { - break - } - - return e.complexity.EventLog.Voted(childComplexity), true - - case "EventLogArg.name": - if e.complexity.EventLogArg.Name == nil { - break - } - - return e.complexity.EventLogArg.Name(childComplexity), true - - case "EventLogArg.value": - if e.complexity.EventLogArg.Value == nil { - break - } - - return e.complexity.EventLogArg.Value(childComplexity), true - - case "EventLogConnection.edges": - if e.complexity.EventLogConnection.Edges == nil { - break - } - - return e.complexity.EventLogConnection.Edges(childComplexity), true - - case "EventLogConnection.pageInfo": - if e.complexity.EventLogConnection.PageInfo == nil { - break - } - - return e.complexity.EventLogConnection.PageInfo(childComplexity), true - - case "EventLogConnection.totalCount": - if e.complexity.EventLogConnection.TotalCount == nil { - break - } - - return e.complexity.EventLogConnection.TotalCount(childComplexity), true - - case "EventLogEdge.cursor": - if e.complexity.EventLogEdge.Cursor == nil { - break - } - - return e.complexity.EventLogEdge.Cursor(childComplexity), true - - case "EventLogEdge.node": - if e.complexity.EventLogEdge.Node == nil { - break - } - - return e.complexity.EventLogEdge.Node(childComplexity), true - - case "PageInfo.endCursor": - if e.complexity.PageInfo.EndCursor == nil { - break - } - - return e.complexity.PageInfo.EndCursor(childComplexity), true - - case "PageInfo.hasNextPage": - if e.complexity.PageInfo.HasNextPage == nil { - break - } - - return e.complexity.PageInfo.HasNextPage(childComplexity), true - - case "PageInfo.hasPreviousPage": - if e.complexity.PageInfo.HasPreviousPage == nil { - break - } - - return e.complexity.PageInfo.HasPreviousPage(childComplexity), true - - case "PageInfo.startCursor": - if e.complexity.PageInfo.StartCursor == nil { - break - } - - return e.complexity.PageInfo.StartCursor(childComplexity), true - - case "Query.assetPrices": - if e.complexity.Query.AssetPrices == nil { - break - } - - args, err := ec.field_Query_assetPrices_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.AssetPrices(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["orderBy"].(*ent.AssetPriceOrder), args["where"].(*ent.AssetPriceWhereInput)), true - - case "Query.correctnessReports": - if e.complexity.Query.CorrectnessReports == nil { - break - } - - args, err := ec.field_Query_correctnessReports_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.CorrectnessReports(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["orderBy"].(*ent.CorrectnessReportOrder), args["where"].(*ent.CorrectnessReportWhereInput)), true - - case "Query.eventLogs": - if e.complexity.Query.EventLogs == nil { - break - } - - args, err := ec.field_Query_eventLogs_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.EventLogs(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["orderBy"].(*ent.EventLogOrder), args["where"].(*ent.EventLogWhereInput)), true - - case "Query.node": - if e.complexity.Query.Node == nil { - break - } - - args, err := ec.field_Query_node_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Node(childComplexity, args["id"].(int)), true - - case "Query.nodes": - if e.complexity.Query.Nodes == nil { - break - } - - args, err := ec.field_Query_nodes_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Nodes(childComplexity, args["ids"].([]int)), true - - case "Query.signers": - if e.complexity.Query.Signers == nil { - break - } - - args, err := ec.field_Query_signers_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Signers(childComplexity, args["after"].(*entgql.Cursor[int]), args["first"].(*int), args["before"].(*entgql.Cursor[int]), args["last"].(*int), args["orderBy"].(*ent.SignerOrder), args["where"].(*ent.SignerWhereInput)), true - - case "Signer.assetprice": - if e.complexity.Signer.AssetPrice == nil { - break - } - - return e.complexity.Signer.AssetPrice(childComplexity), true - - case "Signer.correctnessreport": - if e.complexity.Signer.CorrectnessReport == nil { - break - } - - return e.complexity.Signer.CorrectnessReport(childComplexity), true - - case "Signer.eventlogs": - if e.complexity.Signer.EventLogs == nil { - break - } - - return e.complexity.Signer.EventLogs(childComplexity), true - - case "Signer.evm": - if e.complexity.Signer.Evm == nil { - break - } - - return e.complexity.Signer.Evm(childComplexity), true - - case "Signer.id": - if e.complexity.Signer.ID == nil { - break - } - - return e.complexity.Signer.ID(childComplexity), true - - case "Signer.key": - if e.complexity.Signer.Key == nil { - break - } - - return e.complexity.Signer.Key(childComplexity), true - - case "Signer.name": - if e.complexity.Signer.Name == nil { - break - } - - return e.complexity.Signer.Name(childComplexity), true - - case "Signer.points": - if e.complexity.Signer.Points == nil { - break - } - - return e.complexity.Signer.Points(childComplexity), true - - case "Signer.shortkey": - if e.complexity.Signer.Shortkey == nil { - break - } - - return e.complexity.Signer.Shortkey(childComplexity), true - - case "SignerConnection.edges": - if e.complexity.SignerConnection.Edges == nil { - break - } - - return e.complexity.SignerConnection.Edges(childComplexity), true - - case "SignerConnection.pageInfo": - if e.complexity.SignerConnection.PageInfo == nil { - break - } - - return e.complexity.SignerConnection.PageInfo(childComplexity), true - - case "SignerConnection.totalCount": - if e.complexity.SignerConnection.TotalCount == nil { - break - } - - return e.complexity.SignerConnection.TotalCount(childComplexity), true - - case "SignerEdge.cursor": - if e.complexity.SignerEdge.Cursor == nil { - break - } - - return e.complexity.SignerEdge.Cursor(childComplexity), true - - case "SignerEdge.node": - if e.complexity.SignerEdge.Node == nil { - break - } - - return e.complexity.SignerEdge.Node(childComplexity), true - - } - return 0, false -} - -func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { - rc := graphql.GetOperationContext(ctx) - ec := executionContext{rc, e, 0, 0, make(chan graphql.DeferredResult)} - inputUnmarshalMap := graphql.BuildUnmarshalerMap( - ec.unmarshalInputAssetPriceOrder, - ec.unmarshalInputAssetPriceWhereInput, - ec.unmarshalInputCorrectnessReportOrder, - ec.unmarshalInputCorrectnessReportWhereInput, - ec.unmarshalInputEventLogOrder, - ec.unmarshalInputEventLogWhereInput, - ec.unmarshalInputSignerOrder, - ec.unmarshalInputSignerWhereInput, - ) - first := true - - switch rc.Operation.Operation { - case ast.Query: - return func(ctx context.Context) *graphql.Response { - var response graphql.Response - var data graphql.Marshaler - if first { - first = false - ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) - data = ec._Query(ctx, rc.Operation.SelectionSet) - } else { - if atomic.LoadInt32(&ec.pendingDeferred) > 0 { - result := <-ec.deferredResults - atomic.AddInt32(&ec.pendingDeferred, -1) - data = result.Result - response.Path = result.Path - response.Label = result.Label - response.Errors = result.Errors - } else { - return nil - } - } - var buf bytes.Buffer - data.MarshalGQL(&buf) - response.Data = buf.Bytes() - if atomic.LoadInt32(&ec.deferred) > 0 { - hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 - response.HasNext = &hasNext - } - - return &response - } - - default: - return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) - } -} - -type executionContext struct { - *graphql.OperationContext - *executableSchema - deferred int32 - pendingDeferred int32 - deferredResults chan graphql.DeferredResult -} - -func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { - atomic.AddInt32(&ec.pendingDeferred, 1) - go func() { - ctx := graphql.WithFreshResponseContext(dg.Context) - dg.FieldSet.Dispatch(ctx) - ds := graphql.DeferredResult{ - Path: dg.Path, - Label: dg.Label, - Result: dg.FieldSet, - Errors: graphql.GetErrors(ctx), - } - // null fields should bubble up - if dg.FieldSet.Invalids > 0 { - ds.Result = graphql.Null - } - ec.deferredResults <- ds - }() -} - -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapSchema(ec.Schema()), nil -} - -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil -} - -var sources = []*ast.Source{ - {Name: "../args.graphql", Input: `scalar BigInt -scalar Bytes - -type EventLogArg { - name: String! - value: String! -} -`, BuiltIn: false}, - {Name: "../extensions.graphql", Input: `extend input SignerWhereInput { - key: String -} - -extend input CorrectnessReportWhereInput { - topic: String - hash: String -} -`, BuiltIn: false}, - {Name: "../unchained.graphql", Input: `directive @goField(forceResolver: Boolean, name: String) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION -directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION -type AssetPrice implements Node { - id: ID! - block: Uint! - signerscount: Uint @goField(name: "SignersCount", forceResolver: false) - price: Uint! - signature: Bytes! - asset: String - chain: String - pair: String - consensus: Boolean! - voted: Uint! - signers: [Signer!]! -} -""" -A connection to a list of items. -""" -type AssetPriceConnection { - """ - A list of edges. - """ - edges: [AssetPriceEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} -""" -An edge in a connection. -""" -type AssetPriceEdge { - """ - The item at the end of the edge. - """ - node: AssetPrice - """ - A cursor for use in pagination. - """ - cursor: Cursor! -} -""" -Ordering options for AssetPrice connections -""" -input AssetPriceOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order AssetPrices. - """ - field: AssetPriceOrderField! -} -""" -Properties by which AssetPrice connections can be ordered. -""" -enum AssetPriceOrderField { - BLOCK -} -""" -AssetPriceWhereInput is used for filtering AssetPrice objects. -Input was generated by ent. -""" -input AssetPriceWhereInput { - not: AssetPriceWhereInput - and: [AssetPriceWhereInput!] - or: [AssetPriceWhereInput!] - """ - id field predicates - """ - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """ - block field predicates - """ - block: Uint - blockNEQ: Uint - blockIn: [Uint!] - blockNotIn: [Uint!] - blockGT: Uint - blockGTE: Uint - blockLT: Uint - blockLTE: Uint - """ - signersCount field predicates - """ - signerscount: Uint - signerscountNEQ: Uint - signerscountIn: [Uint!] - signerscountNotIn: [Uint!] - signerscountGT: Uint - signerscountGTE: Uint - signerscountLT: Uint - signerscountLTE: Uint - signerscountIsNil: Boolean - signerscountNotNil: Boolean - """ - price field predicates - """ - price: Uint - priceNEQ: Uint - priceIn: [Uint!] - priceNotIn: [Uint!] - priceGT: Uint - priceGTE: Uint - priceLT: Uint - priceLTE: Uint - """ - asset field predicates - """ - asset: String - assetNEQ: String - assetIn: [String!] - assetNotIn: [String!] - assetGT: String - assetGTE: String - assetLT: String - assetLTE: String - assetContains: String - assetHasPrefix: String - assetHasSuffix: String - assetIsNil: Boolean - assetNotNil: Boolean - assetEqualFold: String - assetContainsFold: String - """ - chain field predicates - """ - chain: String - chainNEQ: String - chainIn: [String!] - chainNotIn: [String!] - chainGT: String - chainGTE: String - chainLT: String - chainLTE: String - chainContains: String - chainHasPrefix: String - chainHasSuffix: String - chainIsNil: Boolean - chainNotNil: Boolean - chainEqualFold: String - chainContainsFold: String - """ - pair field predicates - """ - pair: String - pairNEQ: String - pairIn: [String!] - pairNotIn: [String!] - pairGT: String - pairGTE: String - pairLT: String - pairLTE: String - pairContains: String - pairHasPrefix: String - pairHasSuffix: String - pairIsNil: Boolean - pairNotNil: Boolean - pairEqualFold: String - pairContainsFold: String - """ - consensus field predicates - """ - consensus: Boolean - consensusNEQ: Boolean - """ - voted field predicates - """ - voted: Uint - votedNEQ: Uint - votedIn: [Uint!] - votedNotIn: [Uint!] - votedGT: Uint - votedGTE: Uint - votedLT: Uint - votedLTE: Uint - """ - signers edge predicates - """ - hasSigners: Boolean - hasSignersWith: [SignerWhereInput!] -} -type CorrectnessReport implements Node { - id: ID! - signerscount: Uint! @goField(name: "SignersCount", forceResolver: false) - timestamp: Uint! - signature: Bytes! - hash: Bytes! - topic: Bytes! - correct: Boolean! - consensus: Boolean! - voted: Uint! - signers: [Signer!]! -} -""" -A connection to a list of items. -""" -type CorrectnessReportConnection { - """ - A list of edges. - """ - edges: [CorrectnessReportEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} -""" -An edge in a connection. -""" -type CorrectnessReportEdge { - """ - The item at the end of the edge. - """ - node: CorrectnessReport - """ - A cursor for use in pagination. - """ - cursor: Cursor! -} -""" -Ordering options for CorrectnessReport connections -""" -input CorrectnessReportOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order CorrectnessReports. - """ - field: CorrectnessReportOrderField! -} -""" -Properties by which CorrectnessReport connections can be ordered. -""" -enum CorrectnessReportOrderField { - TIMESTAMP -} -""" -CorrectnessReportWhereInput is used for filtering CorrectnessReport objects. -Input was generated by ent. -""" -input CorrectnessReportWhereInput { - not: CorrectnessReportWhereInput - and: [CorrectnessReportWhereInput!] - or: [CorrectnessReportWhereInput!] - """ - id field predicates - """ - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """ - signersCount field predicates - """ - signerscount: Uint - signerscountNEQ: Uint - signerscountIn: [Uint!] - signerscountNotIn: [Uint!] - signerscountGT: Uint - signerscountGTE: Uint - signerscountLT: Uint - signerscountLTE: Uint - """ - timestamp field predicates - """ - timestamp: Uint - timestampNEQ: Uint - timestampIn: [Uint!] - timestampNotIn: [Uint!] - timestampGT: Uint - timestampGTE: Uint - timestampLT: Uint - timestampLTE: Uint - """ - correct field predicates - """ - correct: Boolean - correctNEQ: Boolean - """ - consensus field predicates - """ - consensus: Boolean - consensusNEQ: Boolean - """ - voted field predicates - """ - voted: Uint - votedNEQ: Uint - votedIn: [Uint!] - votedNotIn: [Uint!] - votedGT: Uint - votedGTE: Uint - votedLT: Uint - votedLTE: Uint - """ - signers edge predicates - """ - hasSigners: Boolean - hasSignersWith: [SignerWhereInput!] -} -""" -Define a Relay Cursor type: -https://relay.dev/graphql/connections.htm#sec-Cursor -""" -scalar Cursor -type EventLog implements Node { - id: ID! - block: Uint! - signerscount: Uint! @goField(name: "SignersCount", forceResolver: false) - signature: Bytes! - address: String! - chain: String! - index: Uint! - event: String! - transaction: Bytes! - args: [EventLogArg!]! - consensus: Boolean! - voted: Uint! - signers: [Signer!]! -} -""" -A connection to a list of items. -""" -type EventLogConnection { - """ - A list of edges. - """ - edges: [EventLogEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} -""" -An edge in a connection. -""" -type EventLogEdge { - """ - The item at the end of the edge. - """ - node: EventLog - """ - A cursor for use in pagination. - """ - cursor: Cursor! -} -""" -Ordering options for EventLog connections -""" -input EventLogOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order EventLogs. - """ - field: EventLogOrderField! -} -""" -Properties by which EventLog connections can be ordered. -""" -enum EventLogOrderField { - BLOCK -} -""" -EventLogWhereInput is used for filtering EventLog objects. -Input was generated by ent. -""" -input EventLogWhereInput { - not: EventLogWhereInput - and: [EventLogWhereInput!] - or: [EventLogWhereInput!] - """ - id field predicates - """ - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """ - block field predicates - """ - block: Uint - blockNEQ: Uint - blockIn: [Uint!] - blockNotIn: [Uint!] - blockGT: Uint - blockGTE: Uint - blockLT: Uint - blockLTE: Uint - """ - signersCount field predicates - """ - signerscount: Uint - signerscountNEQ: Uint - signerscountIn: [Uint!] - signerscountNotIn: [Uint!] - signerscountGT: Uint - signerscountGTE: Uint - signerscountLT: Uint - signerscountLTE: Uint - """ - address field predicates - """ - address: String - addressNEQ: String - addressIn: [String!] - addressNotIn: [String!] - addressGT: String - addressGTE: String - addressLT: String - addressLTE: String - addressContains: String - addressHasPrefix: String - addressHasSuffix: String - addressEqualFold: String - addressContainsFold: String - """ - chain field predicates - """ - chain: String - chainNEQ: String - chainIn: [String!] - chainNotIn: [String!] - chainGT: String - chainGTE: String - chainLT: String - chainLTE: String - chainContains: String - chainHasPrefix: String - chainHasSuffix: String - chainEqualFold: String - chainContainsFold: String - """ - index field predicates - """ - index: Uint - indexNEQ: Uint - indexIn: [Uint!] - indexNotIn: [Uint!] - indexGT: Uint - indexGTE: Uint - indexLT: Uint - indexLTE: Uint - """ - event field predicates - """ - event: String - eventNEQ: String - eventIn: [String!] - eventNotIn: [String!] - eventGT: String - eventGTE: String - eventLT: String - eventLTE: String - eventContains: String - eventHasPrefix: String - eventHasSuffix: String - eventEqualFold: String - eventContainsFold: String - """ - consensus field predicates - """ - consensus: Boolean - consensusNEQ: Boolean - """ - voted field predicates - """ - voted: Uint - votedNEQ: Uint - votedIn: [Uint!] - votedNotIn: [Uint!] - votedGT: Uint - votedGTE: Uint - votedLT: Uint - votedLTE: Uint - """ - signers edge predicates - """ - hasSigners: Boolean - hasSignersWith: [SignerWhereInput!] -} -""" -An object with an ID. -Follows the [Relay Global Object Identification Specification](https://relay.dev/graphql/objectidentification.htm) -""" -interface Node @goModel(model: "github.com/TimeleapLabs/unchained/internal/ent.Noder") { - """ - The id of the object. - """ - id: ID! -} -""" -Possible directions in which to order a list of items when provided an ` + "`" + `orderBy` + "`" + ` argument. -""" -enum OrderDirection { - """ - Specifies an ascending order for a given ` + "`" + `orderBy` + "`" + ` argument. - """ - ASC - """ - Specifies a descending order for a given ` + "`" + `orderBy` + "`" + ` argument. - """ - DESC -} -""" -Information about pagination in a connection. -https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo -""" -type PageInfo { - """ - When paginating forwards, are there more items? - """ - hasNextPage: Boolean! - """ - When paginating backwards, are there more items? - """ - hasPreviousPage: Boolean! - """ - When paginating backwards, the cursor to continue. - """ - startCursor: Cursor - """ - When paginating forwards, the cursor to continue. - """ - endCursor: Cursor -} -type Query { - """ - Fetches an object given its ID. - """ - node( - """ - ID of the object. - """ - id: ID! - ): Node - """ - Lookup nodes by a list of IDs. - """ - nodes( - """ - The list of node IDs. - """ - ids: [ID!]! - ): [Node]! - assetPrices( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for AssetPrices returned from the connection. - """ - orderBy: AssetPriceOrder - - """ - Filtering options for AssetPrices returned from the connection. - """ - where: AssetPriceWhereInput - ): AssetPriceConnection! - correctnessReports( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for CorrectnessReports returned from the connection. - """ - orderBy: CorrectnessReportOrder - - """ - Filtering options for CorrectnessReports returned from the connection. - """ - where: CorrectnessReportWhereInput - ): CorrectnessReportConnection! - eventLogs( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for EventLogs returned from the connection. - """ - orderBy: EventLogOrder - - """ - Filtering options for EventLogs returned from the connection. - """ - where: EventLogWhereInput - ): EventLogConnection! - signers( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for Signers returned from the connection. - """ - orderBy: SignerOrder - - """ - Filtering options for Signers returned from the connection. - """ - where: SignerWhereInput - ): SignerConnection! -} -type Signer implements Node { - id: ID! - name: String! - evm: String - key: Bytes! - shortkey: Bytes! - points: Int! - assetprice: [AssetPrice!] @goField(name: "AssetPrice", forceResolver: false) - eventlogs: [EventLog!] @goField(name: "EventLogs", forceResolver: false) - correctnessreport: [CorrectnessReport!] @goField(name: "CorrectnessReport", forceResolver: false) -} -""" -A connection to a list of items. -""" -type SignerConnection { - """ - A list of edges. - """ - edges: [SignerEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} -""" -An edge in a connection. -""" -type SignerEdge { - """ - The item at the end of the edge. - """ - node: Signer - """ - A cursor for use in pagination. - """ - cursor: Cursor! -} -""" -Ordering options for Signer connections -""" -input SignerOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order Signers. - """ - field: SignerOrderField! -} -""" -Properties by which Signer connections can be ordered. -""" -enum SignerOrderField { - POINTS -} -""" -SignerWhereInput is used for filtering Signer objects. -Input was generated by ent. -""" -input SignerWhereInput { - not: SignerWhereInput - and: [SignerWhereInput!] - or: [SignerWhereInput!] - """ - id field predicates - """ - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """ - name field predicates - """ - name: String - nameNEQ: String - nameIn: [String!] - nameNotIn: [String!] - nameGT: String - nameGTE: String - nameLT: String - nameLTE: String - nameContains: String - nameHasPrefix: String - nameHasSuffix: String - nameEqualFold: String - nameContainsFold: String - """ - evm field predicates - """ - evm: String - evmNEQ: String - evmIn: [String!] - evmNotIn: [String!] - evmGT: String - evmGTE: String - evmLT: String - evmLTE: String - evmContains: String - evmHasPrefix: String - evmHasSuffix: String - evmIsNil: Boolean - evmNotNil: Boolean - evmEqualFold: String - evmContainsFold: String - """ - points field predicates - """ - points: Int - pointsNEQ: Int - pointsIn: [Int!] - pointsNotIn: [Int!] - pointsGT: Int - pointsGTE: Int - pointsLT: Int - pointsLTE: Int - """ - assetPrice edge predicates - """ - hasAssetPrice: Boolean - hasAssetPriceWith: [AssetPriceWhereInput!] - """ - eventLogs edge predicates - """ - hasEventLogs: Boolean - hasEventLogsWith: [EventLogWhereInput!] - """ - correctnessReport edge predicates - """ - hasCorrectnessReport: Boolean - hasCorrectnessReportWith: [CorrectnessReportWhereInput!] -} -""" -The builtin Uint type -""" -scalar Uint -`, BuiltIn: false}, -} -var parsedSchema = gqlparser.MustLoadSchema(sources...) diff --git a/internal/transport/server/gql/generated/unchained.generated.go b/internal/transport/server/gql/generated/unchained.generated.go deleted file mode 100644 index a68d855a..00000000 --- a/internal/transport/server/gql/generated/unchained.generated.go +++ /dev/null @@ -1,8709 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package generated - -import ( - "context" - "errors" - "fmt" - "github.com/TimeleapLabs/unchained/internal/model" - "strconv" - "sync" - "sync/atomic" - - "entgo.io/contrib/entgql" - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/introspection" - "github.com/TimeleapLabs/unchained/internal/ent" - "github.com/TimeleapLabs/unchained/internal/transport/server/gql/types" - "github.com/vektah/gqlparser/v2/ast" -) - -// region ************************** generated!.gotpl ************************** - -type AssetPriceResolver interface { - Price(ctx context.Context, obj *ent.AssetPrice) (uint64, error) - Signature(ctx context.Context, obj *ent.AssetPrice) (types.Bytes, error) - - Voted(ctx context.Context, obj *ent.AssetPrice) (uint64, error) -} -type CorrectnessReportResolver interface { - Signature(ctx context.Context, obj *ent.CorrectnessReport) (types.Bytes, error) - Hash(ctx context.Context, obj *ent.CorrectnessReport) (types.Bytes, error) - Topic(ctx context.Context, obj *ent.CorrectnessReport) (types.Bytes, error) - - Voted(ctx context.Context, obj *ent.CorrectnessReport) (uint64, error) -} -type EventLogResolver interface { - Signature(ctx context.Context, obj *ent.EventLog) (types.Bytes, error) - - Transaction(ctx context.Context, obj *ent.EventLog) (types.Bytes, error) - - Voted(ctx context.Context, obj *ent.EventLog) (uint64, error) -} -type QueryResolver interface { - Node(ctx context.Context, id int) (ent.Noder, error) - Nodes(ctx context.Context, ids []int) ([]ent.Noder, error) - AssetPrices(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.AssetPriceOrder, where *ent.AssetPriceWhereInput) (*ent.AssetPriceConnection, error) - CorrectnessReports(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.CorrectnessReportOrder, where *ent.CorrectnessReportWhereInput) (*ent.CorrectnessReportConnection, error) - EventLogs(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.EventLogOrder, where *ent.EventLogWhereInput) (*ent.EventLogConnection, error) - Signers(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.SignerOrder, where *ent.SignerWhereInput) (*ent.SignerConnection, error) -} -type SignerResolver interface { - Key(ctx context.Context, obj *ent.Signer) (types.Bytes, error) - Shortkey(ctx context.Context, obj *ent.Signer) (types.Bytes, error) -} - -type AssetPriceWhereInputResolver interface { - Price(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - PriceNeq(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - PriceIn(ctx context.Context, obj *ent.AssetPriceWhereInput, data []uint64) error - PriceNotIn(ctx context.Context, obj *ent.AssetPriceWhereInput, data []uint64) error - PriceGt(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - PriceGte(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - PriceLt(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - PriceLte(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - - Voted(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - VotedNeq(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - VotedIn(ctx context.Context, obj *ent.AssetPriceWhereInput, data []uint64) error - VotedNotIn(ctx context.Context, obj *ent.AssetPriceWhereInput, data []uint64) error - VotedGt(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - VotedGte(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - VotedLt(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error - VotedLte(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error -} -type CorrectnessReportWhereInputResolver interface { - Voted(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error - VotedNeq(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error - VotedIn(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data []uint64) error - VotedNotIn(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data []uint64) error - VotedGt(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error - VotedGte(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error - VotedLt(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error - VotedLte(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error - - Topic(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *string) error - Hash(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *string) error -} -type EventLogWhereInputResolver interface { - Voted(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error - VotedNeq(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error - VotedIn(ctx context.Context, obj *ent.EventLogWhereInput, data []uint64) error - VotedNotIn(ctx context.Context, obj *ent.EventLogWhereInput, data []uint64) error - VotedGt(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error - VotedGte(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error - VotedLt(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error - VotedLte(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error -} -type SignerWhereInputResolver interface { - Key(ctx context.Context, obj *ent.SignerWhereInput, data *string) error -} - -// endregion ************************** generated!.gotpl ************************** - -// region ***************************** args.gotpl ***************************** - -func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_assetPrices_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 *entgql.Cursor[int] - if tmp, ok := rawArgs["after"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) - arg0, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) - if err != nil { - return nil, err - } - } - args["after"] = arg0 - var arg1 *int - if tmp, ok := rawArgs["first"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) - arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) - if err != nil { - return nil, err - } - } - args["first"] = arg1 - var arg2 *entgql.Cursor[int] - if tmp, ok := rawArgs["before"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) - arg2, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) - if err != nil { - return nil, err - } - } - args["before"] = arg2 - var arg3 *int - if tmp, ok := rawArgs["last"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("last")) - arg3, err = ec.unmarshalOInt2ᚖint(ctx, tmp) - if err != nil { - return nil, err - } - } - args["last"] = arg3 - var arg4 *ent.AssetPriceOrder - if tmp, ok := rawArgs["orderBy"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg4, err = ec.unmarshalOAssetPriceOrder2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceOrder(ctx, tmp) - if err != nil { - return nil, err - } - } - args["orderBy"] = arg4 - var arg5 *ent.AssetPriceWhereInput - if tmp, ok := rawArgs["where"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("where")) - arg5, err = ec.unmarshalOAssetPriceWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceWhereInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["where"] = arg5 - return args, nil -} - -func (ec *executionContext) field_Query_correctnessReports_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 *entgql.Cursor[int] - if tmp, ok := rawArgs["after"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) - arg0, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) - if err != nil { - return nil, err - } - } - args["after"] = arg0 - var arg1 *int - if tmp, ok := rawArgs["first"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) - arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) - if err != nil { - return nil, err - } - } - args["first"] = arg1 - var arg2 *entgql.Cursor[int] - if tmp, ok := rawArgs["before"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) - arg2, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) - if err != nil { - return nil, err - } - } - args["before"] = arg2 - var arg3 *int - if tmp, ok := rawArgs["last"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("last")) - arg3, err = ec.unmarshalOInt2ᚖint(ctx, tmp) - if err != nil { - return nil, err - } - } - args["last"] = arg3 - var arg4 *ent.CorrectnessReportOrder - if tmp, ok := rawArgs["orderBy"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg4, err = ec.unmarshalOCorrectnessReportOrder2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportOrder(ctx, tmp) - if err != nil { - return nil, err - } - } - args["orderBy"] = arg4 - var arg5 *ent.CorrectnessReportWhereInput - if tmp, ok := rawArgs["where"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("where")) - arg5, err = ec.unmarshalOCorrectnessReportWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportWhereInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["where"] = arg5 - return args, nil -} - -func (ec *executionContext) field_Query_eventLogs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 *entgql.Cursor[int] - if tmp, ok := rawArgs["after"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) - arg0, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) - if err != nil { - return nil, err - } - } - args["after"] = arg0 - var arg1 *int - if tmp, ok := rawArgs["first"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) - arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) - if err != nil { - return nil, err - } - } - args["first"] = arg1 - var arg2 *entgql.Cursor[int] - if tmp, ok := rawArgs["before"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) - arg2, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) - if err != nil { - return nil, err - } - } - args["before"] = arg2 - var arg3 *int - if tmp, ok := rawArgs["last"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("last")) - arg3, err = ec.unmarshalOInt2ᚖint(ctx, tmp) - if err != nil { - return nil, err - } - } - args["last"] = arg3 - var arg4 *ent.EventLogOrder - if tmp, ok := rawArgs["orderBy"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg4, err = ec.unmarshalOEventLogOrder2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogOrder(ctx, tmp) - if err != nil { - return nil, err - } - } - args["orderBy"] = arg4 - var arg5 *ent.EventLogWhereInput - if tmp, ok := rawArgs["where"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("where")) - arg5, err = ec.unmarshalOEventLogWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogWhereInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["where"] = arg5 - return args, nil -} - -func (ec *executionContext) field_Query_node_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 int - if tmp, ok := rawArgs["id"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - arg0, err = ec.unmarshalNID2int(ctx, tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_nodes_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 []int - if tmp, ok := rawArgs["ids"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ids")) - arg0, err = ec.unmarshalNID2ᚕintᚄ(ctx, tmp) - if err != nil { - return nil, err - } - } - args["ids"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_signers_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 *entgql.Cursor[int] - if tmp, ok := rawArgs["after"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) - arg0, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) - if err != nil { - return nil, err - } - } - args["after"] = arg0 - var arg1 *int - if tmp, ok := rawArgs["first"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) - arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) - if err != nil { - return nil, err - } - } - args["first"] = arg1 - var arg2 *entgql.Cursor[int] - if tmp, ok := rawArgs["before"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) - arg2, err = ec.unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, tmp) - if err != nil { - return nil, err - } - } - args["before"] = arg2 - var arg3 *int - if tmp, ok := rawArgs["last"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("last")) - arg3, err = ec.unmarshalOInt2ᚖint(ctx, tmp) - if err != nil { - return nil, err - } - } - args["last"] = arg3 - var arg4 *ent.SignerOrder - if tmp, ok := rawArgs["orderBy"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderBy")) - arg4, err = ec.unmarshalOSignerOrder2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerOrder(ctx, tmp) - if err != nil { - return nil, err - } - } - args["orderBy"] = arg4 - var arg5 *ent.SignerWhereInput - if tmp, ok := rawArgs["where"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("where")) - arg5, err = ec.unmarshalOSignerWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["where"] = arg5 - return args, nil -} - -// endregion ***************************** args.gotpl ***************************** - -// region ************************** directives.gotpl ************************** - -// endregion ************************** directives.gotpl ************************** - -// region **************************** field.gotpl ***************************** - -func (ec *executionContext) _AssetPrice_id(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_id(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_block(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_block(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Block, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_block(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_signerscount(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_signerscount(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SignersCount, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*uint64) - fc.Result = res - return ec.marshalOUint2ᚖuint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_signerscount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_price(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_price(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.AssetPrice().Price(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_price(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_signature(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_signature(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.AssetPrice().Signature(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(types.Bytes) - fc.Result = res - return ec.marshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_signature(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Bytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_asset(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_asset(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Asset, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_asset(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_chain(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_chain(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Chain, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_chain(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_pair(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_pair(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Pair, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_pair(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_consensus(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_consensus(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Consensus, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_consensus(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_voted(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_voted(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.AssetPrice().Voted(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_voted(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPrice_signers(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPrice) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPrice_signers(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Signers(ctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]*ent.Signer) - fc.Result = res - return ec.marshalNSigner2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPrice_signers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPrice", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Signer_id(ctx, field) - case "name": - return ec.fieldContext_Signer_name(ctx, field) - case "evm": - return ec.fieldContext_Signer_evm(ctx, field) - case "key": - return ec.fieldContext_Signer_key(ctx, field) - case "shortkey": - return ec.fieldContext_Signer_shortkey(ctx, field) - case "points": - return ec.fieldContext_Signer_points(ctx, field) - case "assetprice": - return ec.fieldContext_Signer_assetprice(ctx, field) - case "eventlogs": - return ec.fieldContext_Signer_eventlogs(ctx, field) - case "correctnessreport": - return ec.fieldContext_Signer_correctnessreport(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Signer", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPriceConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPriceConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPriceConnection_edges(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Edges, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*ent.AssetPriceEdge) - fc.Result = res - return ec.marshalOAssetPriceEdge2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceEdge(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPriceConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPriceConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_AssetPriceEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_AssetPriceEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AssetPriceEdge", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPriceConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPriceConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPriceConnection_pageInfo(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PageInfo, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(entgql.PageInfo[int]) - fc.Result = res - return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPriceConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPriceConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPriceConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPriceConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPriceConnection_totalCount(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.TotalCount, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPriceConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPriceConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPriceEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPriceEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPriceEdge_node(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Node, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*ent.AssetPrice) - fc.Result = res - return ec.marshalOAssetPrice2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPrice(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPriceEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPriceEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_AssetPrice_id(ctx, field) - case "block": - return ec.fieldContext_AssetPrice_block(ctx, field) - case "signerscount": - return ec.fieldContext_AssetPrice_signerscount(ctx, field) - case "price": - return ec.fieldContext_AssetPrice_price(ctx, field) - case "signature": - return ec.fieldContext_AssetPrice_signature(ctx, field) - case "asset": - return ec.fieldContext_AssetPrice_asset(ctx, field) - case "chain": - return ec.fieldContext_AssetPrice_chain(ctx, field) - case "pair": - return ec.fieldContext_AssetPrice_pair(ctx, field) - case "consensus": - return ec.fieldContext_AssetPrice_consensus(ctx, field) - case "voted": - return ec.fieldContext_AssetPrice_voted(ctx, field) - case "signers": - return ec.fieldContext_AssetPrice_signers(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AssetPrice", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _AssetPriceEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.AssetPriceEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_AssetPriceEdge_cursor(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(entgql.Cursor[int]) - fc.Result = res - return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_AssetPriceEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "AssetPriceEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_id(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_id(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_signerscount(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_signerscount(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SignersCount, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_signerscount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_timestamp(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_timestamp(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Timestamp, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_timestamp(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_signature(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_signature(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.CorrectnessReport().Signature(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(types.Bytes) - fc.Result = res - return ec.marshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_signature(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Bytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_hash(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_hash(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.CorrectnessReport().Hash(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(types.Bytes) - fc.Result = res - return ec.marshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_hash(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Bytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_topic(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_topic(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.CorrectnessReport().Topic(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(types.Bytes) - fc.Result = res - return ec.marshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_topic(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Bytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_correct(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_correct(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Correct, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_correct(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_consensus(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_consensus(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Consensus, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_consensus(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_voted(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_voted(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.CorrectnessReport().Voted(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_voted(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReport_signers(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReport) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReport_signers(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Signers(ctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]*ent.Signer) - fc.Result = res - return ec.marshalNSigner2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReport_signers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReport", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Signer_id(ctx, field) - case "name": - return ec.fieldContext_Signer_name(ctx, field) - case "evm": - return ec.fieldContext_Signer_evm(ctx, field) - case "key": - return ec.fieldContext_Signer_key(ctx, field) - case "shortkey": - return ec.fieldContext_Signer_shortkey(ctx, field) - case "points": - return ec.fieldContext_Signer_points(ctx, field) - case "assetprice": - return ec.fieldContext_Signer_assetprice(ctx, field) - case "eventlogs": - return ec.fieldContext_Signer_eventlogs(ctx, field) - case "correctnessreport": - return ec.fieldContext_Signer_correctnessreport(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Signer", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReportConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReportConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReportConnection_edges(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Edges, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*ent.CorrectnessReportEdge) - fc.Result = res - return ec.marshalOCorrectnessReportEdge2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportEdge(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReportConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReportConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_CorrectnessReportEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_CorrectnessReportEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type CorrectnessReportEdge", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReportConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReportConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReportConnection_pageInfo(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PageInfo, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(entgql.PageInfo[int]) - fc.Result = res - return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReportConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReportConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReportConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReportConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReportConnection_totalCount(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.TotalCount, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReportConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReportConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReportEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReportEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReportEdge_node(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Node, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*ent.CorrectnessReport) - fc.Result = res - return ec.marshalOCorrectnessReport2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReport(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReportEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReportEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_CorrectnessReport_id(ctx, field) - case "signerscount": - return ec.fieldContext_CorrectnessReport_signerscount(ctx, field) - case "timestamp": - return ec.fieldContext_CorrectnessReport_timestamp(ctx, field) - case "signature": - return ec.fieldContext_CorrectnessReport_signature(ctx, field) - case "hash": - return ec.fieldContext_CorrectnessReport_hash(ctx, field) - case "topic": - return ec.fieldContext_CorrectnessReport_topic(ctx, field) - case "correct": - return ec.fieldContext_CorrectnessReport_correct(ctx, field) - case "consensus": - return ec.fieldContext_CorrectnessReport_consensus(ctx, field) - case "voted": - return ec.fieldContext_CorrectnessReport_voted(ctx, field) - case "signers": - return ec.fieldContext_CorrectnessReport_signers(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type CorrectnessReport", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _CorrectnessReportEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.CorrectnessReportEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CorrectnessReportEdge_cursor(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(entgql.Cursor[int]) - fc.Result = res - return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CorrectnessReportEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CorrectnessReportEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_id(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_id(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_block(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_block(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Block, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_block(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_signerscount(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_signerscount(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SignersCount, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_signerscount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_signature(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_signature(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.EventLog().Signature(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(types.Bytes) - fc.Result = res - return ec.marshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_signature(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Bytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_address(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_address(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Address, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_address(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_chain(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_chain(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Chain, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_chain(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_index(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_index(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Index, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_index(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_event(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_event(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Event, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_event(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_transaction(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_transaction(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.EventLog().Transaction(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(types.Bytes) - fc.Result = res - return ec.marshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_transaction(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Bytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_args(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_args(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]model.EventLogArg) - fc.Result = res - return ec.marshalNEventLogArg2ᚕgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋdatasetsᚐEventLogArgᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext_EventLogArg_name(ctx, field) - case "value": - return ec.fieldContext_EventLogArg_value(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type EventLogArg", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_consensus(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_consensus(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Consensus, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_consensus(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_voted(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_voted(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.EventLog().Voted(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(uint64) - fc.Result = res - return ec.marshalNUint2uint64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_voted(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Uint does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLog_signers(ctx context.Context, field graphql.CollectedField, obj *ent.EventLog) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLog_signers(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Signers(ctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]*ent.Signer) - fc.Result = res - return ec.marshalNSigner2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLog_signers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLog", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Signer_id(ctx, field) - case "name": - return ec.fieldContext_Signer_name(ctx, field) - case "evm": - return ec.fieldContext_Signer_evm(ctx, field) - case "key": - return ec.fieldContext_Signer_key(ctx, field) - case "shortkey": - return ec.fieldContext_Signer_shortkey(ctx, field) - case "points": - return ec.fieldContext_Signer_points(ctx, field) - case "assetprice": - return ec.fieldContext_Signer_assetprice(ctx, field) - case "eventlogs": - return ec.fieldContext_Signer_eventlogs(ctx, field) - case "correctnessreport": - return ec.fieldContext_Signer_correctnessreport(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Signer", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLogConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.EventLogConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLogConnection_edges(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Edges, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*ent.EventLogEdge) - fc.Result = res - return ec.marshalOEventLogEdge2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogEdge(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLogConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLogConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_EventLogEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_EventLogEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type EventLogEdge", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLogConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.EventLogConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLogConnection_pageInfo(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PageInfo, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(entgql.PageInfo[int]) - fc.Result = res - return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLogConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLogConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLogConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.EventLogConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLogConnection_totalCount(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.TotalCount, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLogConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLogConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLogEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.EventLogEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLogEdge_node(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Node, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*ent.EventLog) - fc.Result = res - return ec.marshalOEventLog2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLog(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLogEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLogEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_EventLog_id(ctx, field) - case "block": - return ec.fieldContext_EventLog_block(ctx, field) - case "signerscount": - return ec.fieldContext_EventLog_signerscount(ctx, field) - case "signature": - return ec.fieldContext_EventLog_signature(ctx, field) - case "address": - return ec.fieldContext_EventLog_address(ctx, field) - case "chain": - return ec.fieldContext_EventLog_chain(ctx, field) - case "index": - return ec.fieldContext_EventLog_index(ctx, field) - case "event": - return ec.fieldContext_EventLog_event(ctx, field) - case "transaction": - return ec.fieldContext_EventLog_transaction(ctx, field) - case "args": - return ec.fieldContext_EventLog_args(ctx, field) - case "consensus": - return ec.fieldContext_EventLog_consensus(ctx, field) - case "voted": - return ec.fieldContext_EventLog_voted(ctx, field) - case "signers": - return ec.fieldContext_EventLog_signers(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type EventLog", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _EventLogEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.EventLogEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_EventLogEdge_cursor(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(entgql.Cursor[int]) - fc.Result = res - return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_EventLogEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "EventLogEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.HasNextPage, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "PageInfo", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.HasPreviousPage, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "PageInfo", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_startCursor(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.StartCursor, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*entgql.Cursor[int]) - fc.Result = res - return ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_PageInfo_startCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "PageInfo", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_endCursor(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EndCursor, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*entgql.Cursor[int]) - fc.Result = res - return ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_PageInfo_endCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "PageInfo", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_node(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Node(rctx, fc.Args["id"].(int)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(ent.Noder) - fc.Result = res - return ec.marshalONode2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐNoder(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_nodes(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Nodes(rctx, fc.Args["ids"].([]int)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]ent.Noder) - fc.Result = res - return ec.marshalNNode2ᚕgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐNoder(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query_assetPrices(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_assetPrices(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().AssetPrices(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].(*ent.AssetPriceOrder), fc.Args["where"].(*ent.AssetPriceWhereInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*ent.AssetPriceConnection) - fc.Result = res - return ec.marshalNAssetPriceConnection2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceConnection(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_assetPrices(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_AssetPriceConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_AssetPriceConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_AssetPriceConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AssetPriceConnection", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_assetPrices_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query_correctnessReports(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_correctnessReports(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().CorrectnessReports(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].(*ent.CorrectnessReportOrder), fc.Args["where"].(*ent.CorrectnessReportWhereInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*ent.CorrectnessReportConnection) - fc.Result = res - return ec.marshalNCorrectnessReportConnection2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportConnection(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_correctnessReports(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_CorrectnessReportConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_CorrectnessReportConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_CorrectnessReportConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type CorrectnessReportConnection", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_correctnessReports_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query_eventLogs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_eventLogs(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().EventLogs(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].(*ent.EventLogOrder), fc.Args["where"].(*ent.EventLogWhereInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*ent.EventLogConnection) - fc.Result = res - return ec.marshalNEventLogConnection2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogConnection(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_eventLogs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_EventLogConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_EventLogConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_EventLogConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type EventLogConnection", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_eventLogs_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query_signers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_signers(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Signers(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].(*ent.SignerOrder), fc.Args["where"].(*ent.SignerWhereInput)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*ent.SignerConnection) - fc.Result = res - return ec.marshalNSignerConnection2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerConnection(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query_signers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_SignerConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_SignerConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_SignerConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type SignerConnection", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_signers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___type(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectType(fc.Args["name"].(string)) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___schema(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Schema) - fc.Result = res - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "description": - return ec.fieldContext___Schema_description(ctx, field) - case "types": - return ec.fieldContext___Schema_types(ctx, field) - case "queryType": - return ec.fieldContext___Schema_queryType(ctx, field) - case "mutationType": - return ec.fieldContext___Schema_mutationType(ctx, field) - case "subscriptionType": - return ec.fieldContext___Schema_subscriptionType(ctx, field) - case "directives": - return ec.fieldContext___Schema_directives(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Signer_id(ctx context.Context, field graphql.CollectedField, obj *ent.Signer) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signer_id(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Signer_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Signer", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Signer_name(ctx context.Context, field graphql.CollectedField, obj *ent.Signer) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signer_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Signer_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Signer", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Signer_evm(ctx context.Context, field graphql.CollectedField, obj *ent.Signer) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signer_evm(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Evm, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Signer_evm(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Signer", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Signer_key(ctx context.Context, field graphql.CollectedField, obj *ent.Signer) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signer_key(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Signer().Key(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(types.Bytes) - fc.Result = res - return ec.marshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Signer_key(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Signer", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Bytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Signer_shortkey(ctx context.Context, field graphql.CollectedField, obj *ent.Signer) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signer_shortkey(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Signer().Shortkey(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(types.Bytes) - fc.Result = res - return ec.marshalNBytes2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋtransportᚋserverᚋgqlᚋtypesᚐBytes(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Signer_shortkey(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Signer", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Bytes does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Signer_points(ctx context.Context, field graphql.CollectedField, obj *ent.Signer) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signer_points(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Points, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int64) - fc.Result = res - return ec.marshalNInt2int64(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Signer_points(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Signer", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Signer_assetprice(ctx context.Context, field graphql.CollectedField, obj *ent.Signer) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signer_assetprice(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.AssetPrice(ctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*ent.AssetPrice) - fc.Result = res - return ec.marshalOAssetPrice2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Signer_assetprice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Signer", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_AssetPrice_id(ctx, field) - case "block": - return ec.fieldContext_AssetPrice_block(ctx, field) - case "signerscount": - return ec.fieldContext_AssetPrice_signerscount(ctx, field) - case "price": - return ec.fieldContext_AssetPrice_price(ctx, field) - case "signature": - return ec.fieldContext_AssetPrice_signature(ctx, field) - case "asset": - return ec.fieldContext_AssetPrice_asset(ctx, field) - case "chain": - return ec.fieldContext_AssetPrice_chain(ctx, field) - case "pair": - return ec.fieldContext_AssetPrice_pair(ctx, field) - case "consensus": - return ec.fieldContext_AssetPrice_consensus(ctx, field) - case "voted": - return ec.fieldContext_AssetPrice_voted(ctx, field) - case "signers": - return ec.fieldContext_AssetPrice_signers(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AssetPrice", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Signer_eventlogs(ctx context.Context, field graphql.CollectedField, obj *ent.Signer) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signer_eventlogs(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EventLogs(ctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*ent.EventLog) - fc.Result = res - return ec.marshalOEventLog2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Signer_eventlogs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Signer", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_EventLog_id(ctx, field) - case "block": - return ec.fieldContext_EventLog_block(ctx, field) - case "signerscount": - return ec.fieldContext_EventLog_signerscount(ctx, field) - case "signature": - return ec.fieldContext_EventLog_signature(ctx, field) - case "address": - return ec.fieldContext_EventLog_address(ctx, field) - case "chain": - return ec.fieldContext_EventLog_chain(ctx, field) - case "index": - return ec.fieldContext_EventLog_index(ctx, field) - case "event": - return ec.fieldContext_EventLog_event(ctx, field) - case "transaction": - return ec.fieldContext_EventLog_transaction(ctx, field) - case "args": - return ec.fieldContext_EventLog_args(ctx, field) - case "consensus": - return ec.fieldContext_EventLog_consensus(ctx, field) - case "voted": - return ec.fieldContext_EventLog_voted(ctx, field) - case "signers": - return ec.fieldContext_EventLog_signers(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type EventLog", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Signer_correctnessreport(ctx context.Context, field graphql.CollectedField, obj *ent.Signer) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Signer_correctnessreport(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.CorrectnessReport(ctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*ent.CorrectnessReport) - fc.Result = res - return ec.marshalOCorrectnessReport2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Signer_correctnessreport(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Signer", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_CorrectnessReport_id(ctx, field) - case "signerscount": - return ec.fieldContext_CorrectnessReport_signerscount(ctx, field) - case "timestamp": - return ec.fieldContext_CorrectnessReport_timestamp(ctx, field) - case "signature": - return ec.fieldContext_CorrectnessReport_signature(ctx, field) - case "hash": - return ec.fieldContext_CorrectnessReport_hash(ctx, field) - case "topic": - return ec.fieldContext_CorrectnessReport_topic(ctx, field) - case "correct": - return ec.fieldContext_CorrectnessReport_correct(ctx, field) - case "consensus": - return ec.fieldContext_CorrectnessReport_consensus(ctx, field) - case "voted": - return ec.fieldContext_CorrectnessReport_voted(ctx, field) - case "signers": - return ec.fieldContext_CorrectnessReport_signers(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type CorrectnessReport", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _SignerConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.SignerConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SignerConnection_edges(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Edges, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*ent.SignerEdge) - fc.Result = res - return ec.marshalOSignerEdge2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerEdge(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_SignerConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "SignerConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "node": - return ec.fieldContext_SignerEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_SignerEdge_cursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type SignerEdge", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _SignerConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.SignerConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SignerConnection_pageInfo(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PageInfo, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(entgql.PageInfo[int]) - fc.Result = res - return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_SignerConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "SignerConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _SignerConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.SignerConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SignerConnection_totalCount(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.TotalCount, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_SignerConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "SignerConnection", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _SignerEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.SignerEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SignerEdge_node(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Node, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*ent.Signer) - fc.Result = res - return ec.marshalOSigner2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSigner(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_SignerEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "SignerEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Signer_id(ctx, field) - case "name": - return ec.fieldContext_Signer_name(ctx, field) - case "evm": - return ec.fieldContext_Signer_evm(ctx, field) - case "key": - return ec.fieldContext_Signer_key(ctx, field) - case "shortkey": - return ec.fieldContext_Signer_shortkey(ctx, field) - case "points": - return ec.fieldContext_Signer_points(ctx, field) - case "assetprice": - return ec.fieldContext_Signer_assetprice(ctx, field) - case "eventlogs": - return ec.fieldContext_Signer_eventlogs(ctx, field) - case "correctnessreport": - return ec.fieldContext_Signer_correctnessreport(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Signer", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _SignerEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.SignerEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_SignerEdge_cursor(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(entgql.Cursor[int]) - fc.Result = res - return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_SignerEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "SignerEdge", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") - }, - } - return fc, nil -} - -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** - -func (ec *executionContext) unmarshalInputAssetPriceOrder(ctx context.Context, obj interface{}) (ent.AssetPriceOrder, error) { - var it ent.AssetPriceOrder - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" - } - - fieldsInOrder := [...]string{"direction", "field"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "direction": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) - if err != nil { - return it, err - } - it.Direction = data - case "field": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNAssetPriceOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceOrderField(ctx, v) - if err != nil { - return it, err - } - it.Field = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputAssetPriceWhereInput(ctx context.Context, obj interface{}) (ent.AssetPriceWhereInput, error) { - var it ent.AssetPriceWhereInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "block", "blockNEQ", "blockIn", "blockNotIn", "blockGT", "blockGTE", "blockLT", "blockLTE", "signerscount", "signerscountNEQ", "signerscountIn", "signerscountNotIn", "signerscountGT", "signerscountGTE", "signerscountLT", "signerscountLTE", "signerscountIsNil", "signerscountNotNil", "price", "priceNEQ", "priceIn", "priceNotIn", "priceGT", "priceGTE", "priceLT", "priceLTE", "asset", "assetNEQ", "assetIn", "assetNotIn", "assetGT", "assetGTE", "assetLT", "assetLTE", "assetContains", "assetHasPrefix", "assetHasSuffix", "assetIsNil", "assetNotNil", "assetEqualFold", "assetContainsFold", "chain", "chainNEQ", "chainIn", "chainNotIn", "chainGT", "chainGTE", "chainLT", "chainLTE", "chainContains", "chainHasPrefix", "chainHasSuffix", "chainIsNil", "chainNotNil", "chainEqualFold", "chainContainsFold", "pair", "pairNEQ", "pairIn", "pairNotIn", "pairGT", "pairGTE", "pairLT", "pairLTE", "pairContains", "pairHasPrefix", "pairHasSuffix", "pairIsNil", "pairNotNil", "pairEqualFold", "pairContainsFold", "consensus", "consensusNEQ", "voted", "votedNEQ", "votedIn", "votedNotIn", "votedGT", "votedGTE", "votedLT", "votedLTE", "hasSigners", "hasSignersWith"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOAssetPriceWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceWhereInput(ctx, v) - if err != nil { - return it, err - } - it.Not = data - case "and": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOAssetPriceWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.And = data - case "or": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOAssetPriceWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.Or = data - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.ID = data - case "idNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDNEQ = data - case "idIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.IDIn = data - case "idNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDLTE = data - case "block": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("block")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.Block = data - case "blockNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockNEQ = data - case "blockIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.BlockIn = data - case "blockNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.BlockNotIn = data - case "blockGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockGT = data - case "blockGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockGTE = data - case "blockLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockLT = data - case "blockLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockLTE = data - case "signerscount": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscount")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCount = data - case "signerscountNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountNEQ = data - case "signerscountIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.SignersCountIn = data - case "signerscountNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.SignersCountNotIn = data - case "signerscountGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountGT = data - case "signerscountGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountGTE = data - case "signerscountLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountLT = data - case "signerscountLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountLTE = data - case "signerscountIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.SignersCountIsNil = data - case "signerscountNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.SignersCountNotNil = data - case "price": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("price")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().Price(ctx, &it, data); err != nil { - return it, err - } - case "priceNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priceNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().PriceNeq(ctx, &it, data); err != nil { - return it, err - } - case "priceIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priceIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().PriceIn(ctx, &it, data); err != nil { - return it, err - } - case "priceNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priceNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().PriceNotIn(ctx, &it, data); err != nil { - return it, err - } - case "priceGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priceGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().PriceGt(ctx, &it, data); err != nil { - return it, err - } - case "priceGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priceGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().PriceGte(ctx, &it, data); err != nil { - return it, err - } - case "priceLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priceLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().PriceLt(ctx, &it, data); err != nil { - return it, err - } - case "priceLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("priceLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().PriceLte(ctx, &it, data); err != nil { - return it, err - } - case "asset": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("asset")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Asset = data - case "assetNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetNEQ = data - case "assetIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.AssetIn = data - case "assetNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.AssetNotIn = data - case "assetGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetGT = data - case "assetGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetGTE = data - case "assetLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetLT = data - case "assetLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetLTE = data - case "assetContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetContains = data - case "assetHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetHasPrefix = data - case "assetHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetHasSuffix = data - case "assetIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.AssetIsNil = data - case "assetNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.AssetNotNil = data - case "assetEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetEqualFold = data - case "assetContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("assetContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AssetContainsFold = data - case "chain": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chain")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Chain = data - case "chainNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainNEQ = data - case "chainIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.ChainIn = data - case "chainNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.ChainNotIn = data - case "chainGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainGT = data - case "chainGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainGTE = data - case "chainLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainLT = data - case "chainLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainLTE = data - case "chainContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainContains = data - case "chainHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainHasPrefix = data - case "chainHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainHasSuffix = data - case "chainIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ChainIsNil = data - case "chainNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.ChainNotNil = data - case "chainEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainEqualFold = data - case "chainContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainContainsFold = data - case "pair": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pair")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Pair = data - case "pairNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairNEQ = data - case "pairIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.PairIn = data - case "pairNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.PairNotIn = data - case "pairGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairGT = data - case "pairGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairGTE = data - case "pairLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairLT = data - case "pairLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairLTE = data - case "pairContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairContains = data - case "pairHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairHasPrefix = data - case "pairHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairHasSuffix = data - case "pairIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.PairIsNil = data - case "pairNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.PairNotNil = data - case "pairEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairEqualFold = data - case "pairContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pairContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.PairContainsFold = data - case "consensus": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("consensus")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.Consensus = data - case "consensusNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("consensusNEQ")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.ConsensusNEQ = data - case "voted": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("voted")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().Voted(ctx, &it, data); err != nil { - return it, err - } - case "votedNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().VotedNeq(ctx, &it, data); err != nil { - return it, err - } - case "votedIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().VotedIn(ctx, &it, data); err != nil { - return it, err - } - case "votedNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().VotedNotIn(ctx, &it, data); err != nil { - return it, err - } - case "votedGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().VotedGt(ctx, &it, data); err != nil { - return it, err - } - case "votedGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().VotedGte(ctx, &it, data); err != nil { - return it, err - } - case "votedLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().VotedLt(ctx, &it, data); err != nil { - return it, err - } - case "votedLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.AssetPriceWhereInput().VotedLte(ctx, &it, data); err != nil { - return it, err - } - case "hasSigners": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSigners")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasSigners = data - case "hasSignersWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSignersWith")) - data, err := ec.unmarshalOSignerWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasSignersWith = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputCorrectnessReportOrder(ctx context.Context, obj interface{}) (ent.CorrectnessReportOrder, error) { - var it ent.CorrectnessReportOrder - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" - } - - fieldsInOrder := [...]string{"direction", "field"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "direction": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) - if err != nil { - return it, err - } - it.Direction = data - case "field": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNCorrectnessReportOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportOrderField(ctx, v) - if err != nil { - return it, err - } - it.Field = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputCorrectnessReportWhereInput(ctx context.Context, obj interface{}) (ent.CorrectnessReportWhereInput, error) { - var it ent.CorrectnessReportWhereInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "signerscount", "signerscountNEQ", "signerscountIn", "signerscountNotIn", "signerscountGT", "signerscountGTE", "signerscountLT", "signerscountLTE", "timestamp", "timestampNEQ", "timestampIn", "timestampNotIn", "timestampGT", "timestampGTE", "timestampLT", "timestampLTE", "correct", "correctNEQ", "consensus", "consensusNEQ", "voted", "votedNEQ", "votedIn", "votedNotIn", "votedGT", "votedGTE", "votedLT", "votedLTE", "hasSigners", "hasSignersWith", "topic", "hash"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOCorrectnessReportWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportWhereInput(ctx, v) - if err != nil { - return it, err - } - it.Not = data - case "and": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOCorrectnessReportWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.And = data - case "or": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOCorrectnessReportWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.Or = data - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.ID = data - case "idNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDNEQ = data - case "idIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.IDIn = data - case "idNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDLTE = data - case "signerscount": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscount")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCount = data - case "signerscountNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountNEQ = data - case "signerscountIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.SignersCountIn = data - case "signerscountNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.SignersCountNotIn = data - case "signerscountGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountGT = data - case "signerscountGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountGTE = data - case "signerscountLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountLT = data - case "signerscountLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountLTE = data - case "timestamp": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("timestamp")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.Timestamp = data - case "timestampNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("timestampNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.TimestampNEQ = data - case "timestampIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("timestampIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.TimestampIn = data - case "timestampNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("timestampNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.TimestampNotIn = data - case "timestampGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("timestampGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.TimestampGT = data - case "timestampGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("timestampGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.TimestampGTE = data - case "timestampLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("timestampLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.TimestampLT = data - case "timestampLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("timestampLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.TimestampLTE = data - case "correct": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("correct")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.Correct = data - case "correctNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("correctNEQ")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.CorrectNEQ = data - case "consensus": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("consensus")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.Consensus = data - case "consensusNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("consensusNEQ")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.ConsensusNEQ = data - case "voted": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("voted")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().Voted(ctx, &it, data); err != nil { - return it, err - } - case "votedNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().VotedNeq(ctx, &it, data); err != nil { - return it, err - } - case "votedIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().VotedIn(ctx, &it, data); err != nil { - return it, err - } - case "votedNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().VotedNotIn(ctx, &it, data); err != nil { - return it, err - } - case "votedGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().VotedGt(ctx, &it, data); err != nil { - return it, err - } - case "votedGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().VotedGte(ctx, &it, data); err != nil { - return it, err - } - case "votedLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().VotedLt(ctx, &it, data); err != nil { - return it, err - } - case "votedLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().VotedLte(ctx, &it, data); err != nil { - return it, err - } - case "hasSigners": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSigners")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasSigners = data - case "hasSignersWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSignersWith")) - data, err := ec.unmarshalOSignerWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasSignersWith = data - case "topic": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("topic")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().Topic(ctx, &it, data); err != nil { - return it, err - } - case "hash": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.CorrectnessReportWhereInput().Hash(ctx, &it, data); err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputEventLogOrder(ctx context.Context, obj interface{}) (ent.EventLogOrder, error) { - var it ent.EventLogOrder - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" - } - - fieldsInOrder := [...]string{"direction", "field"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "direction": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) - if err != nil { - return it, err - } - it.Direction = data - case "field": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNEventLogOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogOrderField(ctx, v) - if err != nil { - return it, err - } - it.Field = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputEventLogWhereInput(ctx context.Context, obj interface{}) (ent.EventLogWhereInput, error) { - var it ent.EventLogWhereInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "block", "blockNEQ", "blockIn", "blockNotIn", "blockGT", "blockGTE", "blockLT", "blockLTE", "signerscount", "signerscountNEQ", "signerscountIn", "signerscountNotIn", "signerscountGT", "signerscountGTE", "signerscountLT", "signerscountLTE", "address", "addressNEQ", "addressIn", "addressNotIn", "addressGT", "addressGTE", "addressLT", "addressLTE", "addressContains", "addressHasPrefix", "addressHasSuffix", "addressEqualFold", "addressContainsFold", "chain", "chainNEQ", "chainIn", "chainNotIn", "chainGT", "chainGTE", "chainLT", "chainLTE", "chainContains", "chainHasPrefix", "chainHasSuffix", "chainEqualFold", "chainContainsFold", "index", "indexNEQ", "indexIn", "indexNotIn", "indexGT", "indexGTE", "indexLT", "indexLTE", "event", "eventNEQ", "eventIn", "eventNotIn", "eventGT", "eventGTE", "eventLT", "eventLTE", "eventContains", "eventHasPrefix", "eventHasSuffix", "eventEqualFold", "eventContainsFold", "consensus", "consensusNEQ", "voted", "votedNEQ", "votedIn", "votedNotIn", "votedGT", "votedGTE", "votedLT", "votedLTE", "hasSigners", "hasSignersWith"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOEventLogWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogWhereInput(ctx, v) - if err != nil { - return it, err - } - it.Not = data - case "and": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOEventLogWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.And = data - case "or": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOEventLogWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.Or = data - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.ID = data - case "idNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDNEQ = data - case "idIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.IDIn = data - case "idNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDLTE = data - case "block": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("block")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.Block = data - case "blockNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockNEQ = data - case "blockIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.BlockIn = data - case "blockNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.BlockNotIn = data - case "blockGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockGT = data - case "blockGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockGTE = data - case "blockLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockLT = data - case "blockLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("blockLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.BlockLTE = data - case "signerscount": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscount")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCount = data - case "signerscountNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountNEQ = data - case "signerscountIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.SignersCountIn = data - case "signerscountNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.SignersCountNotIn = data - case "signerscountGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountGT = data - case "signerscountGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountGTE = data - case "signerscountLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountLT = data - case "signerscountLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("signerscountLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.SignersCountLTE = data - case "address": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("address")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Address = data - case "addressNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressNEQ = data - case "addressIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.AddressIn = data - case "addressNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.AddressNotIn = data - case "addressGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressGT = data - case "addressGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressGTE = data - case "addressLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressLT = data - case "addressLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressLTE = data - case "addressContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressContains = data - case "addressHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressHasPrefix = data - case "addressHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressHasSuffix = data - case "addressEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressEqualFold = data - case "addressContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addressContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.AddressContainsFold = data - case "chain": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chain")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Chain = data - case "chainNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainNEQ = data - case "chainIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.ChainIn = data - case "chainNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.ChainNotIn = data - case "chainGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainGT = data - case "chainGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainGTE = data - case "chainLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainLT = data - case "chainLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainLTE = data - case "chainContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainContains = data - case "chainHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainHasPrefix = data - case "chainHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainHasSuffix = data - case "chainEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainEqualFold = data - case "chainContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chainContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ChainContainsFold = data - case "index": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("index")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.Index = data - case "indexNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("indexNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.IndexNEQ = data - case "indexIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("indexIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.IndexIn = data - case "indexNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("indexNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.IndexNotIn = data - case "indexGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("indexGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.IndexGT = data - case "indexGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("indexGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.IndexGTE = data - case "indexLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("indexLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.IndexLT = data - case "indexLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("indexLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.IndexLTE = data - case "event": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("event")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Event = data - case "eventNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventNEQ = data - case "eventIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.EventIn = data - case "eventNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.EventNotIn = data - case "eventGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventGT = data - case "eventGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventGTE = data - case "eventLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventLT = data - case "eventLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventLTE = data - case "eventContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventContains = data - case "eventHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventHasPrefix = data - case "eventHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventHasSuffix = data - case "eventEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventEqualFold = data - case "eventContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eventContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EventContainsFold = data - case "consensus": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("consensus")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.Consensus = data - case "consensusNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("consensusNEQ")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.ConsensusNEQ = data - case "voted": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("voted")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.EventLogWhereInput().Voted(ctx, &it, data); err != nil { - return it, err - } - case "votedNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedNEQ")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.EventLogWhereInput().VotedNeq(ctx, &it, data); err != nil { - return it, err - } - case "votedIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.EventLogWhereInput().VotedIn(ctx, &it, data); err != nil { - return it, err - } - case "votedNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedNotIn")) - data, err := ec.unmarshalOUint2ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.EventLogWhereInput().VotedNotIn(ctx, &it, data); err != nil { - return it, err - } - case "votedGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedGT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.EventLogWhereInput().VotedGt(ctx, &it, data); err != nil { - return it, err - } - case "votedGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedGTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.EventLogWhereInput().VotedGte(ctx, &it, data); err != nil { - return it, err - } - case "votedLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedLT")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.EventLogWhereInput().VotedLt(ctx, &it, data); err != nil { - return it, err - } - case "votedLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("votedLTE")) - data, err := ec.unmarshalOUint2ᚖuint64(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.EventLogWhereInput().VotedLte(ctx, &it, data); err != nil { - return it, err - } - case "hasSigners": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSigners")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasSigners = data - case "hasSignersWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSignersWith")) - data, err := ec.unmarshalOSignerWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasSignersWith = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputSignerOrder(ctx context.Context, obj interface{}) (ent.SignerOrder, error) { - var it ent.SignerOrder - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" - } - - fieldsInOrder := [...]string{"direction", "field"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "direction": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) - if err != nil { - return it, err - } - it.Direction = data - case "field": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNSignerOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerOrderField(ctx, v) - if err != nil { - return it, err - } - it.Field = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputSignerWhereInput(ctx context.Context, obj interface{}) (ent.SignerWhereInput, error) { - var it ent.SignerWhereInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "evm", "evmNEQ", "evmIn", "evmNotIn", "evmGT", "evmGTE", "evmLT", "evmLTE", "evmContains", "evmHasPrefix", "evmHasSuffix", "evmIsNil", "evmNotNil", "evmEqualFold", "evmContainsFold", "points", "pointsNEQ", "pointsIn", "pointsNotIn", "pointsGT", "pointsGTE", "pointsLT", "pointsLTE", "hasAssetPrice", "hasAssetPriceWith", "hasEventLogs", "hasEventLogsWith", "hasCorrectnessReport", "hasCorrectnessReportWith", "key"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOSignerWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInput(ctx, v) - if err != nil { - return it, err - } - it.Not = data - case "and": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOSignerWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.And = data - case "or": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOSignerWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.Or = data - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.ID = data - case "idNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDNEQ = data - case "idIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.IDIn = data - case "idNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) - if err != nil { - return it, err - } - it.IDNotIn = data - case "idGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDGT = data - case "idGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDGTE = data - case "idLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDLT = data - case "idLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.IDLTE = data - case "name": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Name = data - case "nameNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameNEQ = data - case "nameIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.NameIn = data - case "nameNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.NameNotIn = data - case "nameGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameGT = data - case "nameGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameGTE = data - case "nameLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameLT = data - case "nameLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameLTE = data - case "nameContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameContains = data - case "nameHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameHasPrefix = data - case "nameHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameHasSuffix = data - case "nameEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameEqualFold = data - case "nameContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameContainsFold = data - case "evm": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evm")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Evm = data - case "evmNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmNEQ = data - case "evmIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.EvmIn = data - case "evmNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.EvmNotIn = data - case "evmGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmGT = data - case "evmGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmGTE = data - case "evmLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmLT = data - case "evmLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmLTE = data - case "evmContains": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmContains = data - case "evmHasPrefix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmHasPrefix = data - case "evmHasSuffix": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmHasSuffix = data - case "evmIsNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.EvmIsNil = data - case "evmNotNil": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) - if err != nil { - return it, err - } - it.EvmNotNil = data - case "evmEqualFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmEqualFold = data - case "evmContainsFold": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("evmContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.EvmContainsFold = data - case "points": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("points")) - data, err := ec.unmarshalOInt2ᚖint64(ctx, v) - if err != nil { - return it, err - } - it.Points = data - case "pointsNEQ": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pointsNEQ")) - data, err := ec.unmarshalOInt2ᚖint64(ctx, v) - if err != nil { - return it, err - } - it.PointsNEQ = data - case "pointsIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pointsIn")) - data, err := ec.unmarshalOInt2ᚕint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.PointsIn = data - case "pointsNotIn": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pointsNotIn")) - data, err := ec.unmarshalOInt2ᚕint64ᚄ(ctx, v) - if err != nil { - return it, err - } - it.PointsNotIn = data - case "pointsGT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pointsGT")) - data, err := ec.unmarshalOInt2ᚖint64(ctx, v) - if err != nil { - return it, err - } - it.PointsGT = data - case "pointsGTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pointsGTE")) - data, err := ec.unmarshalOInt2ᚖint64(ctx, v) - if err != nil { - return it, err - } - it.PointsGTE = data - case "pointsLT": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pointsLT")) - data, err := ec.unmarshalOInt2ᚖint64(ctx, v) - if err != nil { - return it, err - } - it.PointsLT = data - case "pointsLTE": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pointsLTE")) - data, err := ec.unmarshalOInt2ᚖint64(ctx, v) - if err != nil { - return it, err - } - it.PointsLTE = data - case "hasAssetPrice": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasAssetPrice")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasAssetPrice = data - case "hasAssetPriceWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasAssetPriceWith")) - data, err := ec.unmarshalOAssetPriceWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasAssetPriceWith = data - case "hasEventLogs": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasEventLogs")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasEventLogs = data - case "hasEventLogsWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasEventLogsWith")) - data, err := ec.unmarshalOEventLogWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasEventLogsWith = data - case "hasCorrectnessReport": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCorrectnessReport")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.HasCorrectnessReport = data - case "hasCorrectnessReportWith": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasCorrectnessReportWith")) - data, err := ec.unmarshalOCorrectnessReportWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportWhereInputᚄ(ctx, v) - if err != nil { - return it, err - } - it.HasCorrectnessReportWith = data - case "key": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("key")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - if err = ec.resolvers.SignerWhereInput().Key(ctx, &it, data); err != nil { - return it, err - } - } - } - - return it, nil -} - -// endregion **************************** input.gotpl ***************************** - -// region ************************** interface.gotpl *************************** - -func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj ent.Noder) graphql.Marshaler { - switch obj := (obj).(type) { - case nil: - return graphql.Null - case *ent.AssetPrice: - if obj == nil { - return graphql.Null - } - return ec._AssetPrice(ctx, sel, obj) - case *ent.CorrectnessReport: - if obj == nil { - return graphql.Null - } - return ec._CorrectnessReport(ctx, sel, obj) - case *ent.EventLog: - if obj == nil { - return graphql.Null - } - return ec._EventLog(ctx, sel, obj) - case *ent.Signer: - if obj == nil { - return graphql.Null - } - return ec._Signer(ctx, sel, obj) - default: - panic(fmt.Errorf("unexpected type %T", obj)) - } -} - -// endregion ************************** interface.gotpl *************************** - -// region **************************** object.gotpl **************************** - -var assetPriceImplementors = []string{"AssetPrice", "Node"} - -func (ec *executionContext) _AssetPrice(ctx context.Context, sel ast.SelectionSet, obj *ent.AssetPrice) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, assetPriceImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("AssetPrice") - case "id": - out.Values[i] = ec._AssetPrice_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "block": - out.Values[i] = ec._AssetPrice_block(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "signerscount": - out.Values[i] = ec._AssetPrice_signerscount(ctx, field, obj) - case "price": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._AssetPrice_price(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "signature": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._AssetPrice_signature(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "asset": - out.Values[i] = ec._AssetPrice_asset(ctx, field, obj) - case "chain": - out.Values[i] = ec._AssetPrice_chain(ctx, field, obj) - case "pair": - out.Values[i] = ec._AssetPrice_pair(ctx, field, obj) - case "consensus": - out.Values[i] = ec._AssetPrice_consensus(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "voted": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._AssetPrice_voted(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "signers": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._AssetPrice_signers(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var assetPriceConnectionImplementors = []string{"AssetPriceConnection"} - -func (ec *executionContext) _AssetPriceConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.AssetPriceConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, assetPriceConnectionImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("AssetPriceConnection") - case "edges": - out.Values[i] = ec._AssetPriceConnection_edges(ctx, field, obj) - case "pageInfo": - out.Values[i] = ec._AssetPriceConnection_pageInfo(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "totalCount": - out.Values[i] = ec._AssetPriceConnection_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var assetPriceEdgeImplementors = []string{"AssetPriceEdge"} - -func (ec *executionContext) _AssetPriceEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.AssetPriceEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, assetPriceEdgeImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("AssetPriceEdge") - case "node": - out.Values[i] = ec._AssetPriceEdge_node(ctx, field, obj) - case "cursor": - out.Values[i] = ec._AssetPriceEdge_cursor(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var correctnessReportImplementors = []string{"CorrectnessReport", "Node"} - -func (ec *executionContext) _CorrectnessReport(ctx context.Context, sel ast.SelectionSet, obj *ent.CorrectnessReport) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, correctnessReportImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("CorrectnessReport") - case "id": - out.Values[i] = ec._CorrectnessReport_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "signerscount": - out.Values[i] = ec._CorrectnessReport_signerscount(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "timestamp": - out.Values[i] = ec._CorrectnessReport_timestamp(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "signature": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._CorrectnessReport_signature(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "hash": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._CorrectnessReport_hash(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "topic": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._CorrectnessReport_topic(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "correct": - out.Values[i] = ec._CorrectnessReport_correct(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "consensus": - out.Values[i] = ec._CorrectnessReport_consensus(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "voted": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._CorrectnessReport_voted(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "signers": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._CorrectnessReport_signers(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var correctnessReportConnectionImplementors = []string{"CorrectnessReportConnection"} - -func (ec *executionContext) _CorrectnessReportConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.CorrectnessReportConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, correctnessReportConnectionImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("CorrectnessReportConnection") - case "edges": - out.Values[i] = ec._CorrectnessReportConnection_edges(ctx, field, obj) - case "pageInfo": - out.Values[i] = ec._CorrectnessReportConnection_pageInfo(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "totalCount": - out.Values[i] = ec._CorrectnessReportConnection_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var correctnessReportEdgeImplementors = []string{"CorrectnessReportEdge"} - -func (ec *executionContext) _CorrectnessReportEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.CorrectnessReportEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, correctnessReportEdgeImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("CorrectnessReportEdge") - case "node": - out.Values[i] = ec._CorrectnessReportEdge_node(ctx, field, obj) - case "cursor": - out.Values[i] = ec._CorrectnessReportEdge_cursor(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var eventLogImplementors = []string{"EventLog", "Node"} - -func (ec *executionContext) _EventLog(ctx context.Context, sel ast.SelectionSet, obj *ent.EventLog) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, eventLogImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("EventLog") - case "id": - out.Values[i] = ec._EventLog_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "block": - out.Values[i] = ec._EventLog_block(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "signerscount": - out.Values[i] = ec._EventLog_signerscount(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "signature": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._EventLog_signature(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "address": - out.Values[i] = ec._EventLog_address(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "chain": - out.Values[i] = ec._EventLog_chain(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "index": - out.Values[i] = ec._EventLog_index(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "event": - out.Values[i] = ec._EventLog_event(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "transaction": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._EventLog_transaction(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "args": - out.Values[i] = ec._EventLog_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "consensus": - out.Values[i] = ec._EventLog_consensus(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "voted": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._EventLog_voted(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "signers": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._EventLog_signers(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var eventLogConnectionImplementors = []string{"EventLogConnection"} - -func (ec *executionContext) _EventLogConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.EventLogConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, eventLogConnectionImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("EventLogConnection") - case "edges": - out.Values[i] = ec._EventLogConnection_edges(ctx, field, obj) - case "pageInfo": - out.Values[i] = ec._EventLogConnection_pageInfo(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "totalCount": - out.Values[i] = ec._EventLogConnection_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var eventLogEdgeImplementors = []string{"EventLogEdge"} - -func (ec *executionContext) _EventLogEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.EventLogEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, eventLogEdgeImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("EventLogEdge") - case "node": - out.Values[i] = ec._EventLogEdge_node(ctx, field, obj) - case "cursor": - out.Values[i] = ec._EventLogEdge_cursor(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var pageInfoImplementors = []string{"PageInfo"} - -func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *entgql.PageInfo[int]) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, pageInfoImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("PageInfo") - case "hasNextPage": - out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "hasPreviousPage": - out.Values[i] = ec._PageInfo_hasPreviousPage(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "startCursor": - out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj) - case "endCursor": - out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var queryImplementors = []string{"Query"} - -func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) - ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ - Object: "Query", - }) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ - Object: field.Name, - Field: field, - }) - - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "node": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_node(ctx, field) - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "nodes": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_nodes(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "assetPrices": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_assetPrices(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "correctnessReports": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_correctnessReports(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "eventLogs": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_eventLogs(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "signers": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_signers(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "__type": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Query___type(ctx, field) - }) - case "__schema": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Query___schema(ctx, field) - }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var signerImplementors = []string{"Signer", "Node"} - -func (ec *executionContext) _Signer(ctx context.Context, sel ast.SelectionSet, obj *ent.Signer) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, signerImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Signer") - case "id": - out.Values[i] = ec._Signer_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "name": - out.Values[i] = ec._Signer_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "evm": - out.Values[i] = ec._Signer_evm(ctx, field, obj) - case "key": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Signer_key(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "shortkey": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Signer_shortkey(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "points": - out.Values[i] = ec._Signer_points(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "assetprice": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Signer_assetprice(ctx, field, obj) - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "eventlogs": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Signer_eventlogs(ctx, field, obj) - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "correctnessreport": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Signer_correctnessreport(ctx, field, obj) - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var signerConnectionImplementors = []string{"SignerConnection"} - -func (ec *executionContext) _SignerConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.SignerConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, signerConnectionImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("SignerConnection") - case "edges": - out.Values[i] = ec._SignerConnection_edges(ctx, field, obj) - case "pageInfo": - out.Values[i] = ec._SignerConnection_pageInfo(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "totalCount": - out.Values[i] = ec._SignerConnection_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var signerEdgeImplementors = []string{"SignerEdge"} - -func (ec *executionContext) _SignerEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.SignerEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, signerEdgeImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("SignerEdge") - case "node": - out.Values[i] = ec._SignerEdge_node(ctx, field, obj) - case "cursor": - out.Values[i] = ec._SignerEdge_cursor(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -// endregion **************************** object.gotpl **************************** - -// region ***************************** type.gotpl ***************************** - -func (ec *executionContext) marshalNAssetPrice2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPrice(ctx context.Context, sel ast.SelectionSet, v *ent.AssetPrice) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._AssetPrice(ctx, sel, v) -} - -func (ec *executionContext) marshalNAssetPriceConnection2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceConnection(ctx context.Context, sel ast.SelectionSet, v ent.AssetPriceConnection) graphql.Marshaler { - return ec._AssetPriceConnection(ctx, sel, &v) -} - -func (ec *executionContext) marshalNAssetPriceConnection2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceConnection(ctx context.Context, sel ast.SelectionSet, v *ent.AssetPriceConnection) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._AssetPriceConnection(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNAssetPriceOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceOrderField(ctx context.Context, v interface{}) (*ent.AssetPriceOrderField, error) { - var res = new(ent.AssetPriceOrderField) - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNAssetPriceOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.AssetPriceOrderField) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return v -} - -func (ec *executionContext) unmarshalNAssetPriceWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceWhereInput(ctx context.Context, v interface{}) (*ent.AssetPriceWhereInput, error) { - res, err := ec.unmarshalInputAssetPriceWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNCorrectnessReport2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReport(ctx context.Context, sel ast.SelectionSet, v *ent.CorrectnessReport) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._CorrectnessReport(ctx, sel, v) -} - -func (ec *executionContext) marshalNCorrectnessReportConnection2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportConnection(ctx context.Context, sel ast.SelectionSet, v ent.CorrectnessReportConnection) graphql.Marshaler { - return ec._CorrectnessReportConnection(ctx, sel, &v) -} - -func (ec *executionContext) marshalNCorrectnessReportConnection2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportConnection(ctx context.Context, sel ast.SelectionSet, v *ent.CorrectnessReportConnection) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._CorrectnessReportConnection(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNCorrectnessReportOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportOrderField(ctx context.Context, v interface{}) (*ent.CorrectnessReportOrderField, error) { - var res = new(ent.CorrectnessReportOrderField) - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNCorrectnessReportOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.CorrectnessReportOrderField) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return v -} - -func (ec *executionContext) unmarshalNCorrectnessReportWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportWhereInput(ctx context.Context, v interface{}) (*ent.CorrectnessReportWhereInput, error) { - res, err := ec.unmarshalInputCorrectnessReportWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx context.Context, v interface{}) (entgql.Cursor[int], error) { - var res entgql.Cursor[int] - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx context.Context, sel ast.SelectionSet, v entgql.Cursor[int]) graphql.Marshaler { - return v -} - -func (ec *executionContext) marshalNEventLog2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLog(ctx context.Context, sel ast.SelectionSet, v *ent.EventLog) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._EventLog(ctx, sel, v) -} - -func (ec *executionContext) marshalNEventLogConnection2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogConnection(ctx context.Context, sel ast.SelectionSet, v ent.EventLogConnection) graphql.Marshaler { - return ec._EventLogConnection(ctx, sel, &v) -} - -func (ec *executionContext) marshalNEventLogConnection2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogConnection(ctx context.Context, sel ast.SelectionSet, v *ent.EventLogConnection) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._EventLogConnection(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNEventLogOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogOrderField(ctx context.Context, v interface{}) (*ent.EventLogOrderField, error) { - var res = new(ent.EventLogOrderField) - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNEventLogOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.EventLogOrderField) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return v -} - -func (ec *executionContext) unmarshalNEventLogWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogWhereInput(ctx context.Context, v interface{}) (*ent.EventLogWhereInput, error) { - res, err := ec.unmarshalInputEventLogWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNNode2ᚕgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐNoder(ctx context.Context, sel ast.SelectionSet, v []ent.Noder) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalONode2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐNoder(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - -func (ec *executionContext) unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx context.Context, v interface{}) (entgql.OrderDirection, error) { - var res entgql.OrderDirection - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx context.Context, sel ast.SelectionSet, v entgql.OrderDirection) graphql.Marshaler { - return v -} - -func (ec *executionContext) marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx context.Context, sel ast.SelectionSet, v entgql.PageInfo[int]) graphql.Marshaler { - return ec._PageInfo(ctx, sel, &v) -} - -func (ec *executionContext) marshalNSigner2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.Signer) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNSigner2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSigner(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalNSigner2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSigner(ctx context.Context, sel ast.SelectionSet, v *ent.Signer) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._Signer(ctx, sel, v) -} - -func (ec *executionContext) marshalNSignerConnection2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerConnection(ctx context.Context, sel ast.SelectionSet, v ent.SignerConnection) graphql.Marshaler { - return ec._SignerConnection(ctx, sel, &v) -} - -func (ec *executionContext) marshalNSignerConnection2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerConnection(ctx context.Context, sel ast.SelectionSet, v *ent.SignerConnection) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._SignerConnection(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNSignerOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerOrderField(ctx context.Context, v interface{}) (*ent.SignerOrderField, error) { - var res = new(ent.SignerOrderField) - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNSignerOrderField2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.SignerOrderField) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return v -} - -func (ec *executionContext) unmarshalNSignerWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInput(ctx context.Context, v interface{}) (*ent.SignerWhereInput, error) { - res, err := ec.unmarshalInputSignerWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNUint2uint64(ctx context.Context, v interface{}) (uint64, error) { - res, err := graphql.UnmarshalUint64(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNUint2uint64(ctx context.Context, sel ast.SelectionSet, v uint64) graphql.Marshaler { - res := graphql.MarshalUint64(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - -func (ec *executionContext) marshalOAssetPrice2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.AssetPrice) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNAssetPrice2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPrice(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalOAssetPrice2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPrice(ctx context.Context, sel ast.SelectionSet, v *ent.AssetPrice) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._AssetPrice(ctx, sel, v) -} - -func (ec *executionContext) marshalOAssetPriceEdge2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceEdge(ctx context.Context, sel ast.SelectionSet, v []*ent.AssetPriceEdge) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOAssetPriceEdge2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - -func (ec *executionContext) marshalOAssetPriceEdge2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceEdge(ctx context.Context, sel ast.SelectionSet, v *ent.AssetPriceEdge) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._AssetPriceEdge(ctx, sel, v) -} - -func (ec *executionContext) unmarshalOAssetPriceOrder2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceOrder(ctx context.Context, v interface{}) (*ent.AssetPriceOrder, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputAssetPriceOrder(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalOAssetPriceWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.AssetPriceWhereInput, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]*ent.AssetPriceWhereInput, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNAssetPriceWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceWhereInput(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) unmarshalOAssetPriceWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐAssetPriceWhereInput(ctx context.Context, v interface{}) (*ent.AssetPriceWhereInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputAssetPriceWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOCorrectnessReport2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.CorrectnessReport) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNCorrectnessReport2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReport(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalOCorrectnessReport2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReport(ctx context.Context, sel ast.SelectionSet, v *ent.CorrectnessReport) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._CorrectnessReport(ctx, sel, v) -} - -func (ec *executionContext) marshalOCorrectnessReportEdge2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportEdge(ctx context.Context, sel ast.SelectionSet, v []*ent.CorrectnessReportEdge) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOCorrectnessReportEdge2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - -func (ec *executionContext) marshalOCorrectnessReportEdge2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportEdge(ctx context.Context, sel ast.SelectionSet, v *ent.CorrectnessReportEdge) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._CorrectnessReportEdge(ctx, sel, v) -} - -func (ec *executionContext) unmarshalOCorrectnessReportOrder2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportOrder(ctx context.Context, v interface{}) (*ent.CorrectnessReportOrder, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputCorrectnessReportOrder(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalOCorrectnessReportWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.CorrectnessReportWhereInput, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]*ent.CorrectnessReportWhereInput, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNCorrectnessReportWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportWhereInput(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) unmarshalOCorrectnessReportWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐCorrectnessReportWhereInput(ctx context.Context, v interface{}) (*ent.CorrectnessReportWhereInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputCorrectnessReportWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx context.Context, v interface{}) (*entgql.Cursor[int], error) { - if v == nil { - return nil, nil - } - var res = new(entgql.Cursor[int]) - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx context.Context, sel ast.SelectionSet, v *entgql.Cursor[int]) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return v -} - -func (ec *executionContext) marshalOEventLog2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.EventLog) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNEventLog2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLog(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalOEventLog2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLog(ctx context.Context, sel ast.SelectionSet, v *ent.EventLog) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._EventLog(ctx, sel, v) -} - -func (ec *executionContext) marshalOEventLogEdge2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogEdge(ctx context.Context, sel ast.SelectionSet, v []*ent.EventLogEdge) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOEventLogEdge2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - -func (ec *executionContext) marshalOEventLogEdge2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogEdge(ctx context.Context, sel ast.SelectionSet, v *ent.EventLogEdge) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._EventLogEdge(ctx, sel, v) -} - -func (ec *executionContext) unmarshalOEventLogOrder2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogOrder(ctx context.Context, v interface{}) (*ent.EventLogOrder, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputEventLogOrder(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalOEventLogWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.EventLogWhereInput, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]*ent.EventLogWhereInput, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNEventLogWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogWhereInput(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) unmarshalOEventLogWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐEventLogWhereInput(ctx context.Context, v interface{}) (*ent.EventLogWhereInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputEventLogWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalONode2githubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐNoder(ctx context.Context, sel ast.SelectionSet, v ent.Noder) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Node(ctx, sel, v) -} - -func (ec *executionContext) marshalOSigner2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSigner(ctx context.Context, sel ast.SelectionSet, v *ent.Signer) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Signer(ctx, sel, v) -} - -func (ec *executionContext) marshalOSignerEdge2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerEdge(ctx context.Context, sel ast.SelectionSet, v []*ent.SignerEdge) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOSignerEdge2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - -func (ec *executionContext) marshalOSignerEdge2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerEdge(ctx context.Context, sel ast.SelectionSet, v *ent.SignerEdge) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._SignerEdge(ctx, sel, v) -} - -func (ec *executionContext) unmarshalOSignerOrder2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerOrder(ctx context.Context, v interface{}) (*ent.SignerOrder, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputSignerOrder(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalOSignerWhereInput2ᚕᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.SignerWhereInput, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]*ent.SignerWhereInput, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNSignerWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInput(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) unmarshalOSignerWhereInput2ᚖgithubᚗcomᚋTimeleapLabsᚋunchainedᚋinternalᚋentᚐSignerWhereInput(ctx context.Context, v interface{}) (*ent.SignerWhereInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputSignerWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalOUint2ᚕuint64ᚄ(ctx context.Context, v interface{}) ([]uint64, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]uint64, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNUint2uint64(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalOUint2ᚕuint64ᚄ(ctx context.Context, sel ast.SelectionSet, v []uint64) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalNUint2uint64(ctx, sel, v[i]) - } - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) unmarshalOUint2ᚖuint64(ctx context.Context, v interface{}) (*uint64, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalUint64(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOUint2ᚖuint64(ctx context.Context, sel ast.SelectionSet, v *uint64) graphql.Marshaler { - if v == nil { - return graphql.Null - } - res := graphql.MarshalUint64(*v) - return res -} - -// endregion ***************************** type.gotpl ***************************** diff --git a/internal/transport/server/gql/resolver.go b/internal/transport/server/gql/resolver.go deleted file mode 100644 index 38458038..00000000 --- a/internal/transport/server/gql/resolver.go +++ /dev/null @@ -1,18 +0,0 @@ -package gql - -import ( - "github.com/TimeleapLabs/unchained/internal/ent" - "github.com/TimeleapLabs/unchained/internal/transport/server/gql/generated" - - "github.com/99designs/gqlgen/graphql" -) - -// Resolver is the resolver root. -type Resolver struct{ client *ent.Client } - -// NewSchema creates a graphql executable schema. -func NewSchema(client *ent.Client) graphql.ExecutableSchema { - return generated.NewExecutableSchema(generated.Config{ - Resolvers: &Resolver{client}, - }) -} diff --git a/internal/transport/server/gql/server.go b/internal/transport/server/gql/server.go deleted file mode 100644 index 96c2e394..00000000 --- a/internal/transport/server/gql/server.go +++ /dev/null @@ -1,21 +0,0 @@ -package gql - -import ( - "net/http" - - "github.com/TimeleapLabs/unchained/internal/transport/database" - "github.com/TimeleapLabs/unchained/internal/utils" - - "github.com/99designs/gqlgen/graphql/handler" - "github.com/99designs/gqlgen/graphql/playground" -) - -func WithGraphQL(db database.Database) func() { - return func() { - utils.Logger.Info("GraphQL service is activated") - - srv := handler.NewDefaultServer(NewSchema(db.GetConnection())) - http.Handle("/gql", playground.Handler("Unchained Playground", "/gql/query")) - http.Handle("/gql/query", srv) - } -} diff --git a/internal/transport/server/gql/types/bytes.go b/internal/transport/server/gql/types/bytes.go deleted file mode 100644 index 91822bc5..00000000 --- a/internal/transport/server/gql/types/bytes.go +++ /dev/null @@ -1,34 +0,0 @@ -package types - -import ( - "encoding/hex" - "fmt" - "io" - - "github.com/TimeleapLabs/unchained/internal/utils" -) - -type Bytes []byte - -// UnmarshalGQL implements the graphql.Unmarshaler interface. -func (bytes *Bytes) UnmarshalGQL(v interface{}) error { - str, ok := v.(string) - if !ok { - return fmt.Errorf("Bytes must be a string") - } - decoded, err := hex.DecodeString(str) - if err != nil { - return fmt.Errorf("Bytes must be a hex string") - } - *bytes = decoded - return nil -} - -// MarshalGQL implements the graphql.Marshaler interface. -func (bytes Bytes) MarshalGQL(w io.Writer) { - hexValue := fmt.Sprintf(`"%x"`, bytes) - _, err := w.Write([]byte(hexValue)) - if err != nil { - utils.Logger.Error(err.Error()) - } -} diff --git a/internal/transport/server/gql/unchained.graphql b/internal/transport/server/gql/unchained.graphql deleted file mode 100644 index e724f15d..00000000 --- a/internal/transport/server/gql/unchained.graphql +++ /dev/null @@ -1,847 +0,0 @@ -directive @goField(forceResolver: Boolean, name: String) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION -directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION -type AssetPrice implements Node { - id: ID! - block: Uint! - signerscount: Uint @goField(name: "SignersCount", forceResolver: false) - price: Uint! - signature: Bytes! - asset: String - chain: String - pair: String - consensus: Boolean! - voted: Uint! - signers: [Signer!]! -} -""" -A connection to a list of items. -""" -type AssetPriceConnection { - """ - A list of edges. - """ - edges: [AssetPriceEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} -""" -An edge in a connection. -""" -type AssetPriceEdge { - """ - The item at the end of the edge. - """ - node: AssetPrice - """ - A cursor for use in pagination. - """ - cursor: Cursor! -} -""" -Ordering options for AssetPrice connections -""" -input AssetPriceOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order AssetPrices. - """ - field: AssetPriceOrderField! -} -""" -Properties by which AssetPrice connections can be ordered. -""" -enum AssetPriceOrderField { - BLOCK -} -""" -AssetPriceWhereInput is used for filtering AssetPrice objects. -Input was generated by ent. -""" -input AssetPriceWhereInput { - not: AssetPriceWhereInput - and: [AssetPriceWhereInput!] - or: [AssetPriceWhereInput!] - """ - id field predicates - """ - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """ - block field predicates - """ - block: Uint - blockNEQ: Uint - blockIn: [Uint!] - blockNotIn: [Uint!] - blockGT: Uint - blockGTE: Uint - blockLT: Uint - blockLTE: Uint - """ - signersCount field predicates - """ - signerscount: Uint - signerscountNEQ: Uint - signerscountIn: [Uint!] - signerscountNotIn: [Uint!] - signerscountGT: Uint - signerscountGTE: Uint - signerscountLT: Uint - signerscountLTE: Uint - signerscountIsNil: Boolean - signerscountNotNil: Boolean - """ - price field predicates - """ - price: Uint - priceNEQ: Uint - priceIn: [Uint!] - priceNotIn: [Uint!] - priceGT: Uint - priceGTE: Uint - priceLT: Uint - priceLTE: Uint - """ - asset field predicates - """ - asset: String - assetNEQ: String - assetIn: [String!] - assetNotIn: [String!] - assetGT: String - assetGTE: String - assetLT: String - assetLTE: String - assetContains: String - assetHasPrefix: String - assetHasSuffix: String - assetIsNil: Boolean - assetNotNil: Boolean - assetEqualFold: String - assetContainsFold: String - """ - chain field predicates - """ - chain: String - chainNEQ: String - chainIn: [String!] - chainNotIn: [String!] - chainGT: String - chainGTE: String - chainLT: String - chainLTE: String - chainContains: String - chainHasPrefix: String - chainHasSuffix: String - chainIsNil: Boolean - chainNotNil: Boolean - chainEqualFold: String - chainContainsFold: String - """ - pair field predicates - """ - pair: String - pairNEQ: String - pairIn: [String!] - pairNotIn: [String!] - pairGT: String - pairGTE: String - pairLT: String - pairLTE: String - pairContains: String - pairHasPrefix: String - pairHasSuffix: String - pairIsNil: Boolean - pairNotNil: Boolean - pairEqualFold: String - pairContainsFold: String - """ - consensus field predicates - """ - consensus: Boolean - consensusNEQ: Boolean - """ - voted field predicates - """ - voted: Uint - votedNEQ: Uint - votedIn: [Uint!] - votedNotIn: [Uint!] - votedGT: Uint - votedGTE: Uint - votedLT: Uint - votedLTE: Uint - """ - signers edge predicates - """ - hasSigners: Boolean - hasSignersWith: [SignerWhereInput!] -} -type CorrectnessReport implements Node { - id: ID! - signerscount: Uint! @goField(name: "SignersCount", forceResolver: false) - timestamp: Uint! - signature: Bytes! - hash: Bytes! - topic: Bytes! - correct: Boolean! - consensus: Boolean! - voted: Uint! - signers: [Signer!]! -} -""" -A connection to a list of items. -""" -type CorrectnessReportConnection { - """ - A list of edges. - """ - edges: [CorrectnessReportEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} -""" -An edge in a connection. -""" -type CorrectnessReportEdge { - """ - The item at the end of the edge. - """ - node: CorrectnessReport - """ - A cursor for use in pagination. - """ - cursor: Cursor! -} -""" -Ordering options for CorrectnessReport connections -""" -input CorrectnessReportOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order CorrectnessReports. - """ - field: CorrectnessReportOrderField! -} -""" -Properties by which CorrectnessReport connections can be ordered. -""" -enum CorrectnessReportOrderField { - TIMESTAMP -} -""" -CorrectnessReportWhereInput is used for filtering CorrectnessReport objects. -Input was generated by ent. -""" -input CorrectnessReportWhereInput { - not: CorrectnessReportWhereInput - and: [CorrectnessReportWhereInput!] - or: [CorrectnessReportWhereInput!] - """ - id field predicates - """ - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """ - signersCount field predicates - """ - signerscount: Uint - signerscountNEQ: Uint - signerscountIn: [Uint!] - signerscountNotIn: [Uint!] - signerscountGT: Uint - signerscountGTE: Uint - signerscountLT: Uint - signerscountLTE: Uint - """ - timestamp field predicates - """ - timestamp: Uint - timestampNEQ: Uint - timestampIn: [Uint!] - timestampNotIn: [Uint!] - timestampGT: Uint - timestampGTE: Uint - timestampLT: Uint - timestampLTE: Uint - """ - correct field predicates - """ - correct: Boolean - correctNEQ: Boolean - """ - consensus field predicates - """ - consensus: Boolean - consensusNEQ: Boolean - """ - voted field predicates - """ - voted: Uint - votedNEQ: Uint - votedIn: [Uint!] - votedNotIn: [Uint!] - votedGT: Uint - votedGTE: Uint - votedLT: Uint - votedLTE: Uint - """ - signers edge predicates - """ - hasSigners: Boolean - hasSignersWith: [SignerWhereInput!] -} -""" -Define a Relay Cursor type: -https://relay.dev/graphql/connections.htm#sec-Cursor -""" -scalar Cursor -type EventLog implements Node { - id: ID! - block: Uint! - signerscount: Uint! @goField(name: "SignersCount", forceResolver: false) - signature: Bytes! - address: String! - chain: String! - index: Uint! - event: String! - transaction: Bytes! - args: [EventLogArg!]! - consensus: Boolean! - voted: Uint! - signers: [Signer!]! -} -""" -A connection to a list of items. -""" -type EventLogConnection { - """ - A list of edges. - """ - edges: [EventLogEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} -""" -An edge in a connection. -""" -type EventLogEdge { - """ - The item at the end of the edge. - """ - node: EventLog - """ - A cursor for use in pagination. - """ - cursor: Cursor! -} -""" -Ordering options for EventLog connections -""" -input EventLogOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order EventLogs. - """ - field: EventLogOrderField! -} -""" -Properties by which EventLog connections can be ordered. -""" -enum EventLogOrderField { - BLOCK -} -""" -EventLogWhereInput is used for filtering EventLog objects. -Input was generated by ent. -""" -input EventLogWhereInput { - not: EventLogWhereInput - and: [EventLogWhereInput!] - or: [EventLogWhereInput!] - """ - id field predicates - """ - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """ - block field predicates - """ - block: Uint - blockNEQ: Uint - blockIn: [Uint!] - blockNotIn: [Uint!] - blockGT: Uint - blockGTE: Uint - blockLT: Uint - blockLTE: Uint - """ - signersCount field predicates - """ - signerscount: Uint - signerscountNEQ: Uint - signerscountIn: [Uint!] - signerscountNotIn: [Uint!] - signerscountGT: Uint - signerscountGTE: Uint - signerscountLT: Uint - signerscountLTE: Uint - """ - address field predicates - """ - address: String - addressNEQ: String - addressIn: [String!] - addressNotIn: [String!] - addressGT: String - addressGTE: String - addressLT: String - addressLTE: String - addressContains: String - addressHasPrefix: String - addressHasSuffix: String - addressEqualFold: String - addressContainsFold: String - """ - chain field predicates - """ - chain: String - chainNEQ: String - chainIn: [String!] - chainNotIn: [String!] - chainGT: String - chainGTE: String - chainLT: String - chainLTE: String - chainContains: String - chainHasPrefix: String - chainHasSuffix: String - chainEqualFold: String - chainContainsFold: String - """ - index field predicates - """ - index: Uint - indexNEQ: Uint - indexIn: [Uint!] - indexNotIn: [Uint!] - indexGT: Uint - indexGTE: Uint - indexLT: Uint - indexLTE: Uint - """ - event field predicates - """ - event: String - eventNEQ: String - eventIn: [String!] - eventNotIn: [String!] - eventGT: String - eventGTE: String - eventLT: String - eventLTE: String - eventContains: String - eventHasPrefix: String - eventHasSuffix: String - eventEqualFold: String - eventContainsFold: String - """ - consensus field predicates - """ - consensus: Boolean - consensusNEQ: Boolean - """ - voted field predicates - """ - voted: Uint - votedNEQ: Uint - votedIn: [Uint!] - votedNotIn: [Uint!] - votedGT: Uint - votedGTE: Uint - votedLT: Uint - votedLTE: Uint - """ - signers edge predicates - """ - hasSigners: Boolean - hasSignersWith: [SignerWhereInput!] -} -""" -An object with an ID. -Follows the [Relay Global Object Identification Specification](https://relay.dev/graphql/objectidentification.htm) -""" -interface Node @goModel(model: "github.com/TimeleapLabs/unchained/internal/ent.Noder") { - """ - The id of the object. - """ - id: ID! -} -""" -Possible directions in which to order a list of items when provided an `orderBy` argument. -""" -enum OrderDirection { - """ - Specifies an ascending order for a given `orderBy` argument. - """ - ASC - """ - Specifies a descending order for a given `orderBy` argument. - """ - DESC -} -""" -Information about pagination in a connection. -https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo -""" -type PageInfo { - """ - When paginating forwards, are there more items? - """ - hasNextPage: Boolean! - """ - When paginating backwards, are there more items? - """ - hasPreviousPage: Boolean! - """ - When paginating backwards, the cursor to continue. - """ - startCursor: Cursor - """ - When paginating forwards, the cursor to continue. - """ - endCursor: Cursor -} -type Query { - """ - Fetches an object given its ID. - """ - node( - """ - ID of the object. - """ - id: ID! - ): Node - """ - Lookup nodes by a list of IDs. - """ - nodes( - """ - The list of node IDs. - """ - ids: [ID!]! - ): [Node]! - assetPrices( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for AssetPrices returned from the connection. - """ - orderBy: AssetPriceOrder - - """ - Filtering options for AssetPrices returned from the connection. - """ - where: AssetPriceWhereInput - ): AssetPriceConnection! - correctnessReports( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for CorrectnessReports returned from the connection. - """ - orderBy: CorrectnessReportOrder - - """ - Filtering options for CorrectnessReports returned from the connection. - """ - where: CorrectnessReportWhereInput - ): CorrectnessReportConnection! - eventLogs( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for EventLogs returned from the connection. - """ - orderBy: EventLogOrder - - """ - Filtering options for EventLogs returned from the connection. - """ - where: EventLogWhereInput - ): EventLogConnection! - signers( - """ - Returns the elements in the list that come after the specified cursor. - """ - after: Cursor - - """ - Returns the first _n_ elements from the list. - """ - first: Int - - """ - Returns the elements in the list that come before the specified cursor. - """ - before: Cursor - - """ - Returns the last _n_ elements from the list. - """ - last: Int - - """ - Ordering options for Signers returned from the connection. - """ - orderBy: SignerOrder - - """ - Filtering options for Signers returned from the connection. - """ - where: SignerWhereInput - ): SignerConnection! -} -type Signer implements Node { - id: ID! - name: String! - evm: String - key: Bytes! - shortkey: Bytes! - points: Int! - assetprice: [AssetPrice!] @goField(name: "AssetPrice", forceResolver: false) - eventlogs: [EventLog!] @goField(name: "EventLogs", forceResolver: false) - correctnessreport: [CorrectnessReport!] @goField(name: "CorrectnessReport", forceResolver: false) -} -""" -A connection to a list of items. -""" -type SignerConnection { - """ - A list of edges. - """ - edges: [SignerEdge] - """ - Information to aid in pagination. - """ - pageInfo: PageInfo! - """ - Identifies the total count of items in the connection. - """ - totalCount: Int! -} -""" -An edge in a connection. -""" -type SignerEdge { - """ - The item at the end of the edge. - """ - node: Signer - """ - A cursor for use in pagination. - """ - cursor: Cursor! -} -""" -Ordering options for Signer connections -""" -input SignerOrder { - """ - The ordering direction. - """ - direction: OrderDirection! = ASC - """ - The field by which to order Signers. - """ - field: SignerOrderField! -} -""" -Properties by which Signer connections can be ordered. -""" -enum SignerOrderField { - POINTS -} -""" -SignerWhereInput is used for filtering Signer objects. -Input was generated by ent. -""" -input SignerWhereInput { - not: SignerWhereInput - and: [SignerWhereInput!] - or: [SignerWhereInput!] - """ - id field predicates - """ - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """ - name field predicates - """ - name: String - nameNEQ: String - nameIn: [String!] - nameNotIn: [String!] - nameGT: String - nameGTE: String - nameLT: String - nameLTE: String - nameContains: String - nameHasPrefix: String - nameHasSuffix: String - nameEqualFold: String - nameContainsFold: String - """ - evm field predicates - """ - evm: String - evmNEQ: String - evmIn: [String!] - evmNotIn: [String!] - evmGT: String - evmGTE: String - evmLT: String - evmLTE: String - evmContains: String - evmHasPrefix: String - evmHasSuffix: String - evmIsNil: Boolean - evmNotNil: Boolean - evmEqualFold: String - evmContainsFold: String - """ - points field predicates - """ - points: Int - pointsNEQ: Int - pointsIn: [Int!] - pointsNotIn: [Int!] - pointsGT: Int - pointsGTE: Int - pointsLT: Int - pointsLTE: Int - """ - assetPrice edge predicates - """ - hasAssetPrice: Boolean - hasAssetPriceWith: [AssetPriceWhereInput!] - """ - eventLogs edge predicates - """ - hasEventLogs: Boolean - hasEventLogsWith: [EventLogWhereInput!] - """ - correctnessReport edge predicates - """ - hasCorrectnessReport: Boolean - hasCorrectnessReportWith: [CorrectnessReportWhereInput!] -} -""" -The builtin Uint type -""" -scalar Uint diff --git a/internal/transport/server/gql/unchained.resolvers.go b/internal/transport/server/gql/unchained.resolvers.go deleted file mode 100644 index 0c847bea..00000000 --- a/internal/transport/server/gql/unchained.resolvers.go +++ /dev/null @@ -1,342 +0,0 @@ -package gql - -// This file will be automatically regenerated based on the schema, any resolver implementations -// will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.45 - -import ( - "context" - "fmt" - "math/big" - - "entgo.io/contrib/entgql" - "github.com/TimeleapLabs/unchained/internal/ent" - "github.com/TimeleapLabs/unchained/internal/ent/helpers" - "github.com/TimeleapLabs/unchained/internal/transport/server/gql/generated" - "github.com/TimeleapLabs/unchained/internal/transport/server/gql/types" -) - -// Price is the resolver for the price field. -func (r *assetPriceResolver) Price(ctx context.Context, obj *ent.AssetPrice) (uint64, error) { - return obj.Price.Uint64(), nil -} - -// Signature is the resolver for the signature field. -func (r *assetPriceResolver) Signature(ctx context.Context, obj *ent.AssetPrice) (types.Bytes, error) { - return obj.Signature, nil -} - -// Voted is the resolver for the voted field. -func (r *assetPriceResolver) Voted(ctx context.Context, obj *ent.AssetPrice) (uint64, error) { - panic(fmt.Errorf("not implemented: Voted - voted")) -} - -// Signature is the resolver for the signature field. -func (r *correctnessReportResolver) Signature(ctx context.Context, obj *ent.CorrectnessReport) (types.Bytes, error) { - return obj.Signature, nil -} - -// Hash is the resolver for the hash field. -func (r *correctnessReportResolver) Hash(ctx context.Context, obj *ent.CorrectnessReport) (types.Bytes, error) { - return obj.Hash, nil -} - -// Topic is the resolver for the topic field. -func (r *correctnessReportResolver) Topic(ctx context.Context, obj *ent.CorrectnessReport) (types.Bytes, error) { - return obj.Topic, nil -} - -// Voted is the resolver for the voted field. -func (r *correctnessReportResolver) Voted(ctx context.Context, obj *ent.CorrectnessReport) (uint64, error) { - panic(fmt.Errorf("not implemented: Voted - voted")) -} - -// Signature is the resolver for the signature field. -func (r *eventLogResolver) Signature(ctx context.Context, obj *ent.EventLog) (types.Bytes, error) { - return obj.Signature, nil -} - -// Transaction is the resolver for the transaction field. -func (r *eventLogResolver) Transaction(ctx context.Context, obj *ent.EventLog) (types.Bytes, error) { - return obj.Transaction, nil -} - -// Voted is the resolver for the voted field. -func (r *eventLogResolver) Voted(ctx context.Context, obj *ent.EventLog) (uint64, error) { - panic(fmt.Errorf("not implemented: Voted - voted")) -} - -// Node is the resolver for the node field. -func (r *queryResolver) Node(ctx context.Context, id int) (ent.Noder, error) { - return r.client.Noder(ctx, id) -} - -// Nodes is the resolver for the nodes field. -func (r *queryResolver) Nodes(ctx context.Context, ids []int) ([]ent.Noder, error) { - return r.client.Noders(ctx, ids) -} - -// AssetPrices is the resolver for the assetPrices field. -func (r *queryResolver) AssetPrices(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.AssetPriceOrder, where *ent.AssetPriceWhereInput) (*ent.AssetPriceConnection, error) { - return r.client.AssetPrice.Query(). - Paginate(ctx, after, first, before, last, - ent.WithAssetPriceOrder(orderBy), - ent.WithAssetPriceFilter(where.Filter), - ) -} - -// CorrectnessReports is the resolver for the correctnessReports field. -func (r *queryResolver) CorrectnessReports(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.CorrectnessReportOrder, where *ent.CorrectnessReportWhereInput) (*ent.CorrectnessReportConnection, error) { - return r.client.CorrectnessReport.Query(). - Paginate(ctx, after, first, before, last, - ent.WithCorrectnessReportOrder(orderBy), - ent.WithCorrectnessReportFilter(where.Filter), - ) -} - -// EventLogs is the resolver for the eventLogs field. -func (r *queryResolver) EventLogs(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.EventLogOrder, where *ent.EventLogWhereInput) (*ent.EventLogConnection, error) { - return r.client.EventLog.Query(). - Paginate(ctx, after, first, before, last, - ent.WithEventLogOrder(orderBy), - ent.WithEventLogFilter(where.Filter), - ) -} - -// Signers is the resolver for the signers field. -func (r *queryResolver) Signers(ctx context.Context, after *entgql.Cursor[int], first *int, before *entgql.Cursor[int], last *int, orderBy *ent.SignerOrder, where *ent.SignerWhereInput) (*ent.SignerConnection, error) { - return r.client.Signer.Query(). - Paginate(ctx, after, first, before, last, - ent.WithSignerOrder(orderBy), - ent.WithSignerFilter(where.Filter), - ) -} - -// Key is the resolver for the key field. -func (r *signerResolver) Key(ctx context.Context, obj *ent.Signer) (types.Bytes, error) { - return obj.Key, nil -} - -// Shortkey is the resolver for the shortkey field. -func (r *signerResolver) Shortkey(ctx context.Context, obj *ent.Signer) (types.Bytes, error) { - return obj.Shortkey, nil -} - -// Price is the resolver for the price field. -func (r *assetPriceWhereInputResolver) Price(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - obj.Price = &helpers.BigInt{Int: *big.NewInt(int64(*data))} - return nil -} - -// PriceNeq is the resolver for the priceNEQ field. -func (r *assetPriceWhereInputResolver) PriceNeq(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - obj.PriceNEQ = &helpers.BigInt{Int: *big.NewInt(int64(*data))} - return nil -} - -// PriceIn is the resolver for the priceIn field. -func (r *assetPriceWhereInputResolver) PriceIn(ctx context.Context, obj *ent.AssetPriceWhereInput, data []uint64) error { - for _, value := range data { - obj.PriceIn = append(obj.PriceIn, &helpers.BigInt{Int: *big.NewInt(int64(value))}) - } - return nil -} - -// PriceNotIn is the resolver for the priceNotIn field. -func (r *assetPriceWhereInputResolver) PriceNotIn(ctx context.Context, obj *ent.AssetPriceWhereInput, data []uint64) error { - for _, value := range data { - obj.PriceNotIn = append(obj.PriceNotIn, &helpers.BigInt{Int: *big.NewInt(int64(value))}) - } - return nil -} - -// PriceGt is the resolver for the priceGT field. -func (r *assetPriceWhereInputResolver) PriceGt(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - obj.PriceGT = &helpers.BigInt{Int: *big.NewInt(int64(*data))} - return nil -} - -// PriceGte is the resolver for the priceGTE field. -func (r *assetPriceWhereInputResolver) PriceGte(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - obj.PriceGTE = &helpers.BigInt{Int: *big.NewInt(int64(*data))} - return nil -} - -// PriceLt is the resolver for the priceLT field. -func (r *assetPriceWhereInputResolver) PriceLt(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - obj.PriceLT = &helpers.BigInt{Int: *big.NewInt(int64(*data))} - return nil -} - -// PriceLte is the resolver for the priceLTE field. -func (r *assetPriceWhereInputResolver) PriceLte(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - obj.PriceLTE = &helpers.BigInt{Int: *big.NewInt(int64(*data))} - return nil -} - -// Voted is the resolver for the voted field. -func (r *assetPriceWhereInputResolver) Voted(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: Voted - voted")) -} - -// VotedNeq is the resolver for the votedNEQ field. -func (r *assetPriceWhereInputResolver) VotedNeq(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedNeq - votedNEQ")) -} - -// VotedIn is the resolver for the votedIn field. -func (r *assetPriceWhereInputResolver) VotedIn(ctx context.Context, obj *ent.AssetPriceWhereInput, data []uint64) error { - panic(fmt.Errorf("not implemented: VotedIn - votedIn")) -} - -// VotedNotIn is the resolver for the votedNotIn field. -func (r *assetPriceWhereInputResolver) VotedNotIn(ctx context.Context, obj *ent.AssetPriceWhereInput, data []uint64) error { - panic(fmt.Errorf("not implemented: VotedNotIn - votedNotIn")) -} - -// VotedGt is the resolver for the votedGT field. -func (r *assetPriceWhereInputResolver) VotedGt(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedGt - votedGT")) -} - -// VotedGte is the resolver for the votedGTE field. -func (r *assetPriceWhereInputResolver) VotedGte(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedGte - votedGTE")) -} - -// VotedLt is the resolver for the votedLT field. -func (r *assetPriceWhereInputResolver) VotedLt(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedLt - votedLT")) -} - -// VotedLte is the resolver for the votedLTE field. -func (r *assetPriceWhereInputResolver) VotedLte(ctx context.Context, obj *ent.AssetPriceWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedLte - votedLTE")) -} - -// Voted is the resolver for the voted field. -func (r *correctnessReportWhereInputResolver) Voted(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: Voted - voted")) -} - -// VotedNeq is the resolver for the votedNEQ field. -func (r *correctnessReportWhereInputResolver) VotedNeq(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedNeq - votedNEQ")) -} - -// VotedIn is the resolver for the votedIn field. -func (r *correctnessReportWhereInputResolver) VotedIn(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data []uint64) error { - panic(fmt.Errorf("not implemented: VotedIn - votedIn")) -} - -// VotedNotIn is the resolver for the votedNotIn field. -func (r *correctnessReportWhereInputResolver) VotedNotIn(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data []uint64) error { - panic(fmt.Errorf("not implemented: VotedNotIn - votedNotIn")) -} - -// VotedGt is the resolver for the votedGT field. -func (r *correctnessReportWhereInputResolver) VotedGt(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedGt - votedGT")) -} - -// VotedGte is the resolver for the votedGTE field. -func (r *correctnessReportWhereInputResolver) VotedGte(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedGte - votedGTE")) -} - -// VotedLt is the resolver for the votedLT field. -func (r *correctnessReportWhereInputResolver) VotedLt(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedLt - votedLT")) -} - -// VotedLte is the resolver for the votedLTE field. -func (r *correctnessReportWhereInputResolver) VotedLte(ctx context.Context, obj *ent.CorrectnessReportWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedLte - votedLTE")) -} - -// Voted is the resolver for the voted field. -func (r *eventLogWhereInputResolver) Voted(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: Voted - voted")) -} - -// VotedNeq is the resolver for the votedNEQ field. -func (r *eventLogWhereInputResolver) VotedNeq(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedNeq - votedNEQ")) -} - -// VotedIn is the resolver for the votedIn field. -func (r *eventLogWhereInputResolver) VotedIn(ctx context.Context, obj *ent.EventLogWhereInput, data []uint64) error { - panic(fmt.Errorf("not implemented: VotedIn - votedIn")) -} - -// VotedNotIn is the resolver for the votedNotIn field. -func (r *eventLogWhereInputResolver) VotedNotIn(ctx context.Context, obj *ent.EventLogWhereInput, data []uint64) error { - panic(fmt.Errorf("not implemented: VotedNotIn - votedNotIn")) -} - -// VotedGt is the resolver for the votedGT field. -func (r *eventLogWhereInputResolver) VotedGt(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedGt - votedGT")) -} - -// VotedGte is the resolver for the votedGTE field. -func (r *eventLogWhereInputResolver) VotedGte(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedGte - votedGTE")) -} - -// VotedLt is the resolver for the votedLT field. -func (r *eventLogWhereInputResolver) VotedLt(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedLt - votedLT")) -} - -// VotedLte is the resolver for the votedLTE field. -func (r *eventLogWhereInputResolver) VotedLte(ctx context.Context, obj *ent.EventLogWhereInput, data *uint64) error { - panic(fmt.Errorf("not implemented: VotedLte - votedLTE")) -} - -// AssetPrice returns generated.AssetPriceResolver implementation. -func (r *Resolver) AssetPrice() generated.AssetPriceResolver { return &assetPriceResolver{r} } - -// CorrectnessReport returns generated.CorrectnessReportResolver implementation. -func (r *Resolver) CorrectnessReport() generated.CorrectnessReportResolver { - return &correctnessReportResolver{r} -} - -// EventLog returns generated.EventLogResolver implementation. -func (r *Resolver) EventLog() generated.EventLogResolver { return &eventLogResolver{r} } - -// Query returns generated.QueryResolver implementation. -func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } - -// Signer returns generated.SignerResolver implementation. -func (r *Resolver) Signer() generated.SignerResolver { return &signerResolver{r} } - -// AssetPriceWhereInput returns generated.AssetPriceWhereInputResolver implementation. -func (r *Resolver) AssetPriceWhereInput() generated.AssetPriceWhereInputResolver { - return &assetPriceWhereInputResolver{r} -} - -// CorrectnessReportWhereInput returns generated.CorrectnessReportWhereInputResolver implementation. -func (r *Resolver) CorrectnessReportWhereInput() generated.CorrectnessReportWhereInputResolver { - return &correctnessReportWhereInputResolver{r} -} - -// EventLogWhereInput returns generated.EventLogWhereInputResolver implementation. -func (r *Resolver) EventLogWhereInput() generated.EventLogWhereInputResolver { - return &eventLogWhereInputResolver{r} -} - -// SignerWhereInput returns generated.SignerWhereInputResolver implementation. -func (r *Resolver) SignerWhereInput() generated.SignerWhereInputResolver { - return &signerWhereInputResolver{r} -} - -type assetPriceResolver struct{ *Resolver } -type correctnessReportResolver struct{ *Resolver } -type eventLogResolver struct{ *Resolver } -type queryResolver struct{ *Resolver } -type signerResolver struct{ *Resolver } -type assetPriceWhereInputResolver struct{ *Resolver } -type correctnessReportWhereInputResolver struct{ *Resolver } -type eventLogWhereInputResolver struct{ *Resolver } -type signerWhereInputResolver struct{ *Resolver } diff --git a/internal/model/kosk.go b/internal/transport/server/packet/challenge.go similarity index 97% rename from internal/model/kosk.go rename to internal/transport/server/packet/challenge.go index 0a9fe4c6..2b498fb9 100644 --- a/internal/model/kosk.go +++ b/internal/transport/server/packet/challenge.go @@ -1,4 +1,4 @@ -package model +package packet import sia "github.com/pouya-eghbali/go-sia/v2/pkg" diff --git a/internal/transport/server/packet/correctness.go b/internal/transport/server/packet/correctness.go new file mode 100644 index 00000000..c91c330d --- /dev/null +++ b/internal/transport/server/packet/correctness.go @@ -0,0 +1,49 @@ +package packet + +import ( + "github.com/TimeleapLabs/unchained/internal/model" + sia "github.com/pouya-eghbali/go-sia/v2/pkg" +) + +type CorrectnessReportPacket struct { + model.Correctness + Signature [48]byte +} + +func (c *CorrectnessReportPacket) Sia() sia.Sia { + return sia.New(). + EmbedBytes(c.Correctness.Sia().Bytes()). + AddByteArray8(c.Signature[:]) +} + +func (c *CorrectnessReportPacket) FromBytes(payload []byte) *CorrectnessReportPacket { + siaMessage := sia.NewFromBytes(payload) + + c.Correctness.FromSia(siaMessage) + copy(c.Signature[:], siaMessage.ReadByteArray8()) + + return c +} + +type BroadcastCorrectnessPacket struct { + Info model.Correctness + Signature [48]byte + Signer model.Signer +} + +func (b *BroadcastCorrectnessPacket) Sia() sia.Sia { + return sia.New(). + EmbedBytes(b.Info.Sia().Bytes()). + AddByteArray8(b.Signature[:]). + EmbedBytes(b.Signer.Sia().Bytes()) +} + +func (b *BroadcastCorrectnessPacket) FromBytes(payload []byte) *BroadcastCorrectnessPacket { + siaMessage := sia.NewFromBytes(payload) + + b.Info.FromSia(siaMessage) + copy(b.Signature[:], siaMessage.ReadByteArray8()) + b.Signer.FromSia(siaMessage) + + return b +} diff --git a/internal/transport/server/packet/eventlog.go b/internal/transport/server/packet/eventlog.go new file mode 100644 index 00000000..8a753a87 --- /dev/null +++ b/internal/transport/server/packet/eventlog.go @@ -0,0 +1,48 @@ +package packet + +import ( + "github.com/TimeleapLabs/unchained/internal/model" + sia "github.com/pouya-eghbali/go-sia/v2/pkg" +) + +type EventLogReportPacket struct { + model.EventLog + Signature [48]byte +} + +func (e *EventLogReportPacket) Sia() sia.Sia { + return sia.New(). + EmbedBytes(e.EventLog.Sia().Bytes()). + AddByteArray8(e.Signature[:]) +} + +func (e *EventLogReportPacket) FromBytes(payload []byte) *EventLogReportPacket { + siaMessage := sia.NewFromBytes(payload) + e.EventLog.FromSia(siaMessage) + copy(e.Signature[:], siaMessage.ReadByteArray8()) + + return e +} + +type BroadcastEventPacket struct { + Info model.EventLog + Signature [48]byte + Signer model.Signer +} + +func (b *BroadcastEventPacket) Sia() sia.Sia { + return sia.New(). + EmbedBytes(b.Info.Sia().Bytes()). + AddByteArray8(b.Signature[:]). + EmbedBytes(b.Signer.Sia().Bytes()) +} + +func (b *BroadcastEventPacket) FromBytes(payload []byte) *BroadcastEventPacket { + siaMessage := sia.NewFromBytes(payload) + + b.Info.FromSia(siaMessage) + copy(b.Signature[:], siaMessage.ReadByteArray8()) + b.Signer.FromSia(siaMessage) + + return b +} diff --git a/internal/transport/server/packet/price.go b/internal/transport/server/packet/price.go new file mode 100644 index 00000000..6fe51e44 --- /dev/null +++ b/internal/transport/server/packet/price.go @@ -0,0 +1,52 @@ +package packet + +import ( + "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/service/uniswap/types" + sia "github.com/pouya-eghbali/go-sia/v2/pkg" +) + +type PriceReportPacket struct { + PriceInfo types.PriceInfo + Signature [48]byte +} + +func (p *PriceReportPacket) Sia() sia.Sia { + return sia.New(). + EmbedBytes(p.PriceInfo.Sia().Bytes()). + AddByteArray8(p.Signature[:]) +} + +func (p *PriceReportPacket) FromBytes(payload []byte) *PriceReportPacket { + siaMessage := sia.NewFromBytes(payload) + return p.FromSia(siaMessage) +} + +func (p *PriceReportPacket) FromSia(sia sia.Sia) *PriceReportPacket { + p.PriceInfo.FromSia(sia) + copy(p.Signature[:], sia.ReadByteArray8()) + + return p +} + +type BroadcastPricePacket struct { + Info types.PriceInfo + Signature [48]byte + Signer model.Signer +} + +func (b *BroadcastPricePacket) Sia() sia.Sia { + return sia.New(). + EmbedBytes(b.Info.Sia().Bytes()). + AddByteArray8(b.Signature[:]). + EmbedBytes(b.Signer.Sia().Bytes()) +} + +func (b *BroadcastPricePacket) FromBytes(payload []byte) *BroadcastPricePacket { + siaMessage := sia.NewFromBytes(payload) + b.Info.FromSia(siaMessage) + copy(b.Signature[:], siaMessage.ReadByteArray8()) + b.Signer.FromSia(siaMessage) + + return b +} diff --git a/internal/transport/server/websocket/handler/hello.go b/internal/transport/server/websocket/handler/hello.go index 5b967bdf..50571859 100644 --- a/internal/transport/server/websocket/handler/hello.go +++ b/internal/transport/server/websocket/handler/hello.go @@ -3,6 +3,7 @@ package handler import ( "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" "github.com/TimeleapLabs/unchained/internal/transport/server/websocket/store" "github.com/TimeleapLabs/unchained/internal/utils" "github.com/gorilla/websocket" @@ -31,7 +32,7 @@ func Hello(conn *websocket.Conn, payload []byte) { store.Signers.Store(conn, *signer) // Start KOSK verification - challenge := model.ChallengePacket{Random: utils.NewChallenge()} + challenge := packet.ChallengePacket{Random: utils.NewChallenge()} store.Challenges.Store(conn, challenge) SendMessage(conn, consts.OpCodeFeedback, "conf.ok") diff --git a/internal/transport/server/websocket/store/store.go b/internal/transport/server/websocket/store/store.go index 6bf69d7e..67eb731f 100644 --- a/internal/transport/server/websocket/store/store.go +++ b/internal/transport/server/websocket/store/store.go @@ -2,10 +2,11 @@ package store import ( "github.com/TimeleapLabs/unchained/internal/model" + "github.com/TimeleapLabs/unchained/internal/transport/server/packet" "github.com/gorilla/websocket" "github.com/puzpuzpuz/xsync/v3" ) -var Challenges = xsync.NewMapOf[*websocket.Conn, model.ChallengePacket]() +var Challenges = xsync.NewMapOf[*websocket.Conn, packet.ChallengePacket]() var Signers = xsync.NewMapOf[*websocket.Conn, model.Signer]() From 5f05f0263aa1c6379b290ab781af78c723220da3 Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Sat, 6 Jul 2024 19:18:12 +0330 Subject: [PATCH 14/26] fix-service-tests --- internal/crypto/bls/identity.go | 14 +++ internal/service/correctness/correctness.go | 27 +++-- .../service/correctness/correctness_test.go | 98 +++++++++++-------- .../transport/client/handler/correctness.go | 4 - .../transport/database/mock/postgres_mock.go | 4 +- 5 files changed, 87 insertions(+), 60 deletions(-) diff --git a/internal/crypto/bls/identity.go b/internal/crypto/bls/identity.go index b8a57bfd..68adac3b 100644 --- a/internal/crypto/bls/identity.go +++ b/internal/crypto/bls/identity.go @@ -73,6 +73,20 @@ func NewIdentity() *Signer { return s } +func GenerateBlsKeyPair() (*big.Int, *bls12381.G2Affine, *bls12381.G1Affine) { + _, _, g1Aff, g2Aff := bls12381.Generators() + + g2Order := bls12381_fr.Modulus() + sk, err := rand.Int(rand.Reader, g2Order) + if err != nil { + panic(err) + } + + pk := new(bls12381.G2Affine).ScalarMultiplication(&g2Aff, sk) + + return sk, pk, new(bls12381.G1Affine).ScalarMultiplication(&g1Aff, sk) +} + // Sign signs a message with the identities secret key. func (s *Signer) Sign(message []byte) (bls12381.G1Affine, bls12381.G1Affine) { hashedMessage, err := Hash(message) diff --git a/internal/service/correctness/correctness.go b/internal/service/correctness/correctness.go index 802337ba..ff6ac8da 100644 --- a/internal/service/correctness/correctness.go +++ b/internal/service/correctness/correctness.go @@ -37,9 +37,8 @@ type SaveSignatureArgs struct { type Service interface { IsNewSigner(signature Signature, records []model.Correctness) bool RecordSignature( - ctx context.Context, signature bls12381.G1Affine, signer model.Signer, hash bls12381.G1Affine, info model.Correctness, debounce bool, + ctx context.Context, signature bls12381.G1Affine, signer model.Signer, info model.Correctness, debounce bool, ) error - SaveSignatures(ctx context.Context, args SaveSignatureArgs) error } type service struct { @@ -72,7 +71,7 @@ func (s *service) IsNewSigner(signature Signature, records []model.Correctness) // TODO: How should we handle older records? // Possible Solution: Add a not after timestamp to the document. func (s *service) RecordSignature( - ctx context.Context, signature bls12381.G1Affine, signer model.Signer, hash bls12381.G1Affine, info model.Correctness, debounce bool, + ctx context.Context, signature bls12381.G1Affine, signer model.Signer, info model.Correctness, debounce bool, ) error { if supported := s.supportedTopics[info.Topic]; !supported { utils.Logger. @@ -84,7 +83,7 @@ func (s *service) RecordSignature( s.signatureMutex.Lock() defer s.signatureMutex.Unlock() - signatures, ok := s.signatureCache.Get(hash) + signatures, ok := s.signatureCache.Get(info.Bls()) if !ok { signatures = make([]Signature, 0) } @@ -113,7 +112,7 @@ func (s *service) RecordSignature( reportedValues, _ := s.consensus.Get(key) isMajority := true - voted, ok := reportedValues.Load(hash) + voted, ok := reportedValues.Load(info.Bls()) if !ok { voted = *big.NewInt(0) } @@ -136,23 +135,23 @@ func (s *service) RecordSignature( return isMajority }) - reportedValues.Store(hash, *totalVoted) + reportedValues.Store(info.Bls(), *totalVoted) signatures = append(signatures, packed) - s.signatureCache.Add(hash, signatures) + s.signatureCache.Add(info.Bls(), signatures) saveArgs := SaveSignatureArgs{ Info: info, - Hash: hash, + Hash: info.Bls(), Consensus: isMajority, Voted: totalVoted, } if debounce { - s.DebouncedSaveSignatures(hash, saveArgs) + s.DebouncedSaveSignatures(info.Bls(), saveArgs) return nil } - err = s.SaveSignatures(ctx, saveArgs) + err = s.saveSignatures(ctx, saveArgs) if err != nil { return err } @@ -160,7 +159,7 @@ func (s *service) RecordSignature( return nil } -func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) error { +func (s *service) saveSignatures(ctx context.Context, args SaveSignatureArgs) error { signatures, ok := s.signatureCache.Get(args.Hash) if !ok { return consts.ErrSignatureNotfound @@ -250,9 +249,7 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er func (s *service) init() { var err error - s.DebouncedSaveSignatures = utils.Debounce[bls12381.G1Affine, SaveSignatureArgs](5*time.Second, s.SaveSignatures) - s.signatureMutex = new(sync.Mutex) - s.supportedTopics = make(map[[64]byte]bool) + s.DebouncedSaveSignatures = utils.Debounce[bls12381.G1Affine, SaveSignatureArgs](5*time.Second, s.saveSignatures) s.signatureCache, err = lru.New[bls12381.G1Affine, []Signature](LruSize) if err != nil { @@ -269,6 +266,8 @@ func New( pos: pos, signerRepo: signerRepo, correctnessRepo: correctnessRepo, + signatureMutex: new(sync.Mutex), + supportedTopics: make(map[[64]byte]bool), } c.init() diff --git a/internal/service/correctness/correctness_test.go b/internal/service/correctness/correctness_test.go index a70024d1..1345faf4 100644 --- a/internal/service/correctness/correctness_test.go +++ b/internal/service/correctness/correctness_test.go @@ -1,6 +1,11 @@ package correctness import ( + "context" + "github.com/TimeleapLabs/unchained/internal/config" + "github.com/TimeleapLabs/unchained/internal/crypto/bls" + "github.com/TimeleapLabs/unchained/internal/utils" + mock2 "github.com/stretchr/testify/mock" "testing" "github.com/TimeleapLabs/unchained/internal/model" @@ -12,87 +17,100 @@ import ( ) var ( - SignerOne = Signature{ + SignatureOne = Signature{ Signer: model.Signer{ - PublicKey: [96]byte{1, 2, 3}, + PublicKey: [96]byte{1, 2, 3}, + ShortPublicKey: [48]byte{1, 2, 3}, }, } - SignerTwo = Signature{ + SignatureTwo = Signature{ Signer: model.Signer{ - PublicKey: [96]byte{3, 2, 1}, + PublicKey: [96]byte{3, 2, 1}, + ShortPublicKey: [48]byte{1, 2, 3}, }, } + sampleSigner = model.Signer{ + Name: "", + EvmAddress: "12345", + PublicKey: [96]byte{3, 2, 1}, + ShortPublicKey: [48]byte{1, 2, 3}, + } ) +var SampleCorrectness = []model.Correctness{ + { + SignersCount: 1, + Topic: [64]byte(utils.Shake([]byte("123"))), + Signers: []model.Signer{ + { + Name: "test-1", + EvmAddress: "12345", + PublicKey: [96]byte{3, 2, 1}, + ShortPublicKey: [48]byte{3, 2, 1}, + }, + }, + }, +} + type CorrectnessTestSuite struct { suite.Suite service Service } func (s *CorrectnessTestSuite) SetupTest() { + utils.SetupLogger("info") db := mock.New(s.T()) posService := new(pos.MockService) + posService.On("GetVotingPowerOfEvm", mock2.Anything, "12345").Return(10, nil) signerRepo := postgresRepo.NewSigner(db) correctnessRepo := postgresRepo.NewCorrectness(db) + config.App.Plugins.Correctness = []string{"123"} s.service = New(posService, signerRepo, correctnessRepo) } func (s *CorrectnessTestSuite) TestIsNewSigner() { s.Run("Check if new signer with empty values", func() { isSigner := s.service.IsNewSigner(Signature{}, []model.Correctness{}) - assert.False(s.T(), isSigner) + assert.True(s.T(), isSigner) }) s.Run("Check when sign is new signer", func() { - signers := make([]byte, 96) - for i := 1; i < 4; i++ { - signers[i] = byte(i) - } - isSigner := s.service.IsNewSigner( - SignerOne, - []model.Correctness{ - //{ - // Edges: ent.CorrectnessReportEdges{ - // Signers: []*ent.Signer{ - // { - // Key: signers, - // }, - // }, - // }, - // }, - }, + SignatureOne, + SampleCorrectness, ) assert.True(s.T(), isSigner) }) s.Run("Check when sign is not new signer", func() { - signers := make([]byte, 96) - for i := 2; i < 4; i++ { - signers[i] = byte(i) - } - isSigner := s.service.IsNewSigner( - SignerTwo, - []model.Correctness{ - { - //Edges: ent.CorrectnessReportEdges{ - // Signers: []*ent.Signer{ - // { - // Key: signers, - // }, - // }, - // }, - }, - }, + SignatureTwo, + SampleCorrectness, ) - assert.True(s.T(), isSigner) + + assert.False(s.T(), isSigner) }) } +func (s *CorrectnessTestSuite) TestRecordSignatures() { + _, _, shortPublicKey := bls.GenerateBlsKeyPair() + + signature, err := bls.RecoverSignature(shortPublicKey.Bytes()) + s.Require().NoError(err) + + err = s.service.RecordSignature( + context.TODO(), + signature, + sampleSigner, + SampleCorrectness[0], + false, + ) + s.Require().NoError(err) +} + func TestCorrectnessSuite(t *testing.T) { suite.Run(t, new(CorrectnessTestSuite)) } diff --git a/internal/transport/client/handler/correctness.go b/internal/transport/client/handler/correctness.go index fdd3c0b0..b35b9f43 100644 --- a/internal/transport/client/handler/correctness.go +++ b/internal/transport/client/handler/correctness.go @@ -2,7 +2,6 @@ package handler import ( "context" - "github.com/TimeleapLabs/unchained/internal/transport/server/packet" "github.com/TimeleapLabs/unchained/internal/crypto/bls" @@ -12,8 +11,6 @@ import ( func (h *consumer) CorrectnessReport(ctx context.Context, message []byte) { packet := new(packet.BroadcastCorrectnessPacket).FromBytes(message) - correctnessHash := packet.Info.Bls() - signature, err := bls.RecoverSignature(packet.Signature) if err != nil { utils.Logger. @@ -27,7 +24,6 @@ func (h *consumer) CorrectnessReport(ctx context.Context, message []byte) { ctx, signature, packet.Signer, - correctnessHash, packet.Info, true, ) diff --git a/internal/transport/database/mock/postgres_mock.go b/internal/transport/database/mock/postgres_mock.go index 5827cd5b..da1010d3 100644 --- a/internal/transport/database/mock/postgres_mock.go +++ b/internal/transport/database/mock/postgres_mock.go @@ -30,7 +30,7 @@ func (m *mockConnection) GetConnection() *gorm.DB { User: "postgres", Password: "password", Host: "localhost", - Port: "5433", + Port: "5432", Options: "sslmode=disable", }, pgtestdb.NoopMigrator{}, @@ -38,7 +38,7 @@ func (m *mockConnection) GetConnection() *gorm.DB { var err error m.db, err = gorm.Open( - postgres.Open("postgresql://postgres:password@127.0.0.1:5433/unchained?sslmode=disable"), + postgres.Open("postgresql://postgres:password@127.0.0.1:5432/unchained?sslmode=disable"), &gorm.Config{ Logger: logger.Default.LogMode(logger.Warn), TranslateError: true, From fb8e91d7a2429f26b159ea842610f67897bbbc1d Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Fri, 6 Sep 2024 03:17:09 +0330 Subject: [PATCH 15/26] =?UTF-8?q?=F0=9F=93=9D=20docs(concept):=20add=20som?= =?UTF-8?q?e=20charts=20and=20defenition=20>>>=20=E2=8F=B0=204h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Concept.md | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Concept.md diff --git a/Concept.md b/Concept.md new file mode 100644 index 00000000..cbc0d5b1 --- /dev/null +++ b/Concept.md @@ -0,0 +1,71 @@ + +## Project Structure + +The Project follows the Clean Architecture pattern. The project is divided into the following layers: + +- Services: This layer contains the business logic of the application. +- Repository: This layer contains the data access logic of the application which can be implemented for postgres, mongodb, etc. +- Handler: This layer contains the adapters for websocket packet processing. + +and the layout is inspired by this [repository](https://github.com/evrone/go-clean-template), also with some modifications. + +## Federated Network + +The Unchained network is a federated network that consists of three types of nodes: Broker, Worker, and Consumer. Anyone can run a new node and help the network to process the load and requests. + +### Broker + +The broker nodes are responsible for managing the network and routing the data to the correct worker and consumer nodes. The clients of brokers consist of following: + +- Consumers: They listen to the data from the brokers and save or use them. +- Workers: They process the data and send them the brokers. +- Clients: They request to run a rpc function. + +```mermaid + graph TD; + U([ٌClient]) <--> |Websocket| W[Server] + X([ٌWorker]) <--> |Websocket| W[Server] + V([Consumer]) <--> |Websocket| W[Server] + W[Server] --> |Sign & Verify| T[Machine Identity] + +``` + +### Worker + +The workers are the nodes that process the data and send them to the broker. The workers can be a service that listens to the data from the blockchain, or a service that listens to the data from the broker. These services hold different business logics and will provide different services to the network. +```mermaid + graph TD; + Y[Ethereum Network] --> A[EvmLog Scheduler] + Y[Ethereum Network] --> B[Uniswap Scheduler] + A[EvmLog Scheduler] --> |Every x sec| W[Services] + B[Uniswap Scheduler] --> |Every x sec| W[Services] + + V[Broker] <--> |Websocket| W[Services] + W[Services] --> |Sign & Verify| T[Machine Identity] + +``` + +### Consumer + +The consumers are the nodes that listen to the data from the broker and save or use them. These data be saved in a database, or be served to the users by an API. + +```mermaid + graph TD; + V[Broker's Update] --> |Websocket| W[Services] + W[Services] --> |Sign & Verify| T[Machine Identity] + W[Services] --> |Save Data| Z[Database] +``` + +## Identity and Security + +In a network like Unchained we send and receive many data from other parties and we need to identify and validate the data sender. in other hand, we communicate with different blockchains and every node needs to keep the keys and addresses of the blockchain. + +These keys are hold on a global machine identity and will used once the node wants to sign a message or verify a message. + +### BLS + +A BLS digital signature, also known as Boneh–Lynn–Shacham (BLS), is a cryptographic signature scheme which allows a user to verify that a signer is authentic. The scheme uses a bilinear pairing for verification, and signatures are elements of an elliptic curve group. + +### Ethereum + +A Key pair of private and public keys which represent the identity of the node in the Ethereum network. and address of smart contract which is used to sync the nodes together. \ No newline at end of file From 2c62371feffc1b4e49d6277ca35ea51b68a5814e Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Fri, 13 Sep 2024 17:35:47 +0330 Subject: [PATCH 16/26] =?UTF-8?q?=F0=9F=93=9D=20docs(comments):=20update?= =?UTF-8?q?=20and=20complete=20comment=20docs=20of=20layers=20>>>=20?= =?UTF-8?q?=E2=8F=B0=203h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Concept.md => Developer-Guide.md | 0 Readme.md | 1 + cmd/handler/plugin.go | 20 ------------------- cmd/handler/plugins/ai.go | 4 ++-- cmd/handler/plugins/common.go | 2 ++ cmd/handler/plugins/text_to_image.go | 4 ++-- cmd/handler/plugins/translate.go | 4 ++-- internal/app/consumer.go | 4 ++-- internal/app/worker.go | 17 +++++++++------- internal/config/config.go | 3 +++ internal/config/model.go | 19 ++++++++++++++++++ internal/consts/channels.go | 1 + internal/consts/errors.go | 1 + internal/consts/meta.go | 2 ++ internal/consts/opcodes.go | 1 + internal/crypto/bls/identity.go | 1 + internal/repository/repository.go | 6 ++++++ internal/service/ai/common.go | 2 ++ internal/service/ai/text_to_image.go | 1 + internal/service/correctness/correctness.go | 8 +------- internal/service/correctness/types.go | 8 ++++++++ internal/service/evmlog/evmlog.go | 6 ++++++ internal/transport/client/client.go | 1 + internal/transport/client/conn/conn.go | 6 ++---- .../transport/client/handler/challenge.go | 2 ++ internal/transport/client/handler/consumer.go | 2 ++ .../transport/client/handler/correctness.go | 2 ++ internal/transport/client/handler/event.go | 2 ++ internal/transport/client/handler/handler.go | 1 + internal/transport/client/handler/price.go | 2 ++ internal/transport/client/handler/rpc.go | 4 ++++ 31 files changed, 91 insertions(+), 46 deletions(-) rename Concept.md => Developer-Guide.md (100%) diff --git a/Concept.md b/Developer-Guide.md similarity index 100% rename from Concept.md rename to Developer-Guide.md diff --git a/Readme.md b/Readme.md index 840ca853..4464743b 100644 --- a/Readme.md +++ b/Readme.md @@ -27,6 +27,7 @@ Cryptographic signatures and a proof-of-stake consensus secure all computations - [QuickStart](./quickstart.md) for running a node - [Schema](./schema.md) of the Unchained network - [Changelog](./CHANGELOG.md) of Unchained +- [Developer Guide](./Developer-Guide.md) if you are developer and wanna participate - [Contributing](./CONTRIBUTING.md) to Unchained ## License diff --git a/cmd/handler/plugin.go b/cmd/handler/plugin.go index 1f1dafb9..18d6efa6 100644 --- a/cmd/handler/plugin.go +++ b/cmd/handler/plugin.go @@ -4,29 +4,9 @@ import ( "os" "github.com/TimeleapLabs/unchained/cmd/handler/plugins" - "github.com/gorilla/websocket" "github.com/spf13/cobra" ) -var conn *websocket.Conn - -func Read() <-chan []byte { - out := make(chan []byte) - - go func() { - for { - _, payload, err := conn.ReadMessage() - if err != nil { - panic(err) - } - - out <- payload - } - }() - - return out -} - // plugin represents the plugin command. var plugin = &cobra.Command{ Use: "plugin", diff --git a/cmd/handler/plugins/ai.go b/cmd/handler/plugins/ai.go index e2e4edff..173c8cf3 100644 --- a/cmd/handler/plugins/ai.go +++ b/cmd/handler/plugins/ai.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/cobra" ) -// worker represents the worker command. +// aiPlugin represents the ai command. var aiPlugin = &cobra.Command{ Use: "ai", Short: "Start the Unchained ai server for local invocation", @@ -35,7 +35,7 @@ var aiPlugin = &cobra.Command{ }, } -// WithRunCmd appends the run command to the root command. +// WithAIPluginCmd appends the run command to the root command. func WithAIPluginCmd(cmd *cobra.Command) { cmd.AddCommand(aiPlugin) } diff --git a/cmd/handler/plugins/common.go b/cmd/handler/plugins/common.go index 8916ab15..9604d1b8 100644 --- a/cmd/handler/plugins/common.go +++ b/cmd/handler/plugins/common.go @@ -5,6 +5,7 @@ import "github.com/gorilla/websocket" var conn *websocket.Conn var closed = false +// Read is a function that reads messages from the websocket connection. func Read() <-chan []byte { out := make(chan []byte) @@ -24,6 +25,7 @@ func Read() <-chan []byte { return out } +// CloseSocket is a function that closes the websocket connection. func CloseSocket() { if conn != nil { closed = true diff --git a/cmd/handler/plugins/text_to_image.go b/cmd/handler/plugins/text_to_image.go index 13e134a9..38bf5381 100644 --- a/cmd/handler/plugins/text_to_image.go +++ b/cmd/handler/plugins/text_to_image.go @@ -7,7 +7,7 @@ import ( "github.com/spf13/cobra" ) -// worker represents the worker command. +// textToImagePlugin represents the text-to-image plugin command. var textToImagePlugin = &cobra.Command{ Use: "text-to-image", Short: "Run the text-to-image plugin locally", @@ -39,7 +39,7 @@ var textToImagePlugin = &cobra.Command{ }, } -// WithRunCmd appends the run command to the root command. +// WithTextToImagePluginCmd appends the run command to the root command. func WithTextToImagePluginCmd(cmd *cobra.Command) { cmd.AddCommand(textToImagePlugin) } diff --git a/cmd/handler/plugins/translate.go b/cmd/handler/plugins/translate.go index 46453f16..37f348b3 100644 --- a/cmd/handler/plugins/translate.go +++ b/cmd/handler/plugins/translate.go @@ -11,7 +11,7 @@ import ( "github.com/spf13/cobra" ) -// worker represents the worker command. +// translatePlugin represents the translate plugin command. var translatePlugin = &cobra.Command{ Use: "translate", Short: "Run the translate plugin locally", @@ -96,7 +96,7 @@ var translatePlugin = &cobra.Command{ }, } -// WithRunCmd appends the run command to the root command. +// WithTranslatePluginCmd appends the run command to the root command. func WithTranslatePluginCmd(cmd *cobra.Command) { cmd.AddCommand(translatePlugin) } diff --git a/internal/app/consumer.go b/internal/app/consumer.go index 6a3dfe38..db7978ae 100644 --- a/internal/app/consumer.go +++ b/internal/app/consumer.go @@ -64,8 +64,8 @@ func Consumer() { conn.Start() - handler := handler.NewConsumerHandler(correctnessService, uniswapService, evmLogService) - client.NewRPC(handler) + consumerHandler := handler.NewConsumerHandler(_correctnessService, _uniswapService, _evmLogService) + client.NewRPC(consumerHandler) select {} } diff --git a/internal/app/worker.go b/internal/app/worker.go index 4f1ef5d8..76978c62 100644 --- a/internal/app/worker.go +++ b/internal/app/worker.go @@ -34,7 +34,6 @@ func Worker(_ context.Context) { ) ethRPC := ethereum.New() - pos := pos.New(ethRPC) eventLogRepo := postgres.NewEventLog(nil) proofRepo := postgres.NewProof(nil) @@ -43,6 +42,10 @@ func Worker(_ context.Context) { badger := evmlogService.NewBadger(config.App.System.ContextPath) evmLogService := evmlogService.New(ethRPC, pos, eventLogRepo, proofRepo, badger) uniswapService := uniswapService.New(ethRPC, pos, proofRepo, assetPrice) + _posService := pos.New(ethRPC) + _badgerService := evmlogService.NewBadger(config.App.System.ContextPath) + _evmLogService := evmlogService.New(ethRPC, _posService, eventLogRepo, signerRepo, _badgerService) + _uniswapService := uniswapService.New(ethRPC, _posService, signerRepo, assetPrice) rpcFunctions := []rpc.Option{} for _, fun := range config.App.Functions { @@ -53,15 +56,15 @@ func Worker(_ context.Context) { } rpcService := rpc.NewWorker(rpcFunctions...) - scheduler := scheduler.New( - scheduler.WithEthLogs(evmLogService), - scheduler.WithUniswapEvents(uniswapService), + taskScheduler := scheduler.New( + scheduler.WithEthLogs(_evmLogService), + scheduler.WithUniswapEvents(_uniswapService), ) conn.Start() - handler := handler.NewWorkerHandler(rpcService) - client.NewRPC(handler) + workerHandler := handler.NewWorkerHandler(rpcService) + client.NewRPC(workerHandler) - scheduler.Start() + taskScheduler.Start() } diff --git a/internal/config/config.go b/internal/config/config.go index 0533a983..094aef79 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -13,9 +13,11 @@ import ( "github.com/ilyakaznacheev/cleanenv" ) +// App is holding all configuration var App Config var SecretFilePath string +// Load loads configuration from files func Load(configPath, secretPath string) error { if configPath == "" { configPath = "./config.yaml" @@ -45,6 +47,7 @@ func Load(configPath, secretPath string) error { return nil } +// Save saves secret configurations to file func (s *Secret) Save() error { yamlData, err := yaml.Marshal(&s) if err != nil { diff --git a/internal/config/model.go b/internal/config/model.go index 8cdb79b6..4ded1e37 100644 --- a/internal/config/model.go +++ b/internal/config/model.go @@ -16,27 +16,32 @@ type System struct { PrintVersion bool } +// RPC struct hold the rpc configuration of the application. type RPC struct { Name string `yaml:"name"` Nodes []string `yaml:"nodes"` } +// Uniswap struct hold the uniswap task's configurations and monitoring tokens. type Uniswap struct { Schedule map[string]time.Duration `yaml:"schedule"` Tokens []Token `yaml:"tokens"` } +// EthLog struct hold the ethlog task's configurations and monitoring events. type EthLog struct { Schedule map[string]time.Duration `yaml:"schedule"` Events []Event `yaml:"events"` } +// Plugins struct hold the plugins configurations of the application. type Plugins struct { EthLog *EthLog `yaml:"logs"` Uniswap *Uniswap `yaml:"uniswap"` Correctness []string `yaml:"correctness"` } +// Event struct hold the monitored event on Ethereum network. type Event struct { Name string `yaml:"name"` Chain string `yaml:"chain"` @@ -50,6 +55,7 @@ type Event struct { Send bool `yaml:"send"` } +// Token struct hold the monitored token on Uniswap network. type Token struct { Name string `yaml:"name"` Pair string `yaml:"pair"` @@ -61,14 +67,18 @@ type Token struct { Store bool `yaml:"store"` } +// ProofOfStake struct hold the proof of stake contract's configurations. type ProofOfStake struct { Chain string `env:"POS_CHAIN" env-default:"arbitrumSepolia" yaml:"chain"` Address string `env:"POS_ADDRESS" env-default:"0x965e364987356785b7E89e2Fe7B70f5E5107332d" yaml:"address"` Base int64 `env:"POS_BASE" env-default:"1" yaml:"base"` } +// Network struct hold the network configuration of the application. type Network struct { Bind string `env:"BIND" env-default:"0.0.0.0:9123" yaml:"bind"` + CertFile string `env:"CERT_FILE" env-default:"" yaml:"certFile"` + KeyFile string `env:"KEY_FILE" env-default:"" yaml:"keyFile"` BrokerURI string `env:"BROKER_URI" env-default:"wss://shinobi.brokers.kenshi.io" yaml:"brokerUri"` SubscribedChannel string `env:"SUBSCRIBED_CHANNEL" env-default:"unchained:" yaml:"subscribedChannel"` BrokerTimeout time.Duration `env:"BROKER_TIMEOUT" env-default:"3s" yaml:"brokerTimeout"` @@ -79,6 +89,7 @@ type Mongo struct { Database string `env:"Mongo_Database" yaml:"database"` } +// Postgres struct hold the postgres configuration of the application. type Postgres struct { URL string `env:"DATABASE_URL" yaml:"url"` } @@ -92,12 +103,20 @@ type Secret struct { EvmPrivateKey string `env:"EVM_PRIVATE_KEY" yaml:"evmPrivateKey"` } +// Function struct hold the function configuration of the application. +type Function struct { + Type string `json:"type"` + Name string `json:"name"` + Endpoint string `json:"endpoint"` +} + // Config struct is the main configuration struct of application. type Config struct { System System `yaml:"system"` Network Network `yaml:"network"` RPC []RPC `yaml:"rpc"` Mongo Mongo `yaml:"mongo"` + Functions []Function `yaml:"functions"` Postgres Postgres `yaml:"postgres"` ProofOfStake ProofOfStake `yaml:"pos"` Plugins Plugins `yaml:"plugins"` diff --git a/internal/consts/channels.go b/internal/consts/channels.go index 178cff37..b876e909 100644 --- a/internal/consts/channels.go +++ b/internal/consts/channels.go @@ -2,6 +2,7 @@ package consts type Channels string +// Channels of broker to be watched for events const ( ChannelPriceReport Channels = "unchained:price_report" ChannelEventLog Channels = "unchained:event_log" diff --git a/internal/consts/errors.go b/internal/consts/errors.go index cb5585e6..71fe5620 100644 --- a/internal/consts/errors.go +++ b/internal/consts/errors.go @@ -2,6 +2,7 @@ package consts import "errors" +// Error list of the project var ( ErrInvalidKosk = errors.New("kosk.invalid") ErrInvalidConfig = errors.New("conf.invalid") diff --git a/internal/consts/meta.go b/internal/consts/meta.go index a7b38eaa..470897f2 100644 --- a/internal/consts/meta.go +++ b/internal/consts/meta.go @@ -1,4 +1,6 @@ package consts +// Meta information of the application + var Version = "0.13.0" var ProtocolVersion = "0.13.0" diff --git a/internal/consts/opcodes.go b/internal/consts/opcodes.go index ef89c430..1d5d046f 100644 --- a/internal/consts/opcodes.go +++ b/internal/consts/opcodes.go @@ -4,6 +4,7 @@ package consts type OpCode byte +// OpCodes of events const ( OpCodeHello OpCode = iota OpCodeKoskChallenge OpCode = 1 diff --git a/internal/crypto/bls/identity.go b/internal/crypto/bls/identity.go index 68adac3b..f802da8a 100644 --- a/internal/crypto/bls/identity.go +++ b/internal/crypto/bls/identity.go @@ -73,6 +73,7 @@ func NewIdentity() *Signer { return s } +// GenerateBlsKeyPair generates a BLS key pair. func GenerateBlsKeyPair() (*big.Int, *bls12381.G2Affine, *bls12381.G1Affine) { _, _, g1Aff, g2Aff := bls12381.Generators() diff --git a/internal/repository/repository.go b/internal/repository/repository.go index 51856fca..df6a149c 100644 --- a/internal/repository/repository.go +++ b/internal/repository/repository.go @@ -18,6 +18,12 @@ type EventLog interface { Upsert(ctx context.Context, data model.EventLog) error } +// Signer interface represents the methods that can be used to interact with the Signer table in the database. +type Signer interface { + CreateSigners(ctx context.Context, signers []model.Signer) error + GetSingerIDsByKeys(ctx context.Context, keys [][]byte) ([]int, error) +} + // AssetPrice interface represents the methods that can be used to interact with the AssetPrice table in the database. type AssetPrice interface { Find(ctx context.Context, block uint64, chain string, name string, pair string) ([]model.AssetPrice, error) diff --git a/internal/service/ai/common.go b/internal/service/ai/common.go index 92138de5..44554e81 100644 --- a/internal/service/ai/common.go +++ b/internal/service/ai/common.go @@ -4,6 +4,7 @@ import ( "github.com/gorilla/websocket" ) +// Read reads messages from the websocket connection. func Read(conn *websocket.Conn, closed *bool) <-chan []byte { out := make(chan []byte) @@ -24,6 +25,7 @@ func Read(conn *websocket.Conn, closed *bool) <-chan []byte { return out } +// CloseSocket closes the websocket connection. func CloseSocket(conn *websocket.Conn, closed *bool) { if conn != nil { *closed = true diff --git a/internal/service/ai/text_to_image.go b/internal/service/ai/text_to_image.go index cd811065..28f86d1b 100644 --- a/internal/service/ai/text_to_image.go +++ b/internal/service/ai/text_to_image.go @@ -9,6 +9,7 @@ import ( sia "github.com/pouya-eghbali/go-sia/v2/pkg" ) +// TextToImage converts a text prompt to an image by requesting the broker. func TextToImage(prompt string, negativePrompt string, model string, loraWeights string, steps uint8) []byte { conn, _, err := websocket.DefaultDialer.Dial( "ws://localhost:8765", nil, diff --git a/internal/service/correctness/correctness.go b/internal/service/correctness/correctness.go index b9c06641..4a0fce93 100644 --- a/internal/service/correctness/correctness.go +++ b/internal/service/correctness/correctness.go @@ -28,13 +28,7 @@ const ( LruSize = 128 ) -type SaveSignatureArgs struct { - Info model.Correctness - Hash bls12381.G1Affine - Consensus bool - Voted *big.Int -} - +// Service represents the correctness service which confirm and store the correctness reports. type Service interface { RecordSignature( ctx context.Context, signature bls12381.G1Affine, signer model.Signer, hash bls12381.G1Affine, info model.Correctness, debounce bool, diff --git a/internal/service/correctness/types.go b/internal/service/correctness/types.go index bc73fa07..8bb8f8f8 100644 --- a/internal/service/correctness/types.go +++ b/internal/service/correctness/types.go @@ -4,6 +4,7 @@ import ( "github.com/TimeleapLabs/unchained/internal/model" bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" sia "github.com/pouya-eghbali/go-sia/v2/pkg" + "math/big" ) type Key struct { @@ -17,6 +18,13 @@ type Signature struct { Signer model.Signer } +type SaveSignatureArgs struct { + Info model.Correctness + Hash bls12381.G1Affine + Consensus bool + Voted *big.Int +} + func (s *Signature) Sia() sia.Sia { return sia.New(). AddByteArray8(s.Signature.Marshal()). diff --git a/internal/service/evmlog/evmlog.go b/internal/service/evmlog/evmlog.go index 6cb5582d..4abc1dc6 100644 --- a/internal/service/evmlog/evmlog.go +++ b/internal/service/evmlog/evmlog.go @@ -40,6 +40,7 @@ type SaveSignatureArgs struct { Voted *big.Int } +// Service is the interface that provides methods for processing Ethereum logs. type Service interface { GetBlockNumber(ctx context.Context, network string) (*uint64, error) SaveSignatures(ctx context.Context, args SaveSignatureArgs) error @@ -50,6 +51,7 @@ type Service interface { ) error } +// service is the implementation of the Service interface. type service struct { ethRPC ethereum.RPC pos pos.Service @@ -66,6 +68,7 @@ type service struct { abiMap map[string]abi.ABI } +// GetBlockNumber returns the latest block number of the specified network. func (s *service) GetBlockNumber(ctx context.Context, network string) (*uint64, error) { blockNumber, err := s.ethRPC.GetBlockNumber(ctx, network) @@ -77,6 +80,7 @@ func (s *service) GetBlockNumber(ctx context.Context, network string) (*uint64, return &blockNumber, nil } +// SaveSignatures saves the signatures to the database. func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) error { signatures, ok := s.signatureCache.Get(args.Hash) if !ok { @@ -169,6 +173,7 @@ func (s *service) SaveSignatures(ctx context.Context, args SaveSignatureArgs) er return nil } +// SendPriceReport sends the event report to the server. func (s *service) SendPriceReport(signature bls12381.G1Affine, event model.EventLog) { priceReport := packet.EventLogReportPacket{ EventLog: event, @@ -178,6 +183,7 @@ func (s *service) SendPriceReport(signature bls12381.G1Affine, event model.Event conn.Send(consts.OpCodeEventLog, priceReport.Sia().Bytes()) } +// New creates a new EVM log service. func New( ethRPC ethereum.RPC, pos pos.Service, eventLogRepo repository.EventLog, proofRepo repository.Proof, persistence *Badger, ) Service { diff --git a/internal/transport/client/client.go b/internal/transport/client/client.go index 68940435..88ed0d18 100644 --- a/internal/transport/client/client.go +++ b/internal/transport/client/client.go @@ -10,6 +10,7 @@ import ( "github.com/TimeleapLabs/unchained/internal/utils" ) +// NewRPC is a function that starts a new RPC client and connect to broker to consume events. func NewRPC(handler handler.Handler) { incoming := conn.Read() diff --git a/internal/transport/client/conn/conn.go b/internal/transport/client/conn/conn.go index 87a15bc3..b9a2f979 100644 --- a/internal/transport/client/conn/conn.go +++ b/internal/transport/client/conn/conn.go @@ -135,12 +135,14 @@ func Read() <-chan []byte { return out } +// SendRaw function sends byte array data to the broker. func SendRaw(data []byte) error { mu.Lock() defer mu.Unlock() return conn.WriteMessage(websocket.BinaryMessage, data) } +// Send function sends a message with specific opCode to the broker. func Send(opCode consts.OpCode, payload []byte) { err := SendRaw( append([]byte{byte(opCode)}, payload...), @@ -149,7 +151,3 @@ func Send(opCode consts.OpCode, payload []byte) { utils.Logger.Error("Can't send packet: %v", err) } } - -func SendMessage(opCode consts.OpCode, message string) { - Send(opCode, []byte(message)) -} diff --git a/internal/transport/client/handler/challenge.go b/internal/transport/client/handler/challenge.go index d42f08e5..c7b26d44 100644 --- a/internal/transport/client/handler/challenge.go +++ b/internal/transport/client/handler/challenge.go @@ -5,6 +5,7 @@ import ( "github.com/TimeleapLabs/unchained/internal/transport/server/packet" ) +// Challenge is a method that is used to sign the challenge packet and return the signed packet to verify the client. func (h *consumer) Challenge(message []byte) []byte { challenge := new(packet.ChallengePacket).FromBytes(message) @@ -14,6 +15,7 @@ func (h *consumer) Challenge(message []byte) []byte { return challenge.Sia().Bytes() } +// Challenge is a method that is used to sign the challenge packet and return the signed packet to verify the client. func (w worker) Challenge(message []byte) []byte { challenge := new(packet.ChallengePacket).FromBytes(message) diff --git a/internal/transport/client/handler/consumer.go b/internal/transport/client/handler/consumer.go index abf6aef0..151693a3 100644 --- a/internal/transport/client/handler/consumer.go +++ b/internal/transport/client/handler/consumer.go @@ -9,12 +9,14 @@ import ( "github.com/TimeleapLabs/unchained/internal/transport/client/conn" ) +// consumer is a struct that holds the services required by the consumer handler. type consumer struct { correctness correctness.Service uniswap uniswap.Service evmlog evmlog.Service } +// NewConsumerHandler is a function that creates a new consumer handler. func NewConsumerHandler( correctness correctness.Service, uniswap uniswap.Service, diff --git a/internal/transport/client/handler/correctness.go b/internal/transport/client/handler/correctness.go index a190b801..8d7d3283 100644 --- a/internal/transport/client/handler/correctness.go +++ b/internal/transport/client/handler/correctness.go @@ -9,6 +9,7 @@ import ( "github.com/TimeleapLabs/unchained/internal/utils" ) +// CorrectnessReport is a method that handles correctness report packets. func (h *consumer) CorrectnessReport(ctx context.Context, message []byte) { packet := new(packet.BroadcastCorrectnessPacket).FromBytes(message) @@ -34,4 +35,5 @@ func (h *consumer) CorrectnessReport(ctx context.Context, message []byte) { } } +// CorrectnessReport is not defined for worker nodes. func (w worker) CorrectnessReport(_ context.Context, _ []byte) {} diff --git a/internal/transport/client/handler/event.go b/internal/transport/client/handler/event.go index 45db0c7a..f7a0c170 100644 --- a/internal/transport/client/handler/event.go +++ b/internal/transport/client/handler/event.go @@ -9,6 +9,7 @@ import ( "github.com/TimeleapLabs/unchained/internal/utils" ) +// EventLog is a method that handles event log packets. func (h *consumer) EventLog(ctx context.Context, message []byte) { packet := new(packet.BroadcastEventPacket).FromBytes(message) @@ -35,4 +36,5 @@ func (h *consumer) EventLog(ctx context.Context, message []byte) { } } +// EventLog is not defined for worker nodes. func (w worker) EventLog(_ context.Context, _ []byte) {} diff --git a/internal/transport/client/handler/handler.go b/internal/transport/client/handler/handler.go index 61501bee..982ca7d0 100644 --- a/internal/transport/client/handler/handler.go +++ b/internal/transport/client/handler/handler.go @@ -4,6 +4,7 @@ import ( "context" ) +// Handler is an interface that represent the handlers of client nodes. type Handler interface { Challenge(message []byte) []byte CorrectnessReport(ctx context.Context, message []byte) diff --git a/internal/transport/client/handler/price.go b/internal/transport/client/handler/price.go index 10531d8f..90668885 100644 --- a/internal/transport/client/handler/price.go +++ b/internal/transport/client/handler/price.go @@ -9,6 +9,7 @@ import ( "github.com/TimeleapLabs/unchained/internal/utils" ) +// PriceReport is a method that handles price report packets. func (h *consumer) PriceReport(ctx context.Context, message []byte) { packet := new(packet.BroadcastPricePacket).FromBytes(message) @@ -40,4 +41,5 @@ func (h *consumer) PriceReport(ctx context.Context, message []byte) { } } +// PriceReport is not defined for worker nodes. func (w worker) PriceReport(_ context.Context, _ []byte) {} diff --git a/internal/transport/client/handler/rpc.go b/internal/transport/client/handler/rpc.go index 95ba377a..6b0faf6f 100644 --- a/internal/transport/client/handler/rpc.go +++ b/internal/transport/client/handler/rpc.go @@ -16,8 +16,10 @@ import ( var TimeleapRPC = "https://devnet.timeleap.swiss/rpc" var CollectorAddress = common.HexToAddress("0xA2dEc4f8089f89F426e6beB76B555f3Cf9E7f499") +// RPCRequest is not defined for consumer nodes. func (h *consumer) RPCRequest(_ context.Context, _ []byte) {} +// RPCRequest is a method that handles RPC request packets and call the corresponding function. func (w worker) RPCRequest(ctx context.Context, message []byte) { utils.Logger.Info("RPC Request") packet := new(dto.RPCRequest).FromSiaBytes(message) @@ -44,6 +46,8 @@ func (w worker) RPCRequest(ctx context.Context, message []byte) { conn.Send(consts.OpCodeRPCResponse, response) } +// RPCResponse is not defined for worker nodes. func (w worker) RPCResponse(_ context.Context, _ []byte) {} +// RPCResponse is not defined for consumer nodes. func (h *consumer) RPCResponse(_ context.Context, _ []byte) {} From b0ac69d2a71006b4b2eb48788b98eb85f3b992ec Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Sat, 14 Sep 2024 10:36:19 +0330 Subject: [PATCH 17/26] =?UTF-8?q?=F0=9F=93=9D=20docs(docs):=20update=20doc?= =?UTF-8?q?s=20with=20developer=20guide=20part=20>>>=20=E2=8F=B0=202h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Developer-Guide.md | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/Developer-Guide.md b/Developer-Guide.md index cbc0d5b1..58faece0 100644 --- a/Developer-Guide.md +++ b/Developer-Guide.md @@ -1,4 +1,26 @@ +# Developer Guide + +This article is a guide for developers who want to contribute to the Unchained project. The project is written in Go and we are open to all new suggestions and ideas, so keeping the codes clean and efficient is really important. + +## Conventions + +We follow the practices which is recommended by golang documents as [Effective Golang](https://go.dev/doc/effective_go) actually with some modifications. But its better to read it and follow the rules. Most of the important ones are covered in our linters, so if you need to check your codes, you can use the following command: + +```bash +golangci-lint run --fix +``` +It will fix correctable issues and show the rest of them. + +## Development Environment + +The project is not depends on a specific IDE or special tools, but some tools are necessary to be installed on your machine to run the project: + +- Go: The project is written in Go, so you need to install Go on your machine. You can download it from [here](https://golang.org/dl/). +- Docker: The project uses docker to run the services on production mode, if you need to test and run project on docker, so you need to install docker on your machine. You can download it from [here](https://docs.docker.com/get-docker/). +- Golang linter: The project uses golangci-lint to lint the codes and check the best practices. You can install it from [here](https://golangci-lint.run/welcome/install/). +- Other: for other tools and contribution ways please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) doc. + ## Project Structure The Project follows the Clean Architecture pattern. The project is divided into the following layers: @@ -9,11 +31,13 @@ The Project follows the Clean Architecture pattern. The project is divided into and the layout is inspired by this [repository](https://github.com/evrone/go-clean-template), also with some modifications. -## Federated Network +## Concepts + +### Federated Network The Unchained network is a federated network that consists of three types of nodes: Broker, Worker, and Consumer. Anyone can run a new node and help the network to process the load and requests. -### Broker +#### Broker The broker nodes are responsible for managing the network and routing the data to the correct worker and consumer nodes. The clients of brokers consist of following: @@ -30,7 +54,7 @@ The broker nodes are responsible for managing the network and routing the data t ``` -### Worker +#### Worker The workers are the nodes that process the data and send them to the broker. The workers can be a service that listens to the data from the blockchain, or a service that listens to the data from the broker. These services hold different business logics and will provide different services to the network. ```mermaid @@ -45,7 +69,7 @@ The workers are the nodes that process the data and send them to the broker. The ``` -### Consumer +#### Consumer The consumers are the nodes that listen to the data from the broker and save or use them. These data be saved in a database, or be served to the users by an API. @@ -56,7 +80,7 @@ The consumers are the nodes that listen to the data from the broker and save or W[Services] --> |Save Data| Z[Database] ``` -## Identity and Security +### Identity and Security In a network like Unchained we send and receive many data from other parties and we need to identify and validate the data sender. in other hand, we communicate with different blockchains and every node needs to keep the keys and addresses of the blockchain. From d3e007103c51d7d733e1d1265ddbf1c59466bfff Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Sat, 14 Sep 2024 16:34:27 +0330 Subject: [PATCH 18/26] =?UTF-8?q?=F0=9F=93=9D=20docs(docs):=20add=20chart?= =?UTF-8?q?=20for=20bls=20section=20>>>=20=E2=8F=B0=201h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Developer-Guide.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Developer-Guide.md b/Developer-Guide.md index 58faece0..6ff5a6f8 100644 --- a/Developer-Guide.md +++ b/Developer-Guide.md @@ -25,6 +25,10 @@ The project is not depends on a specific IDE or special tools, but some tools ar The Project follows the Clean Architecture pattern. The project is divided into the following layers: +```mermaid + +``` + - Services: This layer contains the business logic of the application. - Repository: This layer contains the data access logic of the application which can be implemented for postgres, mongodb, etc. - Handler: This layer contains the adapters for websocket packet processing. @@ -90,6 +94,20 @@ These keys are hold on a global machine identity and will used once the node wan A BLS digital signature, also known as Boneh–Lynn–Shacham (BLS), is a cryptographic signature scheme which allows a user to verify that a signer is authentic. The scheme uses a bilinear pairing for verification, and signatures are elements of an elliptic curve group. +```mermaid +sequenceDiagram + worker->>+Broker: Say Hello! + Consumer->>+Broker: Say Hello! + Broker->>+worker: Sign this challenge! Ill remember you... + Broker->>+Consumer: Sign this challenge! Ill remember you... + Consumer->>+Broker: Here you go! Signed... + worker->>+Broker: Here you go! Signed... + Broker->>+worker: Now you can send other messages + Broker->>+Consumer: Now you can send other messages + Consumer->>+Broker: I wanna listen to XXX topic + Broker-->>+Consumer: All events on subscribed topic +``` + ### Ethereum A Key pair of private and public keys which represent the identity of the node in the Ethereum network. and address of smart contract which is used to sync the nodes together. \ No newline at end of file From 1b4c91c84f1e96ad3b850dfc32400aaee6a3dd79 Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Sat, 14 Sep 2024 17:21:18 +0330 Subject: [PATCH 19/26] =?UTF-8?q?=F0=9F=93=9D=20docs(docs):=20add=20rpc=20?= =?UTF-8?q?chart=20>>>=20=E2=8F=B0=201h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Developer-Guide.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Developer-Guide.md b/Developer-Guide.md index 6ff5a6f8..6df0c2cb 100644 --- a/Developer-Guide.md +++ b/Developer-Guide.md @@ -83,6 +83,16 @@ The consumers are the nodes that listen to the data from the broker and save or W[Services] --> |Sign & Verify| T[Machine Identity] W[Services] --> |Save Data| Z[Database] ``` +### RPC infrastructure + +```mermaid +sequenceDiagram + Worker->>+Broker: I can run these functions + Client->>+Broker: Run X func with these args + Broker->>+Worker: Run X func with these args + Worker->>+Broker: Ok! here is the results. + Broker->>+Client: Here is your result. +``` ### Identity and Security From b26e6eba81763d2e111598598009efcd59ebb45a Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Sat, 14 Sep 2024 17:53:19 +0330 Subject: [PATCH 20/26] =?UTF-8?q?=F0=9F=93=9D=20docs(docs):=20fix=20some?= =?UTF-8?q?=20problems=20>>>=20=E2=8F=B0=2030m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Developer-Guide.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Developer-Guide.md b/Developer-Guide.md index 6df0c2cb..290aef6d 100644 --- a/Developer-Guide.md +++ b/Developer-Guide.md @@ -85,6 +85,8 @@ The consumers are the nodes that listen to the data from the broker and save or ``` ### RPC infrastructure +The unchained network makes ability to run a function on a worker node and get the result. The broker node is responsible for routing the request to the correct worker node and get the result back to the client. + ```mermaid sequenceDiagram Worker->>+Broker: I can run these functions @@ -100,7 +102,7 @@ In a network like Unchained we send and receive many data from other parties and These keys are hold on a global machine identity and will used once the node wants to sign a message or verify a message. -### BLS +#### BLS A BLS digital signature, also known as Boneh–Lynn–Shacham (BLS), is a cryptographic signature scheme which allows a user to verify that a signer is authentic. The scheme uses a bilinear pairing for verification, and signatures are elements of an elliptic curve group. @@ -118,6 +120,6 @@ sequenceDiagram Broker-->>+Consumer: All events on subscribed topic ``` -### Ethereum +#### Ethereum A Key pair of private and public keys which represent the identity of the node in the Ethereum network. and address of smart contract which is used to sync the nodes together. \ No newline at end of file From 5e5f0fc5b837199c859191f8732553959314736e Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Sun, 15 Sep 2024 02:23:35 +0330 Subject: [PATCH 21/26] =?UTF-8?q?=F0=9F=8E=A8=20style(linter):=20update=20?= =?UTF-8?q?linter=20and=20fix=20problems=20>>>=20=E2=8F=B0=201h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .golangci.yml | 2 ++ cmd/handler/plugin.go | 2 +- internal/config/config.go | 6 +++--- internal/consts/channels.go | 2 +- internal/consts/errors.go | 2 +- internal/consts/opcodes.go | 2 +- internal/service/correctness/types.go | 3 ++- internal/service/pos/pos.go | 2 +- internal/transport/client/conn/conn.go | 4 +++- .../transport/server/websocket/handler/correctness.go | 3 +++ internal/transport/server/websocket/websocket.go | 11 ++++++++--- 11 files changed, 26 insertions(+), 13 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index a1fdb50e..9932b91f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -9,6 +9,8 @@ linters-settings: gosec: excludes: - G601 + - G115 + errcheck: check-type-assertions: true diff --git a/cmd/handler/plugin.go b/cmd/handler/plugin.go index 18d6efa6..59835aa0 100644 --- a/cmd/handler/plugin.go +++ b/cmd/handler/plugin.go @@ -13,7 +13,7 @@ var plugin = &cobra.Command{ Short: "Run an Unchained plugin locally", Long: `Run an Unchained plugin locally`, - Run: func(cmd *cobra.Command, _ []string) { + Run: func(_ *cobra.Command, _ []string) { os.Exit(1) }, } diff --git a/internal/config/config.go b/internal/config/config.go index 094aef79..efc1b700 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -13,11 +13,11 @@ import ( "github.com/ilyakaznacheev/cleanenv" ) -// App is holding all configuration +// App is holding all configuration. var App Config var SecretFilePath string -// Load loads configuration from files +// Load loads configuration from files. func Load(configPath, secretPath string) error { if configPath == "" { configPath = "./config.yaml" @@ -47,7 +47,7 @@ func Load(configPath, secretPath string) error { return nil } -// Save saves secret configurations to file +// Save saves secret configurations to file. func (s *Secret) Save() error { yamlData, err := yaml.Marshal(&s) if err != nil { diff --git a/internal/consts/channels.go b/internal/consts/channels.go index b876e909..11332653 100644 --- a/internal/consts/channels.go +++ b/internal/consts/channels.go @@ -2,7 +2,7 @@ package consts type Channels string -// Channels of broker to be watched for events +// Channels of broker to be watched for events. const ( ChannelPriceReport Channels = "unchained:price_report" ChannelEventLog Channels = "unchained:event_log" diff --git a/internal/consts/errors.go b/internal/consts/errors.go index 71fe5620..104447a0 100644 --- a/internal/consts/errors.go +++ b/internal/consts/errors.go @@ -2,7 +2,7 @@ package consts import "errors" -// Error list of the project +// Error list of the project. var ( ErrInvalidKosk = errors.New("kosk.invalid") ErrInvalidConfig = errors.New("conf.invalid") diff --git a/internal/consts/opcodes.go b/internal/consts/opcodes.go index 1d5d046f..8feef597 100644 --- a/internal/consts/opcodes.go +++ b/internal/consts/opcodes.go @@ -4,7 +4,7 @@ package consts type OpCode byte -// OpCodes of events +// OpCodes of events. const ( OpCodeHello OpCode = iota OpCodeKoskChallenge OpCode = 1 diff --git a/internal/service/correctness/types.go b/internal/service/correctness/types.go index 8bb8f8f8..3f062181 100644 --- a/internal/service/correctness/types.go +++ b/internal/service/correctness/types.go @@ -1,10 +1,11 @@ package correctness import ( + "math/big" + "github.com/TimeleapLabs/unchained/internal/model" bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" sia "github.com/pouya-eghbali/go-sia/v2/pkg" - "math/big" ) type Key struct { diff --git a/internal/service/pos/pos.go b/internal/service/pos/pos.go index aaf64a8f..42322e6a 100644 --- a/internal/service/pos/pos.go +++ b/internal/service/pos/pos.go @@ -99,7 +99,7 @@ func (s *service) GetVotingPowerOfPublicKey(ctx context.Context, pkBytes [96]byt if err != nil { return nil, err } - return s.GetVotingPower(addrHex, big.NewInt(int64(block))) + return s.GetVotingPower(addrHex, big.NewInt(int64(block))) // } func New(ethRPC ethereum.RPC) Service { diff --git a/internal/transport/client/conn/conn.go b/internal/transport/client/conn/conn.go index b9a2f979..5f399daa 100644 --- a/internal/transport/client/conn/conn.go +++ b/internal/transport/client/conn/conn.go @@ -1,7 +1,9 @@ package conn import ( + "context" "fmt" + "log/slog" "sync" "time" @@ -148,6 +150,6 @@ func Send(opCode consts.OpCode, payload []byte) { append([]byte{byte(opCode)}, payload...), ) if err != nil { - utils.Logger.Error("Can't send packet: %v", err) + utils.Logger.ErrorContext(context.TODO(), "Can't send packet", slog.Any("error", err)) } } diff --git a/internal/transport/server/websocket/handler/correctness.go b/internal/transport/server/websocket/handler/correctness.go index a60708e8..37821c63 100644 --- a/internal/transport/server/websocket/handler/correctness.go +++ b/internal/transport/server/websocket/handler/correctness.go @@ -1,11 +1,14 @@ package handler import ( + "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/transport/server/packet" + "github.com/TimeleapLabs/unchained/internal/transport/server/pubsub" "github.com/TimeleapLabs/unchained/internal/transport/server/websocket/middleware" "github.com/gorilla/websocket" ) +// CorrectnessRecord is a handler for correctness report. func CorrectnessRecord(conn *websocket.Conn, payload []byte) ([]byte, error) { err := middleware.IsConnectionAuthenticated(conn) if err != nil { diff --git a/internal/transport/server/websocket/websocket.go b/internal/transport/server/websocket/websocket.go index 2f59f0db..5668de90 100644 --- a/internal/transport/server/websocket/websocket.go +++ b/internal/transport/server/websocket/websocket.go @@ -3,6 +3,7 @@ package websocket import ( "context" "fmt" + "log/slog" "net/http" "github.com/TimeleapLabs/unchained/internal/consts" @@ -16,6 +17,7 @@ import ( var upgrader = websocket.Upgrader{} +// WithWebsocket is a function that starts a websocket server. func WithWebsocket() func() { return func() { utils.Logger.Info("Starting a websocket server") @@ -25,10 +27,13 @@ func WithWebsocket() func() { } } +// multiplexer is a function that routes incoming messages to the appropriate handler. func multiplexer(w http.ResponseWriter, r *http.Request) { + upgrader.CheckOrigin = func(_ *http.Request) bool { return true } // remove this line in production + conn, err := upgrader.Upgrade(w, r, nil) if err != nil { - utils.Logger.Error("Can't upgrade the HTTP connection: %v", err) + utils.Logger.ErrorContext(context.TODO(), "Can't upgrade the HTTP connection", slog.Any("error", err)) return } @@ -41,11 +46,11 @@ func multiplexer(w http.ResponseWriter, r *http.Request) { for { messageType, payload, err := conn.ReadMessage() if err != nil { - utils.Logger.Error("Can't read message: %v", err) + utils.Logger.ErrorContext(ctx, "Can't read message", slog.Any("error", err)) err := conn.Close() if err != nil { - utils.Logger.Error("Can't close connection: %v", err) + utils.Logger.ErrorContext(ctx, "Can't close connection", slog.Any("error", err)) } break From e66be1788c5be27aa37c2487f1a2021478b4bc67 Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Sun, 15 Sep 2024 02:46:16 +0330 Subject: [PATCH 22/26] =?UTF-8?q?=F0=9F=92=9A=20ci(linter):=20update=20ver?= =?UTF-8?q?ison=20of=20golang=20linter=20>>>=20=E2=8F=B0=205m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3b28cf73..0601b742 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,8 @@ strip: tools: go mod tidy curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \ - sh -s -- -b $(CURDIR)/bin v1.55.2 + sh -s -- -b $(CURDIR)/bin v1.61.0 + go get golang.org/x/tools/cmd/goimports go install github.com/kisielk/errcheck@latest From 58f193d73d8fe7331987a4af640820faf5380047 Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Sun, 15 Sep 2024 14:05:54 +0330 Subject: [PATCH 23/26] =?UTF-8?q?=F0=9F=93=9D=20docs(docs):=20add=20system?= =?UTF-8?q?=20chart=20>>>=20=E2=8F=B0=201h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Developer-Guide.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/Developer-Guide.md b/Developer-Guide.md index 290aef6d..979951e0 100644 --- a/Developer-Guide.md +++ b/Developer-Guide.md @@ -26,6 +26,27 @@ The project is not depends on a specific IDE or special tools, but some tools ar The Project follows the Clean Architecture pattern. The project is divided into the following layers: ```mermaid +flowchart TD + X[Broker] <--> |Websocket|Y[Worker Handler] + X[Broker] <--> |Websocket|Z[Consumer Handler] + Y[Worker Handler] <--> B(EvmLog Service) + Y[Worker Handler] <--> C(Correctness Service) + Y[Worker Handler] <--> D(Uniswap Service) + Z[Consumer Handler] <--> B(EvmLog Service) + Z[Consumer Handler] <--> C(Correctness Service) + Z[Consumer Handler] <--> D(Uniswap Service) + E[Schduler] -->|every X min| B(EvmLog Service) + E[Schduler] -->|every X min| C(Correctness Service) + E[Schduler] -->|every X min| D(Uniswap Service) + B(EvmLog Service) <--> U(Repository) + C(Correctness Service) <--> U(Repository) + D(Uniswap Service) <--> U(Repository) + B(EvmLog Service) <--> V(Ethereum) + C(Correctness Service) <--> V(Ethereum) + D(Uniswap Service) <--> V(Ethereum) + B(EvmLog Service) <--> M(Machine Identity) + C(Correctness Service) <--> M(Machine Identity) + D(Uniswap Service) <--> M(Machine Identity) ``` @@ -96,6 +117,40 @@ sequenceDiagram Broker->>+Client: Here is your result. ``` +#### RPC Runtime + +When you start a worker node, you can register the functions that you can run on the worker node. The broker node will get the list of functions and will route the request to the correct worker node. each function has a unique id and the runtime configuration of how it works. The runtimes can be: + +- **Unix Socket**: This method will refer the request to a unix socket which is provided on worker startup with this struct: +```go +type RPCRequest struct { + // The ID of the request + ID uuid.UUID `json:"id"` + // The signature of the request + Signature [48]byte `json:"signature"` + // Payment information + TxHash string `json:"tx_hash"` + // The method to be called + Method string `json:"method"` + // params to pass to the function + Params []byte `json:"params"` +} +``` +and at the end worker expect a result like this: +```go +type RPCResponse struct { + // The ID of the request + ID uuid.UUID `json:"id"` + // The error of the function + Error uint64 `json:"error"` + // The response of the function + Response []byte `json:"response"` +} +``` + +- **Docker**: This method will refer the request to a docker container. + + ### Identity and Security In a network like Unchained we send and receive many data from other parties and we need to identify and validate the data sender. in other hand, we communicate with different blockchains and every node needs to keep the keys and addresses of the blockchain. From c54723bc4e13121e88f86f780a030b3d87985cf6 Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Fri, 27 Sep 2024 00:22:39 +0330 Subject: [PATCH 24/26] =?UTF-8?q?=F0=9F=94=80=20merge(mongodb):=20merge=20?= =?UTF-8?q?with=20139=20-=20upgrade=20golang=20version=20to=201.23=20-=20u?= =?UTF-8?q?pdate=20and=20fix=20linters=20>>>=20=E2=8F=B0=204h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .golangci.yml | 3 +- cmd/handler/broker.go | 7 + go.mod | 53 ++-- go.sum | 227 ++++-------------- internal/app/consumer.go | 10 +- internal/app/worker.go | 10 +- internal/config/model.go | 1 + internal/model/assetprice.go | 2 +- internal/model/correctness.go | 2 +- internal/model/logs.go | 2 +- internal/model/proof.go | 4 +- internal/model/signer.go | 8 +- internal/repository/mongo/assetprice.go | 14 +- internal/repository/mongo/correctness.go | 16 +- internal/repository/mongo/eventlog.go | 20 +- internal/service/correctness/correctness.go | 2 +- internal/service/evmlog/record.go | 2 +- internal/service/uniswap/record.go | 2 +- internal/service/uniswap/uniswap.go | 2 +- internal/transport/client/conn/conn.go | 3 +- .../server/websocket/handler/correctness.go | 2 - .../server/websocket/handler/hello.go | 8 +- .../server/websocket/handler/helper.go | 12 +- .../server/websocket/middleware/signature.go | 2 +- .../transport/server/websocket/websocket.go | 32 +-- 25 files changed, 146 insertions(+), 300 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 9932b91f..0acbcbce 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -142,9 +142,8 @@ linters: - durationcheck - errname - errorlint - - execinquery - exhaustive - - exportloopref + - copyloopvar - forbidigo - funlen - gocheckcompilerdirectives diff --git a/cmd/handler/broker.go b/cmd/handler/broker.go index b135dab4..d25fa73b 100644 --- a/cmd/handler/broker.go +++ b/cmd/handler/broker.go @@ -35,6 +35,13 @@ func WithBrokerCmd(cmd *cobra.Command) { } func init() { + broker.Flags().StringP( + "broker", + "b", + "wss://shinobi.brokers.kenshi.io", + "Unchained broker to connect to", + ) + broker.Flags().StringP( "cert-file", "C", diff --git a/go.mod b/go.mod index 7ef56a9b..f8e2aba4 100644 --- a/go.mod +++ b/go.mod @@ -6,23 +6,25 @@ require ( github.com/btcsuite/btcutil v1.0.2 github.com/consensys/gnark-crypto v0.12.1 github.com/dgraph-io/badger/v4 v4.2.0 - github.com/ethereum/go-ethereum v1.13.14 + github.com/ethereum/go-ethereum v1.14.9 + github.com/fergusstrange/embedded-postgres v1.27.0 github.com/go-co-op/gocron/v2 v2.2.6 + github.com/google/uuid v1.6.0 github.com/gorilla/websocket v1.5.1 github.com/hashicorp/golang-lru/v2 v2.0.7 github.com/ilyakaznacheev/cleanenv v1.5.0 github.com/lmittmann/tint v1.0.4 github.com/mattn/go-colorable v0.1.13 github.com/newrelic/go-agent/v3/integrations/nrmongo v1.1.3 - github.com/peterldowns/pgtestdb v0.0.14 - github.com/pouya-eghbali/go-sia/v2 v2.2.2 + github.com/pouya-eghbali/go-sia/v2 v2.3.0 github.com/puzpuzpuz/xsync/v3 v3.1.0 github.com/spf13/cobra v1.8.0 github.com/stretchr/testify v1.9.0 github.com/tryvium-travels/memongo v0.12.0 go.mongodb.org/mongo-driver v1.15.1 - golang.org/x/crypto v0.21.0 - golang.org/x/net v0.22.0 + golang.org/x/crypto v0.22.0 + golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81 + golang.org/x/net v0.24.0 golang.org/x/text v0.14.0 gopkg.in/yaml.v3 v3.0.1 gorm.io/driver/postgres v1.5.9 @@ -32,35 +34,34 @@ require ( require ( github.com/BurntSushi/toml v1.3.2 // indirect github.com/DataDog/zstd v1.4.5 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/VictoriaMetrics/fastcache v1.12.1 // indirect + github.com/Microsoft/go-winio v0.6.2 // indirect + github.com/VictoriaMetrics/fastcache v1.12.2 // indirect github.com/acobaugh/osrelease v0.0.0-20181218015638-a93a0a55a249 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bits-and-blooms/bitset v1.13.0 // indirect - github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect + github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/cockroachdb/errors v1.8.1 // indirect - github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect - github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // indirect - github.com/cockroachdb/redact v1.0.8 // indirect - github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/cockroachdb/errors v1.11.3 // indirect + github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect + github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect + github.com/cockroachdb/pebble v1.1.2 // indirect + github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect - github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect - github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect + github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect + github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/deckarep/golang-set/v2 v2.6.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/ethereum/c-kzg-4844 v1.0.0 // indirect - github.com/fergusstrange/embedded-postgres v1.27.0 // indirect - github.com/fjl/memsize v0.0.2 // indirect + github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect - github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect + github.com/getsentry/sentry-go v0.27.0 // indirect github.com/go-ole/go-ole v1.3.0 // indirect github.com/gofrs/flock v0.8.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -70,11 +71,10 @@ require ( github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/flatbuffers v24.3.7+incompatible // indirect - github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-bexpr v0.1.10 // indirect github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 // indirect github.com/holiman/bloomfilter/v2 v2.0.3 // indirect - github.com/holiman/uint256 v1.2.4 // indirect + github.com/holiman/uint256 v1.3.1 // indirect github.com/huin/goupnp v1.3.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect @@ -129,16 +129,13 @@ require ( github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go.opencensus.io v0.24.0 // indirect - golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81 // indirect - golang.org/x/mod v0.16.0 // indirect - golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.18.0 // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/sys v0.22.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.19.0 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect google.golang.org/grpc v1.56.3 // indirect - google.golang.org/protobuf v1.33.0 // indirect - gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect + gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect olympos.io/encoding/edn v0.0.0-20201019073823-d3554ca0b0a3 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) diff --git a/go.sum b/go.sum index 49d6d8b3..92ccf16f 100644 --- a/go.sum +++ b/go.sum @@ -31,27 +31,20 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw= -github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w= github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= -github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= -github.com/Joker/jade v1.0.1-0.20190614124447-d475f43051e7/go.mod h1:6E6s8o2AE4KhCrqr6GRJjdC/gNfTdxkIXvuGZZda2VM= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= -github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40= -github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= +github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= github.com/acobaugh/osrelease v0.0.0-20181218015638-a93a0a55a249 h1:fMi9ZZ/it4orHj3xWrM6cLkVFcCbkXQALFUiNtHtCPs= github.com/acobaugh/osrelease v0.0.0-20181218015638-a93a0a55a249/go.mod h1:iU1PxQMQwoHZZWmMKrMkrNlY+3+p9vxIjpZOVyxWa0g= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= -github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -59,8 +52,6 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -68,8 +59,8 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE= github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= -github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= -github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= +github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= +github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ= github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= @@ -86,44 +77,38 @@ github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cockroachdb/datadriven v1.0.0/go.mod h1:5Ib8Meh+jk1RlHIXej6Pzevx/NLlNvQB9pmSBZErGA4= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= -github.com/cockroachdb/errors v1.6.1/go.mod h1:tm6FTP5G81vwJ5lC0SizQo374JNCOPrHyXGitRJoDqM= -github.com/cockroachdb/errors v1.8.1 h1:A5+txlVZfOqFBDa4mGz2bUWSp0aHElvHX2bKkdbQu+Y= -github.com/cockroachdb/errors v1.8.1/go.mod h1:qGwQn6JmZ+oMjuLwjWzUNqblqk0xl4CVV3SQbGwK7Ac= -github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f h1:o/kfcElHqOiXqcou5a3rIlMc7oJbMQkeLk0VQJ7zgqY= -github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= -github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 h1:aPEJyR4rPBvDmeyi+l/FS/VtA00IWvjeFvjen1m1l1A= -github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593/go.mod h1:6hk1eMY/u5t+Cf18q5lFMUA1Rc+Sm5I6Ra1QuPyxXCo= -github.com/cockroachdb/redact v1.0.8 h1:8QG/764wK+vmEYoOlfobpe12EQcS81ukx/a4hdVMxNw= -github.com/cockroachdb/redact v1.0.8/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= -github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 h1:IKgmqgMQlVJIZj19CdocBeSfSaiCbEBZGKODaixqtHM= -github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2/go.mod h1:8BT+cPK6xvFOcRlk0R8eg+OTkcqI6baNH4xAkpiYVvQ= +github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= +github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= +github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/esnpM7Geqxka4WSqI1SZc7sMJFd3y4= +github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v1.1.2 h1:CUh2IPtR4swHlEj48Rhfzw6l/d0qA31fItcIszQVIsA= +github.com/cockroachdb/pebble v1.1.2/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= +github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= +github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= -github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 h1:d28BXYi+wUpz1KBmiF9bWrjEMacUEREV6MBi2ODnrfQ= -github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= -github.com/crate-crypto/go-kzg-4844 v0.7.0 h1:C0vgZRk4q4EZ/JgPfzuSoxdCq3C3mOZMBShovmncxvA= -github.com/crate-crypto/go-kzg-4844 v0.7.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= +github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= +github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -136,50 +121,39 @@ github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5il github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= github.com/dgraph-io/badger/v4 v4.2.0 h1:kJrlajbXXL9DFTNuhhu9yCx7JJa4qpYWxtE8BzuWsEs= github.com/dgraph-io/badger/v4 v4.2.0/go.mod h1:qfCqhPoWDFJRx1gp5QwwyGo8xk1lbHUxvK9nK0OGAak= github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= -github.com/ethereum/go-ethereum v1.13.14 h1:EwiY3FZP94derMCIam1iW4HFVrSgIcpsu0HwTQtm6CQ= -github.com/ethereum/go-ethereum v1.13.14/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU= -github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= -github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/ethereum/go-ethereum v1.14.9 h1:J7iwXDrtUyE9FUjUYbd4c9tyzwMh6dTJsKzo9i6SrwA= +github.com/ethereum/go-ethereum v1.14.9/go.mod h1:QeW+MtTpRdBEm2pUFoonByee8zfHv7kGp0wK0odvU1I= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ60YRB8ChToFTUzl8awsc3cJ8CbLjGIl/A= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk= github.com/fergusstrange/embedded-postgres v1.27.0 h1:RAlpWL194IhEpPgeJceTM0ifMJKhiSVxBVIDYB1Jee8= github.com/fergusstrange/embedded-postgres v1.27.0/go.mod h1:t/MLs0h9ukYM6FSt99R7InCHs1nW0ordoVCcnzmpTYw= -github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA= -github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= -github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4/go.mod h1:T9YF2M40nIgbVgp3rreNmTged+9HrbNTIQf1PsaIiTA= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= -github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2GihuqhwdILrV+7GJel5lyPV3u1+PgzrWLc0TkE= -github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc= -github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= -github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= -github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= +github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= +github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/go-co-op/gocron/v2 v2.2.6 h1:sKRt4kemEzY9HnBx9BBnFDPXoOxBy77V4WVtoouhJgg= github.com/go-co-op/gocron/v2 v2.2.6/go.mod h1:mZx3gMSlFnb97k3hRqX3+GdlG3+DUwTh6B8fnsTScXg= -github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= -github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= +github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -189,23 +163,15 @@ github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vb github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= -github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= -github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= -github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -246,7 +212,6 @@ github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6 github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/flatbuffers v24.3.7+incompatible h1:BxGUkIQnOciBu33bd5BdvqY8Qvo0O/GR4SPhh7x9Ed0= @@ -263,7 +228,6 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -283,39 +247,28 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4= github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= -github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= -github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= +github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= -github.com/hydrogen18/memlistener v0.0.0-20141126152155-54553eb933fb/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ilyakaznacheev/cleanenv v1.5.0 h1:0VNZXggJE2OYdXE87bfSSwGxeiGt9moSR2lOrsHHvr4= github.com/ilyakaznacheev/cleanenv v1.5.0/go.mod h1:a5aDzaJrLCQZsazHol1w8InnDcOX0OColm64SlIi6gk= -github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= -github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= -github.com/iris-contrib/i18n v0.0.0-20171121225848-987a633949d0/go.mod h1:pMCz62A0xJL6I+umB2YTlFRwWXaDFA0jy+5HzGiJjqI= -github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= @@ -343,26 +296,13 @@ github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= -github.com/juju/loggo v0.0.0-20180524022052-584905176618/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= -github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= -github.com/kataras/golog v0.0.9/go.mod h1:12HJgwBIZFNGL0EJnMRhmvGA0PQGx8VFwrZtM4CqbAk= -github.com/kataras/iris/v12 v12.0.1/go.mod h1:udK4vLQKkdDqMGJJVd/msuMtN6hpYJhg/lSzuxjhO+U= -github.com/kataras/neffos v0.0.10/go.mod h1:ZYmJC07hQPW67eKuzlfY7SO3bC0mw83A3j6im82hfqw= -github.com/kataras/pio v0.0.0-20190103105442-ea782b38602d/go.mod h1:NV88laa9UiiDuX9AhMbDPkGYSPugBOV6yTZB1l2K9Z0= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= -github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.9.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= -github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= @@ -376,36 +316,23 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/labstack/echo/v4 v4.1.11/go.mod h1:i541M3Fj6f76NZtHSj7TXnyM8n2gaodfvfxNnFqi74g= -github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lmittmann/tint v1.0.4 h1:LeYihpJ9hyGvE0w+K2okPTGUdVLfng1+nDNVR4vWISc= github.com/lmittmann/tint v1.0.4/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/mediocregopher/mediocre-go-lib v0.0.0-20181029021733-cb65787f37ed/go.mod h1:dSsfyI2zABAdhcbvkXqgxOxrCsbYeHCPgrZkku60dSg= -github.com/mediocregopher/radix/v3 v3.3.0/go.mod h1:EmfVyvspXz1uZEyPBMyGK+kjWiKQGvsUt6O3Pj+LDCQ= -github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= @@ -421,12 +348,8 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= -github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/nats-io/nats.go v1.8.1/go.mod h1:BrFz9vVn0fU3AcH9Vn4Kd7W0NpJ651tD5omQ3M8LwxM= -github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4= -github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/newrelic/go-agent/v3 v3.29.1 h1:OINNRev5ImiyRq0IUYwhfTmtqQgQFYyDNQEtbRFAi+k= github.com/newrelic/go-agent/v3 v3.29.1/go.mod h1:9utrgxlSryNqRrTvII2XBL+0lpofXbqXApvVWPpbzUg= github.com/newrelic/go-agent/v3/integrations/nrmongo v1.1.3 h1:Z85RJZKk+hghOQYJzsKUo3s4vP9W7/HUlB+CuLelqnc= @@ -438,18 +361,12 @@ github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0= github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/peterldowns/pgtestdb v0.0.14 h1:myVNL8ethaPZG7CQIjZxZCXwOG428THYRbSm0mIelpU= -github.com/peterldowns/pgtestdb v0.0.14/go.mod h1:aG99+zgvWKOdGH+vtEFTDNVmaPOJD8ldIleuwJOgacA= -github.com/peterldowns/testy v0.0.1 h1:9a6LzvnKcL52Crzud1z7jbsAojTntCh89ho6mgsr4KU= -github.com/peterldowns/testy v0.0.1/go.mod h1:J4sm75UEzbfBIcq0zbrshWWjsJQiJ5RrhTPYKVY2Ww8= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= @@ -461,8 +378,8 @@ github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pouya-eghbali/go-sia/v2 v2.2.2 h1:W8K5CR00gLLMO3JLRfPBfeD93BSA5VpwuOOwfp5RKHw= -github.com/pouya-eghbali/go-sia/v2 v2.2.2/go.mod h1:E+hUvytS6uLa+HSBY+oi19zPvVGZdVzWSVW9zwzZnr8= +github.com/pouya-eghbali/go-sia/v2 v2.3.0 h1:x2bGKFnQOUOP9H+k8rr5hm3Qf2uWMnhLuDndwDApxGg= +github.com/pouya-eghbali/go-sia/v2 v2.3.0/go.mod h1:E+hUvytS6uLa+HSBY+oi19zPvVGZdVzWSVW9zwzZnr8= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= @@ -497,32 +414,19 @@ github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZV github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -552,35 +456,20 @@ github.com/tryvium-travels/memongo v0.12.0 h1:B56+Do7Z3vcR93oqkyUubvdFPJEqpHn1ZB github.com/tryvium-travels/memongo v0.12.0/go.mod h1:riRUHKRQ5JbeX2ryzFfmr7P2EYXIkNwgloSQJPpBikA= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= -github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho= github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= -github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= -github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= -github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= -github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= -github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= -github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= -github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -601,18 +490,16 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -646,17 +533,13 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= -golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -665,7 +548,6 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -687,8 +569,8 @@ golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= -golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -707,15 +589,13 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -723,9 +603,7 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -763,10 +641,10 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -785,15 +663,11 @@ golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190327201419-c70d86f8b7cf/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= @@ -831,8 +705,6 @@ golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= -golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -860,7 +732,6 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -892,7 +763,6 @@ google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= -google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -920,8 +790,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -930,11 +800,8 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= -gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= -gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= -gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= -gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/internal/app/consumer.go b/internal/app/consumer.go index db7978ae..203227ca 100644 --- a/internal/app/consumer.go +++ b/internal/app/consumer.go @@ -34,7 +34,7 @@ func Consumer() { ) ethRPC := ethereum.New() - pos := pos.New(ethRPC) + _posService := pos.New(ethRPC) var eventLogRepo repository.EventLog var proofRepo repository.Proof @@ -42,6 +42,7 @@ func Consumer() { var correctnessRepo repository.CorrectnessReport if config.App.Mongo.URL != "" { + utils.Logger.Info("MongoDB configuration found, initializing...") db := mongo.New() eventLogRepo = mongoRepo.NewEventLog(db) @@ -49,6 +50,7 @@ func Consumer() { assetPrice = mongoRepo.NewAssetPrice(db) correctnessRepo = mongoRepo.NewCorrectness(db) } else { + utils.Logger.Info("Postgresql configuration found, initializing...") db := postgres.New() db.Migrate() @@ -58,9 +60,9 @@ func Consumer() { correctnessRepo = postgresRepo.NewCorrectness(db) } - correctnessService := correctnessService.New(pos, proofRepo, correctnessRepo) - evmLogService := evmlogService.New(ethRPC, pos, eventLogRepo, proofRepo, nil) - uniswapService := uniswapService.New(ethRPC, pos, proofRepo, assetPrice) + _correctnessService := correctnessService.New(_posService, proofRepo, correctnessRepo) + _evmLogService := evmlogService.New(ethRPC, _posService, eventLogRepo, proofRepo, nil) + _uniswapService := uniswapService.New(ethRPC, _posService, proofRepo, assetPrice) conn.Start() diff --git a/internal/app/worker.go b/internal/app/worker.go index 76978c62..ef73e6f7 100644 --- a/internal/app/worker.go +++ b/internal/app/worker.go @@ -39,13 +39,11 @@ func Worker(_ context.Context) { proofRepo := postgres.NewProof(nil) assetPrice := postgres.NewAssetPrice(nil) - badger := evmlogService.NewBadger(config.App.System.ContextPath) - evmLogService := evmlogService.New(ethRPC, pos, eventLogRepo, proofRepo, badger) - uniswapService := uniswapService.New(ethRPC, pos, proofRepo, assetPrice) - _posService := pos.New(ethRPC) _badgerService := evmlogService.NewBadger(config.App.System.ContextPath) - _evmLogService := evmlogService.New(ethRPC, _posService, eventLogRepo, signerRepo, _badgerService) - _uniswapService := uniswapService.New(ethRPC, _posService, signerRepo, assetPrice) + _posService := pos.New(ethRPC) + + _evmLogService := evmlogService.New(ethRPC, _posService, eventLogRepo, proofRepo, _badgerService) + _uniswapService := uniswapService.New(ethRPC, _posService, proofRepo, assetPrice) rpcFunctions := []rpc.Option{} for _, fun := range config.App.Functions { diff --git a/internal/config/model.go b/internal/config/model.go index 4ded1e37..9db2a211 100644 --- a/internal/config/model.go +++ b/internal/config/model.go @@ -13,6 +13,7 @@ type System struct { SecretsPath string AllowGenerateSecrets bool ContextPath string + Home string PrintVersion bool } diff --git a/internal/model/assetprice.go b/internal/model/assetprice.go index 9c5ede5b..0475b2f4 100644 --- a/internal/model/assetprice.go +++ b/internal/model/assetprice.go @@ -66,7 +66,7 @@ func (c *AssetPrice) FromSia(siaObj sia.Sia) *AssetPrice { func (c *AssetPrice) Bls() *bls12381.G1Affine { hash, err := bls.Hash(c.Sia().Bytes()) if err != nil { - utils.Logger.Error("Can't hash bls: %v", err) + utils.Logger.With("Err", err).Error("Can't hash bls") return &bls12381.G1Affine{} } diff --git a/internal/model/correctness.go b/internal/model/correctness.go index f4155c86..5433d4b2 100644 --- a/internal/model/correctness.go +++ b/internal/model/correctness.go @@ -57,7 +57,7 @@ func (c *Correctness) FromSia(sia sia.Sia) *Correctness { func (c *Correctness) Bls() *bls12381.G1Affine { hash, err := bls.Hash(c.Sia().Bytes()) if err != nil { - utils.Logger.Error("Can't hash bls: %v", err) + utils.Logger.With("Err", err).Error("Can't hash bls") return &bls12381.G1Affine{} } diff --git a/internal/model/logs.go b/internal/model/logs.go index 6da41072..fc8819c3 100644 --- a/internal/model/logs.go +++ b/internal/model/logs.go @@ -86,7 +86,7 @@ func (e *EventLog) FromSia(sia sia.Sia) *EventLog { func (e *EventLog) Bls() *bls12381.G1Affine { hash, err := bls.Hash(e.Sia().Bytes()) if err != nil { - utils.Logger.Error("Can't hash bls: %v", err) + utils.Logger.With("Err", err).Error("Can't hash bls") return &bls12381.G1Affine{} } diff --git a/internal/model/proof.go b/internal/model/proof.go index 73de1cd1..8a12c03d 100644 --- a/internal/model/proof.go +++ b/internal/model/proof.go @@ -29,13 +29,13 @@ func (p *Proof) Sia() sia.Sia { hashBytes, err := hex.DecodeString(p.Hash) if err != nil { - utils.Logger.Error("Can't decode hash: %v", err) + utils.Logger.With("Err", err).Error("Can't decode hash") return sia.New() } signatureBytes, err := hex.DecodeString(p.Signature) if err != nil { - utils.Logger.Error("Can't decode signature: %v", err) + utils.Logger.With("Err", err).Error("Can't decode signature") return sia.New() } diff --git a/internal/model/signer.go b/internal/model/signer.go index 71b3b7e3..1089ba3c 100644 --- a/internal/model/signer.go +++ b/internal/model/signer.go @@ -25,13 +25,13 @@ type Signer struct { func (s *Signer) Sia() sia.Sia { publicKeyBytes, err := hex.DecodeString(s.PublicKey) if err != nil { - utils.Logger.Error("Can't decode public key: %v", err) + utils.Logger.With("Err", err).Error("Can't decode public key") return sia.New() } shortPublicKey, err := hex.DecodeString(s.ShortPublicKey) if err != nil { - utils.Logger.Error("Can't decode short public key: %v", err) + utils.Logger.With("Err", err).Error("Can't decode short public key") return sia.New() } @@ -59,7 +59,7 @@ func (s *Signer) FromSia(sia sia.Sia) *Signer { func (s *Signer) Bls() bls12381.G1Affine { hash, err := bls.Hash(s.Sia().Bytes()) if err != nil { - utils.Logger.Error("Can't hash bls: %v", err) + utils.Logger.With("Err", err).Error("Can't hash bls") return bls12381.G1Affine{} } @@ -72,7 +72,7 @@ func (s Signers) Bls() []byte { for _, signer := range s { hash, err := bls.Hash(signer.Sia().Bytes()) if err != nil { - utils.Logger.Error("Can't hash bls: %v", err) + utils.Logger.With("Err", err).Error("Can't hash bls") return bytes } diff --git a/internal/repository/mongo/assetprice.go b/internal/repository/mongo/assetprice.go index 0c864fee..10da40a6 100644 --- a/internal/repository/mongo/assetprice.go +++ b/internal/repository/mongo/assetprice.go @@ -43,14 +43,12 @@ func (a AssetPriceRepo) Upsert(ctx context.Context, data model.AssetPrice) error "data.voted": data.Voted, }, "$setOnInsert": bson.M{ - "hash": data.Bls().Bytes(), - "timestamp": time.Now(), - "data": bson.M{ - "pair": data.Pair, - "chain": data.Chain, - "block": data.Block, - "asset": data.Name, - }, + "hash": data.Bls().Bytes(), + "timestamp": time.Now(), + "data.pair": data.Pair, + "data.chain": data.Chain, + "data.block": data.Block, + "data.asset": data.Name, }, }, opt) diff --git a/internal/repository/mongo/correctness.go b/internal/repository/mongo/correctness.go index 3c157e68..9f5e068c 100644 --- a/internal/repository/mongo/correctness.go +++ b/internal/repository/mongo/correctness.go @@ -64,18 +64,10 @@ func (c CorrectnessRepo) Upsert(ctx context.Context, data model.Correctness) err "data.voted": data.Voted, }, "$setOnInsert": bson.M{ - "hash": data.Bls().Bytes(), - "timestamp": time.Now(), - "data": bson.M{ - "correct": data.Correct, - "signers_count": data.SignersCount, - "signature": data.Signature, - "hash": data.Hash, - "timestamp": data.Timestamp, - "topic": data.Topic, - "consensus": data.Consensus, - "voted": data.Voted, - }, + "hash": data.Bls().Bytes(), + "timestamp": time.Now(), + "data.hash": data.Hash, + "data.topic": data.Topic, }, }, opt) diff --git a/internal/repository/mongo/eventlog.go b/internal/repository/mongo/eventlog.go index f6a0d792..52b90f7c 100644 --- a/internal/repository/mongo/eventlog.go +++ b/internal/repository/mongo/eventlog.go @@ -67,21 +67,11 @@ func (r EventLogRepo) Upsert(ctx context.Context, data model.EventLog) error { "data.voted": data.Voted, }, "$setOnInsert": bson.M{ - "hash": data.Bls().Bytes(), - "timestamp": time.Now(), - "data": bson.M{ - "block": data.Block, - "chain": data.Chain, - "address": data.Address, - "event": data.Event, - "index": data.LogIndex, - "transaction": data.TxHash[:], - "signers_count": data.SignersCount, - "signature": data.Signature, - "args": data.Args, - "consensus": data.Consensus, - "voted": data.Voted, - }, + "hash": data.Bls().Bytes(), + "timestamp": time.Now(), + "data.block": data.Block, + "data.index": data.LogIndex, + "data.tx": data.TxHash[:], }, }, opt) diff --git a/internal/service/correctness/correctness.go b/internal/service/correctness/correctness.go index 4a0fce93..4801fb03 100644 --- a/internal/service/correctness/correctness.go +++ b/internal/service/correctness/correctness.go @@ -96,7 +96,7 @@ func (s *service) RecordSignature( if err != nil { publicKeyBytes, err := hex.DecodeString(signer.PublicKey) if err != nil { - utils.Logger.Error("Can't decode public key: %v", err) + utils.Logger.With("Err", err).ErrorContext(ctx, "Can't decode public key") return err } diff --git a/internal/service/evmlog/record.go b/internal/service/evmlog/record.go index 1b394645..58085df5 100644 --- a/internal/service/evmlog/record.go +++ b/internal/service/evmlog/record.go @@ -72,7 +72,7 @@ func (s *service) RecordSignature( if err != nil { publicKeyBytes, err := hex.DecodeString(signer.PublicKey) if err != nil { - utils.Logger.Error("Can't decode public key: %v", err) + utils.Logger.With("Err", err).ErrorContext(ctx, "Can't decode public key") return err } diff --git a/internal/service/uniswap/record.go b/internal/service/uniswap/record.go index 4da98961..9dd3c77f 100644 --- a/internal/service/uniswap/record.go +++ b/internal/service/uniswap/record.go @@ -65,7 +65,7 @@ func (s *service) RecordSignature( if err != nil { publicKeyBytes, err := hex.DecodeString(signer.PublicKey) if err != nil { - utils.Logger.Error("Can't decode public key: %v", err) + utils.Logger.With("Err", err).ErrorContext(ctx, "Can't decode public key") return err } utils.Logger. diff --git a/internal/service/uniswap/uniswap.go b/internal/service/uniswap/uniswap.go index a221926a..b113419a 100644 --- a/internal/service/uniswap/uniswap.go +++ b/internal/service/uniswap/uniswap.go @@ -98,7 +98,7 @@ func (s *service) checkAndCacheSignature( if item.Signer.PublicKey == signer.PublicKey { publicKeyBytes, err := hex.DecodeString(signer.PublicKey) if err != nil { - utils.Logger.Error("Can't decode public key: %v", err) + utils.Logger.With("Err", err).Error("Can't decode public key") return err } diff --git a/internal/transport/client/conn/conn.go b/internal/transport/client/conn/conn.go index 5f399daa..16442f8c 100644 --- a/internal/transport/client/conn/conn.go +++ b/internal/transport/client/conn/conn.go @@ -1,7 +1,6 @@ package conn import ( - "context" "fmt" "log/slog" "sync" @@ -150,6 +149,6 @@ func Send(opCode consts.OpCode, payload []byte) { append([]byte{byte(opCode)}, payload...), ) if err != nil { - utils.Logger.ErrorContext(context.TODO(), "Can't send packet", slog.Any("error", err)) + utils.Logger.Error("Can't send packet", slog.Any("error", err)) } } diff --git a/internal/transport/server/websocket/handler/correctness.go b/internal/transport/server/websocket/handler/correctness.go index 37821c63..4314d64f 100644 --- a/internal/transport/server/websocket/handler/correctness.go +++ b/internal/transport/server/websocket/handler/correctness.go @@ -1,9 +1,7 @@ package handler import ( - "github.com/TimeleapLabs/unchained/internal/consts" "github.com/TimeleapLabs/unchained/internal/transport/server/packet" - "github.com/TimeleapLabs/unchained/internal/transport/server/pubsub" "github.com/TimeleapLabs/unchained/internal/transport/server/websocket/middleware" "github.com/gorilla/websocket" ) diff --git a/internal/transport/server/websocket/handler/hello.go b/internal/transport/server/websocket/handler/hello.go index 50571859..bfe79109 100644 --- a/internal/transport/server/websocket/handler/hello.go +++ b/internal/transport/server/websocket/handler/hello.go @@ -10,14 +10,13 @@ import ( ) // Hello handler store the new client in the Signers map and send it a challenge packet. -func Hello(conn *websocket.Conn, payload []byte) { +func Hello(conn *websocket.Conn, payload []byte) ([]byte, error) { utils.Logger.With("IP", conn.RemoteAddr().String()).Info("New Client Registered") signer := new(model.Signer).FromBytes(payload) if signer.Name == "" { utils.Logger.Error("Signer name is empty Or public key is invalid") - SendError(conn, consts.OpCodeError, consts.ErrInvalidConfig) - return + return []byte{}, consts.ErrInvalidConfig } store.Signers.Range(func(conn *websocket.Conn, signerInMap model.Signer) bool { @@ -35,6 +34,5 @@ func Hello(conn *websocket.Conn, payload []byte) { challenge := packet.ChallengePacket{Random: utils.NewChallenge()} store.Challenges.Store(conn, challenge) - SendMessage(conn, consts.OpCodeFeedback, "conf.ok") - Send(conn, consts.OpCodeKoskChallenge, challenge.Sia().Bytes()) + return challenge.Sia().Bytes(), nil } diff --git a/internal/transport/server/websocket/handler/helper.go b/internal/transport/server/websocket/handler/helper.go index 6a64b7fd..6d7ab74b 100644 --- a/internal/transport/server/websocket/handler/helper.go +++ b/internal/transport/server/websocket/handler/helper.go @@ -10,9 +10,9 @@ import ( "github.com/gorilla/websocket" ) -func Send(conn *websocket.Conn, messageType int, opCode consts.OpCode, payload []byte) { +func Send(conn *websocket.Conn, opCode consts.OpCode, payload []byte) { err := conn.WriteMessage( - messageType, + websocket.BinaryMessage, append( []byte{byte(opCode)}, payload...), @@ -22,8 +22,8 @@ func Send(conn *websocket.Conn, messageType int, opCode consts.OpCode, payload [ } } -func SendMessage(conn *websocket.Conn, messageType int, opCode consts.OpCode, message string) { - Send(conn, messageType, opCode, []byte(message)) +func SendMessage(conn *websocket.Conn, opCode consts.OpCode, message string) { + Send(conn, opCode, []byte(message)) } func BroadcastListener(ctx context.Context, conn *websocket.Conn, topic string, ch chan []byte) { @@ -42,8 +42,8 @@ func BroadcastListener(ctx context.Context, conn *websocket.Conn, topic string, } } -func SendError(conn *websocket.Conn, messageType int, opCode consts.OpCode, err error) { - SendMessage(conn, messageType, opCode, err.Error()) +func SendError(conn *websocket.Conn, opCode consts.OpCode, err error) { + SendMessage(conn, opCode, err.Error()) } func Close(conn *websocket.Conn) { diff --git a/internal/transport/server/websocket/middleware/signature.go b/internal/transport/server/websocket/middleware/signature.go index 7507bf53..956afc3a 100644 --- a/internal/transport/server/websocket/middleware/signature.go +++ b/internal/transport/server/websocket/middleware/signature.go @@ -28,7 +28,7 @@ func IsMessageValid(conn *websocket.Conn, message bls12381.G1Affine, signature [ publicKeyBytes, err := hex.DecodeString(signer.PublicKey) if err != nil { - utils.Logger.Error("Can't decode public key: %v", err) + utils.Logger.With("Err", err).Error("Can't decode public key") return model.Signer{}, consts.ErrInternalError } diff --git a/internal/transport/server/websocket/websocket.go b/internal/transport/server/websocket/websocket.go index 5668de90..7851abd7 100644 --- a/internal/transport/server/websocket/websocket.go +++ b/internal/transport/server/websocket/websocket.go @@ -33,7 +33,7 @@ func multiplexer(w http.ResponseWriter, r *http.Request) { conn, err := upgrader.Upgrade(w, r, nil) if err != nil { - utils.Logger.ErrorContext(context.TODO(), "Can't upgrade the HTTP connection", slog.Any("error", err)) + utils.Logger.Error("Can't upgrade the HTTP connection", slog.Any("error", err)) return } @@ -44,13 +44,13 @@ func multiplexer(w http.ResponseWriter, r *http.Request) { defer cancel() for { - messageType, payload, err := conn.ReadMessage() + _, payload, err := conn.ReadMessage() if err != nil { - utils.Logger.ErrorContext(ctx, "Can't read message", slog.Any("error", err)) + utils.Logger.With("Err", err).ErrorContext(ctx, "Can't read message") err := conn.Close() if err != nil { - utils.Logger.ErrorContext(ctx, "Can't close connection", slog.Any("error", err)) + utils.Logger.With("Err", err).ErrorContext(ctx, "Can't close connection") } break @@ -65,47 +65,47 @@ func multiplexer(w http.ResponseWriter, r *http.Request) { utils.Logger.With("IP", conn.RemoteAddr().String()).Info("New Client Registered") result, err := handler.Hello(conn, payload[1:]) if err != nil { - handler.SendError(conn, messageType, consts.OpCodeError, err) + handler.SendError(conn, consts.OpCodeError, err) continue } - handler.SendMessage(conn, messageType, consts.OpCodeFeedback, "conf.ok") - handler.Send(conn, messageType, consts.OpCodeKoskChallenge, result) + handler.SendMessage(conn, consts.OpCodeFeedback, "conf.ok") + handler.Send(conn, consts.OpCodeKoskChallenge, result) case consts.OpCodePriceReport: result, err := handler.PriceReport(conn, payload[1:]) if err != nil { - handler.SendError(conn, messageType, consts.OpCodeError, err) + handler.SendError(conn, consts.OpCodeError, err) continue } pubsub.Publish(consts.ChannelPriceReport, consts.OpCodePriceReportBroadcast, result) - handler.SendMessage(conn, messageType, consts.OpCodeFeedback, "signature.accepted") + handler.SendMessage(conn, consts.OpCodeFeedback, "signature.accepted") case consts.OpCodeEventLog: result, err := handler.EventLog(conn, payload[1:]) if err != nil { - handler.SendError(conn, messageType, consts.OpCodeError, err) + handler.SendError(conn, consts.OpCodeError, err) continue } pubsub.Publish(consts.ChannelEventLog, consts.OpCodeEventLogBroadcast, result) - handler.SendMessage(conn, messageType, consts.OpCodeFeedback, "signature.accepted") + handler.SendMessage(conn, consts.OpCodeFeedback, "signature.accepted") case consts.OpCodeCorrectnessReport: result, err := handler.CorrectnessRecord(conn, payload[1:]) if err != nil { - handler.SendError(conn, messageType, consts.OpCodeError, err) + handler.SendError(conn, consts.OpCodeError, err) continue } pubsub.Publish(consts.ChannelCorrectnessReport, consts.OpCodeCorrectnessReportBroadcast, result) - handler.SendMessage(conn, messageType, consts.OpCodeFeedback, "signature.accepted") + handler.SendMessage(conn, consts.OpCodeFeedback, "signature.accepted") case consts.OpCodeKoskResult: err := handler.Kosk(conn, payload[1:]) if err != nil { - handler.SendError(conn, messageType, consts.OpCodeError, err) + handler.SendError(conn, consts.OpCodeError, err) continue } - handler.SendMessage(conn, messageType, consts.OpCodeFeedback, "kosk.ok") + handler.SendMessage(conn, consts.OpCodeFeedback, "kosk.ok") case consts.OpCodeRegisterConsumer: utils.Logger. With("IP", conn.RemoteAddr().String()). @@ -115,7 +115,7 @@ func multiplexer(w http.ResponseWriter, r *http.Request) { topic := string(payload[1:]) go handler.BroadcastListener(ctx, conn, topic, pubsub.Subscribe(topic)) default: - handler.SendError(conn, messageType, consts.OpCodeError, consts.ErrNotSupportedInstruction) + handler.SendError(conn, consts.OpCodeError, consts.ErrNotSupportedInstruction) } } } From d0d5bef8186aa73f67888b806683d4e31f5bc9d2 Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Fri, 27 Sep 2024 01:23:35 +0330 Subject: [PATCH 25/26] =?UTF-8?q?=E2=9C=A8=20feat(mongo):=20change=20binar?= =?UTF-8?q?y=20fields=20of=20signer=20models=20to=20binary=20>>>=20?= =?UTF-8?q?=E2=8F=B0=2010m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/model/proof.go | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/internal/model/proof.go b/internal/model/proof.go index 8a12c03d..ac068920 100644 --- a/internal/model/proof.go +++ b/internal/model/proof.go @@ -1,11 +1,8 @@ package model import ( - "encoding/hex" "time" - "github.com/TimeleapLabs/unchained/internal/utils" - "go.mongodb.org/mongo-driver/bson/primitive" sia "github.com/pouya-eghbali/go-sia/v2/pkg" @@ -15,9 +12,9 @@ type Proof struct { ID uint `bson:"-" gorm:"primarykey"` DocID primitive.ObjectID `bson:"_id,omitempty" gorm:"-"` - Hash string `bson:"hash" json:"hash"` + Hash []byte `bson:"hash" json:"hash"` Timestamp time.Time `bson:"timestamp" json:"timestamp"` - Signature string `bson:"signature" json:"signature"` + Signature []byte `bson:"signature" json:"signature"` Signers []Signer `bson:"signers" gorm:"many2many:proof_signers;" json:"signers"` } @@ -27,22 +24,10 @@ func (p *Proof) Sia() sia.Sia { s.EmbedBytes(item.Sia().Bytes()) }) - hashBytes, err := hex.DecodeString(p.Hash) - if err != nil { - utils.Logger.With("Err", err).Error("Can't decode hash") - return sia.New() - } - - signatureBytes, err := hex.DecodeString(p.Signature) - if err != nil { - utils.Logger.With("Err", err).Error("Can't decode signature") - return sia.New() - } - return sia.New(). - AddByteArray8(hashBytes). + AddByteArray8(p.Hash). AddInt64(p.Timestamp.Unix()). - AddByteArray8(signatureBytes). + AddByteArray8(p.Signature). AddByteArray64(signers.Bytes()) } @@ -58,18 +43,18 @@ func (p *Proof) FromSia(siaObj sia.Sia) *Proof { return signer }) - p.Hash = hex.EncodeToString(siaObj.ReadByteArray8()) + p.Hash = siaObj.ReadByteArray8() p.Timestamp = time.Unix(siaObj.ReadInt64(), 0) - p.Signature = hex.EncodeToString(siaObj.ReadByteArray8()) + p.Signature = siaObj.ReadByteArray8() p.Signers = signers return p } func NewProof(signers []Signer, signature []byte) *Proof { return &Proof{ - Hash: hex.EncodeToString(Signers(signers).Bls()), + Hash: Signers(signers).Bls(), Timestamp: time.Now(), - Signature: hex.EncodeToString(signature), + Signature: signature, Signers: signers, } } From 6a6dcd11df2cc5a50057216dc46b310fa3f528e2 Mon Sep 17 00:00:00 2001 From: Parya Rastegar Date: Fri, 27 Sep 2024 01:35:03 +0330 Subject: [PATCH 26/26] =?UTF-8?q?=E2=9C=A8=20feat(signer):=20make=20signer?= =?UTF-8?q?=20fields=20byte=20array=20>>>=20=E2=8F=B0=205m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/model/signer.go | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/internal/model/signer.go b/internal/model/signer.go index 1089ba3c..b1f72c47 100644 --- a/internal/model/signer.go +++ b/internal/model/signer.go @@ -1,8 +1,6 @@ package model import ( - "encoding/hex" - "github.com/TimeleapLabs/unchained/internal/crypto/bls" "github.com/TimeleapLabs/unchained/internal/utils" bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" @@ -18,28 +16,16 @@ type Signer struct { Name string `json:"name"` EvmAddress string `json:"evm_address"` - PublicKey string `json:"public_key"` - ShortPublicKey string `json:"short_public_key"` + PublicKey []byte `json:"public_key"` + ShortPublicKey []byte `json:"short_public_key"` } func (s *Signer) Sia() sia.Sia { - publicKeyBytes, err := hex.DecodeString(s.PublicKey) - if err != nil { - utils.Logger.With("Err", err).Error("Can't decode public key") - return sia.New() - } - - shortPublicKey, err := hex.DecodeString(s.ShortPublicKey) - if err != nil { - utils.Logger.With("Err", err).Error("Can't decode short public key") - return sia.New() - } - return sia.New(). AddString8(s.Name). AddString8(s.EvmAddress). - AddByteArray8(publicKeyBytes). - AddByteArray8(shortPublicKey) + AddByteArray8(s.PublicKey). + AddByteArray8(s.ShortPublicKey) } func (s *Signer) FromBytes(payload []byte) *Signer { @@ -50,8 +36,8 @@ func (s *Signer) FromBytes(payload []byte) *Signer { func (s *Signer) FromSia(sia sia.Sia) *Signer { s.Name = sia.ReadString8() s.EvmAddress = sia.ReadString8() - s.PublicKey = hex.EncodeToString(sia.ReadByteArray8()) - s.ShortPublicKey = hex.EncodeToString(sia.ReadByteArray8()) + s.PublicKey = sia.ReadByteArray8() + s.ShortPublicKey = sia.ReadByteArray8() return s }