From 000f8ebeeb6e17d71e2095c97b8188bf01053c18 Mon Sep 17 00:00:00 2001 From: jzhe Date: Thu, 29 Apr 2021 10:15:53 +0800 Subject: [PATCH] feat:support erc20 interchain --- go.mod | 2 +- go.sum | 25 +- internal/app/bitxhub.go | 4 +- internal/coreapi/broker.go | 25 + internal/executor/contracts/eth_header.go | 164 + internal/executor/executor.go | 21 +- internal/executor/oracle/appchain/escrow.go | 4602 +++++++++++++++++ internal/executor/oracle/appchain/eth.go | 147 + internal/executor/oracle/appchain/eth_test.go | 124 + pkg/peermgr/handle.go | 48 + pkg/peermgr/mock_peermgr/mock_peermgr.go | 291 +- pkg/vm/boltvm/bolt_stub.go | 2 + 12 files changed, 5284 insertions(+), 171 deletions(-) create mode 100644 internal/executor/contracts/eth_header.go create mode 100644 internal/executor/oracle/appchain/escrow.go create mode 100644 internal/executor/oracle/appchain/eth.go create mode 100644 internal/executor/oracle/appchain/eth_test.go diff --git a/go.mod b/go.mod index ca1c290..d33f1ff 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/magiconair/properties v1.8.4 github.com/meshplus/bitxhub-core v1.3.0 github.com/meshplus/bitxhub-kit v1.2.0 - github.com/meshplus/bitxhub-model v1.2.0 + github.com/meshplus/bitxhub-model v1.2.1-0.20210429021628-d64a34d749b4 github.com/meshplus/bitxid v0.0.0-20210412025850-e0eaf0f9063a github.com/meshplus/did-registry v0.0.0-20210413035015-509c6c3a0bae github.com/meshplus/go-libp2p-cert v0.0.0-20210125063330-7c25fd5b7a49 diff --git a/go.sum b/go.sum index aace02f..06af86d 100644 --- a/go.sum +++ b/go.sum @@ -126,6 +126,7 @@ github.com/cbergoon/merkletree v0.2.0 h1:Bttqr3OuoiZEo4ed1L7fTasHka9II+BF9fhBfbN github.com/cbergoon/merkletree v0.2.0/go.mod h1:5c15eckUgiucMGDOCanvalj/yJnD+KAZj1qyJtRW5aM= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +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= @@ -192,6 +193,7 @@ github.com/dgryski/go-farm v0.0.0-20190104051053-3adb47b1fb0f/go.mod h1:SqUrOPUn github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= +github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf h1:sh8rkQZavChcmakYiSlqu2425CHyFXLZZnvm7PDpU8M= github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/dop251/goja v0.0.0-20200721192441-a695b0cdd498/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -221,6 +223,7 @@ github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc h1:jtW8jbpkO4YirRSyepBOH8E+2HEw6/hKkBvFPwhUN8c= github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= +github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6 h1:u/UEqS66A5ckRmS4yNpjmVH56sVtS/RfclBAYocb4as= github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:1i71OnUq3iUe1ma7Lr6yG6/rjvM3emb6yoL7xLFzcVQ= @@ -553,6 +556,7 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV github.com/juju/ratelimit v1.0.1 h1:+7AIFJVQ0EQgq/K9+0Krm7m530Du7tIz0METWzN0RgY= github.com/juju/ratelimit v1.0.1/go.mod h1:qapgC/Gy+xNh9UxzV13HGGl/6UXNN+ct+vwSgWNm/qk= github.com/julienschmidt/httprouter v1.1.1-0.20170430222011-975b5c4c7c21/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0= @@ -817,10 +821,6 @@ github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpe github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/meshplus/bitxhub-core v0.1.0-rc1.0.20210318102029-494ee3060b0c/go.mod h1:G19Wrz1u66UmwaES/iLM19jmlv3APAZ5qfYOlNnIIZw= -github.com/meshplus/bitxhub-core v0.1.0-rc1.0.20210423140028-7c7e2fd80a46 h1:ZX6J+BcLFuxzCmC8yf7DC5ah9MVJ+birGL5xd5SMdgY= -github.com/meshplus/bitxhub-core v0.1.0-rc1.0.20210423140028-7c7e2fd80a46/go.mod h1:ijf/8xybq2lGz86VKSTghDQGrKhx7GHavDQpCJWcsDs= -github.com/meshplus/bitxhub-core v1.2.0 h1:tSOIN3Fg89UJwu0XhlCIP+oCLwhg/TP4JQehTFp4Las= -github.com/meshplus/bitxhub-core v1.2.0/go.mod h1:2ksSKEiox4B06gSPT6h4+GcdWnh92/FDPUUImX/dI04= github.com/meshplus/bitxhub-core v1.3.0 h1:bv4iAQMk7tg0Gz6WfoC3q1/ssLhE0czNnUcLglWrltM= github.com/meshplus/bitxhub-core v1.3.0/go.mod h1:2ksSKEiox4B06gSPT6h4+GcdWnh92/FDPUUImX/dI04= github.com/meshplus/bitxhub-kit v1.1.1 h1:vkPO88oA3+Kpc0N8lIgfj/U52KBuI+633hPbMYt1xm8= @@ -831,25 +831,15 @@ github.com/meshplus/bitxhub-kit v1.1.2-0.20201203072410-8a0383a6870d h1:J9tzTNf2 github.com/meshplus/bitxhub-kit v1.1.2-0.20201203072410-8a0383a6870d/go.mod h1:KR7ZlXhII9n0Bu8viaZTScvXCYn0MCQnYlsTvHPp0XA= github.com/meshplus/bitxhub-kit v1.1.2-0.20210112075018-319e668d6359 h1:GdgS14bnCF4b/a5zhQi2wlu92pHc9cfl6A1HcbO7zmE= github.com/meshplus/bitxhub-kit v1.1.2-0.20210112075018-319e668d6359/go.mod h1:KR7ZlXhII9n0Bu8viaZTScvXCYn0MCQnYlsTvHPp0XA= -github.com/meshplus/bitxhub-kit v1.1.2-0.20210423082909-97edee705d22 h1:4PguI96NAg5IFHTnUi0YGQ9HgSiV3K0b/PkxaWRmUrg= -github.com/meshplus/bitxhub-kit v1.1.2-0.20210423082909-97edee705d22/go.mod h1:ltiaMnupw2mzE1gENiV6LF6C8UYu0bF7w1NrG3QDvFQ= -github.com/meshplus/bitxhub-kit v1.1.2-0.20210425013549-7a642723d279/go.mod h1:ltiaMnupw2mzE1gENiV6LF6C8UYu0bF7w1NrG3QDvFQ= -github.com/meshplus/bitxhub-kit v1.1.2-0.20210425020456-3e87ac09c707 h1:xkeoue4sog72PnVVmPrcGgGiQDjaougHallr4RjDTEk= -github.com/meshplus/bitxhub-kit v1.1.2-0.20210425020456-3e87ac09c707/go.mod h1:Zs4eZnVtI0uX6aIMN7DnqXCJTthQ0WNrjF1/h6KkGRc= github.com/meshplus/bitxhub-kit v1.2.0 h1:lG6vyRD14bPoQFNU8ygmgzMXAy4xDlEueJyM6vShndo= github.com/meshplus/bitxhub-kit v1.2.0/go.mod h1:vGTKDkCAU7/IlirT6tlq6BMnCpY9UbfrrwGDy6foQIg= github.com/meshplus/bitxhub-model v1.1.1/go.mod h1:lUl9vPZXM9tP+B0ABRW/2eOW/6KCmjFTdoiTj5Vut/A= github.com/meshplus/bitxhub-model v1.1.2-0.20201021152621-0b3c17c54b23/go.mod h1:4qWBZx5wv7WZzUqiuBsbkQqQ2Ju8aOFpsoNpBBNy8Us= github.com/meshplus/bitxhub-model v1.1.2-0.20210409090411-de23bd385c5f/go.mod h1:x3H+TL24wcByzHegenLfs+5PQkQGNsk8eCm31QJMa+Q= -github.com/meshplus/bitxhub-model v1.1.2-0.20210423135747-9546174eabb0/go.mod h1:rW2Sd4ZFdBoch0h4i1lSuyHNFIOg/3t8loQ+LV5rvNc= -github.com/meshplus/bitxhub-model v1.1.2-0.20210425021723-411f67ad49be h1:SGCgDzpMEu/cpjlewBrotZmGujB9tPOEL614CrJxlLk= -github.com/meshplus/bitxhub-model v1.1.2-0.20210425021723-411f67ad49be/go.mod h1:XIfxB6AAi0D5Qd7jmOykijSvI0GSKQZRR0OG0cp23iU= -github.com/meshplus/bitxhub-model v1.1.2-0.20210426012554-bb170814ec11 h1:rdevlFfnfLNvoSfnJx/pdJkfUHAQGoJfyqxDxWOyhJw= -github.com/meshplus/bitxhub-model v1.1.2-0.20210426012554-bb170814ec11/go.mod h1:XIfxB6AAi0D5Qd7jmOykijSvI0GSKQZRR0OG0cp23iU= -github.com/meshplus/bitxhub-model v1.1.2-0.20210426065438-954f4d830abc h1:Xdr93A4XsYXzI0Sxcmrvsl9aDt0QGnaXfs8i1vbGmhk= -github.com/meshplus/bitxhub-model v1.1.2-0.20210426065438-954f4d830abc/go.mod h1:XIfxB6AAi0D5Qd7jmOykijSvI0GSKQZRR0OG0cp23iU= github.com/meshplus/bitxhub-model v1.2.0 h1:Ac8ol1HZNLIegyZkU/DZGYkPeeAWp3ZgYsbJGNF2GV0= github.com/meshplus/bitxhub-model v1.2.0/go.mod h1:QCYJy8fUQex0cvxqAZtGHJn31F5mwuXnE3Lyri15zUc= +github.com/meshplus/bitxhub-model v1.2.1-0.20210429021628-d64a34d749b4 h1:qfn8eq0RJyIsTbUkoXPKYsGIvW29pZl/bsWjGB6bLDE= +github.com/meshplus/bitxhub-model v1.2.1-0.20210429021628-d64a34d749b4/go.mod h1:2zFpbwQ/2y7JiTCsnLYSa3XTF1jTz0ElsQJhUksj2EE= github.com/meshplus/bitxid v0.0.0-20210412025850-e0eaf0f9063a h1:c4ESPDa60Jd4zfzZIGGTyzhfaVM3vKN+xV2G9BwIDGQ= github.com/meshplus/bitxid v0.0.0-20210412025850-e0eaf0f9063a/go.mod h1:vAldSRfDe2Qo7exsSTbchVmZWXPY7fhWQrRw18QJHho= github.com/meshplus/did-registry v0.0.0-20210413035015-509c6c3a0bae h1:E4iaFwHAg1ScyiU9Bz3RY0wjfXNZzPH3O43DBTl9iWg= @@ -1433,6 +1423,7 @@ golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 h1:Hir2P/De0WpUhtrKGGjvSb2YxUgyZ7EFOSLIcSSpiwE= golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -1543,6 +1534,7 @@ gopkg.in/src-d/go-cli.v0 v0.0.0-20181105080154-d492247bbc0d/go.mod h1:z+K8VcOYVY gopkg.in/src-d/go-log.v1 v1.0.1/go.mod h1:GN34hKP0g305ysm2/hctJ0Y8nWP3zxXXJ8GFabTyABE= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/urfave/cli.v1 v1.20.0 h1:NdAVW6RYxDif9DhDHaAortIu956m2c0v+09AZBPTbE0= gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= @@ -1559,6 +1551,7 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200601152816-913338de1bd2 h1:VEmvx0P+GVTgkNu2EdTN988YCZPcD3lo9AoczZpucwc= gopkg.in/yaml.v3 v3.0.0-20200601152816-913338de1bd2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/internal/app/bitxhub.go b/internal/app/bitxhub.go index ddfe039..93befbd 100644 --- a/internal/app/bitxhub.go +++ b/internal/app/bitxhub.go @@ -128,12 +128,12 @@ func GenerateBitXHubWithoutOrder(rep *repo.Repo) (*BitXHub, error) { } // 1. create executor and view executor - txExec, err := executor.New(rwLdg, loggers.Logger(loggers.Executor), rep.Config.Executor.Type, rep.Config.GasLimit) + txExec, err := executor.New(rwLdg, loggers.Logger(loggers.Executor), *rep.Config) if err != nil { return nil, fmt.Errorf("create BlockExecutor: %w", err) } - viewExec, err := executor.New(viewLdg, loggers.Logger(loggers.Executor), rep.Config.Executor.Type, rep.Config.GasLimit) + viewExec, err := executor.New(viewLdg, loggers.Logger(loggers.Executor), *rep.Config) if err != nil { return nil, fmt.Errorf("create ViewExecutor: %w", err) } diff --git a/internal/coreapi/broker.go b/internal/coreapi/broker.go index 41add4c..2c0b94b 100644 --- a/internal/coreapi/broker.go +++ b/internal/coreapi/broker.go @@ -162,6 +162,8 @@ func (b *BrokerAPI) FetchSignsFromOtherPeers(id string, typ pb.GetMultiSignsRequ address, sign, err = b.requestIBTPSignPeer(pid, id) case pb.GetMultiSignsRequest_BLOCK_HEADER: address, sign, err = b.requestBlockHeaderSignFromPeer(pid, id) + case pb.GetMultiSignsRequest_MINT: + address, sign, err = b.requestMintSignFromPeer(pid, id) } if err != nil { @@ -250,6 +252,29 @@ func (b *BrokerAPI) requestBlockHeaderSignFromPeer(pid uint64, height string) (s return data.Address, data.Signature, nil } +func (b *BrokerAPI) requestMintSignFromPeer(pid uint64, height string) (string, []byte, error) { + req := pb.Message{ + Type: pb.Message_FETCH_MINT_SIGN, + Data: []byte(height), + } + + resp, err := b.bxh.PeerMgr.Send(pid, &req) + if err != nil { + return "", nil, err + } + + if resp == nil || resp.Type != pb.Message_FETCH_MINT_SIGN_ACK { + return "", nil, fmt.Errorf("invalid fetch minter sign resp") + } + + data := model.MerkleWrapperSign{} + if err := data.Unmarshal(resp.Data); err != nil { + return "", nil, err + } + + return data.Address, data.Signature, nil +} + func (b *BrokerAPI) GetSign(content string, typ pb.GetMultiSignsRequest_Type) (string, []byte, error) { switch typ { case pb.GetMultiSignsRequest_ASSET_EXCHANGE: diff --git a/internal/executor/contracts/eth_header.go b/internal/executor/contracts/eth_header.go new file mode 100644 index 0000000..9ce11df --- /dev/null +++ b/internal/executor/contracts/eth_header.go @@ -0,0 +1,164 @@ +package contracts + +import ( + "bytes" + "encoding/json" + "fmt" + "strconv" + "strings" + + "github.com/ethereum/go-ethereum/crypto" + + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/meshplus/bitxhub-core/boltvm" + "github.com/meshplus/bitxhub/internal/executor/oracle/appchain" + "github.com/sirupsen/logrus" +) + +const ( + EscrowsAddrKey = "escrows_addr_key" + MINT_HASH_PREFIX = "mint" +) + +type EscrowsAddr struct { + EscrowsAddr string `json:"addr"` +} + +type EthHeaderManager struct { + boltvm.Stub + oracle *appchain.EthLightChainOracle +} + +func NewEthHeaderManager(path string, logger logrus.FieldLogger) *EthHeaderManager { + ropstenOracle, err := appchain.NewRopstenOracle(path, logger) + if err != nil { + panic(err) + } + return &EthHeaderManager{oracle: ropstenOracle} +} + +func (ehm *EthHeaderManager) SetEscrowAddr(addr string) *boltvm.Response { + //TODO:add governance + ok := common.IsHexAddress(addr) + if ok { + escrowsAddr := EscrowsAddr{addr} + ehm.SetObject(EscrowsAddrKey, escrowsAddr) + } + return boltvm.Success([]byte(addr)) +} + +func (ehm *EthHeaderManager) GetEscrowAddr() *boltvm.Response { + var escrowsAddr EscrowsAddr + ok := ehm.GetObject(EscrowsAddrKey, escrowsAddr) + if ok { + return boltvm.Success([]byte(escrowsAddr.EscrowsAddr)) + } + return boltvm.Error("not found") +} + +func (ehm *EthHeaderManager) InsertBlockHeaders(headersData []byte) *boltvm.Response { + headers := make([]*types.Header, 0) + err := json.Unmarshal(headersData, &headers) + if err != nil { + return boltvm.Error(err.Error()) + } + num, err := ehm.oracle.InsertBlockHeaders(headers) + if err != nil { + return boltvm.Error(err.Error()) + } + return boltvm.Success([]byte(strconv.Itoa(num))) +} + +func (ehm *EthHeaderManager) CurrentBlockHeader() *boltvm.Response { + header := ehm.oracle.CurrentHeader() + if header == nil { + return boltvm.Error("not found") + } + data, err := header.MarshalJSON() + if err != nil { + return boltvm.Error(err.Error()) + } + return boltvm.Success(data) +} + +func (ehm *EthHeaderManager) GetBlockHeader(hash string) *boltvm.Response { + header := ehm.oracle.GetHeader(common.HexToHash(hash)) + if header == nil { + return boltvm.Error("not found") + } + data, err := header.MarshalJSON() + if err != nil { + return boltvm.Error(err.Error()) + } + return boltvm.Success(data) +} + +func (ehm *EthHeaderManager) PreMint(receiptData []byte, proofData []byte) *boltvm.Response { + var receipt types.Receipt + err := receipt.UnmarshalJSON(receiptData) + if err != nil { + return boltvm.Error(err.Error()) + } + err = ehm.oracle.VerifyProof(&receipt, proofData) + if err != nil { + return boltvm.Error(err.Error()) + } + escrowsLockEvent, err := ehm.unpackEscrowsLock(&receipt) + if err != nil { + return boltvm.Error(err.Error()) + } + + //abi.encodePacked + hash := crypto.Keccak256Hash( + escrowsLockEvent.EthToken.Bytes(), + escrowsLockEvent.RelayToken.Bytes(), + escrowsLockEvent.Locker.Bytes(), + escrowsLockEvent.Recipient.Bytes(), + common.LeftPadBytes(escrowsLockEvent.Amount.Bytes(), 32), + ) + prefixedHash := crypto.Keccak256Hash( + []byte(fmt.Sprintf("\x19Ethereum Signed Message:\n%v", len(hash))), + hash.Bytes(), + ) + ehm.SetObject(MintKey(prefixedHash.String()), escrowsLockEvent) + return boltvm.Success(prefixedHash.Bytes()) +} + +func (ehm *EthHeaderManager) unpackEscrowsLock(receipt *types.Receipt) (*appchain.EscrowsLock, error) { + escrowsAbi, err := abi.JSON(bytes.NewReader([]byte(appchain.EscrowsABI))) + if err != nil { + return nil, err + } + var escrowsAddr EscrowsAddr + ok := ehm.GetObject(EscrowsAddrKey, escrowsAddr) + if !ok { + return nil, fmt.Errorf("not found the escrows contract address") + } + var lock *appchain.EscrowsLock + for _, log := range receipt.Logs { + if !strings.EqualFold(log.Address.String(), escrowsAddr.EscrowsAddr) { + continue + } + + if log.Removed { + continue + } + for _, topic := range log.Topics { + if strings.EqualFold(topic.String(), escrowsAbi.Events["Lock"].ID.String()) { + if err := escrowsAbi.UnpackIntoInterface(&lock, "Lock", log.Data); err != nil { + continue + } + } + } + } + if lock == nil { + return nil, fmt.Errorf("not found the escrow lock event") + } + return lock, nil +} + +func MintKey(hash string) string { + return fmt.Sprintf("%s-%s", MINT_HASH_PREFIX, hash) +} diff --git a/internal/executor/executor.go b/internal/executor/executor.go index b56eca7..79c1d63 100755 --- a/internal/executor/executor.go +++ b/internal/executor/executor.go @@ -17,6 +17,7 @@ import ( "github.com/meshplus/bitxhub/internal/executor/contracts" "github.com/meshplus/bitxhub/internal/ledger" "github.com/meshplus/bitxhub/internal/model/events" + "github.com/meshplus/bitxhub/internal/repo" "github.com/meshplus/bitxhub/pkg/proof" "github.com/meshplus/bitxhub/pkg/vm/boltvm" "github.com/sirupsen/logrus" @@ -51,13 +52,14 @@ type BlockExecutor struct { evm *vm.EVM evmChainCfg *params.ChainConfig gasLimit uint64 + config repo.Config } // New creates executor instance -func New(chainLedger ledger.Ledger, logger logrus.FieldLogger, typ string, gasLimit uint64) (*BlockExecutor, error) { - ibtpVerify := proof.New(chainLedger, logger) +func New(chainLedger ledger.Ledger, logger logrus.FieldLogger, config repo.Config) (*BlockExecutor, error) { - txsExecutor, err := agency.GetExecutorConstructor(typ) + ibtpVerify := proof.New(chainLedger, logger) + txsExecutor, err := agency.GetExecutorConstructor(config.Executor.Type) if err != nil { return nil, err } @@ -78,12 +80,13 @@ func New(chainLedger ledger.Ledger, logger logrus.FieldLogger, typ string, gasLi currentBlockHash: chainLedger.GetChainMeta().BlockHash, wasmInstances: make(map[string]wasmer.Instance), evmChainCfg: newEVMChainCfg(), - gasLimit: gasLimit, + config: config, + gasLimit: config.GasLimit, } blockExecutor.evm = newEvm(1, uint64(0), blockExecutor.evmChainCfg, blockExecutor.ledger.StateDB()) - blockExecutor.txsExecutor = txsExecutor(blockExecutor.applyTx, registerBoltContracts, logger) + blockExecutor.txsExecutor = txsExecutor(blockExecutor.applyTx, blockExecutor.registerBoltContracts, logger) return blockExecutor, nil } @@ -222,7 +225,7 @@ func (exec *BlockExecutor) persistData() { } } -func registerBoltContracts() map[string]agency.Contract { +func (exec *BlockExecutor) registerBoltContracts() map[string]agency.Contract { boltContracts := []*boltvm.BoltContract{ { Enabled: true, @@ -278,6 +281,12 @@ func registerBoltContracts() map[string]agency.Contract { Address: constant.GovernanceContractAddr.Address().String(), Contract: &contracts.Governance{}, }, + { + Enabled: true, + Name: "ethereum header service", + Address: constant.EthHeaderMgrContractAddr.Address().String(), + Contract: contracts.NewEthHeaderManager(exec.config.RepoRoot, exec.logger), + }, } ContractsInfo := agency.GetRegisteredContractInfo() diff --git a/internal/executor/oracle/appchain/escrow.go b/internal/executor/oracle/appchain/escrow.go new file mode 100644 index 0000000..ba9a0e3 --- /dev/null +++ b/internal/executor/oracle/appchain/escrow.go @@ -0,0 +1,4602 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package appchain + +import ( + "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 ( + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + +// AccessControlABI is the input ABI used to generate the binding from. +const AccessControlABI = "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" + +// AccessControlFuncSigs maps the 4-byte function signature to its string representation. +var AccessControlFuncSigs = map[string]string{ + "a217fddf": "DEFAULT_ADMIN_ROLE()", + "248a9ca3": "getRoleAdmin(bytes32)", + "9010d07c": "getRoleMember(bytes32,uint256)", + "ca15c873": "getRoleMemberCount(bytes32)", + "2f2ff15d": "grantRole(bytes32,address)", + "91d14854": "hasRole(bytes32,address)", + "36568abe": "renounceRole(bytes32,address)", + "d547741f": "revokeRole(bytes32,address)", +} + +// AccessControl is an auto generated Go binding around an Ethereum contract. +type AccessControl struct { + AccessControlCaller // Read-only binding to the contract + AccessControlTransactor // Write-only binding to the contract + AccessControlFilterer // Log filterer for contract events +} + +// AccessControlCaller is an auto generated read-only Go binding around an Ethereum contract. +type AccessControlCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// AccessControlTransactor is an auto generated write-only Go binding around an Ethereum contract. +type AccessControlTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// AccessControlFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type AccessControlFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// AccessControlSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type AccessControlSession struct { + Contract *AccessControl // 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 +} + +// AccessControlCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type AccessControlCallerSession struct { + Contract *AccessControlCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// AccessControlTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type AccessControlTransactorSession struct { + Contract *AccessControlTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// AccessControlRaw is an auto generated low-level Go binding around an Ethereum contract. +type AccessControlRaw struct { + Contract *AccessControl // Generic contract binding to access the raw methods on +} + +// AccessControlCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type AccessControlCallerRaw struct { + Contract *AccessControlCaller // Generic read-only contract binding to access the raw methods on +} + +// AccessControlTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type AccessControlTransactorRaw struct { + Contract *AccessControlTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewAccessControl creates a new instance of AccessControl, bound to a specific deployed contract. +func NewAccessControl(address common.Address, backend bind.ContractBackend) (*AccessControl, error) { + contract, err := bindAccessControl(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &AccessControl{AccessControlCaller: AccessControlCaller{contract: contract}, AccessControlTransactor: AccessControlTransactor{contract: contract}, AccessControlFilterer: AccessControlFilterer{contract: contract}}, nil +} + +// NewAccessControlCaller creates a new read-only instance of AccessControl, bound to a specific deployed contract. +func NewAccessControlCaller(address common.Address, caller bind.ContractCaller) (*AccessControlCaller, error) { + contract, err := bindAccessControl(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &AccessControlCaller{contract: contract}, nil +} + +// NewAccessControlTransactor creates a new write-only instance of AccessControl, bound to a specific deployed contract. +func NewAccessControlTransactor(address common.Address, transactor bind.ContractTransactor) (*AccessControlTransactor, error) { + contract, err := bindAccessControl(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &AccessControlTransactor{contract: contract}, nil +} + +// NewAccessControlFilterer creates a new log filterer instance of AccessControl, bound to a specific deployed contract. +func NewAccessControlFilterer(address common.Address, filterer bind.ContractFilterer) (*AccessControlFilterer, error) { + contract, err := bindAccessControl(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &AccessControlFilterer{contract: contract}, nil +} + +// bindAccessControl binds a generic wrapper to an already deployed contract. +func bindAccessControl(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(AccessControlABI)) + 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 (_AccessControl *AccessControlRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _AccessControl.Contract.AccessControlCaller.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 (_AccessControl *AccessControlRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _AccessControl.Contract.AccessControlTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_AccessControl *AccessControlRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _AccessControl.Contract.AccessControlTransactor.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 (_AccessControl *AccessControlCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _AccessControl.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 (_AccessControl *AccessControlTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _AccessControl.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_AccessControl *AccessControlTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _AccessControl.Contract.contract.Transact(opts, method, params...) +} + +// DEFAULTADMINROLE is a free data retrieval call binding the contract method 0xa217fddf. +// +// Solidity: function DEFAULT_ADMIN_ROLE() view returns(bytes32) +func (_AccessControl *AccessControlCaller) DEFAULTADMINROLE(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _AccessControl.contract.Call(opts, &out, "DEFAULT_ADMIN_ROLE") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// DEFAULTADMINROLE is a free data retrieval call binding the contract method 0xa217fddf. +// +// Solidity: function DEFAULT_ADMIN_ROLE() view returns(bytes32) +func (_AccessControl *AccessControlSession) DEFAULTADMINROLE() ([32]byte, error) { + return _AccessControl.Contract.DEFAULTADMINROLE(&_AccessControl.CallOpts) +} + +// DEFAULTADMINROLE is a free data retrieval call binding the contract method 0xa217fddf. +// +// Solidity: function DEFAULT_ADMIN_ROLE() view returns(bytes32) +func (_AccessControl *AccessControlCallerSession) DEFAULTADMINROLE() ([32]byte, error) { + return _AccessControl.Contract.DEFAULTADMINROLE(&_AccessControl.CallOpts) +} + +// GetRoleAdmin is a free data retrieval call binding the contract method 0x248a9ca3. +// +// Solidity: function getRoleAdmin(bytes32 role) view returns(bytes32) +func (_AccessControl *AccessControlCaller) GetRoleAdmin(opts *bind.CallOpts, role [32]byte) ([32]byte, error) { + var out []interface{} + err := _AccessControl.contract.Call(opts, &out, "getRoleAdmin", role) + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// GetRoleAdmin is a free data retrieval call binding the contract method 0x248a9ca3. +// +// Solidity: function getRoleAdmin(bytes32 role) view returns(bytes32) +func (_AccessControl *AccessControlSession) GetRoleAdmin(role [32]byte) ([32]byte, error) { + return _AccessControl.Contract.GetRoleAdmin(&_AccessControl.CallOpts, role) +} + +// GetRoleAdmin is a free data retrieval call binding the contract method 0x248a9ca3. +// +// Solidity: function getRoleAdmin(bytes32 role) view returns(bytes32) +func (_AccessControl *AccessControlCallerSession) GetRoleAdmin(role [32]byte) ([32]byte, error) { + return _AccessControl.Contract.GetRoleAdmin(&_AccessControl.CallOpts, role) +} + +// GetRoleMember is a free data retrieval call binding the contract method 0x9010d07c. +// +// Solidity: function getRoleMember(bytes32 role, uint256 index) view returns(address) +func (_AccessControl *AccessControlCaller) GetRoleMember(opts *bind.CallOpts, role [32]byte, index *big.Int) (common.Address, error) { + var out []interface{} + err := _AccessControl.contract.Call(opts, &out, "getRoleMember", role, index) + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// GetRoleMember is a free data retrieval call binding the contract method 0x9010d07c. +// +// Solidity: function getRoleMember(bytes32 role, uint256 index) view returns(address) +func (_AccessControl *AccessControlSession) GetRoleMember(role [32]byte, index *big.Int) (common.Address, error) { + return _AccessControl.Contract.GetRoleMember(&_AccessControl.CallOpts, role, index) +} + +// GetRoleMember is a free data retrieval call binding the contract method 0x9010d07c. +// +// Solidity: function getRoleMember(bytes32 role, uint256 index) view returns(address) +func (_AccessControl *AccessControlCallerSession) GetRoleMember(role [32]byte, index *big.Int) (common.Address, error) { + return _AccessControl.Contract.GetRoleMember(&_AccessControl.CallOpts, role, index) +} + +// GetRoleMemberCount is a free data retrieval call binding the contract method 0xca15c873. +// +// Solidity: function getRoleMemberCount(bytes32 role) view returns(uint256) +func (_AccessControl *AccessControlCaller) GetRoleMemberCount(opts *bind.CallOpts, role [32]byte) (*big.Int, error) { + var out []interface{} + err := _AccessControl.contract.Call(opts, &out, "getRoleMemberCount", role) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetRoleMemberCount is a free data retrieval call binding the contract method 0xca15c873. +// +// Solidity: function getRoleMemberCount(bytes32 role) view returns(uint256) +func (_AccessControl *AccessControlSession) GetRoleMemberCount(role [32]byte) (*big.Int, error) { + return _AccessControl.Contract.GetRoleMemberCount(&_AccessControl.CallOpts, role) +} + +// GetRoleMemberCount is a free data retrieval call binding the contract method 0xca15c873. +// +// Solidity: function getRoleMemberCount(bytes32 role) view returns(uint256) +func (_AccessControl *AccessControlCallerSession) GetRoleMemberCount(role [32]byte) (*big.Int, error) { + return _AccessControl.Contract.GetRoleMemberCount(&_AccessControl.CallOpts, role) +} + +// HasRole is a free data retrieval call binding the contract method 0x91d14854. +// +// Solidity: function hasRole(bytes32 role, address account) view returns(bool) +func (_AccessControl *AccessControlCaller) HasRole(opts *bind.CallOpts, role [32]byte, account common.Address) (bool, error) { + var out []interface{} + err := _AccessControl.contract.Call(opts, &out, "hasRole", role, account) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// HasRole is a free data retrieval call binding the contract method 0x91d14854. +// +// Solidity: function hasRole(bytes32 role, address account) view returns(bool) +func (_AccessControl *AccessControlSession) HasRole(role [32]byte, account common.Address) (bool, error) { + return _AccessControl.Contract.HasRole(&_AccessControl.CallOpts, role, account) +} + +// HasRole is a free data retrieval call binding the contract method 0x91d14854. +// +// Solidity: function hasRole(bytes32 role, address account) view returns(bool) +func (_AccessControl *AccessControlCallerSession) HasRole(role [32]byte, account common.Address) (bool, error) { + return _AccessControl.Contract.HasRole(&_AccessControl.CallOpts, role, account) +} + +// GrantRole is a paid mutator transaction binding the contract method 0x2f2ff15d. +// +// Solidity: function grantRole(bytes32 role, address account) returns() +func (_AccessControl *AccessControlTransactor) GrantRole(opts *bind.TransactOpts, role [32]byte, account common.Address) (*types.Transaction, error) { + return _AccessControl.contract.Transact(opts, "grantRole", role, account) +} + +// GrantRole is a paid mutator transaction binding the contract method 0x2f2ff15d. +// +// Solidity: function grantRole(bytes32 role, address account) returns() +func (_AccessControl *AccessControlSession) GrantRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _AccessControl.Contract.GrantRole(&_AccessControl.TransactOpts, role, account) +} + +// GrantRole is a paid mutator transaction binding the contract method 0x2f2ff15d. +// +// Solidity: function grantRole(bytes32 role, address account) returns() +func (_AccessControl *AccessControlTransactorSession) GrantRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _AccessControl.Contract.GrantRole(&_AccessControl.TransactOpts, role, account) +} + +// RenounceRole is a paid mutator transaction binding the contract method 0x36568abe. +// +// Solidity: function renounceRole(bytes32 role, address account) returns() +func (_AccessControl *AccessControlTransactor) RenounceRole(opts *bind.TransactOpts, role [32]byte, account common.Address) (*types.Transaction, error) { + return _AccessControl.contract.Transact(opts, "renounceRole", role, account) +} + +// RenounceRole is a paid mutator transaction binding the contract method 0x36568abe. +// +// Solidity: function renounceRole(bytes32 role, address account) returns() +func (_AccessControl *AccessControlSession) RenounceRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _AccessControl.Contract.RenounceRole(&_AccessControl.TransactOpts, role, account) +} + +// RenounceRole is a paid mutator transaction binding the contract method 0x36568abe. +// +// Solidity: function renounceRole(bytes32 role, address account) returns() +func (_AccessControl *AccessControlTransactorSession) RenounceRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _AccessControl.Contract.RenounceRole(&_AccessControl.TransactOpts, role, account) +} + +// RevokeRole is a paid mutator transaction binding the contract method 0xd547741f. +// +// Solidity: function revokeRole(bytes32 role, address account) returns() +func (_AccessControl *AccessControlTransactor) RevokeRole(opts *bind.TransactOpts, role [32]byte, account common.Address) (*types.Transaction, error) { + return _AccessControl.contract.Transact(opts, "revokeRole", role, account) +} + +// RevokeRole is a paid mutator transaction binding the contract method 0xd547741f. +// +// Solidity: function revokeRole(bytes32 role, address account) returns() +func (_AccessControl *AccessControlSession) RevokeRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _AccessControl.Contract.RevokeRole(&_AccessControl.TransactOpts, role, account) +} + +// RevokeRole is a paid mutator transaction binding the contract method 0xd547741f. +// +// Solidity: function revokeRole(bytes32 role, address account) returns() +func (_AccessControl *AccessControlTransactorSession) RevokeRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _AccessControl.Contract.RevokeRole(&_AccessControl.TransactOpts, role, account) +} + +// AccessControlRoleAdminChangedIterator is returned from FilterRoleAdminChanged and is used to iterate over the raw logs and unpacked data for RoleAdminChanged events raised by the AccessControl contract. +type AccessControlRoleAdminChangedIterator struct { + Event *AccessControlRoleAdminChanged // 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 *AccessControlRoleAdminChangedIterator) 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(AccessControlRoleAdminChanged) + 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(AccessControlRoleAdminChanged) + 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 *AccessControlRoleAdminChangedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *AccessControlRoleAdminChangedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// AccessControlRoleAdminChanged represents a RoleAdminChanged event raised by the AccessControl contract. +type AccessControlRoleAdminChanged struct { + Role [32]byte + PreviousAdminRole [32]byte + NewAdminRole [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRoleAdminChanged is a free log retrieval operation binding the contract event 0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff. +// +// Solidity: event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole) +func (_AccessControl *AccessControlFilterer) FilterRoleAdminChanged(opts *bind.FilterOpts, role [][32]byte, previousAdminRole [][32]byte, newAdminRole [][32]byte) (*AccessControlRoleAdminChangedIterator, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var previousAdminRoleRule []interface{} + for _, previousAdminRoleItem := range previousAdminRole { + previousAdminRoleRule = append(previousAdminRoleRule, previousAdminRoleItem) + } + var newAdminRoleRule []interface{} + for _, newAdminRoleItem := range newAdminRole { + newAdminRoleRule = append(newAdminRoleRule, newAdminRoleItem) + } + + logs, sub, err := _AccessControl.contract.FilterLogs(opts, "RoleAdminChanged", roleRule, previousAdminRoleRule, newAdminRoleRule) + if err != nil { + return nil, err + } + return &AccessControlRoleAdminChangedIterator{contract: _AccessControl.contract, event: "RoleAdminChanged", logs: logs, sub: sub}, nil +} + +// WatchRoleAdminChanged is a free log subscription operation binding the contract event 0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff. +// +// Solidity: event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole) +func (_AccessControl *AccessControlFilterer) WatchRoleAdminChanged(opts *bind.WatchOpts, sink chan<- *AccessControlRoleAdminChanged, role [][32]byte, previousAdminRole [][32]byte, newAdminRole [][32]byte) (event.Subscription, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var previousAdminRoleRule []interface{} + for _, previousAdminRoleItem := range previousAdminRole { + previousAdminRoleRule = append(previousAdminRoleRule, previousAdminRoleItem) + } + var newAdminRoleRule []interface{} + for _, newAdminRoleItem := range newAdminRole { + newAdminRoleRule = append(newAdminRoleRule, newAdminRoleItem) + } + + logs, sub, err := _AccessControl.contract.WatchLogs(opts, "RoleAdminChanged", roleRule, previousAdminRoleRule, newAdminRoleRule) + 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(AccessControlRoleAdminChanged) + if err := _AccessControl.contract.UnpackLog(event, "RoleAdminChanged", 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 +} + +// ParseRoleAdminChanged is a log parse operation binding the contract event 0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff. +// +// Solidity: event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole) +func (_AccessControl *AccessControlFilterer) ParseRoleAdminChanged(log types.Log) (*AccessControlRoleAdminChanged, error) { + event := new(AccessControlRoleAdminChanged) + if err := _AccessControl.contract.UnpackLog(event, "RoleAdminChanged", log); err != nil { + return nil, err + } + return event, nil +} + +// AccessControlRoleGrantedIterator is returned from FilterRoleGranted and is used to iterate over the raw logs and unpacked data for RoleGranted events raised by the AccessControl contract. +type AccessControlRoleGrantedIterator struct { + Event *AccessControlRoleGranted // 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 *AccessControlRoleGrantedIterator) 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(AccessControlRoleGranted) + 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(AccessControlRoleGranted) + 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 *AccessControlRoleGrantedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *AccessControlRoleGrantedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// AccessControlRoleGranted represents a RoleGranted event raised by the AccessControl contract. +type AccessControlRoleGranted struct { + Role [32]byte + Account common.Address + Sender common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRoleGranted is a free log retrieval operation binding the contract event 0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d. +// +// Solidity: event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender) +func (_AccessControl *AccessControlFilterer) FilterRoleGranted(opts *bind.FilterOpts, role [][32]byte, account []common.Address, sender []common.Address) (*AccessControlRoleGrantedIterator, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _AccessControl.contract.FilterLogs(opts, "RoleGranted", roleRule, accountRule, senderRule) + if err != nil { + return nil, err + } + return &AccessControlRoleGrantedIterator{contract: _AccessControl.contract, event: "RoleGranted", logs: logs, sub: sub}, nil +} + +// WatchRoleGranted is a free log subscription operation binding the contract event 0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d. +// +// Solidity: event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender) +func (_AccessControl *AccessControlFilterer) WatchRoleGranted(opts *bind.WatchOpts, sink chan<- *AccessControlRoleGranted, role [][32]byte, account []common.Address, sender []common.Address) (event.Subscription, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _AccessControl.contract.WatchLogs(opts, "RoleGranted", roleRule, accountRule, senderRule) + 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(AccessControlRoleGranted) + if err := _AccessControl.contract.UnpackLog(event, "RoleGranted", 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 +} + +// ParseRoleGranted is a log parse operation binding the contract event 0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d. +// +// Solidity: event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender) +func (_AccessControl *AccessControlFilterer) ParseRoleGranted(log types.Log) (*AccessControlRoleGranted, error) { + event := new(AccessControlRoleGranted) + if err := _AccessControl.contract.UnpackLog(event, "RoleGranted", log); err != nil { + return nil, err + } + return event, nil +} + +// AccessControlRoleRevokedIterator is returned from FilterRoleRevoked and is used to iterate over the raw logs and unpacked data for RoleRevoked events raised by the AccessControl contract. +type AccessControlRoleRevokedIterator struct { + Event *AccessControlRoleRevoked // 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 *AccessControlRoleRevokedIterator) 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(AccessControlRoleRevoked) + 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(AccessControlRoleRevoked) + 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 *AccessControlRoleRevokedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *AccessControlRoleRevokedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// AccessControlRoleRevoked represents a RoleRevoked event raised by the AccessControl contract. +type AccessControlRoleRevoked struct { + Role [32]byte + Account common.Address + Sender common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRoleRevoked is a free log retrieval operation binding the contract event 0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b. +// +// Solidity: event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender) +func (_AccessControl *AccessControlFilterer) FilterRoleRevoked(opts *bind.FilterOpts, role [][32]byte, account []common.Address, sender []common.Address) (*AccessControlRoleRevokedIterator, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _AccessControl.contract.FilterLogs(opts, "RoleRevoked", roleRule, accountRule, senderRule) + if err != nil { + return nil, err + } + return &AccessControlRoleRevokedIterator{contract: _AccessControl.contract, event: "RoleRevoked", logs: logs, sub: sub}, nil +} + +// WatchRoleRevoked is a free log subscription operation binding the contract event 0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b. +// +// Solidity: event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender) +func (_AccessControl *AccessControlFilterer) WatchRoleRevoked(opts *bind.WatchOpts, sink chan<- *AccessControlRoleRevoked, role [][32]byte, account []common.Address, sender []common.Address) (event.Subscription, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _AccessControl.contract.WatchLogs(opts, "RoleRevoked", roleRule, accountRule, senderRule) + 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(AccessControlRoleRevoked) + if err := _AccessControl.contract.UnpackLog(event, "RoleRevoked", 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 +} + +// ParseRoleRevoked is a log parse operation binding the contract event 0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b. +// +// Solidity: event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender) +func (_AccessControl *AccessControlFilterer) ParseRoleRevoked(log types.Log) (*AccessControlRoleRevoked, error) { + event := new(AccessControlRoleRevoked) + if err := _AccessControl.contract.UnpackLog(event, "RoleRevoked", log); err != nil { + return nil, err + } + return event, nil +} + +// AddressABI is the input ABI used to generate the binding from. +const AddressABI = "[]" + +// AddressBin is the compiled bytecode used for deploying new contracts. +var AddressBin = "0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212209a38ae4f8dae6266e9ee3e8b74e9fb581b0ff48775118e80e642516c1a154e9a64736f6c634300060c0033" + +// DeployAddress deploys a new Ethereum contract, binding an instance of Address to it. +func DeployAddress(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Address, error) { + parsed, err := abi.JSON(strings.NewReader(AddressABI)) + if err != nil { + return common.Address{}, nil, nil, err + } + + address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(AddressBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &Address{AddressCaller: AddressCaller{contract: contract}, AddressTransactor: AddressTransactor{contract: contract}, AddressFilterer: AddressFilterer{contract: contract}}, nil +} + +// Address is an auto generated Go binding around an Ethereum contract. +type Address struct { + AddressCaller // Read-only binding to the contract + AddressTransactor // Write-only binding to the contract + AddressFilterer // Log filterer for contract events +} + +// AddressCaller is an auto generated read-only Go binding around an Ethereum contract. +type AddressCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// AddressTransactor is an auto generated write-only Go binding around an Ethereum contract. +type AddressTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// AddressFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type AddressFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// AddressSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type AddressSession struct { + Contract *Address // 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 +} + +// AddressCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type AddressCallerSession struct { + Contract *AddressCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// AddressTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type AddressTransactorSession struct { + Contract *AddressTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// AddressRaw is an auto generated low-level Go binding around an Ethereum contract. +type AddressRaw struct { + Contract *Address // Generic contract binding to access the raw methods on +} + +// AddressCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type AddressCallerRaw struct { + Contract *AddressCaller // Generic read-only contract binding to access the raw methods on +} + +// AddressTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type AddressTransactorRaw struct { + Contract *AddressTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewAddress creates a new instance of Address, bound to a specific deployed contract. +func NewAddress(address common.Address, backend bind.ContractBackend) (*Address, error) { + contract, err := bindAddress(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Address{AddressCaller: AddressCaller{contract: contract}, AddressTransactor: AddressTransactor{contract: contract}, AddressFilterer: AddressFilterer{contract: contract}}, nil +} + +// NewAddressCaller creates a new read-only instance of Address, bound to a specific deployed contract. +func NewAddressCaller(address common.Address, caller bind.ContractCaller) (*AddressCaller, error) { + contract, err := bindAddress(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &AddressCaller{contract: contract}, nil +} + +// NewAddressTransactor creates a new write-only instance of Address, bound to a specific deployed contract. +func NewAddressTransactor(address common.Address, transactor bind.ContractTransactor) (*AddressTransactor, error) { + contract, err := bindAddress(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &AddressTransactor{contract: contract}, nil +} + +// NewAddressFilterer creates a new log filterer instance of Address, bound to a specific deployed contract. +func NewAddressFilterer(address common.Address, filterer bind.ContractFilterer) (*AddressFilterer, error) { + contract, err := bindAddress(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &AddressFilterer{contract: contract}, nil +} + +// bindAddress binds a generic wrapper to an already deployed contract. +func bindAddress(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(AddressABI)) + 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 (_Address *AddressRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Address.Contract.AddressCaller.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 (_Address *AddressRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Address.Contract.AddressTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Address *AddressRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Address.Contract.AddressTransactor.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 (_Address *AddressCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Address.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 (_Address *AddressTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Address.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Address *AddressTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Address.Contract.contract.Transact(opts, method, params...) +} + +// ContextABI is the input ABI used to generate the binding from. +const ContextABI = "[]" + +// Context is an auto generated Go binding around an Ethereum contract. +type Context struct { + ContextCaller // Read-only binding to the contract + ContextTransactor // Write-only binding to the contract + ContextFilterer // Log filterer for contract events +} + +// ContextCaller is an auto generated read-only Go binding around an Ethereum contract. +type ContextCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ContextTransactor is an auto generated write-only Go binding around an Ethereum contract. +type ContextTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ContextFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type ContextFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ContextSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type ContextSession struct { + Contract *Context // 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 +} + +// ContextCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type ContextCallerSession struct { + Contract *ContextCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// ContextTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type ContextTransactorSession struct { + Contract *ContextTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ContextRaw is an auto generated low-level Go binding around an Ethereum contract. +type ContextRaw struct { + Contract *Context // Generic contract binding to access the raw methods on +} + +// ContextCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type ContextCallerRaw struct { + Contract *ContextCaller // Generic read-only contract binding to access the raw methods on +} + +// ContextTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type ContextTransactorRaw struct { + Contract *ContextTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewContext creates a new instance of Context, bound to a specific deployed contract. +func NewContext(address common.Address, backend bind.ContractBackend) (*Context, error) { + contract, err := bindContext(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Context{ContextCaller: ContextCaller{contract: contract}, ContextTransactor: ContextTransactor{contract: contract}, ContextFilterer: ContextFilterer{contract: contract}}, nil +} + +// NewContextCaller creates a new read-only instance of Context, bound to a specific deployed contract. +func NewContextCaller(address common.Address, caller bind.ContractCaller) (*ContextCaller, error) { + contract, err := bindContext(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &ContextCaller{contract: contract}, nil +} + +// NewContextTransactor creates a new write-only instance of Context, bound to a specific deployed contract. +func NewContextTransactor(address common.Address, transactor bind.ContractTransactor) (*ContextTransactor, error) { + contract, err := bindContext(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &ContextTransactor{contract: contract}, nil +} + +// NewContextFilterer creates a new log filterer instance of Context, bound to a specific deployed contract. +func NewContextFilterer(address common.Address, filterer bind.ContractFilterer) (*ContextFilterer, error) { + contract, err := bindContext(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &ContextFilterer{contract: contract}, nil +} + +// bindContext binds a generic wrapper to an already deployed contract. +func bindContext(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(ContextABI)) + 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 (_Context *ContextRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Context.Contract.ContextCaller.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 (_Context *ContextRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Context.Contract.ContextTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Context *ContextRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Context.Contract.ContextTransactor.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 (_Context *ContextCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Context.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 (_Context *ContextTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Context.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Context *ContextTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Context.Contract.contract.Transact(opts, method, params...) +} + +// ECDSAABI is the input ABI used to generate the binding from. +const ECDSAABI = "[]" + +// ECDSABin is the compiled bytecode used for deploying new contracts. +var ECDSABin = "0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220742e3fe74232a7cb8cf0ccfaeeff39f04d52bced976fd0c15bafbc40e828257f64736f6c634300060c0033" + +// DeployECDSA deploys a new Ethereum contract, binding an instance of ECDSA to it. +func DeployECDSA(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *ECDSA, error) { + parsed, err := abi.JSON(strings.NewReader(ECDSAABI)) + if err != nil { + return common.Address{}, nil, nil, err + } + + address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(ECDSABin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &ECDSA{ECDSACaller: ECDSACaller{contract: contract}, ECDSATransactor: ECDSATransactor{contract: contract}, ECDSAFilterer: ECDSAFilterer{contract: contract}}, nil +} + +// ECDSA is an auto generated Go binding around an Ethereum contract. +type ECDSA struct { + ECDSACaller // Read-only binding to the contract + ECDSATransactor // Write-only binding to the contract + ECDSAFilterer // Log filterer for contract events +} + +// ECDSACaller is an auto generated read-only Go binding around an Ethereum contract. +type ECDSACaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ECDSATransactor is an auto generated write-only Go binding around an Ethereum contract. +type ECDSATransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ECDSAFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type ECDSAFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ECDSASession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type ECDSASession struct { + Contract *ECDSA // 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 +} + +// ECDSACallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type ECDSACallerSession struct { + Contract *ECDSACaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// ECDSATransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type ECDSATransactorSession struct { + Contract *ECDSATransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ECDSARaw is an auto generated low-level Go binding around an Ethereum contract. +type ECDSARaw struct { + Contract *ECDSA // Generic contract binding to access the raw methods on +} + +// ECDSACallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type ECDSACallerRaw struct { + Contract *ECDSACaller // Generic read-only contract binding to access the raw methods on +} + +// ECDSATransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type ECDSATransactorRaw struct { + Contract *ECDSATransactor // Generic write-only contract binding to access the raw methods on +} + +// NewECDSA creates a new instance of ECDSA, bound to a specific deployed contract. +func NewECDSA(address common.Address, backend bind.ContractBackend) (*ECDSA, error) { + contract, err := bindECDSA(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &ECDSA{ECDSACaller: ECDSACaller{contract: contract}, ECDSATransactor: ECDSATransactor{contract: contract}, ECDSAFilterer: ECDSAFilterer{contract: contract}}, nil +} + +// NewECDSACaller creates a new read-only instance of ECDSA, bound to a specific deployed contract. +func NewECDSACaller(address common.Address, caller bind.ContractCaller) (*ECDSACaller, error) { + contract, err := bindECDSA(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &ECDSACaller{contract: contract}, nil +} + +// NewECDSATransactor creates a new write-only instance of ECDSA, bound to a specific deployed contract. +func NewECDSATransactor(address common.Address, transactor bind.ContractTransactor) (*ECDSATransactor, error) { + contract, err := bindECDSA(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &ECDSATransactor{contract: contract}, nil +} + +// NewECDSAFilterer creates a new log filterer instance of ECDSA, bound to a specific deployed contract. +func NewECDSAFilterer(address common.Address, filterer bind.ContractFilterer) (*ECDSAFilterer, error) { + contract, err := bindECDSA(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &ECDSAFilterer{contract: contract}, nil +} + +// bindECDSA binds a generic wrapper to an already deployed contract. +func bindECDSA(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(ECDSAABI)) + 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 (_ECDSA *ECDSARaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ECDSA.Contract.ECDSACaller.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 (_ECDSA *ECDSARaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ECDSA.Contract.ECDSATransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ECDSA *ECDSARaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ECDSA.Contract.ECDSATransactor.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 (_ECDSA *ECDSACallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ECDSA.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 (_ECDSA *ECDSATransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ECDSA.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ECDSA *ECDSATransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ECDSA.Contract.contract.Transact(opts, method, params...) +} + +// EnumerableSetABI is the input ABI used to generate the binding from. +const EnumerableSetABI = "[]" + +// EnumerableSetBin is the compiled bytecode used for deploying new contracts. +var EnumerableSetBin = "0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220f182142d87e0d8933575eadd70f55d0945ffbb568801c67ea23f9a14b913a85f64736f6c634300060c0033" + +// DeployEnumerableSet deploys a new Ethereum contract, binding an instance of EnumerableSet to it. +func DeployEnumerableSet(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *EnumerableSet, error) { + parsed, err := abi.JSON(strings.NewReader(EnumerableSetABI)) + if err != nil { + return common.Address{}, nil, nil, err + } + + address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(EnumerableSetBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &EnumerableSet{EnumerableSetCaller: EnumerableSetCaller{contract: contract}, EnumerableSetTransactor: EnumerableSetTransactor{contract: contract}, EnumerableSetFilterer: EnumerableSetFilterer{contract: contract}}, nil +} + +// EnumerableSet is an auto generated Go binding around an Ethereum contract. +type EnumerableSet struct { + EnumerableSetCaller // Read-only binding to the contract + EnumerableSetTransactor // Write-only binding to the contract + EnumerableSetFilterer // Log filterer for contract events +} + +// EnumerableSetCaller is an auto generated read-only Go binding around an Ethereum contract. +type EnumerableSetCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// EnumerableSetTransactor is an auto generated write-only Go binding around an Ethereum contract. +type EnumerableSetTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// EnumerableSetFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type EnumerableSetFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// EnumerableSetSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type EnumerableSetSession struct { + Contract *EnumerableSet // 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 +} + +// EnumerableSetCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type EnumerableSetCallerSession struct { + Contract *EnumerableSetCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// EnumerableSetTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type EnumerableSetTransactorSession struct { + Contract *EnumerableSetTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// EnumerableSetRaw is an auto generated low-level Go binding around an Ethereum contract. +type EnumerableSetRaw struct { + Contract *EnumerableSet // Generic contract binding to access the raw methods on +} + +// EnumerableSetCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type EnumerableSetCallerRaw struct { + Contract *EnumerableSetCaller // Generic read-only contract binding to access the raw methods on +} + +// EnumerableSetTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type EnumerableSetTransactorRaw struct { + Contract *EnumerableSetTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewEnumerableSet creates a new instance of EnumerableSet, bound to a specific deployed contract. +func NewEnumerableSet(address common.Address, backend bind.ContractBackend) (*EnumerableSet, error) { + contract, err := bindEnumerableSet(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &EnumerableSet{EnumerableSetCaller: EnumerableSetCaller{contract: contract}, EnumerableSetTransactor: EnumerableSetTransactor{contract: contract}, EnumerableSetFilterer: EnumerableSetFilterer{contract: contract}}, nil +} + +// NewEnumerableSetCaller creates a new read-only instance of EnumerableSet, bound to a specific deployed contract. +func NewEnumerableSetCaller(address common.Address, caller bind.ContractCaller) (*EnumerableSetCaller, error) { + contract, err := bindEnumerableSet(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &EnumerableSetCaller{contract: contract}, nil +} + +// NewEnumerableSetTransactor creates a new write-only instance of EnumerableSet, bound to a specific deployed contract. +func NewEnumerableSetTransactor(address common.Address, transactor bind.ContractTransactor) (*EnumerableSetTransactor, error) { + contract, err := bindEnumerableSet(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &EnumerableSetTransactor{contract: contract}, nil +} + +// NewEnumerableSetFilterer creates a new log filterer instance of EnumerableSet, bound to a specific deployed contract. +func NewEnumerableSetFilterer(address common.Address, filterer bind.ContractFilterer) (*EnumerableSetFilterer, error) { + contract, err := bindEnumerableSet(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &EnumerableSetFilterer{contract: contract}, nil +} + +// bindEnumerableSet binds a generic wrapper to an already deployed contract. +func bindEnumerableSet(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(EnumerableSetABI)) + 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 (_EnumerableSet *EnumerableSetRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _EnumerableSet.Contract.EnumerableSetCaller.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 (_EnumerableSet *EnumerableSetRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _EnumerableSet.Contract.EnumerableSetTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_EnumerableSet *EnumerableSetRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _EnumerableSet.Contract.EnumerableSetTransactor.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 (_EnumerableSet *EnumerableSetCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _EnumerableSet.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 (_EnumerableSet *EnumerableSetTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _EnumerableSet.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_EnumerableSet *EnumerableSetTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _EnumerableSet.Contract.contract.Transact(opts, method, params...) +} + +// EscrowsABI is the input ABI used to generate the binding from. +const EscrowsABI = "[{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_relayers\",\"type\":\"address[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"ethToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"relayToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"locker\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Lock\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"ethToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"relayToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"txid\",\"type\":\"string\"}],\"name\":\"Unlock\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"RELAYER_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"ethTokenAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"relayTokenAddr\",\"type\":\"address\"}],\"name\":\"addSupportToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"ethTokenAddrs\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"relayTokenAddrs\",\"type\":\"address[]\"}],\"name\":\"addSupportTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"}],\"name\":\"lock\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"lockAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"ethTokenAddr\",\"type\":\"address\"}],\"name\":\"removeSupportToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"addrs\",\"type\":\"address[]\"}],\"name\":\"removeSupportTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"supportToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"name\":\"txUnlocked\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"_txid\",\"type\":\"string\"},{\"internalType\":\"bytes[]\",\"name\":\"signatures\",\"type\":\"bytes[]\"}],\"name\":\"unlock\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" + +// EscrowsFuncSigs maps the 4-byte function signature to its string representation. +var EscrowsFuncSigs = map[string]string{ + "a217fddf": "DEFAULT_ADMIN_ROLE()", + "926d7d7f": "RELAYER_ROLE()", + "7010584c": "addSupportToken(address,address)", + "ab1494de": "addSupportTokens(address[],address[])", + "248a9ca3": "getRoleAdmin(bytes32)", + "9010d07c": "getRoleMember(bytes32,uint256)", + "ca15c873": "getRoleMemberCount(bytes32)", + "2f2ff15d": "grantRole(bytes32,address)", + "91d14854": "hasRole(bytes32,address)", + "4bbc170a": "lock(address,uint256,address)", + "e2095ab4": "lockAmount(address,address)", + "e2769cfa": "removeSupportToken(address)", + "0daff621": "removeSupportTokens(address[])", + "36568abe": "renounceRole(bytes32,address)", + "d547741f": "revokeRole(bytes32,address)", + "2a4f1621": "supportToken(address)", + "967145af": "txUnlocked(string)", + "e4242dd5": "unlock(address,address,address,uint256,string,bytes[])", +} + +// EscrowsBin is the compiled bytecode used for deploying new contracts. +var EscrowsBin = "0x60806040523480156200001157600080fd5b5060405162001cce38038062001cce8339810160408190526200003491620001c0565b6200004160003362000094565b60005b81518110156200008c57620000836b52454c415945525f524f4c4560a01b8383815181106200006f57fe5b60200260200101516200009460201b60201c565b60010162000044565b50506200029c565b620000a08282620000a4565b5050565b600082815260208181526040909120620000c9918390620009f66200011d821b17901c565b15620000a057620000d96200013d565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600062000134836001600160a01b03841662000141565b90505b92915050565b3390565b60006200014f838362000190565b620001875750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000137565b50600062000137565b60009081526001919091016020526040902054151590565b80516001600160a01b03811681146200013757600080fd5b60006020808385031215620001d3578182fd5b82516001600160401b0380821115620001ea578384fd5b818501915085601f830112620001fe578384fd5b8151818111156200020d578485fd5b83810291506200021f84830162000275565b8181528481019084860184860187018a10156200023a578788fd5b8795505b838610156200026857620002538a82620001a8565b8352600195909501949186019186016200023e565b5098975050505050505050565b6040518181016001600160401b03811182821017156200029457600080fd5b604052919050565b611a2280620002ac6000396000f3fe608060405234801561001057600080fd5b50600436106101165760003560e01c8063926d7d7f116100a2578063ca15c87311610071578063ca15c8731461022e578063d547741f14610241578063e2095ab414610254578063e2769cfa14610267578063e4242dd51461027a57610116565b8063926d7d7f146101f8578063967145af14610200578063a217fddf14610213578063ab1494de1461021b57610116565b806336568abe116100e957806336568abe1461018c5780634bbc170a1461019f5780637010584c146101b25780639010d07c146101c557806391d14854146101d857610116565b80630daff6211461011b578063248a9ca3146101305780632a4f1621146101595780632f2ff15d14610179575b600080fd5b61012e6101293660046112c8565b61028d565b005b61014361013e36600461137c565b6102c1565b60405161015091906115c7565b60405180910390f35b61016c61016736600461114b565b6102d6565b60405161015091906114e9565b61012e610187366004611394565b6102f1565b61012e61019a366004611394565b61033e565b61012e6101ad366004611287565b610380565b61012e6101c0366004611166565b61047c565b61016c6101d33660046113c3565b610509565b6101eb6101e6366004611394565b61052a565b60405161015091906115bc565b610143610542565b6101eb61020e3660046113e4565b610555565b610143610575565b61012e6102293660046112fb565b61057a565b61014361023c36600461137c565b6105e4565b61012e61024f366004611394565b6105fb565b610143610262366004611166565b610635565b61012e61027536600461114b565b610652565b61012e61028836600461119a565b6106d7565b60005b81518110156102bd576102b58282815181106102a857fe5b6020026020010151610652565b600101610290565b5050565b60009081526020819052604090206002015490565b6001602052600090815260409020546001600160a01b031681565b60008281526020819052604090206002015461030f906101e6610a0b565b6103345760405162461bcd60e51b815260040161032b90611670565b60405180910390fd5b6102bd8282610a0f565b610346610a0b565b6001600160a01b0316816001600160a01b0316146103765760405162461bcd60e51b815260040161032b90611912565b6102bd8282610a78565b6001600160a01b038084166000908152600160205260409020548491166103b95760405162461bcd60e51b815260040161032b9061185a565b6001600160a01b03841660009081526002602090815260408083203384529091529020546103e79084610ae1565b6001600160a01b03851660008181526002602090815260408083203380855292529091209290925561041a913086610b06565b6001600160a01b03808516600090815260016020526040908190205490517f4e9dc37847123badcca2493e1da785f59908e20645214cf795e6914bfdbaada29261046e9288929116903390879089906114fd565b60405180910390a150505050565b61048760003361052a565b6104a35760405162461bcd60e51b815260040161032b90611601565b6001600160a01b0382811660009081526001602052604090205416156104db5760405162461bcd60e51b815260040161032b90611823565b6001600160a01b03918216600090815260016020526040902080546001600160a01b03191691909216179055565b60008281526020819052604081206105219083610b64565b90505b92915050565b60008281526020819052604081206105219083610b70565b6b52454c415945525f524f4c4560a01b81565b805160208183018101805160038252928201919093012091525460ff1681565b600081565b805182511461059b5760405162461bcd60e51b815260040161032b906116bf565b60005b82518110156105df576105d78382815181106105b657fe5b60200260200101518383815181106105ca57fe5b602002602001015161047c565b60010161059e565b505050565b600081815260208190526040812061052490610b85565b600082815260208190526040902060020154610619906101e6610a0b565b6103765760405162461bcd60e51b815260040161032b906117a4565b600260209081526000928352604080842090915290825290205481565b61065d60003361052a565b6106795760405162461bcd60e51b815260040161032b90611601565b6001600160a01b03818116600090815260016020526040902054166106b05760405162461bcd60e51b815260040161032b90611777565b6001600160a01b0316600090815260016020526040902080546001600160a01b0319169055565b6001600160a01b038087166000908152600160205260409020548791166107105760405162461bcd60e51b815260040161032b9061185a565b6107296b52454c415945525f524f4c4560a01b3361052a565b6107455760405162461bcd60e51b815260040161032b906117f4565b82600381604051610756919061149c565b9081526040519081900360200190205460ff16156107865760405162461bcd60e51b815260040161032b90611726565b60006107a06b52454c415945525f524f4c4560a01b6105e4565b84519091506003600019830104906002828401810104908111156107c6575050506109ec565b60008b8b8b8b8b6040516020016107e1959493929190611443565b60405160208183030381529060405280519060200120905060005b875181101561086f57600061082c61081384610b90565b8a848151811061081f57fe5b6020026020010151610bc0565b90506108476b52454c415945525f524f4c4560a01b8261052a565b1561086657600083815260046020526040902061086490826109f6565b505b506001016107fc565b506000818152600460205260409020829061088990610b85565b10156108a75760405162461bcd60e51b815260040161032b9061174b565b60016003896040516108b9919061149c565b9081526040805160209281900383019020805460ff1916931515939093179092556001600160a01b038e8116600090815260028352838120918e16815291522054610904908a610c9f565b600260008e6001600160a01b03166001600160a01b0316815260200190815260200160002060008c6001600160a01b03166001600160a01b031681526020019081526020016000208190555061096e8a8a8e6001600160a01b0316610ce19092919063ffffffff16565b7f5800596ed55e41c52e6e763640e29ff0d4c09c47408a512c4fb0974a452c1f0c8c600160008f6001600160a01b03166001600160a01b0316815260200190815260200160002060009054906101000a90046001600160a01b03168d8d8d8d6040516109df96959493929190611530565b60405180910390a1505050505b5050505050505050565b6000610521836001600160a01b038416610d00565b3390565b6000828152602081905260409020610a2790826109f6565b156102bd57610a34610a0b565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152602081905260409020610a909082610d4a565b156102bd57610a9d610a0b565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b6000828201838110156105215760405162461bcd60e51b815260040161032b906116ef565b610b5e846323b872dd60e01b858585604051602401610b279392919061157f565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610d5f565b50505050565b60006105218383610dee565b6000610521836001600160a01b038416610e33565b600061052482610e4b565b600081604051602001610ba391906114b8565b604051602081830303815290604052805190602001209050919050565b60008151604114610bd357506000610524565b60208201516040830151606084015160001a7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0821115610c195760009350505050610524565b8060ff16601b14158015610c3157508060ff16601c14155b15610c425760009350505050610524565b600060018783868660405160008152602001604052604051610c6794939291906115d0565b6020604051602081039080840390855afa158015610c89573d6000803e3d6000fd5b5050604051601f19015198975050505050505050565b600061052183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610e4f565b6105df8363a9059cbb60e01b8484604051602401610b279291906115a3565b6000610d0c8383610e33565b610d4257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610524565b506000610524565b6000610521836001600160a01b038416610e7b565b6060610db4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610f419092919063ffffffff16565b8051909150156105df5780806020019051810190610dd2919061135c565b6105df5760405162461bcd60e51b815260040161032b906118c8565b81546000908210610e115760405162461bcd60e51b815260040161032b9061162e565b826000018281548110610e2057fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b60008184841115610e735760405162461bcd60e51b815260040161032b91906115ee565b505050900390565b60008181526001830160205260408120548015610f375783546000198083019190810190600090879083908110610eae57fe5b9060005260206000200154905080876000018481548110610ecb57fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080610efb57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610524565b6000915050610524565b6060610f508484600085610f58565b949350505050565b6060610f638561101c565b610f7f5760405162461bcd60e51b815260040161032b90611891565b60006060866001600160a01b03168587604051610f9c919061149c565b60006040518083038185875af1925050503d8060008114610fd9576040519150601f19603f3d011682016040523d82523d6000602084013e610fde565b606091505b50915091508115610ff2579150610f509050565b8051156110025780518082602001fd5b8360405162461bcd60e51b815260040161032b91906115ee565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590610f50575050151592915050565b80356001600160a01b038116811461052457600080fd5b600082601f83011261107c578081fd5b813561108f61108a82611988565b611961565b8181529150602080830190848101818402860182018710156110b057600080fd5b60005b848110156110d7576110c58883611055565b845292820192908201906001016110b3565b505050505092915050565b600082601f8301126110f2578081fd5b813567ffffffffffffffff811115611108578182fd5b61111b601f8201601f1916602001611961565b915080825283602082850101111561113257600080fd5b8060208401602084013760009082016020015292915050565b60006020828403121561115c578081fd5b6105218383611055565b60008060408385031215611178578081fd5b6111828484611055565b91506111918460208501611055565b90509250929050565b60008060008060008060c087890312156111b2578182fd5b6111bc8888611055565b955060206111cc89828a01611055565b95506111db8960408a01611055565b945060608801359350608088013567ffffffffffffffff808211156111fe578485fd5b61120a8b838c016110e2565b945060a08a013591508082111561121f578384fd5b508801601f81018a13611230578283fd5b803561123e61108a82611988565b81815283810190838501865b84811015611273576112618f8884358901016110e2565b8452928601929086019060010161124a565b505080955050505050509295509295509295565b60008060006060848603121561129b578283fd5b83356112a6816119d4565b92506020840135915060408401356112bd816119d4565b809150509250925092565b6000602082840312156112d9578081fd5b813567ffffffffffffffff8111156112ef578182fd5b610f508482850161106c565b6000806040838503121561130d578182fd5b823567ffffffffffffffff80821115611324578384fd5b6113308683870161106c565b93506020850135915080821115611345578283fd5b506113528582860161106c565b9150509250929050565b60006020828403121561136d578081fd5b81518015158114610521578182fd5b60006020828403121561138d578081fd5b5035919050565b600080604083850312156113a6578182fd5b8235915060208301356113b8816119d4565b809150509250929050565b600080604083850312156113d5578182fd5b50508035926020909101359150565b6000602082840312156113f5578081fd5b813567ffffffffffffffff81111561140b578182fd5b610f50848285016110e2565b6000815180845261142f8160208601602086016119a8565b601f01601f19169290920160200192915050565b60006bffffffffffffffffffffffff19808860601b168352808760601b166014840152808660601b1660288401525083603c830152825161148b81605c8501602087016119a8565b91909101605c019695505050505050565b600082516114ae8184602087016119a8565b9190910192915050565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b6001600160a01b0391909116815260200190565b6001600160a01b039586168152938516602085015291841660408401529092166060820152608081019190915260a00190565b6001600160a01b03878116825286811660208301528581166040830152841660608201526080810183905260c060a0820181905260009061157390830184611417565b98975050505050505050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b90815260200190565b93845260ff9290921660208401526040830152606082015260800190565b6000602082526105216020830184611417565b60208082526013908201527231b0b63632b91034b9903737ba1030b236b4b760691b604082015260600190565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201526e0818591b5a5b881d1bc819dc985b9d608a1b606082015260800190565b6020808252601690820152750a8ded6cadc40d8cadccee8d040dcdee840dac2e8c6d60531b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252600b908201526a1d1e081d5b9b1bd8dad95960aa1b604082015260600190565b6020808252601290820152711cda59db985d1d5c995cc81a5b9d985a5b1960721b604082015260600190565b602080825260139082015272151bdad95b881b9bdd0814dd5c1c1bdc9d1959606a1b604082015260600190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201526f2061646d696e20746f207265766f6b6560801b606082015260800190565b60208082526015908201527431b0b63632b91034b9903737ba1031b937b9b9b2b960591b604082015260600190565b60208082526017908201527f546f6b656e20616c726561647920537570706f72746564000000000000000000604082015260600190565b60208082526017908201527f4c6f636b3a3a4e6f7420537570706f727420546f6b656e000000000000000000604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201526e103937b632b9903337b91039b2b63360891b606082015260800190565b60405181810167ffffffffffffffff8111828210171561198057600080fd5b604052919050565b600067ffffffffffffffff82111561199e578081fd5b5060209081020190565b60005b838110156119c35781810151838201526020016119ab565b83811115610b5e5750506000910152565b6001600160a01b03811681146119e957600080fd5b5056fea2646970667358221220ae159d9971200769811ad876cc9bf81087951357be6506a2d0e799c8f4c61f0064736f6c634300060c0033" + +// DeployEscrows deploys a new Ethereum contract, binding an instance of Escrows to it. +func DeployEscrows(auth *bind.TransactOpts, backend bind.ContractBackend, _relayers []common.Address) (common.Address, *types.Transaction, *Escrows, error) { + parsed, err := abi.JSON(strings.NewReader(EscrowsABI)) + if err != nil { + return common.Address{}, nil, nil, err + } + + address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(EscrowsBin), backend, _relayers) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &Escrows{EscrowsCaller: EscrowsCaller{contract: contract}, EscrowsTransactor: EscrowsTransactor{contract: contract}, EscrowsFilterer: EscrowsFilterer{contract: contract}}, nil +} + +// Escrows is an auto generated Go binding around an Ethereum contract. +type Escrows struct { + EscrowsCaller // Read-only binding to the contract + EscrowsTransactor // Write-only binding to the contract + EscrowsFilterer // Log filterer for contract events +} + +// EscrowsCaller is an auto generated read-only Go binding around an Ethereum contract. +type EscrowsCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// EscrowsTransactor is an auto generated write-only Go binding around an Ethereum contract. +type EscrowsTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// EscrowsFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type EscrowsFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// EscrowsSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type EscrowsSession struct { + Contract *Escrows // 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 +} + +// EscrowsCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type EscrowsCallerSession struct { + Contract *EscrowsCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// EscrowsTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type EscrowsTransactorSession struct { + Contract *EscrowsTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// EscrowsRaw is an auto generated low-level Go binding around an Ethereum contract. +type EscrowsRaw struct { + Contract *Escrows // Generic contract binding to access the raw methods on +} + +// EscrowsCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type EscrowsCallerRaw struct { + Contract *EscrowsCaller // Generic read-only contract binding to access the raw methods on +} + +// EscrowsTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type EscrowsTransactorRaw struct { + Contract *EscrowsTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewEscrows creates a new instance of Escrows, bound to a specific deployed contract. +func NewEscrows(address common.Address, backend bind.ContractBackend) (*Escrows, error) { + contract, err := bindEscrows(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Escrows{EscrowsCaller: EscrowsCaller{contract: contract}, EscrowsTransactor: EscrowsTransactor{contract: contract}, EscrowsFilterer: EscrowsFilterer{contract: contract}}, nil +} + +// NewEscrowsCaller creates a new read-only instance of Escrows, bound to a specific deployed contract. +func NewEscrowsCaller(address common.Address, caller bind.ContractCaller) (*EscrowsCaller, error) { + contract, err := bindEscrows(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &EscrowsCaller{contract: contract}, nil +} + +// NewEscrowsTransactor creates a new write-only instance of Escrows, bound to a specific deployed contract. +func NewEscrowsTransactor(address common.Address, transactor bind.ContractTransactor) (*EscrowsTransactor, error) { + contract, err := bindEscrows(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &EscrowsTransactor{contract: contract}, nil +} + +// NewEscrowsFilterer creates a new log filterer instance of Escrows, bound to a specific deployed contract. +func NewEscrowsFilterer(address common.Address, filterer bind.ContractFilterer) (*EscrowsFilterer, error) { + contract, err := bindEscrows(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &EscrowsFilterer{contract: contract}, nil +} + +// bindEscrows binds a generic wrapper to an already deployed contract. +func bindEscrows(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(EscrowsABI)) + 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 (_Escrows *EscrowsRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Escrows.Contract.EscrowsCaller.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 (_Escrows *EscrowsRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Escrows.Contract.EscrowsTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Escrows *EscrowsRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Escrows.Contract.EscrowsTransactor.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 (_Escrows *EscrowsCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Escrows.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 (_Escrows *EscrowsTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Escrows.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Escrows *EscrowsTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Escrows.Contract.contract.Transact(opts, method, params...) +} + +// DEFAULTADMINROLE is a free data retrieval call binding the contract method 0xa217fddf. +// +// Solidity: function DEFAULT_ADMIN_ROLE() view returns(bytes32) +func (_Escrows *EscrowsCaller) DEFAULTADMINROLE(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _Escrows.contract.Call(opts, &out, "DEFAULT_ADMIN_ROLE") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// DEFAULTADMINROLE is a free data retrieval call binding the contract method 0xa217fddf. +// +// Solidity: function DEFAULT_ADMIN_ROLE() view returns(bytes32) +func (_Escrows *EscrowsSession) DEFAULTADMINROLE() ([32]byte, error) { + return _Escrows.Contract.DEFAULTADMINROLE(&_Escrows.CallOpts) +} + +// DEFAULTADMINROLE is a free data retrieval call binding the contract method 0xa217fddf. +// +// Solidity: function DEFAULT_ADMIN_ROLE() view returns(bytes32) +func (_Escrows *EscrowsCallerSession) DEFAULTADMINROLE() ([32]byte, error) { + return _Escrows.Contract.DEFAULTADMINROLE(&_Escrows.CallOpts) +} + +// RELAYERROLE is a free data retrieval call binding the contract method 0x926d7d7f. +// +// Solidity: function RELAYER_ROLE() view returns(bytes32) +func (_Escrows *EscrowsCaller) RELAYERROLE(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _Escrows.contract.Call(opts, &out, "RELAYER_ROLE") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// RELAYERROLE is a free data retrieval call binding the contract method 0x926d7d7f. +// +// Solidity: function RELAYER_ROLE() view returns(bytes32) +func (_Escrows *EscrowsSession) RELAYERROLE() ([32]byte, error) { + return _Escrows.Contract.RELAYERROLE(&_Escrows.CallOpts) +} + +// RELAYERROLE is a free data retrieval call binding the contract method 0x926d7d7f. +// +// Solidity: function RELAYER_ROLE() view returns(bytes32) +func (_Escrows *EscrowsCallerSession) RELAYERROLE() ([32]byte, error) { + return _Escrows.Contract.RELAYERROLE(&_Escrows.CallOpts) +} + +// GetRoleAdmin is a free data retrieval call binding the contract method 0x248a9ca3. +// +// Solidity: function getRoleAdmin(bytes32 role) view returns(bytes32) +func (_Escrows *EscrowsCaller) GetRoleAdmin(opts *bind.CallOpts, role [32]byte) ([32]byte, error) { + var out []interface{} + err := _Escrows.contract.Call(opts, &out, "getRoleAdmin", role) + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// GetRoleAdmin is a free data retrieval call binding the contract method 0x248a9ca3. +// +// Solidity: function getRoleAdmin(bytes32 role) view returns(bytes32) +func (_Escrows *EscrowsSession) GetRoleAdmin(role [32]byte) ([32]byte, error) { + return _Escrows.Contract.GetRoleAdmin(&_Escrows.CallOpts, role) +} + +// GetRoleAdmin is a free data retrieval call binding the contract method 0x248a9ca3. +// +// Solidity: function getRoleAdmin(bytes32 role) view returns(bytes32) +func (_Escrows *EscrowsCallerSession) GetRoleAdmin(role [32]byte) ([32]byte, error) { + return _Escrows.Contract.GetRoleAdmin(&_Escrows.CallOpts, role) +} + +// GetRoleMember is a free data retrieval call binding the contract method 0x9010d07c. +// +// Solidity: function getRoleMember(bytes32 role, uint256 index) view returns(address) +func (_Escrows *EscrowsCaller) GetRoleMember(opts *bind.CallOpts, role [32]byte, index *big.Int) (common.Address, error) { + var out []interface{} + err := _Escrows.contract.Call(opts, &out, "getRoleMember", role, index) + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// GetRoleMember is a free data retrieval call binding the contract method 0x9010d07c. +// +// Solidity: function getRoleMember(bytes32 role, uint256 index) view returns(address) +func (_Escrows *EscrowsSession) GetRoleMember(role [32]byte, index *big.Int) (common.Address, error) { + return _Escrows.Contract.GetRoleMember(&_Escrows.CallOpts, role, index) +} + +// GetRoleMember is a free data retrieval call binding the contract method 0x9010d07c. +// +// Solidity: function getRoleMember(bytes32 role, uint256 index) view returns(address) +func (_Escrows *EscrowsCallerSession) GetRoleMember(role [32]byte, index *big.Int) (common.Address, error) { + return _Escrows.Contract.GetRoleMember(&_Escrows.CallOpts, role, index) +} + +// GetRoleMemberCount is a free data retrieval call binding the contract method 0xca15c873. +// +// Solidity: function getRoleMemberCount(bytes32 role) view returns(uint256) +func (_Escrows *EscrowsCaller) GetRoleMemberCount(opts *bind.CallOpts, role [32]byte) (*big.Int, error) { + var out []interface{} + err := _Escrows.contract.Call(opts, &out, "getRoleMemberCount", role) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetRoleMemberCount is a free data retrieval call binding the contract method 0xca15c873. +// +// Solidity: function getRoleMemberCount(bytes32 role) view returns(uint256) +func (_Escrows *EscrowsSession) GetRoleMemberCount(role [32]byte) (*big.Int, error) { + return _Escrows.Contract.GetRoleMemberCount(&_Escrows.CallOpts, role) +} + +// GetRoleMemberCount is a free data retrieval call binding the contract method 0xca15c873. +// +// Solidity: function getRoleMemberCount(bytes32 role) view returns(uint256) +func (_Escrows *EscrowsCallerSession) GetRoleMemberCount(role [32]byte) (*big.Int, error) { + return _Escrows.Contract.GetRoleMemberCount(&_Escrows.CallOpts, role) +} + +// HasRole is a free data retrieval call binding the contract method 0x91d14854. +// +// Solidity: function hasRole(bytes32 role, address account) view returns(bool) +func (_Escrows *EscrowsCaller) HasRole(opts *bind.CallOpts, role [32]byte, account common.Address) (bool, error) { + var out []interface{} + err := _Escrows.contract.Call(opts, &out, "hasRole", role, account) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// HasRole is a free data retrieval call binding the contract method 0x91d14854. +// +// Solidity: function hasRole(bytes32 role, address account) view returns(bool) +func (_Escrows *EscrowsSession) HasRole(role [32]byte, account common.Address) (bool, error) { + return _Escrows.Contract.HasRole(&_Escrows.CallOpts, role, account) +} + +// HasRole is a free data retrieval call binding the contract method 0x91d14854. +// +// Solidity: function hasRole(bytes32 role, address account) view returns(bool) +func (_Escrows *EscrowsCallerSession) HasRole(role [32]byte, account common.Address) (bool, error) { + return _Escrows.Contract.HasRole(&_Escrows.CallOpts, role, account) +} + +// LockAmount is a free data retrieval call binding the contract method 0xe2095ab4. +// +// Solidity: function lockAmount(address , address ) view returns(uint256) +func (_Escrows *EscrowsCaller) LockAmount(opts *bind.CallOpts, arg0 common.Address, arg1 common.Address) (*big.Int, error) { + var out []interface{} + err := _Escrows.contract.Call(opts, &out, "lockAmount", arg0, arg1) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// LockAmount is a free data retrieval call binding the contract method 0xe2095ab4. +// +// Solidity: function lockAmount(address , address ) view returns(uint256) +func (_Escrows *EscrowsSession) LockAmount(arg0 common.Address, arg1 common.Address) (*big.Int, error) { + return _Escrows.Contract.LockAmount(&_Escrows.CallOpts, arg0, arg1) +} + +// LockAmount is a free data retrieval call binding the contract method 0xe2095ab4. +// +// Solidity: function lockAmount(address , address ) view returns(uint256) +func (_Escrows *EscrowsCallerSession) LockAmount(arg0 common.Address, arg1 common.Address) (*big.Int, error) { + return _Escrows.Contract.LockAmount(&_Escrows.CallOpts, arg0, arg1) +} + +// SupportToken is a free data retrieval call binding the contract method 0x2a4f1621. +// +// Solidity: function supportToken(address ) view returns(address) +func (_Escrows *EscrowsCaller) SupportToken(opts *bind.CallOpts, arg0 common.Address) (common.Address, error) { + var out []interface{} + err := _Escrows.contract.Call(opts, &out, "supportToken", arg0) + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// SupportToken is a free data retrieval call binding the contract method 0x2a4f1621. +// +// Solidity: function supportToken(address ) view returns(address) +func (_Escrows *EscrowsSession) SupportToken(arg0 common.Address) (common.Address, error) { + return _Escrows.Contract.SupportToken(&_Escrows.CallOpts, arg0) +} + +// SupportToken is a free data retrieval call binding the contract method 0x2a4f1621. +// +// Solidity: function supportToken(address ) view returns(address) +func (_Escrows *EscrowsCallerSession) SupportToken(arg0 common.Address) (common.Address, error) { + return _Escrows.Contract.SupportToken(&_Escrows.CallOpts, arg0) +} + +// TxUnlocked is a free data retrieval call binding the contract method 0x967145af. +// +// Solidity: function txUnlocked(string ) view returns(bool) +func (_Escrows *EscrowsCaller) TxUnlocked(opts *bind.CallOpts, arg0 string) (bool, error) { + var out []interface{} + err := _Escrows.contract.Call(opts, &out, "txUnlocked", arg0) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// TxUnlocked is a free data retrieval call binding the contract method 0x967145af. +// +// Solidity: function txUnlocked(string ) view returns(bool) +func (_Escrows *EscrowsSession) TxUnlocked(arg0 string) (bool, error) { + return _Escrows.Contract.TxUnlocked(&_Escrows.CallOpts, arg0) +} + +// TxUnlocked is a free data retrieval call binding the contract method 0x967145af. +// +// Solidity: function txUnlocked(string ) view returns(bool) +func (_Escrows *EscrowsCallerSession) TxUnlocked(arg0 string) (bool, error) { + return _Escrows.Contract.TxUnlocked(&_Escrows.CallOpts, arg0) +} + +// AddSupportToken is a paid mutator transaction binding the contract method 0x7010584c. +// +// Solidity: function addSupportToken(address ethTokenAddr, address relayTokenAddr) returns() +func (_Escrows *EscrowsTransactor) AddSupportToken(opts *bind.TransactOpts, ethTokenAddr common.Address, relayTokenAddr common.Address) (*types.Transaction, error) { + return _Escrows.contract.Transact(opts, "addSupportToken", ethTokenAddr, relayTokenAddr) +} + +// AddSupportToken is a paid mutator transaction binding the contract method 0x7010584c. +// +// Solidity: function addSupportToken(address ethTokenAddr, address relayTokenAddr) returns() +func (_Escrows *EscrowsSession) AddSupportToken(ethTokenAddr common.Address, relayTokenAddr common.Address) (*types.Transaction, error) { + return _Escrows.Contract.AddSupportToken(&_Escrows.TransactOpts, ethTokenAddr, relayTokenAddr) +} + +// AddSupportToken is a paid mutator transaction binding the contract method 0x7010584c. +// +// Solidity: function addSupportToken(address ethTokenAddr, address relayTokenAddr) returns() +func (_Escrows *EscrowsTransactorSession) AddSupportToken(ethTokenAddr common.Address, relayTokenAddr common.Address) (*types.Transaction, error) { + return _Escrows.Contract.AddSupportToken(&_Escrows.TransactOpts, ethTokenAddr, relayTokenAddr) +} + +// AddSupportTokens is a paid mutator transaction binding the contract method 0xab1494de. +// +// Solidity: function addSupportTokens(address[] ethTokenAddrs, address[] relayTokenAddrs) returns() +func (_Escrows *EscrowsTransactor) AddSupportTokens(opts *bind.TransactOpts, ethTokenAddrs []common.Address, relayTokenAddrs []common.Address) (*types.Transaction, error) { + return _Escrows.contract.Transact(opts, "addSupportTokens", ethTokenAddrs, relayTokenAddrs) +} + +// AddSupportTokens is a paid mutator transaction binding the contract method 0xab1494de. +// +// Solidity: function addSupportTokens(address[] ethTokenAddrs, address[] relayTokenAddrs) returns() +func (_Escrows *EscrowsSession) AddSupportTokens(ethTokenAddrs []common.Address, relayTokenAddrs []common.Address) (*types.Transaction, error) { + return _Escrows.Contract.AddSupportTokens(&_Escrows.TransactOpts, ethTokenAddrs, relayTokenAddrs) +} + +// AddSupportTokens is a paid mutator transaction binding the contract method 0xab1494de. +// +// Solidity: function addSupportTokens(address[] ethTokenAddrs, address[] relayTokenAddrs) returns() +func (_Escrows *EscrowsTransactorSession) AddSupportTokens(ethTokenAddrs []common.Address, relayTokenAddrs []common.Address) (*types.Transaction, error) { + return _Escrows.Contract.AddSupportTokens(&_Escrows.TransactOpts, ethTokenAddrs, relayTokenAddrs) +} + +// GrantRole is a paid mutator transaction binding the contract method 0x2f2ff15d. +// +// Solidity: function grantRole(bytes32 role, address account) returns() +func (_Escrows *EscrowsTransactor) GrantRole(opts *bind.TransactOpts, role [32]byte, account common.Address) (*types.Transaction, error) { + return _Escrows.contract.Transact(opts, "grantRole", role, account) +} + +// GrantRole is a paid mutator transaction binding the contract method 0x2f2ff15d. +// +// Solidity: function grantRole(bytes32 role, address account) returns() +func (_Escrows *EscrowsSession) GrantRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _Escrows.Contract.GrantRole(&_Escrows.TransactOpts, role, account) +} + +// GrantRole is a paid mutator transaction binding the contract method 0x2f2ff15d. +// +// Solidity: function grantRole(bytes32 role, address account) returns() +func (_Escrows *EscrowsTransactorSession) GrantRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _Escrows.Contract.GrantRole(&_Escrows.TransactOpts, role, account) +} + +// Lock is a paid mutator transaction binding the contract method 0x4bbc170a. +// +// Solidity: function lock(address token, uint256 amount, address recipient) returns() +func (_Escrows *EscrowsTransactor) Lock(opts *bind.TransactOpts, token common.Address, amount *big.Int, recipient common.Address) (*types.Transaction, error) { + return _Escrows.contract.Transact(opts, "lock", token, amount, recipient) +} + +// Lock is a paid mutator transaction binding the contract method 0x4bbc170a. +// +// Solidity: function lock(address token, uint256 amount, address recipient) returns() +func (_Escrows *EscrowsSession) Lock(token common.Address, amount *big.Int, recipient common.Address) (*types.Transaction, error) { + return _Escrows.Contract.Lock(&_Escrows.TransactOpts, token, amount, recipient) +} + +// Lock is a paid mutator transaction binding the contract method 0x4bbc170a. +// +// Solidity: function lock(address token, uint256 amount, address recipient) returns() +func (_Escrows *EscrowsTransactorSession) Lock(token common.Address, amount *big.Int, recipient common.Address) (*types.Transaction, error) { + return _Escrows.Contract.Lock(&_Escrows.TransactOpts, token, amount, recipient) +} + +// RemoveSupportToken is a paid mutator transaction binding the contract method 0xe2769cfa. +// +// Solidity: function removeSupportToken(address ethTokenAddr) returns() +func (_Escrows *EscrowsTransactor) RemoveSupportToken(opts *bind.TransactOpts, ethTokenAddr common.Address) (*types.Transaction, error) { + return _Escrows.contract.Transact(opts, "removeSupportToken", ethTokenAddr) +} + +// RemoveSupportToken is a paid mutator transaction binding the contract method 0xe2769cfa. +// +// Solidity: function removeSupportToken(address ethTokenAddr) returns() +func (_Escrows *EscrowsSession) RemoveSupportToken(ethTokenAddr common.Address) (*types.Transaction, error) { + return _Escrows.Contract.RemoveSupportToken(&_Escrows.TransactOpts, ethTokenAddr) +} + +// RemoveSupportToken is a paid mutator transaction binding the contract method 0xe2769cfa. +// +// Solidity: function removeSupportToken(address ethTokenAddr) returns() +func (_Escrows *EscrowsTransactorSession) RemoveSupportToken(ethTokenAddr common.Address) (*types.Transaction, error) { + return _Escrows.Contract.RemoveSupportToken(&_Escrows.TransactOpts, ethTokenAddr) +} + +// RemoveSupportTokens is a paid mutator transaction binding the contract method 0x0daff621. +// +// Solidity: function removeSupportTokens(address[] addrs) returns() +func (_Escrows *EscrowsTransactor) RemoveSupportTokens(opts *bind.TransactOpts, addrs []common.Address) (*types.Transaction, error) { + return _Escrows.contract.Transact(opts, "removeSupportTokens", addrs) +} + +// RemoveSupportTokens is a paid mutator transaction binding the contract method 0x0daff621. +// +// Solidity: function removeSupportTokens(address[] addrs) returns() +func (_Escrows *EscrowsSession) RemoveSupportTokens(addrs []common.Address) (*types.Transaction, error) { + return _Escrows.Contract.RemoveSupportTokens(&_Escrows.TransactOpts, addrs) +} + +// RemoveSupportTokens is a paid mutator transaction binding the contract method 0x0daff621. +// +// Solidity: function removeSupportTokens(address[] addrs) returns() +func (_Escrows *EscrowsTransactorSession) RemoveSupportTokens(addrs []common.Address) (*types.Transaction, error) { + return _Escrows.Contract.RemoveSupportTokens(&_Escrows.TransactOpts, addrs) +} + +// RenounceRole is a paid mutator transaction binding the contract method 0x36568abe. +// +// Solidity: function renounceRole(bytes32 role, address account) returns() +func (_Escrows *EscrowsTransactor) RenounceRole(opts *bind.TransactOpts, role [32]byte, account common.Address) (*types.Transaction, error) { + return _Escrows.contract.Transact(opts, "renounceRole", role, account) +} + +// RenounceRole is a paid mutator transaction binding the contract method 0x36568abe. +// +// Solidity: function renounceRole(bytes32 role, address account) returns() +func (_Escrows *EscrowsSession) RenounceRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _Escrows.Contract.RenounceRole(&_Escrows.TransactOpts, role, account) +} + +// RenounceRole is a paid mutator transaction binding the contract method 0x36568abe. +// +// Solidity: function renounceRole(bytes32 role, address account) returns() +func (_Escrows *EscrowsTransactorSession) RenounceRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _Escrows.Contract.RenounceRole(&_Escrows.TransactOpts, role, account) +} + +// RevokeRole is a paid mutator transaction binding the contract method 0xd547741f. +// +// Solidity: function revokeRole(bytes32 role, address account) returns() +func (_Escrows *EscrowsTransactor) RevokeRole(opts *bind.TransactOpts, role [32]byte, account common.Address) (*types.Transaction, error) { + return _Escrows.contract.Transact(opts, "revokeRole", role, account) +} + +// RevokeRole is a paid mutator transaction binding the contract method 0xd547741f. +// +// Solidity: function revokeRole(bytes32 role, address account) returns() +func (_Escrows *EscrowsSession) RevokeRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _Escrows.Contract.RevokeRole(&_Escrows.TransactOpts, role, account) +} + +// RevokeRole is a paid mutator transaction binding the contract method 0xd547741f. +// +// Solidity: function revokeRole(bytes32 role, address account) returns() +func (_Escrows *EscrowsTransactorSession) RevokeRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _Escrows.Contract.RevokeRole(&_Escrows.TransactOpts, role, account) +} + +// Unlock is a paid mutator transaction binding the contract method 0xe4242dd5. +// +// Solidity: function unlock(address token, address from, address recipient, uint256 amount, string _txid, bytes[] signatures) returns() +func (_Escrows *EscrowsTransactor) Unlock(opts *bind.TransactOpts, token common.Address, from common.Address, recipient common.Address, amount *big.Int, _txid string, signatures [][]byte) (*types.Transaction, error) { + return _Escrows.contract.Transact(opts, "unlock", token, from, recipient, amount, _txid, signatures) +} + +// Unlock is a paid mutator transaction binding the contract method 0xe4242dd5. +// +// Solidity: function unlock(address token, address from, address recipient, uint256 amount, string _txid, bytes[] signatures) returns() +func (_Escrows *EscrowsSession) Unlock(token common.Address, from common.Address, recipient common.Address, amount *big.Int, _txid string, signatures [][]byte) (*types.Transaction, error) { + return _Escrows.Contract.Unlock(&_Escrows.TransactOpts, token, from, recipient, amount, _txid, signatures) +} + +// Unlock is a paid mutator transaction binding the contract method 0xe4242dd5. +// +// Solidity: function unlock(address token, address from, address recipient, uint256 amount, string _txid, bytes[] signatures) returns() +func (_Escrows *EscrowsTransactorSession) Unlock(token common.Address, from common.Address, recipient common.Address, amount *big.Int, _txid string, signatures [][]byte) (*types.Transaction, error) { + return _Escrows.Contract.Unlock(&_Escrows.TransactOpts, token, from, recipient, amount, _txid, signatures) +} + +// EscrowsLockIterator is returned from FilterLock and is used to iterate over the raw logs and unpacked data for Lock events raised by the Escrows contract. +type EscrowsLockIterator struct { + Event *EscrowsLock // 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 *EscrowsLockIterator) 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(EscrowsLock) + 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(EscrowsLock) + 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 *EscrowsLockIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *EscrowsLockIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// EscrowsLock represents a Lock event raised by the Escrows contract. +type EscrowsLock struct { + EthToken common.Address + RelayToken common.Address + Locker common.Address + Recipient common.Address + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterLock is a free log retrieval operation binding the contract event 0x4e9dc37847123badcca2493e1da785f59908e20645214cf795e6914bfdbaada2. +// +// Solidity: event Lock(address ethToken, address relayToken, address locker, address recipient, uint256 amount) +func (_Escrows *EscrowsFilterer) FilterLock(opts *bind.FilterOpts) (*EscrowsLockIterator, error) { + + logs, sub, err := _Escrows.contract.FilterLogs(opts, "Lock") + if err != nil { + return nil, err + } + return &EscrowsLockIterator{contract: _Escrows.contract, event: "Lock", logs: logs, sub: sub}, nil +} + +// WatchLock is a free log subscription operation binding the contract event 0x4e9dc37847123badcca2493e1da785f59908e20645214cf795e6914bfdbaada2. +// +// Solidity: event Lock(address ethToken, address relayToken, address locker, address recipient, uint256 amount) +func (_Escrows *EscrowsFilterer) WatchLock(opts *bind.WatchOpts, sink chan<- *EscrowsLock) (event.Subscription, error) { + + logs, sub, err := _Escrows.contract.WatchLogs(opts, "Lock") + 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(EscrowsLock) + if err := _Escrows.contract.UnpackLog(event, "Lock", 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 +} + +// ParseLock is a log parse operation binding the contract event 0x4e9dc37847123badcca2493e1da785f59908e20645214cf795e6914bfdbaada2. +// +// Solidity: event Lock(address ethToken, address relayToken, address locker, address recipient, uint256 amount) +func (_Escrows *EscrowsFilterer) ParseLock(log types.Log) (*EscrowsLock, error) { + event := new(EscrowsLock) + if err := _Escrows.contract.UnpackLog(event, "Lock", log); err != nil { + return nil, err + } + return event, nil +} + +// EscrowsRoleAdminChangedIterator is returned from FilterRoleAdminChanged and is used to iterate over the raw logs and unpacked data for RoleAdminChanged events raised by the Escrows contract. +type EscrowsRoleAdminChangedIterator struct { + Event *EscrowsRoleAdminChanged // 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 *EscrowsRoleAdminChangedIterator) 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(EscrowsRoleAdminChanged) + 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(EscrowsRoleAdminChanged) + 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 *EscrowsRoleAdminChangedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *EscrowsRoleAdminChangedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// EscrowsRoleAdminChanged represents a RoleAdminChanged event raised by the Escrows contract. +type EscrowsRoleAdminChanged struct { + Role [32]byte + PreviousAdminRole [32]byte + NewAdminRole [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRoleAdminChanged is a free log retrieval operation binding the contract event 0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff. +// +// Solidity: event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole) +func (_Escrows *EscrowsFilterer) FilterRoleAdminChanged(opts *bind.FilterOpts, role [][32]byte, previousAdminRole [][32]byte, newAdminRole [][32]byte) (*EscrowsRoleAdminChangedIterator, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var previousAdminRoleRule []interface{} + for _, previousAdminRoleItem := range previousAdminRole { + previousAdminRoleRule = append(previousAdminRoleRule, previousAdminRoleItem) + } + var newAdminRoleRule []interface{} + for _, newAdminRoleItem := range newAdminRole { + newAdminRoleRule = append(newAdminRoleRule, newAdminRoleItem) + } + + logs, sub, err := _Escrows.contract.FilterLogs(opts, "RoleAdminChanged", roleRule, previousAdminRoleRule, newAdminRoleRule) + if err != nil { + return nil, err + } + return &EscrowsRoleAdminChangedIterator{contract: _Escrows.contract, event: "RoleAdminChanged", logs: logs, sub: sub}, nil +} + +// WatchRoleAdminChanged is a free log subscription operation binding the contract event 0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff. +// +// Solidity: event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole) +func (_Escrows *EscrowsFilterer) WatchRoleAdminChanged(opts *bind.WatchOpts, sink chan<- *EscrowsRoleAdminChanged, role [][32]byte, previousAdminRole [][32]byte, newAdminRole [][32]byte) (event.Subscription, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var previousAdminRoleRule []interface{} + for _, previousAdminRoleItem := range previousAdminRole { + previousAdminRoleRule = append(previousAdminRoleRule, previousAdminRoleItem) + } + var newAdminRoleRule []interface{} + for _, newAdminRoleItem := range newAdminRole { + newAdminRoleRule = append(newAdminRoleRule, newAdminRoleItem) + } + + logs, sub, err := _Escrows.contract.WatchLogs(opts, "RoleAdminChanged", roleRule, previousAdminRoleRule, newAdminRoleRule) + 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(EscrowsRoleAdminChanged) + if err := _Escrows.contract.UnpackLog(event, "RoleAdminChanged", 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 +} + +// ParseRoleAdminChanged is a log parse operation binding the contract event 0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff. +// +// Solidity: event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole) +func (_Escrows *EscrowsFilterer) ParseRoleAdminChanged(log types.Log) (*EscrowsRoleAdminChanged, error) { + event := new(EscrowsRoleAdminChanged) + if err := _Escrows.contract.UnpackLog(event, "RoleAdminChanged", log); err != nil { + return nil, err + } + return event, nil +} + +// EscrowsRoleGrantedIterator is returned from FilterRoleGranted and is used to iterate over the raw logs and unpacked data for RoleGranted events raised by the Escrows contract. +type EscrowsRoleGrantedIterator struct { + Event *EscrowsRoleGranted // 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 *EscrowsRoleGrantedIterator) 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(EscrowsRoleGranted) + 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(EscrowsRoleGranted) + 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 *EscrowsRoleGrantedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *EscrowsRoleGrantedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// EscrowsRoleGranted represents a RoleGranted event raised by the Escrows contract. +type EscrowsRoleGranted struct { + Role [32]byte + Account common.Address + Sender common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRoleGranted is a free log retrieval operation binding the contract event 0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d. +// +// Solidity: event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender) +func (_Escrows *EscrowsFilterer) FilterRoleGranted(opts *bind.FilterOpts, role [][32]byte, account []common.Address, sender []common.Address) (*EscrowsRoleGrantedIterator, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _Escrows.contract.FilterLogs(opts, "RoleGranted", roleRule, accountRule, senderRule) + if err != nil { + return nil, err + } + return &EscrowsRoleGrantedIterator{contract: _Escrows.contract, event: "RoleGranted", logs: logs, sub: sub}, nil +} + +// WatchRoleGranted is a free log subscription operation binding the contract event 0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d. +// +// Solidity: event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender) +func (_Escrows *EscrowsFilterer) WatchRoleGranted(opts *bind.WatchOpts, sink chan<- *EscrowsRoleGranted, role [][32]byte, account []common.Address, sender []common.Address) (event.Subscription, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _Escrows.contract.WatchLogs(opts, "RoleGranted", roleRule, accountRule, senderRule) + 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(EscrowsRoleGranted) + if err := _Escrows.contract.UnpackLog(event, "RoleGranted", 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 +} + +// ParseRoleGranted is a log parse operation binding the contract event 0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d. +// +// Solidity: event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender) +func (_Escrows *EscrowsFilterer) ParseRoleGranted(log types.Log) (*EscrowsRoleGranted, error) { + event := new(EscrowsRoleGranted) + if err := _Escrows.contract.UnpackLog(event, "RoleGranted", log); err != nil { + return nil, err + } + return event, nil +} + +// EscrowsRoleRevokedIterator is returned from FilterRoleRevoked and is used to iterate over the raw logs and unpacked data for RoleRevoked events raised by the Escrows contract. +type EscrowsRoleRevokedIterator struct { + Event *EscrowsRoleRevoked // 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 *EscrowsRoleRevokedIterator) 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(EscrowsRoleRevoked) + 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(EscrowsRoleRevoked) + 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 *EscrowsRoleRevokedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *EscrowsRoleRevokedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// EscrowsRoleRevoked represents a RoleRevoked event raised by the Escrows contract. +type EscrowsRoleRevoked struct { + Role [32]byte + Account common.Address + Sender common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRoleRevoked is a free log retrieval operation binding the contract event 0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b. +// +// Solidity: event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender) +func (_Escrows *EscrowsFilterer) FilterRoleRevoked(opts *bind.FilterOpts, role [][32]byte, account []common.Address, sender []common.Address) (*EscrowsRoleRevokedIterator, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _Escrows.contract.FilterLogs(opts, "RoleRevoked", roleRule, accountRule, senderRule) + if err != nil { + return nil, err + } + return &EscrowsRoleRevokedIterator{contract: _Escrows.contract, event: "RoleRevoked", logs: logs, sub: sub}, nil +} + +// WatchRoleRevoked is a free log subscription operation binding the contract event 0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b. +// +// Solidity: event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender) +func (_Escrows *EscrowsFilterer) WatchRoleRevoked(opts *bind.WatchOpts, sink chan<- *EscrowsRoleRevoked, role [][32]byte, account []common.Address, sender []common.Address) (event.Subscription, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _Escrows.contract.WatchLogs(opts, "RoleRevoked", roleRule, accountRule, senderRule) + 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(EscrowsRoleRevoked) + if err := _Escrows.contract.UnpackLog(event, "RoleRevoked", 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 +} + +// ParseRoleRevoked is a log parse operation binding the contract event 0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b. +// +// Solidity: event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender) +func (_Escrows *EscrowsFilterer) ParseRoleRevoked(log types.Log) (*EscrowsRoleRevoked, error) { + event := new(EscrowsRoleRevoked) + if err := _Escrows.contract.UnpackLog(event, "RoleRevoked", log); err != nil { + return nil, err + } + return event, nil +} + +// EscrowsUnlockIterator is returned from FilterUnlock and is used to iterate over the raw logs and unpacked data for Unlock events raised by the Escrows contract. +type EscrowsUnlockIterator struct { + Event *EscrowsUnlock // 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 *EscrowsUnlockIterator) 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(EscrowsUnlock) + 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(EscrowsUnlock) + 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 *EscrowsUnlockIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *EscrowsUnlockIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// EscrowsUnlock represents a Unlock event raised by the Escrows contract. +type EscrowsUnlock struct { + EthToken common.Address + RelayToken common.Address + From common.Address + Recipient common.Address + Amount *big.Int + Txid string + Raw types.Log // Blockchain specific contextual infos +} + +// FilterUnlock is a free log retrieval operation binding the contract event 0x5800596ed55e41c52e6e763640e29ff0d4c09c47408a512c4fb0974a452c1f0c. +// +// Solidity: event Unlock(address ethToken, address relayToken, address from, address recipient, uint256 amount, string txid) +func (_Escrows *EscrowsFilterer) FilterUnlock(opts *bind.FilterOpts) (*EscrowsUnlockIterator, error) { + + logs, sub, err := _Escrows.contract.FilterLogs(opts, "Unlock") + if err != nil { + return nil, err + } + return &EscrowsUnlockIterator{contract: _Escrows.contract, event: "Unlock", logs: logs, sub: sub}, nil +} + +// WatchUnlock is a free log subscription operation binding the contract event 0x5800596ed55e41c52e6e763640e29ff0d4c09c47408a512c4fb0974a452c1f0c. +// +// Solidity: event Unlock(address ethToken, address relayToken, address from, address recipient, uint256 amount, string txid) +func (_Escrows *EscrowsFilterer) WatchUnlock(opts *bind.WatchOpts, sink chan<- *EscrowsUnlock) (event.Subscription, error) { + + logs, sub, err := _Escrows.contract.WatchLogs(opts, "Unlock") + 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(EscrowsUnlock) + if err := _Escrows.contract.UnpackLog(event, "Unlock", 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 +} + +// ParseUnlock is a log parse operation binding the contract event 0x5800596ed55e41c52e6e763640e29ff0d4c09c47408a512c4fb0974a452c1f0c. +// +// Solidity: event Unlock(address ethToken, address relayToken, address from, address recipient, uint256 amount, string txid) +func (_Escrows *EscrowsFilterer) ParseUnlock(log types.Log) (*EscrowsUnlock, error) { + event := new(EscrowsUnlock) + if err := _Escrows.contract.UnpackLog(event, "Unlock", log); err != nil { + return nil, err + } + return event, nil +} + +// IERC20ABI is the input ABI used to generate the binding from. +const IERC20ABI = "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" + +// IERC20FuncSigs maps the 4-byte function signature to its string representation. +var IERC20FuncSigs = map[string]string{ + "dd62ed3e": "allowance(address,address)", + "095ea7b3": "approve(address,uint256)", + "70a08231": "balanceOf(address)", + "18160ddd": "totalSupply()", + "a9059cbb": "transfer(address,uint256)", + "23b872dd": "transferFrom(address,address,uint256)", +} + +// IERC20 is an auto generated Go binding around an Ethereum contract. +type IERC20 struct { + IERC20Caller // Read-only binding to the contract + IERC20Transactor // Write-only binding to the contract + IERC20Filterer // Log filterer for contract events +} + +// IERC20Caller is an auto generated read-only Go binding around an Ethereum contract. +type IERC20Caller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// IERC20Transactor is an auto generated write-only Go binding around an Ethereum contract. +type IERC20Transactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// IERC20Filterer is an auto generated log filtering Go binding around an Ethereum contract events. +type IERC20Filterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// IERC20Session is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type IERC20Session struct { + Contract *IERC20 // 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 +} + +// IERC20CallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type IERC20CallerSession struct { + Contract *IERC20Caller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// IERC20TransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type IERC20TransactorSession struct { + Contract *IERC20Transactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// IERC20Raw is an auto generated low-level Go binding around an Ethereum contract. +type IERC20Raw struct { + Contract *IERC20 // Generic contract binding to access the raw methods on +} + +// IERC20CallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type IERC20CallerRaw struct { + Contract *IERC20Caller // Generic read-only contract binding to access the raw methods on +} + +// IERC20TransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type IERC20TransactorRaw struct { + Contract *IERC20Transactor // Generic write-only contract binding to access the raw methods on +} + +// NewIERC20 creates a new instance of IERC20, bound to a specific deployed contract. +func NewIERC20(address common.Address, backend bind.ContractBackend) (*IERC20, error) { + contract, err := bindIERC20(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &IERC20{IERC20Caller: IERC20Caller{contract: contract}, IERC20Transactor: IERC20Transactor{contract: contract}, IERC20Filterer: IERC20Filterer{contract: contract}}, nil +} + +// NewIERC20Caller creates a new read-only instance of IERC20, bound to a specific deployed contract. +func NewIERC20Caller(address common.Address, caller bind.ContractCaller) (*IERC20Caller, error) { + contract, err := bindIERC20(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &IERC20Caller{contract: contract}, nil +} + +// NewIERC20Transactor creates a new write-only instance of IERC20, bound to a specific deployed contract. +func NewIERC20Transactor(address common.Address, transactor bind.ContractTransactor) (*IERC20Transactor, error) { + contract, err := bindIERC20(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &IERC20Transactor{contract: contract}, nil +} + +// NewIERC20Filterer creates a new log filterer instance of IERC20, bound to a specific deployed contract. +func NewIERC20Filterer(address common.Address, filterer bind.ContractFilterer) (*IERC20Filterer, error) { + contract, err := bindIERC20(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &IERC20Filterer{contract: contract}, nil +} + +// bindIERC20 binds a generic wrapper to an already deployed contract. +func bindIERC20(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(IERC20ABI)) + 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 (_IERC20 *IERC20Raw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _IERC20.Contract.IERC20Caller.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 (_IERC20 *IERC20Raw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _IERC20.Contract.IERC20Transactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_IERC20 *IERC20Raw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _IERC20.Contract.IERC20Transactor.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 (_IERC20 *IERC20CallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _IERC20.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 (_IERC20 *IERC20TransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _IERC20.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_IERC20 *IERC20TransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _IERC20.Contract.contract.Transact(opts, method, params...) +} + +// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. +// +// Solidity: function allowance(address owner, address spender) view returns(uint256) +func (_IERC20 *IERC20Caller) Allowance(opts *bind.CallOpts, owner common.Address, spender common.Address) (*big.Int, error) { + var out []interface{} + err := _IERC20.contract.Call(opts, &out, "allowance", owner, spender) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. +// +// Solidity: function allowance(address owner, address spender) view returns(uint256) +func (_IERC20 *IERC20Session) Allowance(owner common.Address, spender common.Address) (*big.Int, error) { + return _IERC20.Contract.Allowance(&_IERC20.CallOpts, owner, spender) +} + +// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. +// +// Solidity: function allowance(address owner, address spender) view returns(uint256) +func (_IERC20 *IERC20CallerSession) Allowance(owner common.Address, spender common.Address) (*big.Int, error) { + return _IERC20.Contract.Allowance(&_IERC20.CallOpts, owner, spender) +} + +// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. +// +// Solidity: function balanceOf(address account) view returns(uint256) +func (_IERC20 *IERC20Caller) BalanceOf(opts *bind.CallOpts, account common.Address) (*big.Int, error) { + var out []interface{} + err := _IERC20.contract.Call(opts, &out, "balanceOf", account) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. +// +// Solidity: function balanceOf(address account) view returns(uint256) +func (_IERC20 *IERC20Session) BalanceOf(account common.Address) (*big.Int, error) { + return _IERC20.Contract.BalanceOf(&_IERC20.CallOpts, account) +} + +// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. +// +// Solidity: function balanceOf(address account) view returns(uint256) +func (_IERC20 *IERC20CallerSession) BalanceOf(account common.Address) (*big.Int, error) { + return _IERC20.Contract.BalanceOf(&_IERC20.CallOpts, account) +} + +// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. +// +// Solidity: function totalSupply() view returns(uint256) +func (_IERC20 *IERC20Caller) TotalSupply(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _IERC20.contract.Call(opts, &out, "totalSupply") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. +// +// Solidity: function totalSupply() view returns(uint256) +func (_IERC20 *IERC20Session) TotalSupply() (*big.Int, error) { + return _IERC20.Contract.TotalSupply(&_IERC20.CallOpts) +} + +// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. +// +// Solidity: function totalSupply() view returns(uint256) +func (_IERC20 *IERC20CallerSession) TotalSupply() (*big.Int, error) { + return _IERC20.Contract.TotalSupply(&_IERC20.CallOpts) +} + +// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. +// +// Solidity: function approve(address spender, uint256 amount) returns(bool) +func (_IERC20 *IERC20Transactor) Approve(opts *bind.TransactOpts, spender common.Address, amount *big.Int) (*types.Transaction, error) { + return _IERC20.contract.Transact(opts, "approve", spender, amount) +} + +// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. +// +// Solidity: function approve(address spender, uint256 amount) returns(bool) +func (_IERC20 *IERC20Session) Approve(spender common.Address, amount *big.Int) (*types.Transaction, error) { + return _IERC20.Contract.Approve(&_IERC20.TransactOpts, spender, amount) +} + +// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. +// +// Solidity: function approve(address spender, uint256 amount) returns(bool) +func (_IERC20 *IERC20TransactorSession) Approve(spender common.Address, amount *big.Int) (*types.Transaction, error) { + return _IERC20.Contract.Approve(&_IERC20.TransactOpts, spender, amount) +} + +// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. +// +// Solidity: function transfer(address recipient, uint256 amount) returns(bool) +func (_IERC20 *IERC20Transactor) Transfer(opts *bind.TransactOpts, recipient common.Address, amount *big.Int) (*types.Transaction, error) { + return _IERC20.contract.Transact(opts, "transfer", recipient, amount) +} + +// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. +// +// Solidity: function transfer(address recipient, uint256 amount) returns(bool) +func (_IERC20 *IERC20Session) Transfer(recipient common.Address, amount *big.Int) (*types.Transaction, error) { + return _IERC20.Contract.Transfer(&_IERC20.TransactOpts, recipient, amount) +} + +// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. +// +// Solidity: function transfer(address recipient, uint256 amount) returns(bool) +func (_IERC20 *IERC20TransactorSession) Transfer(recipient common.Address, amount *big.Int) (*types.Transaction, error) { + return _IERC20.Contract.Transfer(&_IERC20.TransactOpts, recipient, amount) +} + +// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. +// +// Solidity: function transferFrom(address sender, address recipient, uint256 amount) returns(bool) +func (_IERC20 *IERC20Transactor) TransferFrom(opts *bind.TransactOpts, sender common.Address, recipient common.Address, amount *big.Int) (*types.Transaction, error) { + return _IERC20.contract.Transact(opts, "transferFrom", sender, recipient, amount) +} + +// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. +// +// Solidity: function transferFrom(address sender, address recipient, uint256 amount) returns(bool) +func (_IERC20 *IERC20Session) TransferFrom(sender common.Address, recipient common.Address, amount *big.Int) (*types.Transaction, error) { + return _IERC20.Contract.TransferFrom(&_IERC20.TransactOpts, sender, recipient, amount) +} + +// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. +// +// Solidity: function transferFrom(address sender, address recipient, uint256 amount) returns(bool) +func (_IERC20 *IERC20TransactorSession) TransferFrom(sender common.Address, recipient common.Address, amount *big.Int) (*types.Transaction, error) { + return _IERC20.Contract.TransferFrom(&_IERC20.TransactOpts, sender, recipient, amount) +} + +// IERC20ApprovalIterator is returned from FilterApproval and is used to iterate over the raw logs and unpacked data for Approval events raised by the IERC20 contract. +type IERC20ApprovalIterator struct { + Event *IERC20Approval // 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 *IERC20ApprovalIterator) 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(IERC20Approval) + 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(IERC20Approval) + 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 *IERC20ApprovalIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *IERC20ApprovalIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// IERC20Approval represents a Approval event raised by the IERC20 contract. +type IERC20Approval struct { + Owner common.Address + Spender common.Address + Value *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterApproval is a free log retrieval operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. +// +// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) +func (_IERC20 *IERC20Filterer) FilterApproval(opts *bind.FilterOpts, owner []common.Address, spender []common.Address) (*IERC20ApprovalIterator, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var spenderRule []interface{} + for _, spenderItem := range spender { + spenderRule = append(spenderRule, spenderItem) + } + + logs, sub, err := _IERC20.contract.FilterLogs(opts, "Approval", ownerRule, spenderRule) + if err != nil { + return nil, err + } + return &IERC20ApprovalIterator{contract: _IERC20.contract, event: "Approval", logs: logs, sub: sub}, nil +} + +// WatchApproval is a free log subscription operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. +// +// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) +func (_IERC20 *IERC20Filterer) WatchApproval(opts *bind.WatchOpts, sink chan<- *IERC20Approval, owner []common.Address, spender []common.Address) (event.Subscription, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var spenderRule []interface{} + for _, spenderItem := range spender { + spenderRule = append(spenderRule, spenderItem) + } + + logs, sub, err := _IERC20.contract.WatchLogs(opts, "Approval", ownerRule, spenderRule) + 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(IERC20Approval) + if err := _IERC20.contract.UnpackLog(event, "Approval", 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 +} + +// ParseApproval is a log parse operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. +// +// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) +func (_IERC20 *IERC20Filterer) ParseApproval(log types.Log) (*IERC20Approval, error) { + event := new(IERC20Approval) + if err := _IERC20.contract.UnpackLog(event, "Approval", log); err != nil { + return nil, err + } + return event, nil +} + +// IERC20TransferIterator is returned from FilterTransfer and is used to iterate over the raw logs and unpacked data for Transfer events raised by the IERC20 contract. +type IERC20TransferIterator struct { + Event *IERC20Transfer // 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 *IERC20TransferIterator) 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(IERC20Transfer) + 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(IERC20Transfer) + 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 *IERC20TransferIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *IERC20TransferIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// IERC20Transfer represents a Transfer event raised by the IERC20 contract. +type IERC20Transfer struct { + From common.Address + To common.Address + Value *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterTransfer is a free log retrieval operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. +// +// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) +func (_IERC20 *IERC20Filterer) FilterTransfer(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*IERC20TransferIterator, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _IERC20.contract.FilterLogs(opts, "Transfer", fromRule, toRule) + if err != nil { + return nil, err + } + return &IERC20TransferIterator{contract: _IERC20.contract, event: "Transfer", logs: logs, sub: sub}, nil +} + +// WatchTransfer is a free log subscription operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. +// +// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) +func (_IERC20 *IERC20Filterer) WatchTransfer(opts *bind.WatchOpts, sink chan<- *IERC20Transfer, from []common.Address, to []common.Address) (event.Subscription, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _IERC20.contract.WatchLogs(opts, "Transfer", fromRule, toRule) + 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(IERC20Transfer) + if err := _IERC20.contract.UnpackLog(event, "Transfer", 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 +} + +// ParseTransfer is a log parse operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. +// +// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) +func (_IERC20 *IERC20Filterer) ParseTransfer(log types.Log) (*IERC20Transfer, error) { + event := new(IERC20Transfer) + if err := _IERC20.contract.UnpackLog(event, "Transfer", log); err != nil { + return nil, err + } + return event, nil +} + +// OwnableABI is the input ABI used to generate the binding from. +const OwnableABI = "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" + +// OwnableFuncSigs maps the 4-byte function signature to its string representation. +var OwnableFuncSigs = map[string]string{ + "8da5cb5b": "owner()", + "715018a6": "renounceOwnership()", + "f2fde38b": "transferOwnership(address)", +} + +// Ownable is an auto generated Go binding around an Ethereum contract. +type Ownable struct { + OwnableCaller // Read-only binding to the contract + OwnableTransactor // Write-only binding to the contract + OwnableFilterer // Log filterer for contract events +} + +// OwnableCaller is an auto generated read-only Go binding around an Ethereum contract. +type OwnableCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// OwnableTransactor is an auto generated write-only Go binding around an Ethereum contract. +type OwnableTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// OwnableFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type OwnableFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// OwnableSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type OwnableSession struct { + Contract *Ownable // 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 +} + +// OwnableCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type OwnableCallerSession struct { + Contract *OwnableCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// OwnableTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type OwnableTransactorSession struct { + Contract *OwnableTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// OwnableRaw is an auto generated low-level Go binding around an Ethereum contract. +type OwnableRaw struct { + Contract *Ownable // Generic contract binding to access the raw methods on +} + +// OwnableCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type OwnableCallerRaw struct { + Contract *OwnableCaller // Generic read-only contract binding to access the raw methods on +} + +// OwnableTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type OwnableTransactorRaw struct { + Contract *OwnableTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewOwnable creates a new instance of Ownable, bound to a specific deployed contract. +func NewOwnable(address common.Address, backend bind.ContractBackend) (*Ownable, error) { + contract, err := bindOwnable(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Ownable{OwnableCaller: OwnableCaller{contract: contract}, OwnableTransactor: OwnableTransactor{contract: contract}, OwnableFilterer: OwnableFilterer{contract: contract}}, nil +} + +// NewOwnableCaller creates a new read-only instance of Ownable, bound to a specific deployed contract. +func NewOwnableCaller(address common.Address, caller bind.ContractCaller) (*OwnableCaller, error) { + contract, err := bindOwnable(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &OwnableCaller{contract: contract}, nil +} + +// NewOwnableTransactor creates a new write-only instance of Ownable, bound to a specific deployed contract. +func NewOwnableTransactor(address common.Address, transactor bind.ContractTransactor) (*OwnableTransactor, error) { + contract, err := bindOwnable(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &OwnableTransactor{contract: contract}, nil +} + +// NewOwnableFilterer creates a new log filterer instance of Ownable, bound to a specific deployed contract. +func NewOwnableFilterer(address common.Address, filterer bind.ContractFilterer) (*OwnableFilterer, error) { + contract, err := bindOwnable(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &OwnableFilterer{contract: contract}, nil +} + +// bindOwnable binds a generic wrapper to an already deployed contract. +func bindOwnable(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(OwnableABI)) + 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 (_Ownable *OwnableRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Ownable.Contract.OwnableCaller.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 (_Ownable *OwnableRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Ownable.Contract.OwnableTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Ownable *OwnableRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Ownable.Contract.OwnableTransactor.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 (_Ownable *OwnableCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Ownable.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 (_Ownable *OwnableTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Ownable.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Ownable *OwnableTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Ownable.Contract.contract.Transact(opts, method, params...) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Ownable *OwnableCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Ownable.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Ownable *OwnableSession) Owner() (common.Address, error) { + return _Ownable.Contract.Owner(&_Ownable.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Ownable *OwnableCallerSession) Owner() (common.Address, error) { + return _Ownable.Contract.Owner(&_Ownable.CallOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Ownable *OwnableTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Ownable.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Ownable *OwnableSession) RenounceOwnership() (*types.Transaction, error) { + return _Ownable.Contract.RenounceOwnership(&_Ownable.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Ownable *OwnableTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _Ownable.Contract.RenounceOwnership(&_Ownable.TransactOpts) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Ownable *OwnableTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _Ownable.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Ownable *OwnableSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _Ownable.Contract.TransferOwnership(&_Ownable.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Ownable *OwnableTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _Ownable.Contract.TransferOwnership(&_Ownable.TransactOpts, newOwner) +} + +// OwnableOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the Ownable contract. +type OwnableOwnershipTransferredIterator struct { + Event *OwnableOwnershipTransferred // 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 *OwnableOwnershipTransferredIterator) 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(OwnableOwnershipTransferred) + 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(OwnableOwnershipTransferred) + 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 *OwnableOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *OwnableOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// OwnableOwnershipTransferred represents a OwnershipTransferred event raised by the Ownable contract. +type OwnableOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Ownable *OwnableFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*OwnableOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _Ownable.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &OwnableOwnershipTransferredIterator{contract: _Ownable.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Ownable *OwnableFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *OwnableOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _Ownable.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + 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(OwnableOwnershipTransferred) + if err := _Ownable.contract.UnpackLog(event, "OwnershipTransferred", 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 +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Ownable *OwnableFilterer) ParseOwnershipTransferred(log types.Log) (*OwnableOwnershipTransferred, error) { + event := new(OwnableOwnershipTransferred) + if err := _Ownable.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + return event, nil +} + +// SafeDecimalMathABI is the input ABI used to generate the binding from. +const SafeDecimalMathABI = "[{\"inputs\":[],\"name\":\"PRECISE_UNIT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"UNIT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"highPrecisionDecimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"preciseUnit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"}]" + +// SafeDecimalMathFuncSigs maps the 4-byte function signature to its string representation. +var SafeDecimalMathFuncSigs = map[string]string{ + "864029e7": "PRECISE_UNIT()", + "9d8e2177": "UNIT()", + "313ce567": "decimals()", + "def4419d": "highPrecisionDecimals()", + "d5e5e6e6": "preciseUnit()", + "907af6c0": "unit()", +} + +// SafeDecimalMathBin is the compiled bytecode used for deploying new contracts. +var SafeDecimalMathBin = "0x61012e610026600b82828239805160001a60731461001957fe5b30600052607381538281f3fe730000000000000000000000000000000000000000301460806040526004361060655760003560e01c8063313ce56714606a578063864029e7146086578063907af6c014609e5780639d8e21771460a4578063d5e5e6e61460aa578063def4419d1460b0575b600080fd5b607060b6565b6040805160ff9092168252519081900360200190f35b608c60bb565b60408051918252519081900360200190f35b608c60cb565b608c60d7565b608c60e3565b607060f3565b601281565b6b033b2e3c9fd0803ce800000081565b670de0b6b3a764000090565b670de0b6b3a764000081565b6b033b2e3c9fd0803ce800000090565b601b8156fea2646970667358221220ed29d33b4623a4c9a0bce035538048d1b652e9d8d37b4073f4bf08be08af2bf564736f6c634300060c0033" + +// DeploySafeDecimalMath deploys a new Ethereum contract, binding an instance of SafeDecimalMath to it. +func DeploySafeDecimalMath(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *SafeDecimalMath, error) { + parsed, err := abi.JSON(strings.NewReader(SafeDecimalMathABI)) + if err != nil { + return common.Address{}, nil, nil, err + } + + address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(SafeDecimalMathBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &SafeDecimalMath{SafeDecimalMathCaller: SafeDecimalMathCaller{contract: contract}, SafeDecimalMathTransactor: SafeDecimalMathTransactor{contract: contract}, SafeDecimalMathFilterer: SafeDecimalMathFilterer{contract: contract}}, nil +} + +// SafeDecimalMath is an auto generated Go binding around an Ethereum contract. +type SafeDecimalMath struct { + SafeDecimalMathCaller // Read-only binding to the contract + SafeDecimalMathTransactor // Write-only binding to the contract + SafeDecimalMathFilterer // Log filterer for contract events +} + +// SafeDecimalMathCaller is an auto generated read-only Go binding around an Ethereum contract. +type SafeDecimalMathCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SafeDecimalMathTransactor is an auto generated write-only Go binding around an Ethereum contract. +type SafeDecimalMathTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SafeDecimalMathFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type SafeDecimalMathFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SafeDecimalMathSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type SafeDecimalMathSession struct { + Contract *SafeDecimalMath // 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 +} + +// SafeDecimalMathCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type SafeDecimalMathCallerSession struct { + Contract *SafeDecimalMathCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// SafeDecimalMathTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type SafeDecimalMathTransactorSession struct { + Contract *SafeDecimalMathTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// SafeDecimalMathRaw is an auto generated low-level Go binding around an Ethereum contract. +type SafeDecimalMathRaw struct { + Contract *SafeDecimalMath // Generic contract binding to access the raw methods on +} + +// SafeDecimalMathCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type SafeDecimalMathCallerRaw struct { + Contract *SafeDecimalMathCaller // Generic read-only contract binding to access the raw methods on +} + +// SafeDecimalMathTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type SafeDecimalMathTransactorRaw struct { + Contract *SafeDecimalMathTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewSafeDecimalMath creates a new instance of SafeDecimalMath, bound to a specific deployed contract. +func NewSafeDecimalMath(address common.Address, backend bind.ContractBackend) (*SafeDecimalMath, error) { + contract, err := bindSafeDecimalMath(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &SafeDecimalMath{SafeDecimalMathCaller: SafeDecimalMathCaller{contract: contract}, SafeDecimalMathTransactor: SafeDecimalMathTransactor{contract: contract}, SafeDecimalMathFilterer: SafeDecimalMathFilterer{contract: contract}}, nil +} + +// NewSafeDecimalMathCaller creates a new read-only instance of SafeDecimalMath, bound to a specific deployed contract. +func NewSafeDecimalMathCaller(address common.Address, caller bind.ContractCaller) (*SafeDecimalMathCaller, error) { + contract, err := bindSafeDecimalMath(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &SafeDecimalMathCaller{contract: contract}, nil +} + +// NewSafeDecimalMathTransactor creates a new write-only instance of SafeDecimalMath, bound to a specific deployed contract. +func NewSafeDecimalMathTransactor(address common.Address, transactor bind.ContractTransactor) (*SafeDecimalMathTransactor, error) { + contract, err := bindSafeDecimalMath(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &SafeDecimalMathTransactor{contract: contract}, nil +} + +// NewSafeDecimalMathFilterer creates a new log filterer instance of SafeDecimalMath, bound to a specific deployed contract. +func NewSafeDecimalMathFilterer(address common.Address, filterer bind.ContractFilterer) (*SafeDecimalMathFilterer, error) { + contract, err := bindSafeDecimalMath(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &SafeDecimalMathFilterer{contract: contract}, nil +} + +// bindSafeDecimalMath binds a generic wrapper to an already deployed contract. +func bindSafeDecimalMath(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(SafeDecimalMathABI)) + 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 (_SafeDecimalMath *SafeDecimalMathRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _SafeDecimalMath.Contract.SafeDecimalMathCaller.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 (_SafeDecimalMath *SafeDecimalMathRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SafeDecimalMath.Contract.SafeDecimalMathTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_SafeDecimalMath *SafeDecimalMathRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _SafeDecimalMath.Contract.SafeDecimalMathTransactor.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 (_SafeDecimalMath *SafeDecimalMathCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _SafeDecimalMath.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 (_SafeDecimalMath *SafeDecimalMathTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SafeDecimalMath.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_SafeDecimalMath *SafeDecimalMathTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _SafeDecimalMath.Contract.contract.Transact(opts, method, params...) +} + +// PRECISEUNIT is a free data retrieval call binding the contract method 0x864029e7. +// +// Solidity: function PRECISE_UNIT() view returns(uint256) +func (_SafeDecimalMath *SafeDecimalMathCaller) PRECISEUNIT(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _SafeDecimalMath.contract.Call(opts, &out, "PRECISE_UNIT") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// PRECISEUNIT is a free data retrieval call binding the contract method 0x864029e7. +// +// Solidity: function PRECISE_UNIT() view returns(uint256) +func (_SafeDecimalMath *SafeDecimalMathSession) PRECISEUNIT() (*big.Int, error) { + return _SafeDecimalMath.Contract.PRECISEUNIT(&_SafeDecimalMath.CallOpts) +} + +// PRECISEUNIT is a free data retrieval call binding the contract method 0x864029e7. +// +// Solidity: function PRECISE_UNIT() view returns(uint256) +func (_SafeDecimalMath *SafeDecimalMathCallerSession) PRECISEUNIT() (*big.Int, error) { + return _SafeDecimalMath.Contract.PRECISEUNIT(&_SafeDecimalMath.CallOpts) +} + +// UNIT is a free data retrieval call binding the contract method 0x9d8e2177. +// +// Solidity: function UNIT() view returns(uint256) +func (_SafeDecimalMath *SafeDecimalMathCaller) UNIT(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _SafeDecimalMath.contract.Call(opts, &out, "UNIT") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// UNIT is a free data retrieval call binding the contract method 0x9d8e2177. +// +// Solidity: function UNIT() view returns(uint256) +func (_SafeDecimalMath *SafeDecimalMathSession) UNIT() (*big.Int, error) { + return _SafeDecimalMath.Contract.UNIT(&_SafeDecimalMath.CallOpts) +} + +// UNIT is a free data retrieval call binding the contract method 0x9d8e2177. +// +// Solidity: function UNIT() view returns(uint256) +func (_SafeDecimalMath *SafeDecimalMathCallerSession) UNIT() (*big.Int, error) { + return _SafeDecimalMath.Contract.UNIT(&_SafeDecimalMath.CallOpts) +} + +// Decimals is a free data retrieval call binding the contract method 0x313ce567. +// +// Solidity: function decimals() view returns(uint8) +func (_SafeDecimalMath *SafeDecimalMathCaller) Decimals(opts *bind.CallOpts) (uint8, error) { + var out []interface{} + err := _SafeDecimalMath.contract.Call(opts, &out, "decimals") + + if err != nil { + return *new(uint8), err + } + + out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) + + return out0, err + +} + +// Decimals is a free data retrieval call binding the contract method 0x313ce567. +// +// Solidity: function decimals() view returns(uint8) +func (_SafeDecimalMath *SafeDecimalMathSession) Decimals() (uint8, error) { + return _SafeDecimalMath.Contract.Decimals(&_SafeDecimalMath.CallOpts) +} + +// Decimals is a free data retrieval call binding the contract method 0x313ce567. +// +// Solidity: function decimals() view returns(uint8) +func (_SafeDecimalMath *SafeDecimalMathCallerSession) Decimals() (uint8, error) { + return _SafeDecimalMath.Contract.Decimals(&_SafeDecimalMath.CallOpts) +} + +// HighPrecisionDecimals is a free data retrieval call binding the contract method 0xdef4419d. +// +// Solidity: function highPrecisionDecimals() view returns(uint8) +func (_SafeDecimalMath *SafeDecimalMathCaller) HighPrecisionDecimals(opts *bind.CallOpts) (uint8, error) { + var out []interface{} + err := _SafeDecimalMath.contract.Call(opts, &out, "highPrecisionDecimals") + + if err != nil { + return *new(uint8), err + } + + out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) + + return out0, err + +} + +// HighPrecisionDecimals is a free data retrieval call binding the contract method 0xdef4419d. +// +// Solidity: function highPrecisionDecimals() view returns(uint8) +func (_SafeDecimalMath *SafeDecimalMathSession) HighPrecisionDecimals() (uint8, error) { + return _SafeDecimalMath.Contract.HighPrecisionDecimals(&_SafeDecimalMath.CallOpts) +} + +// HighPrecisionDecimals is a free data retrieval call binding the contract method 0xdef4419d. +// +// Solidity: function highPrecisionDecimals() view returns(uint8) +func (_SafeDecimalMath *SafeDecimalMathCallerSession) HighPrecisionDecimals() (uint8, error) { + return _SafeDecimalMath.Contract.HighPrecisionDecimals(&_SafeDecimalMath.CallOpts) +} + +// PreciseUnit is a free data retrieval call binding the contract method 0xd5e5e6e6. +// +// Solidity: function preciseUnit() pure returns(uint256) +func (_SafeDecimalMath *SafeDecimalMathCaller) PreciseUnit(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _SafeDecimalMath.contract.Call(opts, &out, "preciseUnit") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// PreciseUnit is a free data retrieval call binding the contract method 0xd5e5e6e6. +// +// Solidity: function preciseUnit() pure returns(uint256) +func (_SafeDecimalMath *SafeDecimalMathSession) PreciseUnit() (*big.Int, error) { + return _SafeDecimalMath.Contract.PreciseUnit(&_SafeDecimalMath.CallOpts) +} + +// PreciseUnit is a free data retrieval call binding the contract method 0xd5e5e6e6. +// +// Solidity: function preciseUnit() pure returns(uint256) +func (_SafeDecimalMath *SafeDecimalMathCallerSession) PreciseUnit() (*big.Int, error) { + return _SafeDecimalMath.Contract.PreciseUnit(&_SafeDecimalMath.CallOpts) +} + +// Unit is a free data retrieval call binding the contract method 0x907af6c0. +// +// Solidity: function unit() pure returns(uint256) +func (_SafeDecimalMath *SafeDecimalMathCaller) Unit(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _SafeDecimalMath.contract.Call(opts, &out, "unit") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// Unit is a free data retrieval call binding the contract method 0x907af6c0. +// +// Solidity: function unit() pure returns(uint256) +func (_SafeDecimalMath *SafeDecimalMathSession) Unit() (*big.Int, error) { + return _SafeDecimalMath.Contract.Unit(&_SafeDecimalMath.CallOpts) +} + +// Unit is a free data retrieval call binding the contract method 0x907af6c0. +// +// Solidity: function unit() pure returns(uint256) +func (_SafeDecimalMath *SafeDecimalMathCallerSession) Unit() (*big.Int, error) { + return _SafeDecimalMath.Contract.Unit(&_SafeDecimalMath.CallOpts) +} + +// SafeERC20ABI is the input ABI used to generate the binding from. +const SafeERC20ABI = "[]" + +// SafeERC20Bin is the compiled bytecode used for deploying new contracts. +var SafeERC20Bin = "0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220f64a0b17ce5daff246b8c8f71eeb61da688816d17a2918b7fda6066f829fc19764736f6c634300060c0033" + +// DeploySafeERC20 deploys a new Ethereum contract, binding an instance of SafeERC20 to it. +func DeploySafeERC20(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *SafeERC20, error) { + parsed, err := abi.JSON(strings.NewReader(SafeERC20ABI)) + if err != nil { + return common.Address{}, nil, nil, err + } + + address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(SafeERC20Bin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &SafeERC20{SafeERC20Caller: SafeERC20Caller{contract: contract}, SafeERC20Transactor: SafeERC20Transactor{contract: contract}, SafeERC20Filterer: SafeERC20Filterer{contract: contract}}, nil +} + +// SafeERC20 is an auto generated Go binding around an Ethereum contract. +type SafeERC20 struct { + SafeERC20Caller // Read-only binding to the contract + SafeERC20Transactor // Write-only binding to the contract + SafeERC20Filterer // Log filterer for contract events +} + +// SafeERC20Caller is an auto generated read-only Go binding around an Ethereum contract. +type SafeERC20Caller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SafeERC20Transactor is an auto generated write-only Go binding around an Ethereum contract. +type SafeERC20Transactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SafeERC20Filterer is an auto generated log filtering Go binding around an Ethereum contract events. +type SafeERC20Filterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SafeERC20Session is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type SafeERC20Session struct { + Contract *SafeERC20 // 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 +} + +// SafeERC20CallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type SafeERC20CallerSession struct { + Contract *SafeERC20Caller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// SafeERC20TransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type SafeERC20TransactorSession struct { + Contract *SafeERC20Transactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// SafeERC20Raw is an auto generated low-level Go binding around an Ethereum contract. +type SafeERC20Raw struct { + Contract *SafeERC20 // Generic contract binding to access the raw methods on +} + +// SafeERC20CallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type SafeERC20CallerRaw struct { + Contract *SafeERC20Caller // Generic read-only contract binding to access the raw methods on +} + +// SafeERC20TransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type SafeERC20TransactorRaw struct { + Contract *SafeERC20Transactor // Generic write-only contract binding to access the raw methods on +} + +// NewSafeERC20 creates a new instance of SafeERC20, bound to a specific deployed contract. +func NewSafeERC20(address common.Address, backend bind.ContractBackend) (*SafeERC20, error) { + contract, err := bindSafeERC20(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &SafeERC20{SafeERC20Caller: SafeERC20Caller{contract: contract}, SafeERC20Transactor: SafeERC20Transactor{contract: contract}, SafeERC20Filterer: SafeERC20Filterer{contract: contract}}, nil +} + +// NewSafeERC20Caller creates a new read-only instance of SafeERC20, bound to a specific deployed contract. +func NewSafeERC20Caller(address common.Address, caller bind.ContractCaller) (*SafeERC20Caller, error) { + contract, err := bindSafeERC20(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &SafeERC20Caller{contract: contract}, nil +} + +// NewSafeERC20Transactor creates a new write-only instance of SafeERC20, bound to a specific deployed contract. +func NewSafeERC20Transactor(address common.Address, transactor bind.ContractTransactor) (*SafeERC20Transactor, error) { + contract, err := bindSafeERC20(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &SafeERC20Transactor{contract: contract}, nil +} + +// NewSafeERC20Filterer creates a new log filterer instance of SafeERC20, bound to a specific deployed contract. +func NewSafeERC20Filterer(address common.Address, filterer bind.ContractFilterer) (*SafeERC20Filterer, error) { + contract, err := bindSafeERC20(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &SafeERC20Filterer{contract: contract}, nil +} + +// bindSafeERC20 binds a generic wrapper to an already deployed contract. +func bindSafeERC20(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(SafeERC20ABI)) + 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 (_SafeERC20 *SafeERC20Raw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _SafeERC20.Contract.SafeERC20Caller.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 (_SafeERC20 *SafeERC20Raw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SafeERC20.Contract.SafeERC20Transactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_SafeERC20 *SafeERC20Raw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _SafeERC20.Contract.SafeERC20Transactor.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 (_SafeERC20 *SafeERC20CallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _SafeERC20.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 (_SafeERC20 *SafeERC20TransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SafeERC20.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_SafeERC20 *SafeERC20TransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _SafeERC20.Contract.contract.Transact(opts, method, params...) +} + +// SafeMathABI is the input ABI used to generate the binding from. +const SafeMathABI = "[]" + +// SafeMathBin is the compiled bytecode used for deploying new contracts. +var SafeMathBin = "0x60566023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212207a6457e5aef8ca5b0a41d35562a207929a5c59c0151218bc7139558a0c9030a064736f6c634300060c0033" + +// DeploySafeMath deploys a new Ethereum contract, binding an instance of SafeMath to it. +func DeploySafeMath(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *SafeMath, error) { + parsed, err := abi.JSON(strings.NewReader(SafeMathABI)) + if err != nil { + return common.Address{}, nil, nil, err + } + + address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(SafeMathBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &SafeMath{SafeMathCaller: SafeMathCaller{contract: contract}, SafeMathTransactor: SafeMathTransactor{contract: contract}, SafeMathFilterer: SafeMathFilterer{contract: contract}}, nil +} + +// SafeMath is an auto generated Go binding around an Ethereum contract. +type SafeMath struct { + SafeMathCaller // Read-only binding to the contract + SafeMathTransactor // Write-only binding to the contract + SafeMathFilterer // Log filterer for contract events +} + +// SafeMathCaller is an auto generated read-only Go binding around an Ethereum contract. +type SafeMathCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SafeMathTransactor is an auto generated write-only Go binding around an Ethereum contract. +type SafeMathTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SafeMathFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type SafeMathFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SafeMathSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type SafeMathSession struct { + Contract *SafeMath // 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 +} + +// SafeMathCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type SafeMathCallerSession struct { + Contract *SafeMathCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// SafeMathTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type SafeMathTransactorSession struct { + Contract *SafeMathTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// SafeMathRaw is an auto generated low-level Go binding around an Ethereum contract. +type SafeMathRaw struct { + Contract *SafeMath // Generic contract binding to access the raw methods on +} + +// SafeMathCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type SafeMathCallerRaw struct { + Contract *SafeMathCaller // Generic read-only contract binding to access the raw methods on +} + +// SafeMathTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type SafeMathTransactorRaw struct { + Contract *SafeMathTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewSafeMath creates a new instance of SafeMath, bound to a specific deployed contract. +func NewSafeMath(address common.Address, backend bind.ContractBackend) (*SafeMath, error) { + contract, err := bindSafeMath(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &SafeMath{SafeMathCaller: SafeMathCaller{contract: contract}, SafeMathTransactor: SafeMathTransactor{contract: contract}, SafeMathFilterer: SafeMathFilterer{contract: contract}}, nil +} + +// NewSafeMathCaller creates a new read-only instance of SafeMath, bound to a specific deployed contract. +func NewSafeMathCaller(address common.Address, caller bind.ContractCaller) (*SafeMathCaller, error) { + contract, err := bindSafeMath(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &SafeMathCaller{contract: contract}, nil +} + +// NewSafeMathTransactor creates a new write-only instance of SafeMath, bound to a specific deployed contract. +func NewSafeMathTransactor(address common.Address, transactor bind.ContractTransactor) (*SafeMathTransactor, error) { + contract, err := bindSafeMath(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &SafeMathTransactor{contract: contract}, nil +} + +// NewSafeMathFilterer creates a new log filterer instance of SafeMath, bound to a specific deployed contract. +func NewSafeMathFilterer(address common.Address, filterer bind.ContractFilterer) (*SafeMathFilterer, error) { + contract, err := bindSafeMath(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &SafeMathFilterer{contract: contract}, nil +} + +// bindSafeMath binds a generic wrapper to an already deployed contract. +func bindSafeMath(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(SafeMathABI)) + 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 (_SafeMath *SafeMathRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _SafeMath.Contract.SafeMathCaller.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 (_SafeMath *SafeMathRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SafeMath.Contract.SafeMathTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_SafeMath *SafeMathRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _SafeMath.Contract.SafeMathTransactor.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 (_SafeMath *SafeMathCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _SafeMath.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 (_SafeMath *SafeMathTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SafeMath.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_SafeMath *SafeMathTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _SafeMath.Contract.contract.Transact(opts, method, params...) +} diff --git a/internal/executor/oracle/appchain/eth.go b/internal/executor/oracle/appchain/eth.go new file mode 100644 index 0000000..ab209c7 --- /dev/null +++ b/internal/executor/oracle/appchain/eth.go @@ -0,0 +1,147 @@ +package appchain + +import ( + "bytes" + "fmt" + "path/filepath" + "sort" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/consensus/clique" + "github.com/ethereum/go-ethereum/consensus/ethash" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethdb/leveldb" + "github.com/ethereum/go-ethereum/les" + "github.com/ethereum/go-ethereum/light" + "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/trie" + "github.com/sirupsen/logrus" +) + +type EthLightChainOracle struct { + lc *light.LightChain + logger logrus.FieldLogger +} + +const ( + MinConfirmNum = 15 + // block 10105112 + RopstenHeader = "{\"parentHash\":\"0x4672d904ca88bdb365f83bc6050344fdcb672ce8e639e727f8c69247634e73f0\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"miner\":\"0x1cdb00d07b721b98da52532db9a7d82d2a4bf2e0\",\"stateRoot\":\"0x823fbc8d2cf2d9c32832c6c1bd451ea84acdd79e39e88a7061215746a0794f40\",\"transactionsRoot\":\"0x65abe72faaaa113cf0a9374cefde93bc64cd264e2931ba95ee27c8d62499e63d\",\"receiptsRoot\":\"0xfac424a8e1a45789a5456fe1bc58228d93c28871df42dd789434e4de65f7e2e9\",\"logsBloom\":\"0x00200000000000000000000080000000000000000000000080010000000000000000000000000000020000000000000000000000000000000000000000200000000000000008000000000008000000200000000800000000000000020002000000000000080000000000000000000000000000000000000000000010000000000800000000000000014000000000000000000000000000080000004000000000020000000000000140000000000000000000001000000000001000000000000000000002000000200004000000002200000000000000003000000000020020000010000000000000000000000201000000000080000000000000000400000000\",\"difficulty\":\"0x729df1d\",\"number\":\"0x9a3118\",\"gasLimit\":\"0x98f36f\",\"gasUsed\":\"0x2fd96\",\"timestamp\":\"0x608506bf\",\"extraData\":\"0xd683010a01846765746886676f312e3136856c696e7578\",\"mixHash\":\"0x62c65e608f10001004171345c230a231afed11dad637b93545f600b71adb0f5d\",\"nonce\":\"0x7ea6f1aedb5ea8c1\",\"hash\":\"0x0d37ff8f4a8f1adcfd16add9cf8726e17a8097baa9a50d3b5fd51849476f7ec3\"}\n" +) + +// TODO: need to start with special header height +func NewRinkebyOracle(storagePath string, logger logrus.FieldLogger) (*EthLightChainOracle, error) { + appchainBlockHeaderPath := filepath.Join(storagePath, "eth_rinkeby") + db, err := leveldb.New(appchainBlockHeaderPath, 256, 0, "", false) + if err != nil { + return nil, err + } + database := rawdb.NewDatabase(db) + core.DefaultRinkebyGenesisBlock().MustCommit(database) + lc, err := light.NewLightChain(les.NewLesOdr(database, light.DefaultServerIndexerConfig, nil, nil), + core.DefaultRinkebyGenesisBlock().Config, clique.New(params.RinkebyChainConfig.Clique, database), params.RinkebyTrustedCheckpoint) + if err != nil { + return nil, err + } + return &EthLightChainOracle{lc: lc, logger: logger}, nil +} + +// NewRopstenOracle inits with ropsten block 10105112, receives above the 10105112 headers +func NewRopstenOracle(storagePath string, logger logrus.FieldLogger) (*EthLightChainOracle, error) { + appchainBlockHeaderPath := filepath.Join(storagePath, "eth_ropsten") + db, err := leveldb.New(appchainBlockHeaderPath, 256, 0, "", false) + if err != nil { + return nil, err + } + database := rawdb.NewDatabase(db) + + // block 10105112 + header := types.Header{} + err = header.UnmarshalJSON([]byte(RopstenHeader)) + + if head := rawdb.ReadHeadHeaderHash(database); head == (common.Hash{}) { + core.DefaultRopstenGenesisBlock().MustCommit(database) + rawdb.WriteHeader(database, &header) + rawdb.WriteTd(database, header.Hash(), header.Number.Uint64(), header.Difficulty) + rawdb.WriteCanonicalHash(database, header.Hash(), header.Number.Uint64()) + rawdb.WriteHeadBlockHash(database, header.Hash()) + rawdb.WriteHeadFastBlockHash(database, header.Hash()) + rawdb.WriteHeadHeaderHash(database, header.Hash()) + } + + lc, err := light.NewLightChain(les.NewLesOdr(database, light.DefaultServerIndexerConfig, nil, nil), + core.DefaultRopstenGenesisBlock().Config, ethash.New(ethash.Config{}, nil, false), params.RopstenTrustedCheckpoint) + if err != nil { + return nil, err + } + + return &EthLightChainOracle{lc: lc, logger: logger}, nil +} + +// InsertBlockHeaders attempts to insert the given header chain in to the local +// chain, possibly creating a reorg. If an error is returned, it will return the +// index number of the failing header as well an error describing what went wrong. +// Ropsten receives the block header after the height of 10105112 +func (oracle *EthLightChainOracle) InsertBlockHeaders(headers []*types.Header) (int, error) { + if len(headers) == 0 { + return 0, fmt.Errorf("insert empty headers") + } + sort.Slice(headers, func(i, j int) bool { + return headers[i].Number.Cmp(headers[j].Number) < 0 + }) + + oracle.logger.WithFields(logrus.Fields{ + "start": headers[0].Number.Uint64(), + "end": headers[len(headers)-1].Number.Uint64(), + }).Debugf("insert ethereum block headers") + return oracle.lc.InsertHeaderChain(headers, 0) +} + +// CurrentHeader retrieves the current head header of the canonical chain. +func (oracle *EthLightChainOracle) CurrentHeader() *types.Header { + return oracle.lc.CurrentHeader() +} + +// GetHeader retrieves a block header by hash +func (oracle *EthLightChainOracle) GetHeader(hash common.Hash) *types.Header { + return oracle.lc.GetHeaderByHash(hash) +} + +func (oracle *EthLightChainOracle) VerifyProof(receipt *types.Receipt, proof []byte) error { + if receipt.Status == 0 { + return fmt.Errorf("receipt status is fail, hash is:%v", receipt.TxHash.String()) + } + header := oracle.GetHeader(receipt.BlockHash) + if header == nil { + return fmt.Errorf("not found header:%v", receipt.BlockHash.String()) + } + currentHeader := oracle.CurrentHeader() + if currentHeader.Number.Uint64()-header.Number.Uint64() < MinConfirmNum { + return fmt.Errorf("not enough confirmed") + } + + keyBuf := bytes.Buffer{} + keyBuf.Reset() + if err := rlp.Encode(&keyBuf, receipt.TransactionIndex); err != nil { + return err + } + nodeList := &light.NodeList{} + if err := rlp.DecodeBytes(proof, nodeList); err != nil { + return err + } + value, err := trie.VerifyProof(header.ReceiptHash, keyBuf.Bytes(), nodeList.NodeSet()) + if err != nil { + return err + } + receiptData, err := rlp.EncodeToBytes(receipt) + if err != nil { + return err + } + if !bytes.Equal(receiptData, value) { + return fmt.Errorf("invaild receipt:%v", receipt.TxHash.String()) + } + return nil +} diff --git a/internal/executor/oracle/appchain/eth_test.go b/internal/executor/oracle/appchain/eth_test.go new file mode 100644 index 0000000..232ddc6 --- /dev/null +++ b/internal/executor/oracle/appchain/eth_test.go @@ -0,0 +1,124 @@ +package appchain + +import ( + "bytes" + "io/ioutil" + "os" + "testing" + + "github.com/meshplus/bitxhub-kit/log" + + "github.com/ethereum/go-ethereum/light" + + "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/trie" + + "github.com/ethereum/go-ethereum/core/types" + "github.com/stretchr/testify/require" +) + +// block headers from infura api server +const ( + RinkebyHeader1 = "{\"parentHash\":\"0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"miner\":\"0x0000000000000000000000000000000000000000\",\"stateRoot\":\"0x53580584816f617295ea26c0e17641e0120cab2f0a8ffb53a866fd53aa8e8c2d\",\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"difficulty\":\"0x2\",\"number\":\"0x1\",\"gasLimit\":\"0x47c94c\",\"gasUsed\":\"0x0\",\"timestamp\":\"0x58ee45da\",\"extraData\":\"0xd783010600846765746887676f312e372e33856c696e757800000000000000009f1efa1efa72af138c915966c639544a0255e6288e188c22ce9168c10dbe46da3d88b4aa065930119fb886210bf01a084fde5d3bc48d8aa38bca92e4fcc5215100\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"hash\":\"0xa7684ac44d48494670b2e0d9085b7750e7341620f0a271db146ed5e70c1db854\"}\n" + RinkebyHeader2 = "{\"parentHash\":\"0xa7684ac44d48494670b2e0d9085b7750e7341620f0a271db146ed5e70c1db854\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"miner\":\"0x0000000000000000000000000000000000000000\",\"stateRoot\":\"0x53580584816f617295ea26c0e17641e0120cab2f0a8ffb53a866fd53aa8e8c2d\",\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"difficulty\":\"0x2\",\"number\":\"0x2\",\"gasLimit\":\"0x47db3d\",\"gasUsed\":\"0x0\",\"timestamp\":\"0x58ee45ea\",\"extraData\":\"0xd783010600846765746887676f312e372e33856c696e75780000000000000000b5a4a624d2e19fdab62ff7f4d2f2b80dfab4c518761beb56c2319c4224dd156f698bb1a2750c7edf12d61c4022079622062039637f40fb817e2cce0f0a4dae9c01\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"hash\":\"0x9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9\"}\n" + RinkebyHeader3 = "{\"parentHash\":\"0x9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"miner\":\"0x0000000000000000000000000000000000000000\",\"stateRoot\":\"0x53580584816f617295ea26c0e17641e0120cab2f0a8ffb53a866fd53aa8e8c2d\",\"transactionsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"receiptsRoot\":\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"difficulty\":\"0x2\",\"number\":\"0x3\",\"gasLimit\":\"0x47e7c4\",\"gasUsed\":\"0x0\",\"timestamp\":\"0x58ee45f9\",\"extraData\":\"0xd783010600846765746887676f312e372e33856c696e757800000000000000004e10f96536e45ceca7e34cc1bdda71db3f3bb029eb69afd28b57eb0202c0ec0859d383a99f63503c4df9ab6c1dc63bf6b9db77be952f47d86d2d7b208e77397301\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"nonce\":\"0x0000000000000000\",\"hash\":\"0x9eb9db9c3ec72918c7db73ae44e520139e95319c421ed6f9fc11fa8dd0cddc56\"}\n" + + RopstenHeader1 = "{\"parentHash\":\"0x0d37ff8f4a8f1adcfd16add9cf8726e17a8097baa9a50d3b5fd51849476f7ec3\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"miner\":\"0x033ef6db9fbd0ee60e2931906b987fe0280471a0\",\"stateRoot\":\"0xfc22ae06eb79345da19322573c740ccaf4e224e32c916226c0adf7223c881bc5\",\"transactionsRoot\":\"0x792fa9b9b95e586cd5757922f5f06adff5333bd5fb77059d95debcde4a4d5e0d\",\"receiptsRoot\":\"0x23f3951c0cede08fa61c20c77f36c8d7853d0f205f5053ee9a39f4cf68833546\",\"logsBloom\":\"0x00004000000000200000400000008000000010000000020000000000001004000000001000010000000000000000001040100000001000000010091010200000000000000000000000000008000004000000000000108400000100040000000000100000020000080000000020001880000200800000002000000010000018000000000240000000000000008000000000000020000000102020000000800000420004000000000000000000000020000000000000000014000200200000000000000102000000040000080000100000000060000000008000000200000020000010000000000000000000040000080004000000000000000000000000000000\",\"difficulty\":\"0x72ac658\",\"number\":\"0x9a3119\",\"gasLimit\":\"0x98cd34\",\"gasUsed\":\"0x1d58f8\",\"timestamp\":\"0x608506c2\",\"extraData\":\"0xd683010a01846765746886676f312e3136856c696e7578\",\"mixHash\":\"0xdbca2ed1c216550ef4d7f63d1c223da0530fc196f14960e70ac8f384cd0f8d63\",\"nonce\":\"0x2293d516a92c2912\",\"hash\":\"0x6a04391a825d6a5a7a247c6e5134f020abec8f8073b1eb1fc778bd9e1502b852\"}\n" + RopstenHeader2 = "{\"parentHash\":\"0x6a04391a825d6a5a7a247c6e5134f020abec8f8073b1eb1fc778bd9e1502b852\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"miner\":\"0x773b556e7f3222f3b93d6519484cef0c443b9d7e\",\"stateRoot\":\"0xc45bd719ef83edd7f6afbaa7afb43a3422ef9ca0faf6853565dbd04671a0736f\",\"transactionsRoot\":\"0xf2a97635c98b8c96c6977e5e16418f9b480c0bd6f4922d15a34dffac2a2b23de\",\"receiptsRoot\":\"0x400c370ac70c3031022c8fd923fbff191f5dcfa6b4454e90ef8c5de8d9475af3\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000020000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000\",\"difficulty\":\"0x72ac858\",\"number\":\"0x9a311a\",\"gasLimit\":\"0x98a702\",\"gasUsed\":\"0xd09e6\",\"timestamp\":\"0x608506cb\",\"extraData\":\"0xd683010a01846765746886676f312e3136856c696e7578\",\"mixHash\":\"0xc7d603705499308d968e7e4687325bc227fbe104d62f0bd53eeff154e2749223\",\"nonce\":\"0x3733ef9174a63f69\",\"hash\":\"0x91c4c53daae0fc7fec3310c2c60597349f84183322b1bdaec9faf9a602627151\"}\n" +) + +func TestRinkebyLightClient(t *testing.T) { + repoRoot, err := ioutil.TempDir("", "TestRinkebyLightClient") + require.Nil(t, err) + defer os.RemoveAll(repoRoot) + + oracle, err := NewRinkebyOracle(repoRoot, log.NewWithModule("test")) + require.Nil(t, err) + + header1 := types.Header{} + err = header1.UnmarshalJSON([]byte(RinkebyHeader1)) + require.Nil(t, err) + + header2 := types.Header{} + err = header2.UnmarshalJSON([]byte(RinkebyHeader2)) + require.Nil(t, err) + + header3 := types.Header{} + err = header3.UnmarshalJSON([]byte(RinkebyHeader3)) + require.Nil(t, err) + + num, err := oracle.InsertBlockHeaders([]*types.Header{&header1, &header2}) + require.Nil(t, err) + require.Equal(t, num, 0) + +} + +func TestRopstenLightClient(t *testing.T) { + repoRoot, err := ioutil.TempDir("", "TestRopstenLightClient") + require.Nil(t, err) + defer os.RemoveAll(repoRoot) + + oracle, err := NewRopstenOracle(repoRoot, log.NewWithModule("test")) + require.Nil(t, err) + + currentHeader := oracle.CurrentHeader() + + header1 := &types.Header{} + err = header1.UnmarshalJSON([]byte(RopstenHeader1)) + require.Nil(t, err) + require.Equal(t, currentHeader.Number.Uint64(), header1.Number.Uint64()-1) + + header2 := &types.Header{} + err = header2.UnmarshalJSON([]byte(RopstenHeader2)) + require.Nil(t, err) + require.Equal(t, currentHeader.Number.Uint64(), header2.Number.Uint64()-2) + + num, err := oracle.InsertBlockHeaders([]*types.Header{header1, header2}) + require.Nil(t, err) + require.Equal(t, 0, num) + +} + +func TestVerifyProof(t *testing.T) { + repoRoot, err := ioutil.TempDir("", "TestRopstenLightClient") + require.Nil(t, err) + defer os.RemoveAll(repoRoot) + + var ( + receipt0 = "{\"root\":\"0x\",\"status\":\"0x1\",\"cumulativeGasUsed\":\"0x11336\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000008000000000008000000000000000000000000000000020002000000000000000000000000000000000000000000000000000000000010000000000800000000000000010000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000002000000000004000000000200000000000000002000000000000000000010000000000000000000000001000000000000000000000000000000000000\",\"logs\":[{\"address\":\"0x7a9a60a43edd1d885f9e672dd498c829b101dd07\",\"topics\":[\"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef\",\"0x0000000000000000000000002266463a8b23ddfc606670a06b0ce2e66011f1bf\",\"0x0000000000000000000000000de52d48482bf7f8a4c94bfdbdedd2319e99e92f\"],\"data\":\"0x00000000000000000000000000000000000000000000043c33c1937564800000\",\"blockNumber\":\"0x9a3118\",\"transactionHash\":\"0xba4d94730e0e76992538f19597cc41669d154c103b2ad77fb53ce18c4c0fc3cd\",\"transactionIndex\":\"0x0\",\"blockHash\":\"0x0d37ff8f4a8f1adcfd16add9cf8726e17a8097baa9a50d3b5fd51849476f7ec3\",\"logIndex\":\"0x0\",\"removed\":false},{\"address\":\"0x7a9a60a43edd1d885f9e672dd498c829b101dd07\",\"topics\":[\"0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925\",\"0x0000000000000000000000002266463a8b23ddfc606670a06b0ce2e66011f1bf\",\"0x0000000000000000000000000de52d48482bf7f8a4c94bfdbdedd2319e99e92f\"],\"data\":\"0xfffffffffffffffffffffffffffffffffffffffffffffbc3cc3e6c8a9b7fffff\",\"blockNumber\":\"0x9a3118\",\"transactionHash\":\"0xba4d94730e0e76992538f19597cc41669d154c103b2ad77fb53ce18c4c0fc3cd\",\"transactionIndex\":\"0x0\",\"blockHash\":\"0x0d37ff8f4a8f1adcfd16add9cf8726e17a8097baa9a50d3b5fd51849476f7ec3\",\"logIndex\":\"0x1\",\"removed\":false}],\"transactionHash\":\"0xba4d94730e0e76992538f19597cc41669d154c103b2ad77fb53ce18c4c0fc3cd\",\"contractAddress\":\"0x0000000000000000000000000000000000000000\",\"gasUsed\":\"0x11336\",\"blockHash\":\"0x0d37ff8f4a8f1adcfd16add9cf8726e17a8097baa9a50d3b5fd51849476f7ec3\",\"blockNumber\":\"0x9a3118\",\"transactionIndex\":\"0x0\"}\n" + receipt1 = "{\"root\":\"0x\",\"status\":\"0x1\",\"cumulativeGasUsed\":\"0x1653e\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"logs\":[],\"transactionHash\":\"0xcb158ce1be4b6648dcdc69dedbe7ddda8e3aa284db7dacdb5b22401e9a454845\",\"contractAddress\":\"0x0000000000000000000000000000000000000000\",\"gasUsed\":\"0x5208\",\"blockHash\":\"0x0d37ff8f4a8f1adcfd16add9cf8726e17a8097baa9a50d3b5fd51849476f7ec3\",\"blockNumber\":\"0x9a3118\",\"transactionIndex\":\"0x1\"}\n" + receipt2 = "{\"root\":\"0x\",\"status\":\"0x1\",\"cumulativeGasUsed\":\"0x2fd96\",\"logsBloom\":\"0x00200000000000000000000080000000000000000000000080010000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000008000000200000000800000000000000000000000000000000080000000000000000000000000000000000000000000010000000000000000000000000004000000000000000000000000000080000004000000000000000000000000140000000000000000000001000000000001000000000000000000002000000200000000000002000000000000000001000000000020020000000000000000000000000000200000000000080000000000000000400000000\",\"logs\":[{\"address\":\"0x2d80502854fc7304c3e3457084de549f5016b73f\",\"topics\":[\"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef\",\"0x0000000000000000000000004183d62963434056e75e9854bc4ba92aa43a2d08\",\"0x000000000000000000000000dc914190feeb16d6f7c5d9a22826d515be5c5857\"],\"data\":\"0x00000000000000000000000000000000000000000000000000000000000b4cc6\",\"blockNumber\":\"0x9a3118\",\"transactionHash\":\"0x37fc9bf0e945443c862efe5405d9a179dced048c3baed58751f00d84ba64701c\",\"transactionIndex\":\"0x2\",\"blockHash\":\"0x0d37ff8f4a8f1adcfd16add9cf8726e17a8097baa9a50d3b5fd51849476f7ec3\",\"logIndex\":\"0x2\",\"removed\":false},{\"address\":\"0x0d9c8723b343a8368bebe0b5e89273ff8d712e3c\",\"topics\":[\"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef\",\"0x000000000000000000000000dc914190feeb16d6f7c5d9a22826d515be5c5857\",\"0x0000000000000000000000004183d62963434056e75e9854bc4ba92aa43a2d08\"],\"data\":\"0x0000000000000000000000000000000000000000000000000000000015ee0375\",\"blockNumber\":\"0x9a3118\",\"transactionHash\":\"0x37fc9bf0e945443c862efe5405d9a179dced048c3baed58751f00d84ba64701c\",\"transactionIndex\":\"0x2\",\"blockHash\":\"0x0d37ff8f4a8f1adcfd16add9cf8726e17a8097baa9a50d3b5fd51849476f7ec3\",\"logIndex\":\"0x3\",\"removed\":false},{\"address\":\"0xdc914190feeb16d6f7c5d9a22826d515be5c5857\",\"topics\":[\"0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1\"],\"data\":\"0x00000000000000000000000000000000000000000000000000001a4f9e78bc5e0000000000000000000000000000000000000000000000000000000d8457df78\",\"blockNumber\":\"0x9a3118\",\"transactionHash\":\"0x37fc9bf0e945443c862efe5405d9a179dced048c3baed58751f00d84ba64701c\",\"transactionIndex\":\"0x2\",\"blockHash\":\"0x0d37ff8f4a8f1adcfd16add9cf8726e17a8097baa9a50d3b5fd51849476f7ec3\",\"logIndex\":\"0x4\",\"removed\":false},{\"address\":\"0xdc914190feeb16d6f7c5d9a22826d515be5c5857\",\"topics\":[\"0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822\",\"0x0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d\",\"0x0000000000000000000000004183d62963434056e75e9854bc4ba92aa43a2d08\"],\"data\":\"0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b4cc60000000000000000000000000000000000000000000000000000000015ee03750000000000000000000000000000000000000000000000000000000000000000\",\"blockNumber\":\"0x9a3118\",\"transactionHash\":\"0x37fc9bf0e945443c862efe5405d9a179dced048c3baed58751f00d84ba64701c\",\"transactionIndex\":\"0x2\",\"blockHash\":\"0x0d37ff8f4a8f1adcfd16add9cf8726e17a8097baa9a50d3b5fd51849476f7ec3\",\"logIndex\":\"0x5\",\"removed\":false}],\"transactionHash\":\"0x37fc9bf0e945443c862efe5405d9a179dced048c3baed58751f00d84ba64701c\",\"contractAddress\":\"0x0000000000000000000000000000000000000000\",\"gasUsed\":\"0x19858\",\"blockHash\":\"0x0d37ff8f4a8f1adcfd16add9cf8726e17a8097baa9a50d3b5fd51849476f7ec3\",\"blockNumber\":\"0x9a3118\",\"transactionIndex\":\"0x2\"}\n" + ) + receiptList := []string{receipt0, receipt1, receipt2} + oracle, err := NewRopstenOracle(repoRoot, log.NewWithModule("test")) + require.Nil(t, err) + + receipts := make([]*types.Receipt, 0, len(receiptList)) + for _, r := range receiptList { + var receipt types.Receipt + err := receipt.UnmarshalJSON([]byte(r)) + require.Nil(t, err) + receipts = append(receipts, &receipt) + } + tReceipts := types.Receipts(receipts) + + keybuf := new(bytes.Buffer) + receiptsTrie := new(trie.Trie) + index := uint64(2) + header := oracle.lc.GetHeaderByHash(receipts[index].BlockHash) + + deriveSha := types.DeriveSha(tReceipts, receiptsTrie) + require.Equal(t, header.ReceiptHash, deriveSha) + + err = rlp.Encode(keybuf, index) + require.Nil(t, err) + nodeSet := light.NewNodeSet() + err = receiptsTrie.Prove(keybuf.Bytes(), 0, nodeSet) + require.Nil(t, err) + + proof, err := rlp.EncodeToBytes(nodeSet.NodeList()) + require.Nil(t, err) + + err = VerifyProof(receipts[index], header, proof) + require.Nil(t, err) +} diff --git a/pkg/peermgr/handle.go b/pkg/peermgr/handle.go index 49b3a8c..c16d9cf 100644 --- a/pkg/peermgr/handle.go +++ b/pkg/peermgr/handle.go @@ -40,6 +40,8 @@ func (swarm *Swarm) handleMessage(s network.Stream, data []byte) { swarm.handleFetchAssetExchangeSignMessage(s, m.Data) case pb.Message_FETCH_IBTP_SIGN: swarm.handleFetchIBTPSignMessage(s, m.Data) + case pb.Message_FETCH_MINT_SIGN: + swarm.handleFetchMinterSignMessage(s, m.Data) case pb.Message_CHECK_MASTER_PIER: swarm.handleAskPierMaster(s, m.Data) case pb.Message_CHECK_MASTER_PIER_ACK: @@ -278,6 +280,52 @@ func (swarm *Swarm) handleFetchIBTPSignMessage(s network.Stream, data []byte) { } } +func (swarm *Swarm) handleFetchMinterSignMessage(s network.Stream, data []byte) { + handle := func(id string) (string, []byte, error) { + swarm.logger.WithField("mint id", id).Debug("Handle fetching minter sign message") + + ok, _ := swarm.ledger.GetState(constant.EthHeaderMgrContractAddr.Address(), []byte(contracts.MintKey(id))) + if !ok { + return "", nil, fmt.Errorf("cannot find minter record with id %s", id) + } + + hash := sha256.Sum256([]byte(fmt.Sprintf("%s", id))) + key := swarm.repo.Key + sign, err := key.PrivKey.Sign(hash[:]) + if err != nil { + return "", nil, fmt.Errorf("fetch minter sign: %w", err) + } + + return key.Address, sign, nil + } + + address, signed, err := handle(string(data)) + if err != nil { + swarm.logger.Errorf("handle fetch-minter-sign: %s", err) + return + } + + m := model.MerkleWrapperSign{ + Address: address, + Signature: signed, + } + + body, err := m.Marshal() + if err != nil { + swarm.logger.Errorf("marshal merkle wrapper sign: %s", err) + return + } + + msg := &pb.Message{ + Type: pb.Message_FETCH_MINT_SIGN_ACK, + Data: body, + } + + if err := swarm.SendWithStream(s, msg); err != nil { + swarm.logger.Errorf("send minter sign back: %s", err) + } +} + func (swarm *Swarm) handleGetBlocksPack(s network.Stream, msg *pb.Message) error { req := &pb.GetBlocksRequest{} if err := req.Unmarshal(msg.Data); err != nil { diff --git a/pkg/peermgr/mock_peermgr/mock_peermgr.go b/pkg/peermgr/mock_peermgr/mock_peermgr.go index c157f37..c08f90b 100644 --- a/pkg/peermgr/mock_peermgr/mock_peermgr.go +++ b/pkg/peermgr/mock_peermgr/mock_peermgr.go @@ -5,8 +5,6 @@ package mock_peermgr import ( - reflect "reflect" - event "github.com/ethereum/go-ethereum/event" gomock "github.com/golang/mock/gomock" peer "github.com/libp2p/go-libp2p-core/peer" @@ -14,44 +12,61 @@ import ( events "github.com/meshplus/bitxhub/internal/model/events" peermgr "github.com/meshplus/bitxhub/pkg/peermgr" network "github.com/meshplus/go-lightp2p" + reflect "reflect" ) -// MockPeerManager is a mock of PeerManager interface. +// MockPeerManager is a mock of PeerManager interface type MockPeerManager struct { ctrl *gomock.Controller recorder *MockPeerManagerMockRecorder } -// MockPeerManagerMockRecorder is the mock recorder for MockPeerManager. +// MockPeerManagerMockRecorder is the mock recorder for MockPeerManager type MockPeerManagerMockRecorder struct { mock *MockPeerManager } -// NewMockPeerManager creates a new mock instance. +// NewMockPeerManager creates a new mock instance func NewMockPeerManager(ctrl *gomock.Controller) *MockPeerManager { mock := &MockPeerManager{ctrl: ctrl} mock.recorder = &MockPeerManagerMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use. +// EXPECT returns an object that allows the caller to indicate expected use func (m *MockPeerManager) EXPECT() *MockPeerManagerMockRecorder { return m.recorder } -// AddNode mocks base method. -func (m *MockPeerManager) AddNode(newNodeID uint64, vpInfo *pb.VpInfo) { +// Start mocks base method +func (m *MockPeerManager) Start() error { m.ctrl.T.Helper() - m.ctrl.Call(m, "AddNode", newNodeID, vpInfo) + ret := m.ctrl.Call(m, "Start") + ret0, _ := ret[0].(error) + return ret0 } -// AddNode indicates an expected call of AddNode. -func (mr *MockPeerManagerMockRecorder) AddNode(newNodeID, vpInfo interface{}) *gomock.Call { +// Start indicates an expected call of Start +func (mr *MockPeerManagerMockRecorder) Start() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddNode", reflect.TypeOf((*MockPeerManager)(nil).AddNode), newNodeID, vpInfo) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockPeerManager)(nil).Start)) } -// AsyncSend mocks base method. +// Stop mocks base method +func (m *MockPeerManager) Stop() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Stop") + ret0, _ := ret[0].(error) + return ret0 +} + +// Stop indicates an expected call of Stop +func (mr *MockPeerManagerMockRecorder) Stop() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stop", reflect.TypeOf((*MockPeerManager)(nil).Stop)) +} + +// AsyncSend mocks base method func (m *MockPeerManager) AsyncSend(arg0 uint64, arg1 *pb.Message) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "AsyncSend", arg0, arg1) @@ -59,107 +74,27 @@ func (m *MockPeerManager) AsyncSend(arg0 uint64, arg1 *pb.Message) error { return ret0 } -// AsyncSend indicates an expected call of AsyncSend. +// AsyncSend indicates an expected call of AsyncSend func (mr *MockPeerManagerMockRecorder) AsyncSend(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AsyncSend", reflect.TypeOf((*MockPeerManager)(nil).AsyncSend), arg0, arg1) } -// Broadcast mocks base method. -func (m *MockPeerManager) Broadcast(arg0 *pb.Message) error { +// SendWithStream mocks base method +func (m *MockPeerManager) SendWithStream(arg0 network.Stream, arg1 *pb.Message) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Broadcast", arg0) + ret := m.ctrl.Call(m, "SendWithStream", arg0, arg1) ret0, _ := ret[0].(error) return ret0 } -// Broadcast indicates an expected call of Broadcast. -func (mr *MockPeerManagerMockRecorder) Broadcast(arg0 interface{}) *gomock.Call { +// SendWithStream indicates an expected call of SendWithStream +func (mr *MockPeerManagerMockRecorder) SendWithStream(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Broadcast", reflect.TypeOf((*MockPeerManager)(nil).Broadcast), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendWithStream", reflect.TypeOf((*MockPeerManager)(nil).SendWithStream), arg0, arg1) } -// CountConnectedPeers mocks base method. -func (m *MockPeerManager) CountConnectedPeers() uint64 { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CountConnectedPeers") - ret0, _ := ret[0].(uint64) - return ret0 -} - -// CountConnectedPeers indicates an expected call of CountConnectedPeers. -func (mr *MockPeerManagerMockRecorder) CountConnectedPeers() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountConnectedPeers", reflect.TypeOf((*MockPeerManager)(nil).CountConnectedPeers)) -} - -// DelNode mocks base method. -func (m *MockPeerManager) DelNode(delID uint64) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "DelNode", delID) -} - -// DelNode indicates an expected call of DelNode. -func (mr *MockPeerManagerMockRecorder) DelNode(delID interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DelNode", reflect.TypeOf((*MockPeerManager)(nil).DelNode), delID) -} - -// Disconnect mocks base method. -func (m *MockPeerManager) Disconnect(vpInfos map[uint64]*pb.VpInfo) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "Disconnect", vpInfos) -} - -// Disconnect indicates an expected call of Disconnect. -func (mr *MockPeerManagerMockRecorder) Disconnect(vpInfos interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Disconnect", reflect.TypeOf((*MockPeerManager)(nil).Disconnect), vpInfos) -} - -// OtherPeers mocks base method. -func (m *MockPeerManager) OtherPeers() map[uint64]*peer.AddrInfo { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OtherPeers") - ret0, _ := ret[0].(map[uint64]*peer.AddrInfo) - return ret0 -} - -// OtherPeers indicates an expected call of OtherPeers. -func (mr *MockPeerManagerMockRecorder) OtherPeers() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OtherPeers", reflect.TypeOf((*MockPeerManager)(nil).OtherPeers)) -} - -// Peers mocks base method. -func (m *MockPeerManager) Peers() map[uint64]*pb.VpInfo { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Peers") - ret0, _ := ret[0].(map[uint64]*pb.VpInfo) - return ret0 -} - -// Peers indicates an expected call of Peers. -func (mr *MockPeerManagerMockRecorder) Peers() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Peers", reflect.TypeOf((*MockPeerManager)(nil).Peers)) -} - -// PierManager mocks base method. -func (m *MockPeerManager) PierManager() peermgr.PierManager { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "PierManager") - ret0, _ := ret[0].(peermgr.PierManager) - return ret0 -} - -// PierManager indicates an expected call of PierManager. -func (mr *MockPeerManagerMockRecorder) PierManager() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PierManager", reflect.TypeOf((*MockPeerManager)(nil).PierManager)) -} - -// Send mocks base method. +// Send mocks base method func (m *MockPeerManager) Send(arg0 uint64, arg1 *pb.Message) (*pb.Message, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Send", arg0, arg1) @@ -168,55 +103,69 @@ func (m *MockPeerManager) Send(arg0 uint64, arg1 *pb.Message) (*pb.Message, erro return ret0, ret1 } -// Send indicates an expected call of Send. +// Send indicates an expected call of Send func (mr *MockPeerManagerMockRecorder) Send(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockPeerManager)(nil).Send), arg0, arg1) } -// SendWithStream mocks base method. -func (m *MockPeerManager) SendWithStream(arg0 network.Stream, arg1 *pb.Message) error { +// Broadcast mocks base method +func (m *MockPeerManager) Broadcast(arg0 *pb.Message) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SendWithStream", arg0, arg1) + ret := m.ctrl.Call(m, "Broadcast", arg0) ret0, _ := ret[0].(error) return ret0 } -// SendWithStream indicates an expected call of SendWithStream. -func (mr *MockPeerManagerMockRecorder) SendWithStream(arg0, arg1 interface{}) *gomock.Call { +// Broadcast indicates an expected call of Broadcast +func (mr *MockPeerManagerMockRecorder) Broadcast(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendWithStream", reflect.TypeOf((*MockPeerManager)(nil).SendWithStream), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Broadcast", reflect.TypeOf((*MockPeerManager)(nil).Broadcast), arg0) } -// Start mocks base method. -func (m *MockPeerManager) Start() error { +// CountConnectedPeers mocks base method +func (m *MockPeerManager) CountConnectedPeers() uint64 { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Start") - ret0, _ := ret[0].(error) + ret := m.ctrl.Call(m, "CountConnectedPeers") + ret0, _ := ret[0].(uint64) return ret0 } -// Start indicates an expected call of Start. -func (mr *MockPeerManagerMockRecorder) Start() *gomock.Call { +// CountConnectedPeers indicates an expected call of CountConnectedPeers +func (mr *MockPeerManagerMockRecorder) CountConnectedPeers() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockPeerManager)(nil).Start)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountConnectedPeers", reflect.TypeOf((*MockPeerManager)(nil).CountConnectedPeers)) } -// Stop mocks base method. -func (m *MockPeerManager) Stop() error { +// Peers mocks base method +func (m *MockPeerManager) Peers() map[uint64]*pb.VpInfo { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Stop") - ret0, _ := ret[0].(error) + ret := m.ctrl.Call(m, "Peers") + ret0, _ := ret[0].(map[uint64]*pb.VpInfo) return ret0 } -// Stop indicates an expected call of Stop. -func (mr *MockPeerManagerMockRecorder) Stop() *gomock.Call { +// Peers indicates an expected call of Peers +func (mr *MockPeerManagerMockRecorder) Peers() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stop", reflect.TypeOf((*MockPeerManager)(nil).Stop)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Peers", reflect.TypeOf((*MockPeerManager)(nil).Peers)) } -// SubscribeOrderMessage mocks base method. +// OtherPeers mocks base method +func (m *MockPeerManager) OtherPeers() map[uint64]*peer.AddrInfo { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "OtherPeers") + ret0, _ := ret[0].(map[uint64]*peer.AddrInfo) + return ret0 +} + +// OtherPeers indicates an expected call of OtherPeers +func (mr *MockPeerManagerMockRecorder) OtherPeers() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OtherPeers", reflect.TypeOf((*MockPeerManager)(nil).OtherPeers)) +} + +// SubscribeOrderMessage mocks base method func (m *MockPeerManager) SubscribeOrderMessage(ch chan<- events.OrderMessageEvent) event.Subscription { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SubscribeOrderMessage", ch) @@ -224,13 +173,37 @@ func (m *MockPeerManager) SubscribeOrderMessage(ch chan<- events.OrderMessageEve return ret0 } -// SubscribeOrderMessage indicates an expected call of SubscribeOrderMessage. +// SubscribeOrderMessage indicates an expected call of SubscribeOrderMessage func (mr *MockPeerManagerMockRecorder) SubscribeOrderMessage(ch interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubscribeOrderMessage", reflect.TypeOf((*MockPeerManager)(nil).SubscribeOrderMessage), ch) } -// UpdateRouter mocks base method. +// AddNode mocks base method +func (m *MockPeerManager) AddNode(newNodeID uint64, vpInfo *pb.VpInfo) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "AddNode", newNodeID, vpInfo) +} + +// AddNode indicates an expected call of AddNode +func (mr *MockPeerManagerMockRecorder) AddNode(newNodeID, vpInfo interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddNode", reflect.TypeOf((*MockPeerManager)(nil).AddNode), newNodeID, vpInfo) +} + +// DelNode mocks base method +func (m *MockPeerManager) DelNode(delID uint64) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "DelNode", delID) +} + +// DelNode indicates an expected call of DelNode +func (mr *MockPeerManagerMockRecorder) DelNode(delID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DelNode", reflect.TypeOf((*MockPeerManager)(nil).DelNode), delID) +} + +// UpdateRouter mocks base method func (m *MockPeerManager) UpdateRouter(vpInfos map[uint64]*pb.VpInfo, isNew bool) bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateRouter", vpInfos, isNew) @@ -238,36 +211,76 @@ func (m *MockPeerManager) UpdateRouter(vpInfos map[uint64]*pb.VpInfo, isNew bool return ret0 } -// UpdateRouter indicates an expected call of UpdateRouter. +// UpdateRouter indicates an expected call of UpdateRouter func (mr *MockPeerManagerMockRecorder) UpdateRouter(vpInfos, isNew interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateRouter", reflect.TypeOf((*MockPeerManager)(nil).UpdateRouter), vpInfos, isNew) } -// MockPierManager is a mock of PierManager interface. +// Disconnect mocks base method +func (m *MockPeerManager) Disconnect(vpInfos map[uint64]*pb.VpInfo) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Disconnect", vpInfos) +} + +// Disconnect indicates an expected call of Disconnect +func (mr *MockPeerManagerMockRecorder) Disconnect(vpInfos interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Disconnect", reflect.TypeOf((*MockPeerManager)(nil).Disconnect), vpInfos) +} + +// PierManager mocks base method +func (m *MockPeerManager) PierManager() peermgr.PierManager { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PierManager") + ret0, _ := ret[0].(peermgr.PierManager) + return ret0 +} + +// PierManager indicates an expected call of PierManager +func (mr *MockPeerManagerMockRecorder) PierManager() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PierManager", reflect.TypeOf((*MockPeerManager)(nil).PierManager)) +} + +// MockPierManager is a mock of PierManager interface type MockPierManager struct { ctrl *gomock.Controller recorder *MockPierManagerMockRecorder } -// MockPierManagerMockRecorder is the mock recorder for MockPierManager. +// MockPierManagerMockRecorder is the mock recorder for MockPierManager type MockPierManagerMockRecorder struct { mock *MockPierManager } -// NewMockPierManager creates a new mock instance. +// NewMockPierManager creates a new mock instance func NewMockPierManager(ctrl *gomock.Controller) *MockPierManager { mock := &MockPierManager{ctrl: ctrl} mock.recorder = &MockPierManagerMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use. +// EXPECT returns an object that allows the caller to indicate expected use func (m *MockPierManager) EXPECT() *MockPierManagerMockRecorder { return m.recorder } -// AskPierMaster mocks base method. +// Piers mocks base method +func (m *MockPierManager) Piers() *peermgr.Piers { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Piers") + ret0, _ := ret[0].(*peermgr.Piers) + return ret0 +} + +// Piers indicates an expected call of Piers +func (mr *MockPierManagerMockRecorder) Piers() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Piers", reflect.TypeOf((*MockPierManager)(nil).Piers)) +} + +// AskPierMaster mocks base method func (m *MockPierManager) AskPierMaster(arg0 string) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "AskPierMaster", arg0) @@ -276,22 +289,8 @@ func (m *MockPierManager) AskPierMaster(arg0 string) (bool, error) { return ret0, ret1 } -// AskPierMaster indicates an expected call of AskPierMaster. +// AskPierMaster indicates an expected call of AskPierMaster func (mr *MockPierManagerMockRecorder) AskPierMaster(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AskPierMaster", reflect.TypeOf((*MockPierManager)(nil).AskPierMaster), arg0) } - -// Piers mocks base method. -func (m *MockPierManager) Piers() *peermgr.Piers { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Piers") - ret0, _ := ret[0].(*peermgr.Piers) - return ret0 -} - -// Piers indicates an expected call of Piers. -func (mr *MockPierManagerMockRecorder) Piers() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Piers", reflect.TypeOf((*MockPierManager)(nil).Piers)) -} diff --git a/pkg/vm/boltvm/bolt_stub.go b/pkg/vm/boltvm/bolt_stub.go index cae8ef6..632f6e3 100755 --- a/pkg/vm/boltvm/bolt_stub.go +++ b/pkg/vm/boltvm/bolt_stub.go @@ -5,6 +5,7 @@ import ( "github.com/meshplus/bitxhub-core/boltvm" "github.com/meshplus/bitxhub-core/validator" + evm "github.com/meshplus/bitxhub-kit/evm" "github.com/meshplus/bitxhub-kit/types" "github.com/meshplus/bitxhub-model/pb" "github.com/meshplus/bitxhub/pkg/vm" @@ -15,6 +16,7 @@ var _ boltvm.Stub = (*BoltStubImpl)(nil) type BoltStubImpl struct { bvm *BoltVM + evm *evm.EVM ctx *vm.Context ve validator.Engine }