diff --git a/config.yaml b/config.yaml index 0c91f9d..348786e 100644 --- a/config.yaml +++ b/config.yaml @@ -1,6 +1,8 @@ network: rpc: "" - verifier_address: "" + proposer: "" + voting_registry: "" + lightweight_state: "" vault_address: "http://127.0.0.1:8200" vault_mount_path: "secret_data" diff --git a/docs/spec/paths/integrations@proof-verification-relayer@v1@transit-state.yaml b/docs/spec/paths/integrations@proof-verification-relayer@v1@transit-state.yaml new file mode 100644 index 0000000..dc7a370 --- /dev/null +++ b/docs/spec/paths/integrations@proof-verification-relayer@v1@transit-state.yaml @@ -0,0 +1,49 @@ +post: + tags: + - State + summary: Transit state + operationId: TransitState + requestBody: + content: + application/json: + schema: + type: object + required: + - data + properties: + data: + type: object + required: + - tx_data + properties: + tx_data: + type: string + responses: + '200': + description: Success + content: + application/json: + schema: + type: object + properties: + data: + type: object + $ref: '#/components/schemas/Tx' + '400': + description: Bad Request Error + content: + application/json: + schema: + $ref: '#/components/schemas/Errors' + '429': + description: Too Many Requests Error + content: + application/json: + schema: + $ref: '#/components/schemas/Errors' + '500': + description: Internal Error + content: + application/json: + schema: + $ref: '#/components/schemas/Errors' \ No newline at end of file diff --git a/docs/spec/paths/integrations@proof-verification-relayer@v1@vote.yaml b/docs/spec/paths/integrations@proof-verification-relayer@v1@vote.yaml new file mode 100644 index 0000000..8a990ae --- /dev/null +++ b/docs/spec/paths/integrations@proof-verification-relayer@v1@vote.yaml @@ -0,0 +1,55 @@ +post: + tags: + - Votes + summary: The voting + operationId: vote + requestBody: + content: + application/json: + schema: + type: object + required: + - data + properties: + data: + type: object + required: + - tx_data + - voting + - registration + properties: + tx_data: + type: string + voting: + type: string + registration: + type: string + responses: + '200': + description: Success + content: + application/json: + schema: + type: object + properties: + data: + type: object + $ref: '#/components/schemas/Tx' + '400': + description: Bad Request Error + content: + application/json: + schema: + $ref: '#/components/schemas/Errors' + '429': + description: Too Many Requests Error + content: + application/json: + schema: + $ref: '#/components/schemas/Errors' + '500': + description: Internal Error + content: + application/json: + schema: + $ref: '#/components/schemas/Errors' \ No newline at end of file diff --git a/go.mod b/go.mod index 5852572..fce9e49 100644 --- a/go.mod +++ b/go.mod @@ -3,31 +3,33 @@ module github.com/rarimo/proof-verification-relayer go 1.22.0 require ( - github.com/Masterminds/squirrel v1.5.4 github.com/alecthomas/kingpin v2.2.6+incompatible github.com/ethereum/go-ethereum v1.13.11 - github.com/fatih/structs v1.1.0 github.com/go-chi/chi v4.1.2+incompatible - github.com/google/uuid v1.4.0 + github.com/go-ozzo/ozzo-validation/v4 v4.2.1 github.com/hashicorp/vault/api v1.12.0 + github.com/iden3/go-iden3-core/v2 v2.0.4 + github.com/imroc/req/v3 v3.43.1 github.com/rubenv/sql-migrate v1.6.1 gitlab.com/distributed_lab/ape v1.7.1 gitlab.com/distributed_lab/dig v0.0.0-20230207152643-c44f80a4294c gitlab.com/distributed_lab/figure/v3 v3.1.4 gitlab.com/distributed_lab/kit v1.11.3 gitlab.com/distributed_lab/logan v3.8.1+incompatible - gitlab.com/distributed_lab/running v1.6.0 ) require ( + github.com/Masterminds/squirrel v1.5.4 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/StackExchange/wmi v1.2.1 // indirect github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9 // indirect + github.com/andybalholm/brotli v1.1.0 // indirect github.com/bits-and-blooms/bitset v1.10.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect github.com/cenkalti/backoff/v3 v3.0.0 // indirect github.com/certifi/gocertifi v0.0.0-20200211180108-c7c1fbc02894 // indirect + github.com/cloudflare/circl v1.3.7 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect @@ -40,8 +42,10 @@ require ( github.com/go-gorp/gorp/v3 v3.1.0 // indirect github.com/go-jose/go-jose/v3 v3.0.1 // indirect github.com/go-ole/go-ole v1.3.0 // indirect - github.com/go-ozzo/ozzo-validation/v4 v4.2.1 // indirect + github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/google/jsonapi v0.0.0-20200226002910-c8283f632fb7 // indirect + github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 // indirect + github.com/google/uuid v1.4.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect @@ -53,8 +57,9 @@ require ( github.com/hashicorp/go-sockaddr v1.0.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/holiman/uint256 v1.2.4 // indirect + github.com/iden3/go-iden3-crypto v0.0.15 // indirect github.com/jmoiron/sqlx v1.3.5 // indirect - github.com/klauspost/compress v1.17.4 // indirect + github.com/klauspost/compress v1.17.7 // indirect github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect github.com/lib/pq v1.10.9 // indirect @@ -62,9 +67,14 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect + github.com/mr-tron/base58 v1.2.0 // indirect github.com/oklog/ulid v1.3.1 // indirect + github.com/onsi/ginkgo/v2 v2.16.0 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/quic-go/qpack v0.4.0 // indirect + github.com/quic-go/quic-go v0.41.0 // indirect + github.com/refraction-networking/utls v1.6.3 // indirect github.com/ryanuber/go-glob v1.0.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect @@ -81,17 +91,19 @@ require ( github.com/tklauser/numcpus v0.6.1 // indirect gitlab.com/distributed_lab/figure v2.1.2+incompatible // indirect gitlab.com/distributed_lab/lorem v0.2.0 // indirect + gitlab.com/distributed_lab/running v1.6.0 // indirect go.uber.org/atomic v1.9.0 // indirect + go.uber.org/mock v0.4.0 // indirect go.uber.org/multierr v1.9.0 // indirect - golang.org/x/crypto v0.19.0 // indirect - golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect - golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.21.0 // indirect - golang.org/x/sync v0.5.0 // indirect - golang.org/x/sys v0.17.0 // indirect + golang.org/x/crypto v0.21.0 // indirect + golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // 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/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.16.1 // indirect + golang.org/x/tools v0.19.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect rsc.io/tmplfunc v0.0.3 // indirect diff --git a/go.sum b/go.sum index 1c68c7a..e6b91f6 100644 --- a/go.sum +++ b/go.sum @@ -1187,6 +1187,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= +github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/arrow/go/arrow v0.0.0-20191024131854-af6fa24be0db/go.mod h1:VTxUBvSJ3s3eHAg65PNgrsn5BtqCRPdmyXh6rAfdxN0= github.com/apache/arrow/go/v10 v10.0.1/go.mod h1:YvhnlEePVnBS4+0z3fhPfUy7W1Ikj0Ih0vcRo/gZ1M0= @@ -1236,6 +1238,7 @@ github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= github.com/certifi/gocertifi v0.0.0-20200211180108-c7c1fbc02894 h1:JLaf/iINcLyjwbtTsCJjc6rtlASgHeIJPrB6QmwURnA= github.com/certifi/gocertifi v0.0.0-20200211180108-c7c1fbc02894/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= +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 v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= @@ -1250,6 +1253,8 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= +github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/cloudflare/cloudflare-go v0.14.0/go.mod h1:EnwdgGMaFOruiPZRFSgn+TsQ3hQ7C/YWzIGLeu5c304= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= @@ -1366,7 +1371,6 @@ github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w= github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg= -github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= @@ -1424,6 +1428,8 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9 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-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= @@ -1448,6 +1454,8 @@ github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfC github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/go-test/deep v1.0.2 h1:onZX1rnHT3Wv6cqNgYyFOOlgVKJrksuCMCRvJStbMYw= github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= @@ -1539,6 +1547,8 @@ github.com/google/go-pkcs11 v0.2.1-0.20230907215043-c6f79328ddf9/go.mod h1:6eQoG github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/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= github.com/google/jsonapi v0.0.0-20200226002910-c8283f632fb7 h1:aQ4kMXDAmP9IRIZHcSKB2orXHGwGiSxH4PX1BzKHR50= github.com/google/jsonapi v0.0.0-20200226002910-c8283f632fb7/go.mod h1:XSx4m2SziAqk9DXY9nz659easTq4q6TyrpYd9tHSm0g= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -1562,6 +1572,8 @@ github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 h1:y3N7Bm7Y9/CtpiVkw/ZWj6lSlDF3F74SfKwfTCer72Q= +github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/s2a-go v0.1.0/go.mod h1:OJpEgntRZo8ugHpF9hkoLJbS5dSI20XZeXJ9JVywLlM= github.com/google/s2a-go v0.1.3/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= @@ -1678,7 +1690,13 @@ github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3 github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/iden3/go-iden3-core/v2 v2.0.4 h1:ggzC2zgOWgJAAcuG9X8bQG1r4gAoHZWqY7aLV8b1qgc= +github.com/iden3/go-iden3-core/v2 v2.0.4/go.mod h1:L9PxhWPvoS9qTb3inEkZBm1RpjHBt+VTwvxssdzbAdw= +github.com/iden3/go-iden3-crypto v0.0.15 h1:4MJYlrot1l31Fzlo2sF56u7EVFeHHJkxGXXZCtESgK4= +github.com/iden3/go-iden3-crypto v0.0.15/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E= github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= +github.com/imroc/req/v3 v3.43.1 h1:tsWAhvxik4egtHAvMlxcjaWJtHlJL8EpBqJMOm5rmyQ= +github.com/imroc/req/v3 v3.43.1/go.mod h1:SQIz5iYop16MJxbo8ib+4LnostGCok8NQf8ToyQc2xA= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/flux v0.65.1/go.mod h1:J754/zds0vvpfwuq7Gc2wRdVwEodfpCFM7mYlOw2LqY= github.com/influxdata/influxdb v1.8.3/go.mod h1:JugdFhsvvI8gadxOI6noqNeeBHvWNTbfYGtiAn+2jhI= @@ -1738,8 +1756,8 @@ github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHU github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4= -github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= +github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= +github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg= @@ -1853,6 +1871,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN 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/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= +github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg= 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= @@ -1889,6 +1909,8 @@ github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkA github.com/onsi/ginkgo/v2 v2.5.0/go.mod h1:Luc4sArBICYCS8THh8v3i3i5CuSZO+RaQRaJoeNwomw= github.com/onsi/ginkgo/v2 v2.7.0/go.mod h1:yjiuMwPokqY1XauOgju45q3sJt6VzQ/Fict1LFVcsAo= github.com/onsi/ginkgo/v2 v2.8.1/go.mod h1:N1/NbDngAFcSLdyZ+/aYTYGSlq9qMCS/cNKGJjy+csc= +github.com/onsi/ginkgo/v2 v2.16.0 h1:7q1w9frJDzninhXxjZd+Y/x54XNjG/UlRLIYPZafsPM= +github.com/onsi/ginkgo/v2 v2.16.0/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= @@ -1901,6 +1923,8 @@ github.com/onsi/gomega v1.24.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2 github.com/onsi/gomega v1.24.1/go.mod h1:3AOiACssS3/MajrniINInwbfOOtfZvplPzuRSmvt1jM= github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/onsi/gomega v1.27.1/go.mod h1:aHX5xOykVYzWOV4WqQy0sy8BQptgukenXpCXfadcIAw= +github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= +github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.0.3-0.20180606204148-bd9c31933947/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -1972,6 +1996,12 @@ github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1 github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= +github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= +github.com/quic-go/quic-go v0.41.0 h1:aD8MmHfgqTURWNJy48IYFg2OnxwHT3JL7ahGs73lb4k= +github.com/quic-go/quic-go v0.41.0/go.mod h1:qCkNjqczPEvgsOnxZ0eCD14lv+B2LHlFAB++CNOh9hA= +github.com/refraction-networking/utls v1.6.3 h1:MFOfRN35sSx6K5AZNIoESsBuBxS2LCgRilRIdHb6fDc= +github.com/refraction-networking/utls v1.6.3/go.mod h1:yil9+7qSl+gBwJqztoQseO6Pr3h62pQoY1lXiNR/FPs= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52/go.mod h1:RDpi1RftBQPUCDRw6SmxeaREsAaRKnOclghuzp/WRzc= @@ -2175,6 +2205,8 @@ go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/automaxprocs v1.5.1/go.mod h1:BF4eumQw0P9GtnuxxovUd06vwm1o18oMzFtK66vU6XU= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= +go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= +go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= @@ -2218,8 +2250,8 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +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-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -2238,8 +2270,8 @@ golang.org/x/exp v0.0.0-20220426173459-3bcf042a4bf5/go.mod h1:lgLbSvA5ygNOMpwM/9 golang.org/x/exp v0.0.0-20220827204233-334a2380cb91/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= -golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc h1:ao2WRsKSzW6KuUY9IWPwWahcHCgR0s52IfwutMfEbdM= -golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -2288,8 +2320,8 @@ golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +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-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 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= @@ -2375,8 +2407,8 @@ golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +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= 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= @@ -2431,8 +2463,9 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +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-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 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= @@ -2560,8 +2593,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +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-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= 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= @@ -2691,8 +2724,8 @@ golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= golang.org/x/tools v0.10.0/go.mod h1:UJwyiVBsOA2uwvK/e5OY3GTpDUJriEd+/YlqAwLPmyM= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= -golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= -golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +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= diff --git a/internal/config/network.go b/internal/config/network.go index 931b119..f785120 100644 --- a/internal/config/network.go +++ b/internal/config/network.go @@ -3,6 +3,9 @@ package config import ( "context" "crypto/ecdsa" + "math/big" + "sync" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" @@ -12,8 +15,6 @@ import ( "gitlab.com/distributed_lab/kit/comfig" "gitlab.com/distributed_lab/kit/kv" "gitlab.com/distributed_lab/logan/v3/errors" - "math/big" - "sync" ) type NetworkConfiger interface { @@ -32,11 +33,12 @@ type ethereum struct { } type NetworkConfig struct { - RPC string `fig:"rpc,required"` - Proposer common.Address `fig:"proposer,required"` - VotingRegistry common.Address `fig:"voting_registry,required"` - Address string `fig:"vault_address,required"` - MountPath string `fig:"vault_mount_path,required"` + RPC string `fig:"rpc,required"` + Proposer common.Address `fig:"proposer,required"` + VotingRegistry common.Address `fig:"voting_registry,required"` + LightweightState common.Address `fig:"lightweight_state,required"` + Address string `fig:"vault_address,required"` + MountPath string `fig:"vault_mount_path,required"` ChainID *big.Int `fig:"chain_id"` Token string `dig:"VAULT_TOKEN,clear"` @@ -74,11 +76,12 @@ func (e *ethereum) NetworkConfig() *NetworkConfig { if err := dig.Out(&result). Where(map[string]interface{}{ - "rpc": result.RPC, - "proposer": result.Proposer, - "voting_registry": result.VotingRegistry, - "vault_address": result.Address, - "vault_mount_path": result.MountPath, + "rpc": result.RPC, + "proposer": result.Proposer, + "voting_registry": result.VotingRegistry, + "lightweight_state": result.LightweightState, + "vault_address": result.Address, + "vault_mount_path": result.MountPath, }).Now(); err != nil { panic(err) } diff --git a/internal/contracts/LightweightState.go b/internal/contracts/LightweightState.go new file mode 100644 index 0000000..af4de67 --- /dev/null +++ b/internal/contracts/LightweightState.go @@ -0,0 +1,1569 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package contracts + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// ILightweightStateIdentitiesStatesRootData is an auto generated low-level Go binding around an user-defined struct. +type ILightweightStateIdentitiesStatesRootData struct { + Root [32]byte + SetTimestamp *big.Int +} + +// LightweightStateMetaData contains all meta data concerning the LightweightState contract. +var LightweightStateMetaData = &bind.MetaData{ + ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newGistRoot\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"newIdentitesStatesRoot\",\"type\":\"bytes32\"}],\"name\":\"SignedStateTransited\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"P\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"signer_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"sourceStateContract_\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"sourceChainName_\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"chainName_\",\"type\":\"string\"}],\"name\":\"__LightweightState_init\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"signer_\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"chainName_\",\"type\":\"string\"}],\"name\":\"__Signers_init\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"chainName\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"newSignerPubKey_\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"signature_\",\"type\":\"bytes\"}],\"name\":\"changeSigner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newSourceStateContract_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"signature_\",\"type\":\"bytes\"}],\"name\":\"changeSourceStateContract\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"methodId_\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"contractAddress_\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"signHash_\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"signature_\",\"type\":\"bytes\"}],\"name\":\"checkSignatureAndIncrementNonce\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"root_\",\"type\":\"uint256\"}],\"name\":\"geGISTRootData\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"root\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAtTimestamp\",\"type\":\"uint256\"}],\"internalType\":\"structILightweightState.GistRootData\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentGISTRootInfo\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"root\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAtTimestamp\",\"type\":\"uint256\"}],\"internalType\":\"structILightweightState.GistRootData\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getGISTRoot\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"root_\",\"type\":\"bytes32\"}],\"name\":\"getIdentitiesStatesRootData\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"root\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"setTimestamp\",\"type\":\"uint256\"}],\"internalType\":\"structILightweightState.IdentitiesStatesRootData\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"methodId_\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"contractAddress_\",\"type\":\"address\"}],\"name\":\"getSigComponents\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"chainName_\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"nonce_\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"identitiesStatesRoot\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"root_\",\"type\":\"bytes32\"}],\"name\":\"isIdentitiesStatesRootExists\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"name\":\"nonces\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proxiableUUID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"newIdentitiesStatesRoot_\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"root\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAtTimestamp\",\"type\":\"uint256\"}],\"internalType\":\"structILightweightState.GistRootData\",\"name\":\"gistData_\",\"type\":\"tuple\"},{\"internalType\":\"bytes\",\"name\":\"proof_\",\"type\":\"bytes\"}],\"name\":\"signedTransitState\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"signer\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourceChainName\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourceStateContract\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"signature_\",\"type\":\"bytes\"}],\"name\":\"upgradeToWithSig\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"methodId_\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"contractAddress_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"newAddress_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"signature_\",\"type\":\"bytes\"}],\"name\":\"validateChangeAddressSignature\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"issuerId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"issuerState\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAtTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"bytes32[]\",\"name\":\"merkleProof\",\"type\":\"bytes32[]\"}],\"internalType\":\"structILightweightState.StatesMerkleData\",\"name\":\"statesMerkleData_\",\"type\":\"tuple\"}],\"name\":\"verifyStatesMerkleData\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", +} + +// LightweightStateABI is the input ABI used to generate the binding from. +// Deprecated: Use LightweightStateMetaData.ABI instead. +var LightweightStateABI = LightweightStateMetaData.ABI + +// LightweightState is an auto generated Go binding around an Ethereum contract. +type LightweightState struct { + LightweightStateCaller // Read-only binding to the contract + LightweightStateTransactor // Write-only binding to the contract + LightweightStateFilterer // Log filterer for contract events +} + +// LightweightStateCaller is an auto generated read-only Go binding around an Ethereum contract. +type LightweightStateCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// LightweightStateTransactor is an auto generated write-only Go binding around an Ethereum contract. +type LightweightStateTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// LightweightStateFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type LightweightStateFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// LightweightStateSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type LightweightStateSession struct { + Contract *LightweightState // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// LightweightStateCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type LightweightStateCallerSession struct { + Contract *LightweightStateCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// LightweightStateTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type LightweightStateTransactorSession struct { + Contract *LightweightStateTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// LightweightStateRaw is an auto generated low-level Go binding around an Ethereum contract. +type LightweightStateRaw struct { + Contract *LightweightState // Generic contract binding to access the raw methods on +} + +// LightweightStateCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type LightweightStateCallerRaw struct { + Contract *LightweightStateCaller // Generic read-only contract binding to access the raw methods on +} + +// LightweightStateTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type LightweightStateTransactorRaw struct { + Contract *LightweightStateTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewLightweightState creates a new instance of LightweightState, bound to a specific deployed contract. +func NewLightweightState(address common.Address, backend bind.ContractBackend) (*LightweightState, error) { + contract, err := bindLightweightState(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &LightweightState{LightweightStateCaller: LightweightStateCaller{contract: contract}, LightweightStateTransactor: LightweightStateTransactor{contract: contract}, LightweightStateFilterer: LightweightStateFilterer{contract: contract}}, nil +} + +// NewLightweightStateCaller creates a new read-only instance of LightweightState, bound to a specific deployed contract. +func NewLightweightStateCaller(address common.Address, caller bind.ContractCaller) (*LightweightStateCaller, error) { + contract, err := bindLightweightState(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &LightweightStateCaller{contract: contract}, nil +} + +// NewLightweightStateTransactor creates a new write-only instance of LightweightState, bound to a specific deployed contract. +func NewLightweightStateTransactor(address common.Address, transactor bind.ContractTransactor) (*LightweightStateTransactor, error) { + contract, err := bindLightweightState(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &LightweightStateTransactor{contract: contract}, nil +} + +// NewLightweightStateFilterer creates a new log filterer instance of LightweightState, bound to a specific deployed contract. +func NewLightweightStateFilterer(address common.Address, filterer bind.ContractFilterer) (*LightweightStateFilterer, error) { + contract, err := bindLightweightState(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &LightweightStateFilterer{contract: contract}, nil +} + +// bindLightweightState binds a generic wrapper to an already deployed contract. +func bindLightweightState(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := LightweightStateMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_LightweightState *LightweightStateRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _LightweightState.Contract.LightweightStateCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_LightweightState *LightweightStateRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _LightweightState.Contract.LightweightStateTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_LightweightState *LightweightStateRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _LightweightState.Contract.LightweightStateTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_LightweightState *LightweightStateCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _LightweightState.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_LightweightState *LightweightStateTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _LightweightState.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_LightweightState *LightweightStateTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _LightweightState.Contract.contract.Transact(opts, method, params...) +} + +// P is a free data retrieval call binding the contract method 0x8b8fbd92. +// +// Solidity: function P() view returns(uint256) +func (_LightweightState *LightweightStateCaller) P(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _LightweightState.contract.Call(opts, &out, "P") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// P is a free data retrieval call binding the contract method 0x8b8fbd92. +// +// Solidity: function P() view returns(uint256) +func (_LightweightState *LightweightStateSession) P() (*big.Int, error) { + return _LightweightState.Contract.P(&_LightweightState.CallOpts) +} + +// P is a free data retrieval call binding the contract method 0x8b8fbd92. +// +// Solidity: function P() view returns(uint256) +func (_LightweightState *LightweightStateCallerSession) P() (*big.Int, error) { + return _LightweightState.Contract.P(&_LightweightState.CallOpts) +} + +// ChainName is a free data retrieval call binding the contract method 0x1c93b03a. +// +// Solidity: function chainName() view returns(string) +func (_LightweightState *LightweightStateCaller) ChainName(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _LightweightState.contract.Call(opts, &out, "chainName") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +// ChainName is a free data retrieval call binding the contract method 0x1c93b03a. +// +// Solidity: function chainName() view returns(string) +func (_LightweightState *LightweightStateSession) ChainName() (string, error) { + return _LightweightState.Contract.ChainName(&_LightweightState.CallOpts) +} + +// ChainName is a free data retrieval call binding the contract method 0x1c93b03a. +// +// Solidity: function chainName() view returns(string) +func (_LightweightState *LightweightStateCallerSession) ChainName() (string, error) { + return _LightweightState.Contract.ChainName(&_LightweightState.CallOpts) +} + +// GeGISTRootData is a free data retrieval call binding the contract method 0x0dd93b5d. +// +// Solidity: function geGISTRootData(uint256 root_) view returns((uint256,uint256)) +func (_LightweightState *LightweightStateCaller) GeGISTRootData(opts *bind.CallOpts, root_ *big.Int) (ILightweightStateGistRootData, error) { + var out []interface{} + err := _LightweightState.contract.Call(opts, &out, "geGISTRootData", root_) + + if err != nil { + return *new(ILightweightStateGistRootData), err + } + + out0 := *abi.ConvertType(out[0], new(ILightweightStateGistRootData)).(*ILightweightStateGistRootData) + + return out0, err + +} + +// GeGISTRootData is a free data retrieval call binding the contract method 0x0dd93b5d. +// +// Solidity: function geGISTRootData(uint256 root_) view returns((uint256,uint256)) +func (_LightweightState *LightweightStateSession) GeGISTRootData(root_ *big.Int) (ILightweightStateGistRootData, error) { + return _LightweightState.Contract.GeGISTRootData(&_LightweightState.CallOpts, root_) +} + +// GeGISTRootData is a free data retrieval call binding the contract method 0x0dd93b5d. +// +// Solidity: function geGISTRootData(uint256 root_) view returns((uint256,uint256)) +func (_LightweightState *LightweightStateCallerSession) GeGISTRootData(root_ *big.Int) (ILightweightStateGistRootData, error) { + return _LightweightState.Contract.GeGISTRootData(&_LightweightState.CallOpts, root_) +} + +// GetCurrentGISTRootInfo is a free data retrieval call binding the contract method 0xaf7a3f59. +// +// Solidity: function getCurrentGISTRootInfo() view returns((uint256,uint256)) +func (_LightweightState *LightweightStateCaller) GetCurrentGISTRootInfo(opts *bind.CallOpts) (ILightweightStateGistRootData, error) { + var out []interface{} + err := _LightweightState.contract.Call(opts, &out, "getCurrentGISTRootInfo") + + if err != nil { + return *new(ILightweightStateGistRootData), err + } + + out0 := *abi.ConvertType(out[0], new(ILightweightStateGistRootData)).(*ILightweightStateGistRootData) + + return out0, err + +} + +// GetCurrentGISTRootInfo is a free data retrieval call binding the contract method 0xaf7a3f59. +// +// Solidity: function getCurrentGISTRootInfo() view returns((uint256,uint256)) +func (_LightweightState *LightweightStateSession) GetCurrentGISTRootInfo() (ILightweightStateGistRootData, error) { + return _LightweightState.Contract.GetCurrentGISTRootInfo(&_LightweightState.CallOpts) +} + +// GetCurrentGISTRootInfo is a free data retrieval call binding the contract method 0xaf7a3f59. +// +// Solidity: function getCurrentGISTRootInfo() view returns((uint256,uint256)) +func (_LightweightState *LightweightStateCallerSession) GetCurrentGISTRootInfo() (ILightweightStateGistRootData, error) { + return _LightweightState.Contract.GetCurrentGISTRootInfo(&_LightweightState.CallOpts) +} + +// GetGISTRoot is a free data retrieval call binding the contract method 0x2439e3a6. +// +// Solidity: function getGISTRoot() view returns(uint256) +func (_LightweightState *LightweightStateCaller) GetGISTRoot(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _LightweightState.contract.Call(opts, &out, "getGISTRoot") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetGISTRoot is a free data retrieval call binding the contract method 0x2439e3a6. +// +// Solidity: function getGISTRoot() view returns(uint256) +func (_LightweightState *LightweightStateSession) GetGISTRoot() (*big.Int, error) { + return _LightweightState.Contract.GetGISTRoot(&_LightweightState.CallOpts) +} + +// GetGISTRoot is a free data retrieval call binding the contract method 0x2439e3a6. +// +// Solidity: function getGISTRoot() view returns(uint256) +func (_LightweightState *LightweightStateCallerSession) GetGISTRoot() (*big.Int, error) { + return _LightweightState.Contract.GetGISTRoot(&_LightweightState.CallOpts) +} + +// GetIdentitiesStatesRootData is a free data retrieval call binding the contract method 0xa055a692. +// +// Solidity: function getIdentitiesStatesRootData(bytes32 root_) view returns((bytes32,uint256)) +func (_LightweightState *LightweightStateCaller) GetIdentitiesStatesRootData(opts *bind.CallOpts, root_ [32]byte) (ILightweightStateIdentitiesStatesRootData, error) { + var out []interface{} + err := _LightweightState.contract.Call(opts, &out, "getIdentitiesStatesRootData", root_) + + if err != nil { + return *new(ILightweightStateIdentitiesStatesRootData), err + } + + out0 := *abi.ConvertType(out[0], new(ILightweightStateIdentitiesStatesRootData)).(*ILightweightStateIdentitiesStatesRootData) + + return out0, err + +} + +// GetIdentitiesStatesRootData is a free data retrieval call binding the contract method 0xa055a692. +// +// Solidity: function getIdentitiesStatesRootData(bytes32 root_) view returns((bytes32,uint256)) +func (_LightweightState *LightweightStateSession) GetIdentitiesStatesRootData(root_ [32]byte) (ILightweightStateIdentitiesStatesRootData, error) { + return _LightweightState.Contract.GetIdentitiesStatesRootData(&_LightweightState.CallOpts, root_) +} + +// GetIdentitiesStatesRootData is a free data retrieval call binding the contract method 0xa055a692. +// +// Solidity: function getIdentitiesStatesRootData(bytes32 root_) view returns((bytes32,uint256)) +func (_LightweightState *LightweightStateCallerSession) GetIdentitiesStatesRootData(root_ [32]byte) (ILightweightStateIdentitiesStatesRootData, error) { + return _LightweightState.Contract.GetIdentitiesStatesRootData(&_LightweightState.CallOpts, root_) +} + +// GetSigComponents is a free data retrieval call binding the contract method 0x827e099e. +// +// Solidity: function getSigComponents(uint8 methodId_, address contractAddress_) view returns(string chainName_, uint256 nonce_) +func (_LightweightState *LightweightStateCaller) GetSigComponents(opts *bind.CallOpts, methodId_ uint8, contractAddress_ common.Address) (struct { + ChainName string + Nonce *big.Int +}, error) { + var out []interface{} + err := _LightweightState.contract.Call(opts, &out, "getSigComponents", methodId_, contractAddress_) + + outstruct := new(struct { + ChainName string + Nonce *big.Int + }) + if err != nil { + return *outstruct, err + } + + outstruct.ChainName = *abi.ConvertType(out[0], new(string)).(*string) + outstruct.Nonce = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + + return *outstruct, err + +} + +// GetSigComponents is a free data retrieval call binding the contract method 0x827e099e. +// +// Solidity: function getSigComponents(uint8 methodId_, address contractAddress_) view returns(string chainName_, uint256 nonce_) +func (_LightweightState *LightweightStateSession) GetSigComponents(methodId_ uint8, contractAddress_ common.Address) (struct { + ChainName string + Nonce *big.Int +}, error) { + return _LightweightState.Contract.GetSigComponents(&_LightweightState.CallOpts, methodId_, contractAddress_) +} + +// GetSigComponents is a free data retrieval call binding the contract method 0x827e099e. +// +// Solidity: function getSigComponents(uint8 methodId_, address contractAddress_) view returns(string chainName_, uint256 nonce_) +func (_LightweightState *LightweightStateCallerSession) GetSigComponents(methodId_ uint8, contractAddress_ common.Address) (struct { + ChainName string + Nonce *big.Int +}, error) { + return _LightweightState.Contract.GetSigComponents(&_LightweightState.CallOpts, methodId_, contractAddress_) +} + +// IdentitiesStatesRoot is a free data retrieval call binding the contract method 0xe08e70bb. +// +// Solidity: function identitiesStatesRoot() view returns(bytes32) +func (_LightweightState *LightweightStateCaller) IdentitiesStatesRoot(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _LightweightState.contract.Call(opts, &out, "identitiesStatesRoot") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// IdentitiesStatesRoot is a free data retrieval call binding the contract method 0xe08e70bb. +// +// Solidity: function identitiesStatesRoot() view returns(bytes32) +func (_LightweightState *LightweightStateSession) IdentitiesStatesRoot() ([32]byte, error) { + return _LightweightState.Contract.IdentitiesStatesRoot(&_LightweightState.CallOpts) +} + +// IdentitiesStatesRoot is a free data retrieval call binding the contract method 0xe08e70bb. +// +// Solidity: function identitiesStatesRoot() view returns(bytes32) +func (_LightweightState *LightweightStateCallerSession) IdentitiesStatesRoot() ([32]byte, error) { + return _LightweightState.Contract.IdentitiesStatesRoot(&_LightweightState.CallOpts) +} + +// IsIdentitiesStatesRootExists is a free data retrieval call binding the contract method 0xbfd73455. +// +// Solidity: function isIdentitiesStatesRootExists(bytes32 root_) view returns(bool) +func (_LightweightState *LightweightStateCaller) IsIdentitiesStatesRootExists(opts *bind.CallOpts, root_ [32]byte) (bool, error) { + var out []interface{} + err := _LightweightState.contract.Call(opts, &out, "isIdentitiesStatesRootExists", root_) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// IsIdentitiesStatesRootExists is a free data retrieval call binding the contract method 0xbfd73455. +// +// Solidity: function isIdentitiesStatesRootExists(bytes32 root_) view returns(bool) +func (_LightweightState *LightweightStateSession) IsIdentitiesStatesRootExists(root_ [32]byte) (bool, error) { + return _LightweightState.Contract.IsIdentitiesStatesRootExists(&_LightweightState.CallOpts, root_) +} + +// IsIdentitiesStatesRootExists is a free data retrieval call binding the contract method 0xbfd73455. +// +// Solidity: function isIdentitiesStatesRootExists(bytes32 root_) view returns(bool) +func (_LightweightState *LightweightStateCallerSession) IsIdentitiesStatesRootExists(root_ [32]byte) (bool, error) { + return _LightweightState.Contract.IsIdentitiesStatesRootExists(&_LightweightState.CallOpts, root_) +} + +// Nonces is a free data retrieval call binding the contract method 0xed3218a2. +// +// Solidity: function nonces(address , uint8 ) view returns(uint256) +func (_LightweightState *LightweightStateCaller) Nonces(opts *bind.CallOpts, arg0 common.Address, arg1 uint8) (*big.Int, error) { + var out []interface{} + err := _LightweightState.contract.Call(opts, &out, "nonces", arg0, arg1) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// Nonces is a free data retrieval call binding the contract method 0xed3218a2. +// +// Solidity: function nonces(address , uint8 ) view returns(uint256) +func (_LightweightState *LightweightStateSession) Nonces(arg0 common.Address, arg1 uint8) (*big.Int, error) { + return _LightweightState.Contract.Nonces(&_LightweightState.CallOpts, arg0, arg1) +} + +// Nonces is a free data retrieval call binding the contract method 0xed3218a2. +// +// Solidity: function nonces(address , uint8 ) view returns(uint256) +func (_LightweightState *LightweightStateCallerSession) Nonces(arg0 common.Address, arg1 uint8) (*big.Int, error) { + return _LightweightState.Contract.Nonces(&_LightweightState.CallOpts, arg0, arg1) +} + +// ProxiableUUID is a free data retrieval call binding the contract method 0x52d1902d. +// +// Solidity: function proxiableUUID() view returns(bytes32) +func (_LightweightState *LightweightStateCaller) ProxiableUUID(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _LightweightState.contract.Call(opts, &out, "proxiableUUID") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// ProxiableUUID is a free data retrieval call binding the contract method 0x52d1902d. +// +// Solidity: function proxiableUUID() view returns(bytes32) +func (_LightweightState *LightweightStateSession) ProxiableUUID() ([32]byte, error) { + return _LightweightState.Contract.ProxiableUUID(&_LightweightState.CallOpts) +} + +// ProxiableUUID is a free data retrieval call binding the contract method 0x52d1902d. +// +// Solidity: function proxiableUUID() view returns(bytes32) +func (_LightweightState *LightweightStateCallerSession) ProxiableUUID() ([32]byte, error) { + return _LightweightState.Contract.ProxiableUUID(&_LightweightState.CallOpts) +} + +// Signer is a free data retrieval call binding the contract method 0x238ac933. +// +// Solidity: function signer() view returns(address) +func (_LightweightState *LightweightStateCaller) Signer(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _LightweightState.contract.Call(opts, &out, "signer") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Signer is a free data retrieval call binding the contract method 0x238ac933. +// +// Solidity: function signer() view returns(address) +func (_LightweightState *LightweightStateSession) Signer() (common.Address, error) { + return _LightweightState.Contract.Signer(&_LightweightState.CallOpts) +} + +// Signer is a free data retrieval call binding the contract method 0x238ac933. +// +// Solidity: function signer() view returns(address) +func (_LightweightState *LightweightStateCallerSession) Signer() (common.Address, error) { + return _LightweightState.Contract.Signer(&_LightweightState.CallOpts) +} + +// SourceChainName is a free data retrieval call binding the contract method 0xe4ffd04a. +// +// Solidity: function sourceChainName() view returns(string) +func (_LightweightState *LightweightStateCaller) SourceChainName(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _LightweightState.contract.Call(opts, &out, "sourceChainName") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +// SourceChainName is a free data retrieval call binding the contract method 0xe4ffd04a. +// +// Solidity: function sourceChainName() view returns(string) +func (_LightweightState *LightweightStateSession) SourceChainName() (string, error) { + return _LightweightState.Contract.SourceChainName(&_LightweightState.CallOpts) +} + +// SourceChainName is a free data retrieval call binding the contract method 0xe4ffd04a. +// +// Solidity: function sourceChainName() view returns(string) +func (_LightweightState *LightweightStateCallerSession) SourceChainName() (string, error) { + return _LightweightState.Contract.SourceChainName(&_LightweightState.CallOpts) +} + +// SourceStateContract is a free data retrieval call binding the contract method 0xfc228319. +// +// Solidity: function sourceStateContract() view returns(address) +func (_LightweightState *LightweightStateCaller) SourceStateContract(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _LightweightState.contract.Call(opts, &out, "sourceStateContract") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// SourceStateContract is a free data retrieval call binding the contract method 0xfc228319. +// +// Solidity: function sourceStateContract() view returns(address) +func (_LightweightState *LightweightStateSession) SourceStateContract() (common.Address, error) { + return _LightweightState.Contract.SourceStateContract(&_LightweightState.CallOpts) +} + +// SourceStateContract is a free data retrieval call binding the contract method 0xfc228319. +// +// Solidity: function sourceStateContract() view returns(address) +func (_LightweightState *LightweightStateCallerSession) SourceStateContract() (common.Address, error) { + return _LightweightState.Contract.SourceStateContract(&_LightweightState.CallOpts) +} + +// VerifyStatesMerkleData is a free data retrieval call binding the contract method 0xb0d46f2c. +// +// Solidity: function verifyStatesMerkleData((uint256,uint256,uint256,bytes32[]) statesMerkleData_) view returns(bool, bytes32) +func (_LightweightState *LightweightStateCaller) VerifyStatesMerkleData(opts *bind.CallOpts, statesMerkleData_ ILightweightStateStatesMerkleData) (bool, [32]byte, error) { + var out []interface{} + err := _LightweightState.contract.Call(opts, &out, "verifyStatesMerkleData", statesMerkleData_) + + if err != nil { + return *new(bool), *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + out1 := *abi.ConvertType(out[1], new([32]byte)).(*[32]byte) + + return out0, out1, err + +} + +// VerifyStatesMerkleData is a free data retrieval call binding the contract method 0xb0d46f2c. +// +// Solidity: function verifyStatesMerkleData((uint256,uint256,uint256,bytes32[]) statesMerkleData_) view returns(bool, bytes32) +func (_LightweightState *LightweightStateSession) VerifyStatesMerkleData(statesMerkleData_ ILightweightStateStatesMerkleData) (bool, [32]byte, error) { + return _LightweightState.Contract.VerifyStatesMerkleData(&_LightweightState.CallOpts, statesMerkleData_) +} + +// VerifyStatesMerkleData is a free data retrieval call binding the contract method 0xb0d46f2c. +// +// Solidity: function verifyStatesMerkleData((uint256,uint256,uint256,bytes32[]) statesMerkleData_) view returns(bool, bytes32) +func (_LightweightState *LightweightStateCallerSession) VerifyStatesMerkleData(statesMerkleData_ ILightweightStateStatesMerkleData) (bool, [32]byte, error) { + return _LightweightState.Contract.VerifyStatesMerkleData(&_LightweightState.CallOpts, statesMerkleData_) +} + +// LightweightStateInit is a paid mutator transaction binding the contract method 0x27e25ecf. +// +// Solidity: function __LightweightState_init(address signer_, address sourceStateContract_, string sourceChainName_, string chainName_) returns() +func (_LightweightState *LightweightStateTransactor) LightweightStateInit(opts *bind.TransactOpts, signer_ common.Address, sourceStateContract_ common.Address, sourceChainName_ string, chainName_ string) (*types.Transaction, error) { + return _LightweightState.contract.Transact(opts, "__LightweightState_init", signer_, sourceStateContract_, sourceChainName_, chainName_) +} + +// LightweightStateInit is a paid mutator transaction binding the contract method 0x27e25ecf. +// +// Solidity: function __LightweightState_init(address signer_, address sourceStateContract_, string sourceChainName_, string chainName_) returns() +func (_LightweightState *LightweightStateSession) LightweightStateInit(signer_ common.Address, sourceStateContract_ common.Address, sourceChainName_ string, chainName_ string) (*types.Transaction, error) { + return _LightweightState.Contract.LightweightStateInit(&_LightweightState.TransactOpts, signer_, sourceStateContract_, sourceChainName_, chainName_) +} + +// LightweightStateInit is a paid mutator transaction binding the contract method 0x27e25ecf. +// +// Solidity: function __LightweightState_init(address signer_, address sourceStateContract_, string sourceChainName_, string chainName_) returns() +func (_LightweightState *LightweightStateTransactorSession) LightweightStateInit(signer_ common.Address, sourceStateContract_ common.Address, sourceChainName_ string, chainName_ string) (*types.Transaction, error) { + return _LightweightState.Contract.LightweightStateInit(&_LightweightState.TransactOpts, signer_, sourceStateContract_, sourceChainName_, chainName_) +} + +// SignersInit is a paid mutator transaction binding the contract method 0x509ace95. +// +// Solidity: function __Signers_init(address signer_, string chainName_) returns() +func (_LightweightState *LightweightStateTransactor) SignersInit(opts *bind.TransactOpts, signer_ common.Address, chainName_ string) (*types.Transaction, error) { + return _LightweightState.contract.Transact(opts, "__Signers_init", signer_, chainName_) +} + +// SignersInit is a paid mutator transaction binding the contract method 0x509ace95. +// +// Solidity: function __Signers_init(address signer_, string chainName_) returns() +func (_LightweightState *LightweightStateSession) SignersInit(signer_ common.Address, chainName_ string) (*types.Transaction, error) { + return _LightweightState.Contract.SignersInit(&_LightweightState.TransactOpts, signer_, chainName_) +} + +// SignersInit is a paid mutator transaction binding the contract method 0x509ace95. +// +// Solidity: function __Signers_init(address signer_, string chainName_) returns() +func (_LightweightState *LightweightStateTransactorSession) SignersInit(signer_ common.Address, chainName_ string) (*types.Transaction, error) { + return _LightweightState.Contract.SignersInit(&_LightweightState.TransactOpts, signer_, chainName_) +} + +// ChangeSigner is a paid mutator transaction binding the contract method 0x497f6959. +// +// Solidity: function changeSigner(bytes newSignerPubKey_, bytes signature_) returns() +func (_LightweightState *LightweightStateTransactor) ChangeSigner(opts *bind.TransactOpts, newSignerPubKey_ []byte, signature_ []byte) (*types.Transaction, error) { + return _LightweightState.contract.Transact(opts, "changeSigner", newSignerPubKey_, signature_) +} + +// ChangeSigner is a paid mutator transaction binding the contract method 0x497f6959. +// +// Solidity: function changeSigner(bytes newSignerPubKey_, bytes signature_) returns() +func (_LightweightState *LightweightStateSession) ChangeSigner(newSignerPubKey_ []byte, signature_ []byte) (*types.Transaction, error) { + return _LightweightState.Contract.ChangeSigner(&_LightweightState.TransactOpts, newSignerPubKey_, signature_) +} + +// ChangeSigner is a paid mutator transaction binding the contract method 0x497f6959. +// +// Solidity: function changeSigner(bytes newSignerPubKey_, bytes signature_) returns() +func (_LightweightState *LightweightStateTransactorSession) ChangeSigner(newSignerPubKey_ []byte, signature_ []byte) (*types.Transaction, error) { + return _LightweightState.Contract.ChangeSigner(&_LightweightState.TransactOpts, newSignerPubKey_, signature_) +} + +// ChangeSourceStateContract is a paid mutator transaction binding the contract method 0x89aeb0f5. +// +// Solidity: function changeSourceStateContract(address newSourceStateContract_, bytes signature_) returns() +func (_LightweightState *LightweightStateTransactor) ChangeSourceStateContract(opts *bind.TransactOpts, newSourceStateContract_ common.Address, signature_ []byte) (*types.Transaction, error) { + return _LightweightState.contract.Transact(opts, "changeSourceStateContract", newSourceStateContract_, signature_) +} + +// ChangeSourceStateContract is a paid mutator transaction binding the contract method 0x89aeb0f5. +// +// Solidity: function changeSourceStateContract(address newSourceStateContract_, bytes signature_) returns() +func (_LightweightState *LightweightStateSession) ChangeSourceStateContract(newSourceStateContract_ common.Address, signature_ []byte) (*types.Transaction, error) { + return _LightweightState.Contract.ChangeSourceStateContract(&_LightweightState.TransactOpts, newSourceStateContract_, signature_) +} + +// ChangeSourceStateContract is a paid mutator transaction binding the contract method 0x89aeb0f5. +// +// Solidity: function changeSourceStateContract(address newSourceStateContract_, bytes signature_) returns() +func (_LightweightState *LightweightStateTransactorSession) ChangeSourceStateContract(newSourceStateContract_ common.Address, signature_ []byte) (*types.Transaction, error) { + return _LightweightState.Contract.ChangeSourceStateContract(&_LightweightState.TransactOpts, newSourceStateContract_, signature_) +} + +// CheckSignatureAndIncrementNonce is a paid mutator transaction binding the contract method 0xe3754f90. +// +// Solidity: function checkSignatureAndIncrementNonce(uint8 methodId_, address contractAddress_, bytes32 signHash_, bytes signature_) returns() +func (_LightweightState *LightweightStateTransactor) CheckSignatureAndIncrementNonce(opts *bind.TransactOpts, methodId_ uint8, contractAddress_ common.Address, signHash_ [32]byte, signature_ []byte) (*types.Transaction, error) { + return _LightweightState.contract.Transact(opts, "checkSignatureAndIncrementNonce", methodId_, contractAddress_, signHash_, signature_) +} + +// CheckSignatureAndIncrementNonce is a paid mutator transaction binding the contract method 0xe3754f90. +// +// Solidity: function checkSignatureAndIncrementNonce(uint8 methodId_, address contractAddress_, bytes32 signHash_, bytes signature_) returns() +func (_LightweightState *LightweightStateSession) CheckSignatureAndIncrementNonce(methodId_ uint8, contractAddress_ common.Address, signHash_ [32]byte, signature_ []byte) (*types.Transaction, error) { + return _LightweightState.Contract.CheckSignatureAndIncrementNonce(&_LightweightState.TransactOpts, methodId_, contractAddress_, signHash_, signature_) +} + +// CheckSignatureAndIncrementNonce is a paid mutator transaction binding the contract method 0xe3754f90. +// +// Solidity: function checkSignatureAndIncrementNonce(uint8 methodId_, address contractAddress_, bytes32 signHash_, bytes signature_) returns() +func (_LightweightState *LightweightStateTransactorSession) CheckSignatureAndIncrementNonce(methodId_ uint8, contractAddress_ common.Address, signHash_ [32]byte, signature_ []byte) (*types.Transaction, error) { + return _LightweightState.Contract.CheckSignatureAndIncrementNonce(&_LightweightState.TransactOpts, methodId_, contractAddress_, signHash_, signature_) +} + +// SignedTransitState is a paid mutator transaction binding the contract method 0x189a5073. +// +// Solidity: function signedTransitState(bytes32 newIdentitiesStatesRoot_, (uint256,uint256) gistData_, bytes proof_) returns() +func (_LightweightState *LightweightStateTransactor) SignedTransitState(opts *bind.TransactOpts, newIdentitiesStatesRoot_ [32]byte, gistData_ ILightweightStateGistRootData, proof_ []byte) (*types.Transaction, error) { + return _LightweightState.contract.Transact(opts, "signedTransitState", newIdentitiesStatesRoot_, gistData_, proof_) +} + +// SignedTransitState is a paid mutator transaction binding the contract method 0x189a5073. +// +// Solidity: function signedTransitState(bytes32 newIdentitiesStatesRoot_, (uint256,uint256) gistData_, bytes proof_) returns() +func (_LightweightState *LightweightStateSession) SignedTransitState(newIdentitiesStatesRoot_ [32]byte, gistData_ ILightweightStateGistRootData, proof_ []byte) (*types.Transaction, error) { + return _LightweightState.Contract.SignedTransitState(&_LightweightState.TransactOpts, newIdentitiesStatesRoot_, gistData_, proof_) +} + +// SignedTransitState is a paid mutator transaction binding the contract method 0x189a5073. +// +// Solidity: function signedTransitState(bytes32 newIdentitiesStatesRoot_, (uint256,uint256) gistData_, bytes proof_) returns() +func (_LightweightState *LightweightStateTransactorSession) SignedTransitState(newIdentitiesStatesRoot_ [32]byte, gistData_ ILightweightStateGistRootData, proof_ []byte) (*types.Transaction, error) { + return _LightweightState.Contract.SignedTransitState(&_LightweightState.TransactOpts, newIdentitiesStatesRoot_, gistData_, proof_) +} + +// UpgradeTo is a paid mutator transaction binding the contract method 0x3659cfe6. +// +// Solidity: function upgradeTo(address newImplementation) returns() +func (_LightweightState *LightweightStateTransactor) UpgradeTo(opts *bind.TransactOpts, newImplementation common.Address) (*types.Transaction, error) { + return _LightweightState.contract.Transact(opts, "upgradeTo", newImplementation) +} + +// UpgradeTo is a paid mutator transaction binding the contract method 0x3659cfe6. +// +// Solidity: function upgradeTo(address newImplementation) returns() +func (_LightweightState *LightweightStateSession) UpgradeTo(newImplementation common.Address) (*types.Transaction, error) { + return _LightweightState.Contract.UpgradeTo(&_LightweightState.TransactOpts, newImplementation) +} + +// UpgradeTo is a paid mutator transaction binding the contract method 0x3659cfe6. +// +// Solidity: function upgradeTo(address newImplementation) returns() +func (_LightweightState *LightweightStateTransactorSession) UpgradeTo(newImplementation common.Address) (*types.Transaction, error) { + return _LightweightState.Contract.UpgradeTo(&_LightweightState.TransactOpts, newImplementation) +} + +// UpgradeToAndCall is a paid mutator transaction binding the contract method 0x4f1ef286. +// +// Solidity: function upgradeToAndCall(address newImplementation, bytes data) payable returns() +func (_LightweightState *LightweightStateTransactor) UpgradeToAndCall(opts *bind.TransactOpts, newImplementation common.Address, data []byte) (*types.Transaction, error) { + return _LightweightState.contract.Transact(opts, "upgradeToAndCall", newImplementation, data) +} + +// UpgradeToAndCall is a paid mutator transaction binding the contract method 0x4f1ef286. +// +// Solidity: function upgradeToAndCall(address newImplementation, bytes data) payable returns() +func (_LightweightState *LightweightStateSession) UpgradeToAndCall(newImplementation common.Address, data []byte) (*types.Transaction, error) { + return _LightweightState.Contract.UpgradeToAndCall(&_LightweightState.TransactOpts, newImplementation, data) +} + +// UpgradeToAndCall is a paid mutator transaction binding the contract method 0x4f1ef286. +// +// Solidity: function upgradeToAndCall(address newImplementation, bytes data) payable returns() +func (_LightweightState *LightweightStateTransactorSession) UpgradeToAndCall(newImplementation common.Address, data []byte) (*types.Transaction, error) { + return _LightweightState.Contract.UpgradeToAndCall(&_LightweightState.TransactOpts, newImplementation, data) +} + +// UpgradeToWithSig is a paid mutator transaction binding the contract method 0x52d04661. +// +// Solidity: function upgradeToWithSig(address newImplementation_, bytes signature_) returns() +func (_LightweightState *LightweightStateTransactor) UpgradeToWithSig(opts *bind.TransactOpts, newImplementation_ common.Address, signature_ []byte) (*types.Transaction, error) { + return _LightweightState.contract.Transact(opts, "upgradeToWithSig", newImplementation_, signature_) +} + +// UpgradeToWithSig is a paid mutator transaction binding the contract method 0x52d04661. +// +// Solidity: function upgradeToWithSig(address newImplementation_, bytes signature_) returns() +func (_LightweightState *LightweightStateSession) UpgradeToWithSig(newImplementation_ common.Address, signature_ []byte) (*types.Transaction, error) { + return _LightweightState.Contract.UpgradeToWithSig(&_LightweightState.TransactOpts, newImplementation_, signature_) +} + +// UpgradeToWithSig is a paid mutator transaction binding the contract method 0x52d04661. +// +// Solidity: function upgradeToWithSig(address newImplementation_, bytes signature_) returns() +func (_LightweightState *LightweightStateTransactorSession) UpgradeToWithSig(newImplementation_ common.Address, signature_ []byte) (*types.Transaction, error) { + return _LightweightState.Contract.UpgradeToWithSig(&_LightweightState.TransactOpts, newImplementation_, signature_) +} + +// ValidateChangeAddressSignature is a paid mutator transaction binding the contract method 0x7d1e764b. +// +// Solidity: function validateChangeAddressSignature(uint8 methodId_, address contractAddress_, address newAddress_, bytes signature_) returns() +func (_LightweightState *LightweightStateTransactor) ValidateChangeAddressSignature(opts *bind.TransactOpts, methodId_ uint8, contractAddress_ common.Address, newAddress_ common.Address, signature_ []byte) (*types.Transaction, error) { + return _LightweightState.contract.Transact(opts, "validateChangeAddressSignature", methodId_, contractAddress_, newAddress_, signature_) +} + +// ValidateChangeAddressSignature is a paid mutator transaction binding the contract method 0x7d1e764b. +// +// Solidity: function validateChangeAddressSignature(uint8 methodId_, address contractAddress_, address newAddress_, bytes signature_) returns() +func (_LightweightState *LightweightStateSession) ValidateChangeAddressSignature(methodId_ uint8, contractAddress_ common.Address, newAddress_ common.Address, signature_ []byte) (*types.Transaction, error) { + return _LightweightState.Contract.ValidateChangeAddressSignature(&_LightweightState.TransactOpts, methodId_, contractAddress_, newAddress_, signature_) +} + +// ValidateChangeAddressSignature is a paid mutator transaction binding the contract method 0x7d1e764b. +// +// Solidity: function validateChangeAddressSignature(uint8 methodId_, address contractAddress_, address newAddress_, bytes signature_) returns() +func (_LightweightState *LightweightStateTransactorSession) ValidateChangeAddressSignature(methodId_ uint8, contractAddress_ common.Address, newAddress_ common.Address, signature_ []byte) (*types.Transaction, error) { + return _LightweightState.Contract.ValidateChangeAddressSignature(&_LightweightState.TransactOpts, methodId_, contractAddress_, newAddress_, signature_) +} + +// LightweightStateAdminChangedIterator is returned from FilterAdminChanged and is used to iterate over the raw logs and unpacked data for AdminChanged events raised by the LightweightState contract. +type LightweightStateAdminChangedIterator struct { + Event *LightweightStateAdminChanged // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *LightweightStateAdminChangedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(LightweightStateAdminChanged) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(LightweightStateAdminChanged) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *LightweightStateAdminChangedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *LightweightStateAdminChangedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// LightweightStateAdminChanged represents a AdminChanged event raised by the LightweightState contract. +type LightweightStateAdminChanged struct { + PreviousAdmin common.Address + NewAdmin common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterAdminChanged is a free log retrieval operation binding the contract event 0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f. +// +// Solidity: event AdminChanged(address previousAdmin, address newAdmin) +func (_LightweightState *LightweightStateFilterer) FilterAdminChanged(opts *bind.FilterOpts) (*LightweightStateAdminChangedIterator, error) { + + logs, sub, err := _LightweightState.contract.FilterLogs(opts, "AdminChanged") + if err != nil { + return nil, err + } + return &LightweightStateAdminChangedIterator{contract: _LightweightState.contract, event: "AdminChanged", logs: logs, sub: sub}, nil +} + +// WatchAdminChanged is a free log subscription operation binding the contract event 0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f. +// +// Solidity: event AdminChanged(address previousAdmin, address newAdmin) +func (_LightweightState *LightweightStateFilterer) WatchAdminChanged(opts *bind.WatchOpts, sink chan<- *LightweightStateAdminChanged) (event.Subscription, error) { + + logs, sub, err := _LightweightState.contract.WatchLogs(opts, "AdminChanged") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(LightweightStateAdminChanged) + if err := _LightweightState.contract.UnpackLog(event, "AdminChanged", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseAdminChanged is a log parse operation binding the contract event 0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f. +// +// Solidity: event AdminChanged(address previousAdmin, address newAdmin) +func (_LightweightState *LightweightStateFilterer) ParseAdminChanged(log types.Log) (*LightweightStateAdminChanged, error) { + event := new(LightweightStateAdminChanged) + if err := _LightweightState.contract.UnpackLog(event, "AdminChanged", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// LightweightStateBeaconUpgradedIterator is returned from FilterBeaconUpgraded and is used to iterate over the raw logs and unpacked data for BeaconUpgraded events raised by the LightweightState contract. +type LightweightStateBeaconUpgradedIterator struct { + Event *LightweightStateBeaconUpgraded // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *LightweightStateBeaconUpgradedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(LightweightStateBeaconUpgraded) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(LightweightStateBeaconUpgraded) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *LightweightStateBeaconUpgradedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *LightweightStateBeaconUpgradedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// LightweightStateBeaconUpgraded represents a BeaconUpgraded event raised by the LightweightState contract. +type LightweightStateBeaconUpgraded struct { + Beacon common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterBeaconUpgraded is a free log retrieval operation binding the contract event 0x1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e. +// +// Solidity: event BeaconUpgraded(address indexed beacon) +func (_LightweightState *LightweightStateFilterer) FilterBeaconUpgraded(opts *bind.FilterOpts, beacon []common.Address) (*LightweightStateBeaconUpgradedIterator, error) { + + var beaconRule []interface{} + for _, beaconItem := range beacon { + beaconRule = append(beaconRule, beaconItem) + } + + logs, sub, err := _LightweightState.contract.FilterLogs(opts, "BeaconUpgraded", beaconRule) + if err != nil { + return nil, err + } + return &LightweightStateBeaconUpgradedIterator{contract: _LightweightState.contract, event: "BeaconUpgraded", logs: logs, sub: sub}, nil +} + +// WatchBeaconUpgraded is a free log subscription operation binding the contract event 0x1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e. +// +// Solidity: event BeaconUpgraded(address indexed beacon) +func (_LightweightState *LightweightStateFilterer) WatchBeaconUpgraded(opts *bind.WatchOpts, sink chan<- *LightweightStateBeaconUpgraded, beacon []common.Address) (event.Subscription, error) { + + var beaconRule []interface{} + for _, beaconItem := range beacon { + beaconRule = append(beaconRule, beaconItem) + } + + logs, sub, err := _LightweightState.contract.WatchLogs(opts, "BeaconUpgraded", beaconRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(LightweightStateBeaconUpgraded) + if err := _LightweightState.contract.UnpackLog(event, "BeaconUpgraded", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseBeaconUpgraded is a log parse operation binding the contract event 0x1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e. +// +// Solidity: event BeaconUpgraded(address indexed beacon) +func (_LightweightState *LightweightStateFilterer) ParseBeaconUpgraded(log types.Log) (*LightweightStateBeaconUpgraded, error) { + event := new(LightweightStateBeaconUpgraded) + if err := _LightweightState.contract.UnpackLog(event, "BeaconUpgraded", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// LightweightStateInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the LightweightState contract. +type LightweightStateInitializedIterator struct { + Event *LightweightStateInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *LightweightStateInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(LightweightStateInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(LightweightStateInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *LightweightStateInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *LightweightStateInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// LightweightStateInitialized represents a Initialized event raised by the LightweightState contract. +type LightweightStateInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_LightweightState *LightweightStateFilterer) FilterInitialized(opts *bind.FilterOpts) (*LightweightStateInitializedIterator, error) { + + logs, sub, err := _LightweightState.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &LightweightStateInitializedIterator{contract: _LightweightState.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_LightweightState *LightweightStateFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *LightweightStateInitialized) (event.Subscription, error) { + + logs, sub, err := _LightweightState.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(LightweightStateInitialized) + if err := _LightweightState.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_LightweightState *LightweightStateFilterer) ParseInitialized(log types.Log) (*LightweightStateInitialized, error) { + event := new(LightweightStateInitialized) + if err := _LightweightState.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// LightweightStateSignedStateTransitedIterator is returned from FilterSignedStateTransited and is used to iterate over the raw logs and unpacked data for SignedStateTransited events raised by the LightweightState contract. +type LightweightStateSignedStateTransitedIterator struct { + Event *LightweightStateSignedStateTransited // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *LightweightStateSignedStateTransitedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(LightweightStateSignedStateTransited) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(LightweightStateSignedStateTransited) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *LightweightStateSignedStateTransitedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *LightweightStateSignedStateTransitedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// LightweightStateSignedStateTransited represents a SignedStateTransited event raised by the LightweightState contract. +type LightweightStateSignedStateTransited struct { + NewGistRoot *big.Int + NewIdentitesStatesRoot [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterSignedStateTransited is a free log retrieval operation binding the contract event 0x8e8ff16553fbf4a457c08a5e07cc27c8aac14b9a1a8e1f546a6c1b9366304a56. +// +// Solidity: event SignedStateTransited(uint256 newGistRoot, bytes32 newIdentitesStatesRoot) +func (_LightweightState *LightweightStateFilterer) FilterSignedStateTransited(opts *bind.FilterOpts) (*LightweightStateSignedStateTransitedIterator, error) { + + logs, sub, err := _LightweightState.contract.FilterLogs(opts, "SignedStateTransited") + if err != nil { + return nil, err + } + return &LightweightStateSignedStateTransitedIterator{contract: _LightweightState.contract, event: "SignedStateTransited", logs: logs, sub: sub}, nil +} + +// WatchSignedStateTransited is a free log subscription operation binding the contract event 0x8e8ff16553fbf4a457c08a5e07cc27c8aac14b9a1a8e1f546a6c1b9366304a56. +// +// Solidity: event SignedStateTransited(uint256 newGistRoot, bytes32 newIdentitesStatesRoot) +func (_LightweightState *LightweightStateFilterer) WatchSignedStateTransited(opts *bind.WatchOpts, sink chan<- *LightweightStateSignedStateTransited) (event.Subscription, error) { + + logs, sub, err := _LightweightState.contract.WatchLogs(opts, "SignedStateTransited") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(LightweightStateSignedStateTransited) + if err := _LightweightState.contract.UnpackLog(event, "SignedStateTransited", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseSignedStateTransited is a log parse operation binding the contract event 0x8e8ff16553fbf4a457c08a5e07cc27c8aac14b9a1a8e1f546a6c1b9366304a56. +// +// Solidity: event SignedStateTransited(uint256 newGistRoot, bytes32 newIdentitesStatesRoot) +func (_LightweightState *LightweightStateFilterer) ParseSignedStateTransited(log types.Log) (*LightweightStateSignedStateTransited, error) { + event := new(LightweightStateSignedStateTransited) + if err := _LightweightState.contract.UnpackLog(event, "SignedStateTransited", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// LightweightStateUpgradedIterator is returned from FilterUpgraded and is used to iterate over the raw logs and unpacked data for Upgraded events raised by the LightweightState contract. +type LightweightStateUpgradedIterator struct { + Event *LightweightStateUpgraded // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *LightweightStateUpgradedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(LightweightStateUpgraded) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(LightweightStateUpgraded) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *LightweightStateUpgradedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *LightweightStateUpgradedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// LightweightStateUpgraded represents a Upgraded event raised by the LightweightState contract. +type LightweightStateUpgraded struct { + Implementation common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterUpgraded is a free log retrieval operation binding the contract event 0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b. +// +// Solidity: event Upgraded(address indexed implementation) +func (_LightweightState *LightweightStateFilterer) FilterUpgraded(opts *bind.FilterOpts, implementation []common.Address) (*LightweightStateUpgradedIterator, error) { + + var implementationRule []interface{} + for _, implementationItem := range implementation { + implementationRule = append(implementationRule, implementationItem) + } + + logs, sub, err := _LightweightState.contract.FilterLogs(opts, "Upgraded", implementationRule) + if err != nil { + return nil, err + } + return &LightweightStateUpgradedIterator{contract: _LightweightState.contract, event: "Upgraded", logs: logs, sub: sub}, nil +} + +// WatchUpgraded is a free log subscription operation binding the contract event 0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b. +// +// Solidity: event Upgraded(address indexed implementation) +func (_LightweightState *LightweightStateFilterer) WatchUpgraded(opts *bind.WatchOpts, sink chan<- *LightweightStateUpgraded, implementation []common.Address) (event.Subscription, error) { + + var implementationRule []interface{} + for _, implementationItem := range implementation { + implementationRule = append(implementationRule, implementationItem) + } + + logs, sub, err := _LightweightState.contract.WatchLogs(opts, "Upgraded", implementationRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(LightweightStateUpgraded) + if err := _LightweightState.contract.UnpackLog(event, "Upgraded", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseUpgraded is a log parse operation binding the contract event 0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b. +// +// Solidity: event Upgraded(address indexed implementation) +func (_LightweightState *LightweightStateFilterer) ParseUpgraded(log types.Log) (*LightweightStateUpgraded, error) { + event := new(LightweightStateUpgraded) + if err := _LightweightState.contract.UnpackLog(event, "Upgraded", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/internal/contracts/Voting.go b/internal/contracts/Voting.go new file mode 100644 index 0000000..825a2e8 --- /dev/null +++ b/internal/contracts/Voting.go @@ -0,0 +1,1005 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package contracts + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + +// IVotingVotingCounters is an auto generated low-level Go binding around an user-defined struct. +type IVotingVotingCounters struct { + VotesCount *big.Int +} + +// IVotingVotingParams is an auto generated low-level Go binding around an user-defined struct. +type IVotingVotingParams struct { + Registration common.Address + Remark string + VotingStart *big.Int + VotingPeriod *big.Int + Candidates [][32]byte +} + +// IVotingVotingValues is an auto generated low-level Go binding around an user-defined struct. +type IVotingVotingValues struct { + VotingStartTime *big.Int + VotingEndTime *big.Int + Candidates [][32]byte +} + +// VerifierHelperProofPoints is an auto generated low-level Go binding around an user-defined struct. +type VerifierHelperProofPoints struct { + A [2]*big.Int + B [2][2]*big.Int + C [2]*big.Int +} + +// VotingMetaData contains all meta data concerning the Voting contract. +var VotingMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"voteVerifier_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"root\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"nullifierHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"candidate\",\"type\":\"bytes32\"}],\"name\":\"UserVoted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"proposer\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"contractIRegistration\",\"name\":\"registration\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"remark\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"votingStart\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"votingPeriod\",\"type\":\"uint256\"},{\"internalType\":\"bytes32[]\",\"name\":\"candidates\",\"type\":\"bytes32[]\"}],\"indexed\":false,\"internalType\":\"structIVoting.VotingParams\",\"name\":\"votingParams\",\"type\":\"tuple\"}],\"name\":\"VotingInitialized\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"MAX_CANDIDATES\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"contractIRegistration\",\"name\":\"registration\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"remark\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"votingStart\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"votingPeriod\",\"type\":\"uint256\"},{\"internalType\":\"bytes32[]\",\"name\":\"candidates\",\"type\":\"bytes32[]\"}],\"internalType\":\"structIVoting.VotingParams\",\"name\":\"votingParams_\",\"type\":\"tuple\"}],\"name\":\"__Voting_init\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"candidates\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getProposalStatus\",\"outputs\":[{\"internalType\":\"enumIVoting.VotingStatus\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getRegistrationAddresses\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"nullifiers\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"registration\",\"outputs\":[{\"internalType\":\"contractIRegistration\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"root_\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"nullifierHash_\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"candidate_\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256[2]\",\"name\":\"a\",\"type\":\"uint256[2]\"},{\"internalType\":\"uint256[2][2]\",\"name\":\"b\",\"type\":\"uint256[2][2]\"},{\"internalType\":\"uint256[2]\",\"name\":\"c\",\"type\":\"uint256[2]\"}],\"internalType\":\"structVerifierHelper.ProofPoints\",\"name\":\"proof_\",\"type\":\"tuple\"}],\"name\":\"vote\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"voteVerifier\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"votesPerCandidate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"votingInfo\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"remark\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"votingStartTime\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"votingEndTime\",\"type\":\"uint256\"},{\"internalType\":\"bytes32[]\",\"name\":\"candidates\",\"type\":\"bytes32[]\"}],\"internalType\":\"structIVoting.VotingValues\",\"name\":\"values\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"votesCount\",\"type\":\"uint256\"}],\"internalType\":\"structIVoting.VotingCounters\",\"name\":\"counters\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", +} + +// VotingABI is the input ABI used to generate the binding from. +// Deprecated: Use VotingMetaData.ABI instead. +var VotingABI = VotingMetaData.ABI + +// Voting is an auto generated Go binding around an Ethereum contract. +type Voting struct { + VotingCaller // Read-only binding to the contract + VotingTransactor // Write-only binding to the contract + VotingFilterer // Log filterer for contract events +} + +// VotingCaller is an auto generated read-only Go binding around an Ethereum contract. +type VotingCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// VotingTransactor is an auto generated write-only Go binding around an Ethereum contract. +type VotingTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// VotingFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type VotingFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// VotingSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type VotingSession struct { + Contract *Voting // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// VotingCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type VotingCallerSession struct { + Contract *VotingCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// VotingTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type VotingTransactorSession struct { + Contract *VotingTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// VotingRaw is an auto generated low-level Go binding around an Ethereum contract. +type VotingRaw struct { + Contract *Voting // Generic contract binding to access the raw methods on +} + +// VotingCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type VotingCallerRaw struct { + Contract *VotingCaller // Generic read-only contract binding to access the raw methods on +} + +// VotingTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type VotingTransactorRaw struct { + Contract *VotingTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewVoting creates a new instance of Voting, bound to a specific deployed contract. +func NewVoting(address common.Address, backend bind.ContractBackend) (*Voting, error) { + contract, err := bindVoting(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Voting{VotingCaller: VotingCaller{contract: contract}, VotingTransactor: VotingTransactor{contract: contract}, VotingFilterer: VotingFilterer{contract: contract}}, nil +} + +// NewVotingCaller creates a new read-only instance of Voting, bound to a specific deployed contract. +func NewVotingCaller(address common.Address, caller bind.ContractCaller) (*VotingCaller, error) { + contract, err := bindVoting(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &VotingCaller{contract: contract}, nil +} + +// NewVotingTransactor creates a new write-only instance of Voting, bound to a specific deployed contract. +func NewVotingTransactor(address common.Address, transactor bind.ContractTransactor) (*VotingTransactor, error) { + contract, err := bindVoting(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &VotingTransactor{contract: contract}, nil +} + +// NewVotingFilterer creates a new log filterer instance of Voting, bound to a specific deployed contract. +func NewVotingFilterer(address common.Address, filterer bind.ContractFilterer) (*VotingFilterer, error) { + contract, err := bindVoting(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &VotingFilterer{contract: contract}, nil +} + +// bindVoting binds a generic wrapper to an already deployed contract. +func bindVoting(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(VotingABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Voting *VotingRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Voting.Contract.VotingCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Voting *VotingRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Voting.Contract.VotingTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Voting *VotingRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Voting.Contract.VotingTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Voting *VotingCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Voting.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Voting *VotingTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Voting.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Voting *VotingTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Voting.Contract.contract.Transact(opts, method, params...) +} + +// MAXCANDIDATES is a free data retrieval call binding the contract method 0xf0786096. +// +// Solidity: function MAX_CANDIDATES() view returns(uint256) +func (_Voting *VotingCaller) MAXCANDIDATES(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Voting.contract.Call(opts, &out, "MAX_CANDIDATES") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// MAXCANDIDATES is a free data retrieval call binding the contract method 0xf0786096. +// +// Solidity: function MAX_CANDIDATES() view returns(uint256) +func (_Voting *VotingSession) MAXCANDIDATES() (*big.Int, error) { + return _Voting.Contract.MAXCANDIDATES(&_Voting.CallOpts) +} + +// MAXCANDIDATES is a free data retrieval call binding the contract method 0xf0786096. +// +// Solidity: function MAX_CANDIDATES() view returns(uint256) +func (_Voting *VotingCallerSession) MAXCANDIDATES() (*big.Int, error) { + return _Voting.Contract.MAXCANDIDATES(&_Voting.CallOpts) +} + +// Candidates is a free data retrieval call binding the contract method 0x1a0478d5. +// +// Solidity: function candidates(bytes32 ) view returns(bool) +func (_Voting *VotingCaller) Candidates(opts *bind.CallOpts, arg0 [32]byte) (bool, error) { + var out []interface{} + err := _Voting.contract.Call(opts, &out, "candidates", arg0) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// Candidates is a free data retrieval call binding the contract method 0x1a0478d5. +// +// Solidity: function candidates(bytes32 ) view returns(bool) +func (_Voting *VotingSession) Candidates(arg0 [32]byte) (bool, error) { + return _Voting.Contract.Candidates(&_Voting.CallOpts, arg0) +} + +// Candidates is a free data retrieval call binding the contract method 0x1a0478d5. +// +// Solidity: function candidates(bytes32 ) view returns(bool) +func (_Voting *VotingCallerSession) Candidates(arg0 [32]byte) (bool, error) { + return _Voting.Contract.Candidates(&_Voting.CallOpts, arg0) +} + +// GetProposalStatus is a free data retrieval call binding the contract method 0xcfeb652e. +// +// Solidity: function getProposalStatus() view returns(uint8) +func (_Voting *VotingCaller) GetProposalStatus(opts *bind.CallOpts) (uint8, error) { + var out []interface{} + err := _Voting.contract.Call(opts, &out, "getProposalStatus") + + if err != nil { + return *new(uint8), err + } + + out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) + + return out0, err + +} + +// GetProposalStatus is a free data retrieval call binding the contract method 0xcfeb652e. +// +// Solidity: function getProposalStatus() view returns(uint8) +func (_Voting *VotingSession) GetProposalStatus() (uint8, error) { + return _Voting.Contract.GetProposalStatus(&_Voting.CallOpts) +} + +// GetProposalStatus is a free data retrieval call binding the contract method 0xcfeb652e. +// +// Solidity: function getProposalStatus() view returns(uint8) +func (_Voting *VotingCallerSession) GetProposalStatus() (uint8, error) { + return _Voting.Contract.GetProposalStatus(&_Voting.CallOpts) +} + +// GetRegistrationAddresses is a free data retrieval call binding the contract method 0xe8188f97. +// +// Solidity: function getRegistrationAddresses() view returns(address[]) +func (_Voting *VotingCaller) GetRegistrationAddresses(opts *bind.CallOpts) ([]common.Address, error) { + var out []interface{} + err := _Voting.contract.Call(opts, &out, "getRegistrationAddresses") + + if err != nil { + return *new([]common.Address), err + } + + out0 := *abi.ConvertType(out[0], new([]common.Address)).(*[]common.Address) + + return out0, err + +} + +// GetRegistrationAddresses is a free data retrieval call binding the contract method 0xe8188f97. +// +// Solidity: function getRegistrationAddresses() view returns(address[]) +func (_Voting *VotingSession) GetRegistrationAddresses() ([]common.Address, error) { + return _Voting.Contract.GetRegistrationAddresses(&_Voting.CallOpts) +} + +// GetRegistrationAddresses is a free data retrieval call binding the contract method 0xe8188f97. +// +// Solidity: function getRegistrationAddresses() view returns(address[]) +func (_Voting *VotingCallerSession) GetRegistrationAddresses() ([]common.Address, error) { + return _Voting.Contract.GetRegistrationAddresses(&_Voting.CallOpts) +} + +// Nullifiers is a free data retrieval call binding the contract method 0x2997e86b. +// +// Solidity: function nullifiers(bytes32 ) view returns(bool) +func (_Voting *VotingCaller) Nullifiers(opts *bind.CallOpts, arg0 [32]byte) (bool, error) { + var out []interface{} + err := _Voting.contract.Call(opts, &out, "nullifiers", arg0) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// Nullifiers is a free data retrieval call binding the contract method 0x2997e86b. +// +// Solidity: function nullifiers(bytes32 ) view returns(bool) +func (_Voting *VotingSession) Nullifiers(arg0 [32]byte) (bool, error) { + return _Voting.Contract.Nullifiers(&_Voting.CallOpts, arg0) +} + +// Nullifiers is a free data retrieval call binding the contract method 0x2997e86b. +// +// Solidity: function nullifiers(bytes32 ) view returns(bool) +func (_Voting *VotingCallerSession) Nullifiers(arg0 [32]byte) (bool, error) { + return _Voting.Contract.Nullifiers(&_Voting.CallOpts, arg0) +} + +// Registration is a free data retrieval call binding the contract method 0x443bd1d0. +// +// Solidity: function registration() view returns(address) +func (_Voting *VotingCaller) Registration(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Voting.contract.Call(opts, &out, "registration") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Registration is a free data retrieval call binding the contract method 0x443bd1d0. +// +// Solidity: function registration() view returns(address) +func (_Voting *VotingSession) Registration() (common.Address, error) { + return _Voting.Contract.Registration(&_Voting.CallOpts) +} + +// Registration is a free data retrieval call binding the contract method 0x443bd1d0. +// +// Solidity: function registration() view returns(address) +func (_Voting *VotingCallerSession) Registration() (common.Address, error) { + return _Voting.Contract.Registration(&_Voting.CallOpts) +} + +// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. +// +// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) +func (_Voting *VotingCaller) SupportsInterface(opts *bind.CallOpts, interfaceId [4]byte) (bool, error) { + var out []interface{} + err := _Voting.contract.Call(opts, &out, "supportsInterface", interfaceId) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. +// +// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) +func (_Voting *VotingSession) SupportsInterface(interfaceId [4]byte) (bool, error) { + return _Voting.Contract.SupportsInterface(&_Voting.CallOpts, interfaceId) +} + +// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. +// +// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) +func (_Voting *VotingCallerSession) SupportsInterface(interfaceId [4]byte) (bool, error) { + return _Voting.Contract.SupportsInterface(&_Voting.CallOpts, interfaceId) +} + +// VoteVerifier is a free data retrieval call binding the contract method 0x99d74c71. +// +// Solidity: function voteVerifier() view returns(address) +func (_Voting *VotingCaller) VoteVerifier(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Voting.contract.Call(opts, &out, "voteVerifier") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// VoteVerifier is a free data retrieval call binding the contract method 0x99d74c71. +// +// Solidity: function voteVerifier() view returns(address) +func (_Voting *VotingSession) VoteVerifier() (common.Address, error) { + return _Voting.Contract.VoteVerifier(&_Voting.CallOpts) +} + +// VoteVerifier is a free data retrieval call binding the contract method 0x99d74c71. +// +// Solidity: function voteVerifier() view returns(address) +func (_Voting *VotingCallerSession) VoteVerifier() (common.Address, error) { + return _Voting.Contract.VoteVerifier(&_Voting.CallOpts) +} + +// VotesPerCandidate is a free data retrieval call binding the contract method 0xe0d38faf. +// +// Solidity: function votesPerCandidate(bytes32 ) view returns(uint256) +func (_Voting *VotingCaller) VotesPerCandidate(opts *bind.CallOpts, arg0 [32]byte) (*big.Int, error) { + var out []interface{} + err := _Voting.contract.Call(opts, &out, "votesPerCandidate", arg0) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// VotesPerCandidate is a free data retrieval call binding the contract method 0xe0d38faf. +// +// Solidity: function votesPerCandidate(bytes32 ) view returns(uint256) +func (_Voting *VotingSession) VotesPerCandidate(arg0 [32]byte) (*big.Int, error) { + return _Voting.Contract.VotesPerCandidate(&_Voting.CallOpts, arg0) +} + +// VotesPerCandidate is a free data retrieval call binding the contract method 0xe0d38faf. +// +// Solidity: function votesPerCandidate(bytes32 ) view returns(uint256) +func (_Voting *VotingCallerSession) VotesPerCandidate(arg0 [32]byte) (*big.Int, error) { + return _Voting.Contract.VotesPerCandidate(&_Voting.CallOpts, arg0) +} + +// VotingInfo is a free data retrieval call binding the contract method 0x19e7998c. +// +// Solidity: function votingInfo() view returns(string remark, (uint256,uint256,bytes32[]) values, (uint256) counters) +func (_Voting *VotingCaller) VotingInfo(opts *bind.CallOpts) (struct { + Remark string + Values IVotingVotingValues + Counters IVotingVotingCounters +}, error) { + var out []interface{} + err := _Voting.contract.Call(opts, &out, "votingInfo") + + outstruct := new(struct { + Remark string + Values IVotingVotingValues + Counters IVotingVotingCounters + }) + if err != nil { + return *outstruct, err + } + + outstruct.Remark = *abi.ConvertType(out[0], new(string)).(*string) + outstruct.Values = *abi.ConvertType(out[1], new(IVotingVotingValues)).(*IVotingVotingValues) + outstruct.Counters = *abi.ConvertType(out[2], new(IVotingVotingCounters)).(*IVotingVotingCounters) + + return *outstruct, err + +} + +// VotingInfo is a free data retrieval call binding the contract method 0x19e7998c. +// +// Solidity: function votingInfo() view returns(string remark, (uint256,uint256,bytes32[]) values, (uint256) counters) +func (_Voting *VotingSession) VotingInfo() (struct { + Remark string + Values IVotingVotingValues + Counters IVotingVotingCounters +}, error) { + return _Voting.Contract.VotingInfo(&_Voting.CallOpts) +} + +// VotingInfo is a free data retrieval call binding the contract method 0x19e7998c. +// +// Solidity: function votingInfo() view returns(string remark, (uint256,uint256,bytes32[]) values, (uint256) counters) +func (_Voting *VotingCallerSession) VotingInfo() (struct { + Remark string + Values IVotingVotingValues + Counters IVotingVotingCounters +}, error) { + return _Voting.Contract.VotingInfo(&_Voting.CallOpts) +} + +// VotingInit is a paid mutator transaction binding the contract method 0xf8bd2ace. +// +// Solidity: function __Voting_init((address,string,uint256,uint256,bytes32[]) votingParams_) returns() +func (_Voting *VotingTransactor) VotingInit(opts *bind.TransactOpts, votingParams_ IVotingVotingParams) (*types.Transaction, error) { + return _Voting.contract.Transact(opts, "__Voting_init", votingParams_) +} + +// VotingInit is a paid mutator transaction binding the contract method 0xf8bd2ace. +// +// Solidity: function __Voting_init((address,string,uint256,uint256,bytes32[]) votingParams_) returns() +func (_Voting *VotingSession) VotingInit(votingParams_ IVotingVotingParams) (*types.Transaction, error) { + return _Voting.Contract.VotingInit(&_Voting.TransactOpts, votingParams_) +} + +// VotingInit is a paid mutator transaction binding the contract method 0xf8bd2ace. +// +// Solidity: function __Voting_init((address,string,uint256,uint256,bytes32[]) votingParams_) returns() +func (_Voting *VotingTransactorSession) VotingInit(votingParams_ IVotingVotingParams) (*types.Transaction, error) { + return _Voting.Contract.VotingInit(&_Voting.TransactOpts, votingParams_) +} + +// Vote is a paid mutator transaction binding the contract method 0x0d9eaa43. +// +// Solidity: function vote(bytes32 root_, bytes32 nullifierHash_, bytes32 candidate_, (uint256[2],uint256[2][2],uint256[2]) proof_) returns() +func (_Voting *VotingTransactor) Vote(opts *bind.TransactOpts, root_ [32]byte, nullifierHash_ [32]byte, candidate_ [32]byte, proof_ VerifierHelperProofPoints) (*types.Transaction, error) { + return _Voting.contract.Transact(opts, "vote", root_, nullifierHash_, candidate_, proof_) +} + +// Vote is a paid mutator transaction binding the contract method 0x0d9eaa43. +// +// Solidity: function vote(bytes32 root_, bytes32 nullifierHash_, bytes32 candidate_, (uint256[2],uint256[2][2],uint256[2]) proof_) returns() +func (_Voting *VotingSession) Vote(root_ [32]byte, nullifierHash_ [32]byte, candidate_ [32]byte, proof_ VerifierHelperProofPoints) (*types.Transaction, error) { + return _Voting.Contract.Vote(&_Voting.TransactOpts, root_, nullifierHash_, candidate_, proof_) +} + +// Vote is a paid mutator transaction binding the contract method 0x0d9eaa43. +// +// Solidity: function vote(bytes32 root_, bytes32 nullifierHash_, bytes32 candidate_, (uint256[2],uint256[2][2],uint256[2]) proof_) returns() +func (_Voting *VotingTransactorSession) Vote(root_ [32]byte, nullifierHash_ [32]byte, candidate_ [32]byte, proof_ VerifierHelperProofPoints) (*types.Transaction, error) { + return _Voting.Contract.Vote(&_Voting.TransactOpts, root_, nullifierHash_, candidate_, proof_) +} + +// VotingInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the Voting contract. +type VotingInitializedIterator struct { + Event *VotingInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *VotingInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(VotingInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(VotingInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *VotingInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *VotingInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// VotingInitialized represents a Initialized event raised by the Voting contract. +type VotingInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_Voting *VotingFilterer) FilterInitialized(opts *bind.FilterOpts) (*VotingInitializedIterator, error) { + + logs, sub, err := _Voting.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &VotingInitializedIterator{contract: _Voting.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_Voting *VotingFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *VotingInitialized) (event.Subscription, error) { + + logs, sub, err := _Voting.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(VotingInitialized) + if err := _Voting.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_Voting *VotingFilterer) ParseInitialized(log types.Log) (*VotingInitialized, error) { + event := new(VotingInitialized) + if err := _Voting.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// VotingUserVotedIterator is returned from FilterUserVoted and is used to iterate over the raw logs and unpacked data for UserVoted events raised by the Voting contract. +type VotingUserVotedIterator struct { + Event *VotingUserVoted // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *VotingUserVotedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(VotingUserVoted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(VotingUserVoted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *VotingUserVotedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *VotingUserVotedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// VotingUserVoted represents a UserVoted event raised by the Voting contract. +type VotingUserVoted struct { + User common.Address + Root [32]byte + NullifierHash [32]byte + Candidate [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterUserVoted is a free log retrieval operation binding the contract event 0xd7b642ac96388fe3d629dbcf233cde0723967951c334d29a2b8db1c476182f30. +// +// Solidity: event UserVoted(address indexed user, bytes32 root, bytes32 nullifierHash, bytes32 candidate) +func (_Voting *VotingFilterer) FilterUserVoted(opts *bind.FilterOpts, user []common.Address) (*VotingUserVotedIterator, error) { + + var userRule []interface{} + for _, userItem := range user { + userRule = append(userRule, userItem) + } + + logs, sub, err := _Voting.contract.FilterLogs(opts, "UserVoted", userRule) + if err != nil { + return nil, err + } + return &VotingUserVotedIterator{contract: _Voting.contract, event: "UserVoted", logs: logs, sub: sub}, nil +} + +// WatchUserVoted is a free log subscription operation binding the contract event 0xd7b642ac96388fe3d629dbcf233cde0723967951c334d29a2b8db1c476182f30. +// +// Solidity: event UserVoted(address indexed user, bytes32 root, bytes32 nullifierHash, bytes32 candidate) +func (_Voting *VotingFilterer) WatchUserVoted(opts *bind.WatchOpts, sink chan<- *VotingUserVoted, user []common.Address) (event.Subscription, error) { + + var userRule []interface{} + for _, userItem := range user { + userRule = append(userRule, userItem) + } + + logs, sub, err := _Voting.contract.WatchLogs(opts, "UserVoted", userRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(VotingUserVoted) + if err := _Voting.contract.UnpackLog(event, "UserVoted", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseUserVoted is a log parse operation binding the contract event 0xd7b642ac96388fe3d629dbcf233cde0723967951c334d29a2b8db1c476182f30. +// +// Solidity: event UserVoted(address indexed user, bytes32 root, bytes32 nullifierHash, bytes32 candidate) +func (_Voting *VotingFilterer) ParseUserVoted(log types.Log) (*VotingUserVoted, error) { + event := new(VotingUserVoted) + if err := _Voting.contract.UnpackLog(event, "UserVoted", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// VotingVotingInitializedIterator is returned from FilterVotingInitialized and is used to iterate over the raw logs and unpacked data for VotingInitialized events raised by the Voting contract. +type VotingVotingInitializedIterator struct { + Event *VotingVotingInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *VotingVotingInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(VotingVotingInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(VotingVotingInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *VotingVotingInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *VotingVotingInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// VotingVotingInitialized represents a VotingInitialized event raised by the Voting contract. +type VotingVotingInitialized struct { + Proposer common.Address + VotingParams IVotingVotingParams + Raw types.Log // Blockchain specific contextual infos +} + +// FilterVotingInitialized is a free log retrieval operation binding the contract event 0xb9bbd4e09a06db4d1f06fe2ebe360738047ec15a1f30d6daeb02b0241ebcd290. +// +// Solidity: event VotingInitialized(address indexed proposer, (address,string,uint256,uint256,bytes32[]) votingParams) +func (_Voting *VotingFilterer) FilterVotingInitialized(opts *bind.FilterOpts, proposer []common.Address) (*VotingVotingInitializedIterator, error) { + + var proposerRule []interface{} + for _, proposerItem := range proposer { + proposerRule = append(proposerRule, proposerItem) + } + + logs, sub, err := _Voting.contract.FilterLogs(opts, "VotingInitialized", proposerRule) + if err != nil { + return nil, err + } + return &VotingVotingInitializedIterator{contract: _Voting.contract, event: "VotingInitialized", logs: logs, sub: sub}, nil +} + +// WatchVotingInitialized is a free log subscription operation binding the contract event 0xb9bbd4e09a06db4d1f06fe2ebe360738047ec15a1f30d6daeb02b0241ebcd290. +// +// Solidity: event VotingInitialized(address indexed proposer, (address,string,uint256,uint256,bytes32[]) votingParams) +func (_Voting *VotingFilterer) WatchVotingInitialized(opts *bind.WatchOpts, sink chan<- *VotingVotingInitialized, proposer []common.Address) (event.Subscription, error) { + + var proposerRule []interface{} + for _, proposerItem := range proposer { + proposerRule = append(proposerRule, proposerItem) + } + + logs, sub, err := _Voting.contract.WatchLogs(opts, "VotingInitialized", proposerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(VotingVotingInitialized) + if err := _Voting.contract.UnpackLog(event, "VotingInitialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseVotingInitialized is a log parse operation binding the contract event 0xb9bbd4e09a06db4d1f06fe2ebe360738047ec15a1f30d6daeb02b0241ebcd290. +// +// Solidity: event VotingInitialized(address indexed proposer, (address,string,uint256,uint256,bytes32[]) votingParams) +func (_Voting *VotingFilterer) ParseVotingInitialized(log types.Log) (*VotingVotingInitialized, error) { + event := new(VotingVotingInitialized) + if err := _Voting.contract.UnpackLog(event, "VotingInitialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/internal/service/api/handlers/ctx.go b/internal/service/api/handlers/ctx.go index a3e7d2b..1cf4c44 100644 --- a/internal/service/api/handlers/ctx.go +++ b/internal/service/api/handlers/ctx.go @@ -18,7 +18,10 @@ const ( networkConfigCtxKey ethClientCtxKey voteVerifierRegisterMethodCtxKey + votingVoteMethodCtxKey votingRegistryCtxKey + lightweightStateCtxKey + signedTransitStateCtxKey ) func CtxLog(entry *logan.Entry) func(context.Context) context.Context { @@ -61,6 +64,16 @@ func VoteVerifierRegisterMethod(r *http.Request) *abi.Method { return r.Context().Value(voteVerifierRegisterMethodCtxKey).(*abi.Method) } +func CtxVotingVoteMethod(method *abi.Method) func(context.Context) context.Context { + return func(ctx context.Context) context.Context { + return context.WithValue(ctx, votingVoteMethodCtxKey, method) + } +} + +func VotingVoteMethod(r *http.Request) *abi.Method { + return r.Context().Value(votingVoteMethodCtxKey).(*abi.Method) +} + func CtxVotingRegistry(registry *contracts.VotingRegistry) func(context.Context) context.Context { return func(ctx context.Context) context.Context { return context.WithValue(ctx, votingRegistryCtxKey, registry) @@ -70,3 +83,23 @@ func CtxVotingRegistry(registry *contracts.VotingRegistry) func(context.Context) func VotingRegistry(r *http.Request) *contracts.VotingRegistry { return r.Context().Value(votingRegistryCtxKey).(*contracts.VotingRegistry) } + +func CtxLightweightState(registry *contracts.LightweightState) func(context.Context) context.Context { + return func(ctx context.Context) context.Context { + return context.WithValue(ctx, lightweightStateCtxKey, registry) + } +} + +func LightweightState(r *http.Request) *contracts.LightweightState { + return r.Context().Value(lightweightStateCtxKey).(*contracts.LightweightState) +} + +func CtxSignedTransitStateMethod(method *abi.Method) func(context.Context) context.Context { + return func(ctx context.Context) context.Context { + return context.WithValue(ctx, signedTransitStateCtxKey, method) + } +} + +func SignedTransitStateMethod(r *http.Request) *abi.Method { + return r.Context().Value(signedTransitStateCtxKey).(*abi.Method) +} diff --git a/internal/service/api/handlers/verify_proof.go b/internal/service/api/handlers/register.go similarity index 95% rename from internal/service/api/handlers/verify_proof.go rename to internal/service/api/handlers/register.go index 60c1d7b..5adb266 100644 --- a/internal/service/api/handlers/verify_proof.go +++ b/internal/service/api/handlers/register.go @@ -20,7 +20,7 @@ import ( "gitlab.com/distributed_lab/logan/v3/errors" ) -func VerifyProof(w http.ResponseWriter, r *http.Request) { +func Register(w http.ResponseWriter, r *http.Request) { req, err := requests.NewVerifyProofRequest(r) if err != nil { Log(r).WithError(err).Error("failed to get request") @@ -35,7 +35,7 @@ func VerifyProof(w http.ResponseWriter, r *http.Request) { return } - registration, registerProofParams, err := getTxDataParams(r, dataBytes) + registration, registerProofParams, err := getRegistrationTxDataParams(r, dataBytes) if err != nil { Log(r).WithError(err).Error("failed to get tx data params") ape.RenderErr(w, problems.InternalError()) @@ -71,8 +71,8 @@ func VerifyProof(w http.ResponseWriter, r *http.Request) { if isRegistered { Log(r).WithFields(logan.F{ - "registration": registration.Hex(), - "document_nullififer": registerProofParams.DocumentNullifier.String(), + "registration": registration.Hex(), + "document_nullifier": registerProofParams.DocumentNullifier.String(), }).Error("too many requests for registration and document nullifier") ape.RenderErr(w, problems.TooManyRequests()) return @@ -167,7 +167,7 @@ func VerifyProof(w http.ResponseWriter, r *http.Request) { }) } -func getTxDataParams(r *http.Request, data []byte) ( +func getRegistrationTxDataParams(r *http.Request, data []byte) ( common.Address, contracts.IRegisterVerifierRegisterProofParams, error, ) { unpackResult, err := VoteVerifierRegisterMethod(r).Inputs.Unpack(data[4:]) diff --git a/internal/service/api/handlers/transit_state.go b/internal/service/api/handlers/transit_state.go new file mode 100644 index 0000000..2afa9f8 --- /dev/null +++ b/internal/service/api/handlers/transit_state.go @@ -0,0 +1,101 @@ +package handlers + +import ( + "encoding/json" + "math/big" + "net/http" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/rarimo/proof-verification-relayer/internal/contracts" + "github.com/rarimo/proof-verification-relayer/internal/service/api/requests" + "github.com/rarimo/proof-verification-relayer/resources" + "gitlab.com/distributed_lab/ape" + "gitlab.com/distributed_lab/ape/problems" + "gitlab.com/distributed_lab/logan/v3/errors" +) + +func TransitState(w http.ResponseWriter, r *http.Request) { + req, err := requests.TransitStateDataRequestRequest(r) + if err != nil { + Log(r).WithError(err).Error("failed to get request") + ape.RenderErr(w, problems.BadRequest(err)...) + return + } + + dataBytes, err := hexutil.Decode(req.Data.TxData) + if err != nil { + Log(r).WithError(err).Error("failed to decode data") + ape.RenderErr(w, problems.BadRequest(err)...) + return + } + + newStatesRoot, gistData, proof, err := getSignedTransitStateTxDataParams(r, dataBytes) + if err != nil { + Log(r).WithError(err).Error("failed to get tx data params") + ape.RenderErr(w, problems.InternalError()) + return + } + + gasPrice, err := EthClient(r).SuggestGasPrice(r.Context()) + if err != nil { + Log(r).WithError(err).Error("failed to suggest gas price") + ape.RenderErr(w, problems.InternalError()) + return + } + + NetworkConfig(r).LockNonce() + defer NetworkConfig(r).UnlockNonce() + + tx, err := LightweightState(r).SignedTransitState(&bind.TransactOpts{ + Nonce: new(big.Int).SetUint64(NetworkConfig(r).Nonce()), + GasPrice: gasPrice, + }, newStatesRoot, gistData, proof) + + NetworkConfig(r).IncrementNonce() + + ape.Render(w, resources.Tx{ + Key: resources.Key{ + ID: tx.Hash().String(), + Type: resources.TXS, + }, + Attributes: resources.TxAttributes{ + TxHash: tx.Hash().String(), + }, + }) +} + +func getSignedTransitStateTxDataParams(r *http.Request, data []byte) ([32]byte, contracts.ILightweightStateGistRootData, []byte, error) { + gistRootData := contracts.ILightweightStateGistRootData{} + var newStateRoot [32]byte + + unpackResult, err := SignedTransitStateMethod(r).Inputs.Unpack(data[4:]) + if err != nil { + return newStateRoot, gistRootData, nil, errors.Wrap(err, "failed to unpack tx data") + } + + if len(unpackResult) != 3 { + return newStateRoot, gistRootData, nil, errors.Wrap(err, "unpack result is not valid") + } + + newStateRoot, ok := unpackResult[0].([32]byte) + if !ok { + return newStateRoot, gistRootData, nil, errors.New("failed to convert newIdentitiesStatesRoot_ interface to [32]byte") + } + + gistDataJSON, err := json.Marshal(unpackResult[1]) + if err != nil { + return newStateRoot, gistRootData, nil, errors.Wrap(err, "failed to marshal JSON") + } + + if err := json.Unmarshal(gistDataJSON, &gistRootData); err != nil { + return newStateRoot, gistRootData, nil, errors.Wrap(err, "failed to unmarshal JSON") + } + + lightweightStateProof, ok := unpackResult[2].([]byte) + if !ok { + return newStateRoot, gistRootData, nil, errors.New("failed to convert lightweightStateProof interface to []byte") + } + + return newStateRoot, gistRootData, lightweightStateProof, nil +} diff --git a/internal/service/api/handlers/vote.go b/internal/service/api/handlers/vote.go new file mode 100644 index 0000000..4f6f591 --- /dev/null +++ b/internal/service/api/handlers/vote.go @@ -0,0 +1,138 @@ +package handlers + +import ( + "net/http" + "strings" + + "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + "github.com/rarimo/proof-verification-relayer/internal/service/api/requests" + "github.com/rarimo/proof-verification-relayer/resources" + "gitlab.com/distributed_lab/ape" + "gitlab.com/distributed_lab/ape/problems" + "gitlab.com/distributed_lab/logan/v3/errors" +) + +func Vote(w http.ResponseWriter, r *http.Request) { + req, err := requests.NewVoteRequest(r) + if err != nil { + Log(r).WithError(err).Error("failed to get request") + ape.RenderErr(w, problems.BadRequest(err)...) + return + } + + dataBytes, err := hexutil.Decode(req.Data.TxData) + if err != nil { + Log(r).WithError(err).Error("failed to decode data") + ape.RenderErr(w, problems.BadRequest(err)...) + return + } + + registration := common.HexToAddress(req.Data.Registration) + voting := common.HexToAddress(req.Data.Voting) + + exists, err := VotingRegistry(r).IsPoolExistByProposer(&bind.CallOpts{}, NetworkConfig(r).Proposer, registration) + if err != nil { + Log(r).WithError(err).Error("failed to check if registration exists by proposer") + ape.RenderErr(w, problems.InternalError()) + return + } + + if !exists { + Log(r).WithField("registration", registration.String()).Error("registration does not exist") + ape.RenderErr(w, problems.BadRequest(errors.New("registration does not exist"))...) + return + } + + gasPrice, err := EthClient(r).SuggestGasPrice(r.Context()) + if err != nil { + Log(r).WithError(err).Error("failed to suggest gas price") + ape.RenderErr(w, problems.InternalError()) + return + } + + NetworkConfig(r).LockNonce() + defer NetworkConfig(r).UnlockNonce() + + gas, err := EthClient(r).EstimateGas(r.Context(), ethereum.CallMsg{ + From: crypto.PubkeyToAddress(NetworkConfig(r).PrivateKey.PublicKey), + To: &voting, + GasPrice: gasPrice, + Data: dataBytes, + }) + if err != nil { + Log(r).WithError(err).Error("failed to estimate gas") + ape.RenderErr(w, problems.InternalError()) + return + } + + tx, err := types.SignNewTx( + NetworkConfig(r).PrivateKey, + types.NewCancunSigner(NetworkConfig(r).ChainID), + &types.LegacyTx{ + Nonce: NetworkConfig(r).Nonce(), + Gas: gas, + GasPrice: gasPrice, + To: &voting, + Data: dataBytes, + }, + ) + if err != nil { + Log(r).WithError(err).Error("failed to sign new tx") + ape.RenderErr(w, problems.InternalError()) + return + } + + if err := EthClient(r).SendTransaction(r.Context(), tx); err != nil { + if strings.Contains(err.Error(), "nonce") { + if err := NetworkConfig(r).ResetNonce(EthClient(r)); err != nil { + Log(r).WithError(err).Error("failed to reset nonce") + ape.RenderErr(w, problems.InternalError()) + return + } + + tx, err = types.SignNewTx( + NetworkConfig(r).PrivateKey, + types.NewCancunSigner(NetworkConfig(r).ChainID), + &types.LegacyTx{ + Nonce: NetworkConfig(r).Nonce(), + Gas: gas, + GasPrice: gasPrice, + To: &voting, + Data: dataBytes, + }, + ) + if err != nil { + Log(r).WithError(err).Error("failed to sign new tx") + ape.RenderErr(w, problems.InternalError()) + return + } + + if err := EthClient(r).SendTransaction(r.Context(), tx); err != nil { + Log(r).WithError(err).Error("failed to send transaction") + ape.RenderErr(w, problems.InternalError()) + return + } + } else { + Log(r).WithError(err).Error("failed to send transaction") + ape.RenderErr(w, problems.InternalError()) + return + } + } + + NetworkConfig(r).IncrementNonce() + + ape.Render(w, resources.Tx{ + Key: resources.Key{ + ID: tx.Hash().String(), + Type: resources.TXS, + }, + Attributes: resources.TxAttributes{ + TxHash: tx.Hash().String(), + }, + }) +} diff --git a/internal/service/api/requests/rules.go b/internal/service/api/requests/rules.go new file mode 100644 index 0000000..30a2d40 --- /dev/null +++ b/internal/service/api/requests/rules.go @@ -0,0 +1,14 @@ +package requests + +import ( + "github.com/ethereum/go-ethereum/common" + "gitlab.com/distributed_lab/logan/v3/errors" +) + +func isAddressRule(value interface{}) error { + address, _ := value.(string) + if !common.IsHexAddress(address) { + return errors.New("should be a valid address") + } + return nil +} diff --git a/internal/service/api/requests/transit_state.go b/internal/service/api/requests/transit_state.go new file mode 100644 index 0000000..46c0631 --- /dev/null +++ b/internal/service/api/requests/transit_state.go @@ -0,0 +1,34 @@ +package requests + +import ( + "encoding/json" + "net/http" + + validation "github.com/go-ozzo/ozzo-validation/v4" + "gitlab.com/distributed_lab/logan/v3/errors" +) + +type TransitStateData struct { + TxData string `json:"tx_data"` +} + +type TransitStateDataRequest struct { + Data TransitStateData `json:"data"` +} + +func TransitStateDataRequestRequest(r *http.Request) (TransitStateDataRequest, error) { + var request TransitStateDataRequest + + err := json.NewDecoder(r.Body).Decode(&request) + if err != nil { + return request, errors.Wrap(err, "failed to unmarshal") + } + + return request, validateTransitStateDataRequest(request) +} + +func validateTransitStateDataRequest(r TransitStateDataRequest) error { + return validation.Errors{ + "/data/tx_data": validation.Validate(r.Data.TxData, validation.Required), + }.Filter() +} diff --git a/internal/service/api/requests/vote.go b/internal/service/api/requests/vote.go new file mode 100644 index 0000000..a1885b0 --- /dev/null +++ b/internal/service/api/requests/vote.go @@ -0,0 +1,39 @@ +package requests + +import ( + "encoding/json" + "net/http" + + validation "github.com/go-ozzo/ozzo-validation/v4" + "gitlab.com/distributed_lab/logan/v3/errors" +) + +type VoteRequestData struct { + TxData string `json:"tx_data"` + Voting string `json:"voting"` + Registration string `json:"registration"` +} + +type VoteRequest struct { + Data VoteRequestData `json:"data"` +} + +func NewVoteRequest(r *http.Request) (VoteRequest, error) { + var request VoteRequest + + err := json.NewDecoder(r.Body).Decode(&request) + if err != nil { + return request, errors.Wrap(err, "failed to unmarshal") + } + + return request, validateVoteRequest(request) +} + +func validateVoteRequest(r VoteRequest) error { + return validation.Errors{ + "/data/voting": validation.Validate( + r.Data.Voting, validation.Required, validation.By(isAddressRule)), + "/data/registration": validation.Validate( + r.Data.Registration, validation.Required, validation.By(isAddressRule)), + }.Filter() +} diff --git a/internal/service/router.go b/internal/service/router.go index fd4eb46..fcd1435 100644 --- a/internal/service/router.go +++ b/internal/service/router.go @@ -22,7 +22,17 @@ func (s *service) router() chi.Router { panic(errors.Wrap(err, "failed to get vote verifier ABI")) } - method, ok := verifierABI.Methods["register"] + registerMethod, ok := verifierABI.Methods["register"] + if !ok { + panic(errors.New("register method not found")) + } + + votingABI, err := contracts.VotingMetaData.GetAbi() + if err != nil { + panic(errors.Wrap(err, "failed to get vote verifier ABI")) + } + + votingMethod, ok := votingABI.Methods["vote"] if !ok { panic(errors.New("register method not found")) } @@ -32,6 +42,21 @@ func (s *service) router() chi.Router { panic(errors.Wrap(err, "failed to initialize new voting registry")) } + lightweightState, err := contracts.NewLightweightState(s.cfg.NetworkConfig().LightweightState, ethClient) + if err != nil { + panic(errors.Wrap(err, "failed to initialize new lightweight state")) + } + + lightweightStateABI, err := contracts.LightweightStateMetaData.GetAbi() + if err != nil { + panic(errors.Wrap(err, "failed to get lightweight state ABI")) + } + + signedTransitState, ok := lightweightStateABI.Methods["signedTransitState"] + if !ok { + panic(errors.New("signedTransitState method not found")) + } + r.Use( ape.RecoverMiddleware(s.log), ape.LoganMiddleware(s.log), @@ -39,13 +64,18 @@ func (s *service) router() chi.Router { handlers.CtxLog(s.log), handlers.CtxNetworkConfig(s.cfg.NetworkConfig()), handlers.CtxEthClient(ethClient), - handlers.CtxVoteVerifierRegisterMethod(&method), + handlers.CtxVoteVerifierRegisterMethod(®isterMethod), + handlers.CtxVotingVoteMethod(&votingMethod), handlers.CtxVotingRegistry(votingRegistry), + handlers.CtxLightweightState(lightweightState), + handlers.CtxSignedTransitStateMethod(&signedTransitState), ), ) r.Route("/integrations/proof-verification-relayer", func(r chi.Router) { r.Route("/v1", func(r chi.Router) { - r.Post("/verify-proof", handlers.VerifyProof) + r.Post("/register", handlers.Register) + r.Post("/vote", handlers.Vote) + r.Post("/transit-state", handlers.TransitState) }) })