From fd9ae8ed4d3847b4d2b84e1401f98266f5dbdf6b Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Thu, 16 Jul 2020 15:26:00 -0700 Subject: [PATCH] Use go-bindata to embed schema from text file --- Makefile | 24 +++- go.mod | 5 +- go.sum | 35 +++++ graphql/data/bindata.go | 247 ++++++++++++++++++++++++++++++++++ graphql/schema.go | 166 +---------------------- graphql/schema/schema.graphql | 243 +++++++++++++++++++++++++++++++++ 6 files changed, 552 insertions(+), 168 deletions(-) create mode 100644 graphql/data/bindata.go create mode 100644 graphql/schema/schema.graphql diff --git a/Makefile b/Makefile index 0b192a114..1f885e883 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ .PHONY: deps -deps: deps-ts wasmbrowsertest +deps: deps-ts wasmbrowsertest go-bindata .PHONY: deps-ts @@ -13,6 +13,13 @@ gobin: GO111MODULE=off go get -u github.com/myitcv/gobin +# go-bindata is a tool for embedding files so that they are included in binaries. +# This installs the CLI for go-bindata. +.PHONY: go-bindata +go-bindata: gobin + gobin github.com/go-bindata/go-bindata/v3/go-bindata@v3.1.3 + + # wasmbrowsertest is required for running WebAssembly tests in the browser. .PHONY: wasmbrowsertest wasmbrowsertest: gobin @@ -34,7 +41,7 @@ test-all: test-go test-wasm-browser test-ts test-browser-conversion test-browser .PHONY: test-go -test-go: test-go-parallel test-go-serial +test-go: generate test-go-parallel test-go-serial .PHONY: test-go-parallel @@ -84,8 +91,13 @@ lint-ts: lint-prettier: yarn prettier:ci + +.PHONY: generate +generate: + go generate ./... + .PHONY: mesh -mesh: +mesh: generate go install ./cmd/mesh @@ -105,7 +117,7 @@ db-integrity-check: .PHONY: cut-release -cut-release: +cut-release: generate go run ./cmd/cut-release/main.go @@ -117,7 +129,7 @@ all: mesh mesh-keygen mesh-bootstrap db-integrity-check .PHONY: docker-mesh -docker-mesh: +docker-mesh: generate docker build . -t 0xorg/mesh -f ./dockerfiles/mesh/Dockerfile @@ -132,5 +144,5 @@ docker-mesh-fluent-bit: .PHONY: docker-mesh-bridge -docker-mesh-bridge: +docker-mesh-bridge: generate docker build . -t 0xorg/mesh-bridge -f ./dockerfiles/mesh-bridge/Dockerfile diff --git a/go.mod b/go.mod index 1401873c0..130fbd6cd 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,6 @@ replace ( ) require ( - github.com/0xProject/go-ethereum v1.8.7 github.com/0xProject/sql-datastore v0.0.0-20200129193319-32397013f115 github.com/albrow/stringset v2.1.0+incompatible github.com/aristanetworks/goarista v0.0.0-20190712234253-ed1100a1c015 // indirect @@ -75,8 +74,8 @@ require ( github.com/xeipuuv/gojsonpointer v0.0.0-20190809123943-df4f5c81cb3b // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.1.0 - golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4 - golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 + golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 + golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 golang.org/x/time v0.0.0-20191024005414-555d28b269f0 gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0 // indirect gopkg.in/karlseguin/expect.v1 v1.0.1 // indirect diff --git a/go.sum b/go.sum index 7cbe11b2c..8c7b49557 100644 --- a/go.sum +++ b/go.sum @@ -129,6 +129,10 @@ github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqG github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/gibson042/canonicaljson-go v1.0.3 h1:EAyF8L74AWabkyUmrvEFHEt/AGFQeD6RfwbAuf0j1bI= github.com/gibson042/canonicaljson-go v1.0.3/go.mod h1:DsLpJTThXyGNO+KZlI85C1/KDcImpP67k/RKVjcaEqo= +github.com/go-bindata/go-bindata v1.0.0 h1:DZ34txDXWn1DyWa+vQf7V9ANc2ILTtrEjtlsdJRF26M= +github.com/go-bindata/go-bindata v3.1.2+incompatible h1:5vjJMVhowQdPzjE1LdxyFF7YFTXg5IgGVW4gBr5IbvE= +github.com/go-bindata/go-bindata/v3 v3.1.3 h1:F0nVttLC3ws0ojc7p60veTurcOm//D4QBODNM7EGrCI= +github.com/go-bindata/go-bindata/v3 v3.1.3/go.mod h1:1/zrpXsLD8YDIbhZRqXzm1Ghc7NhEvIN9+Z6R5/xH4I= github.com/go-check/check v0.0.0-20180628173108-788fd7840127 h1:0gkP6mzaMqkmpcJYCFOLkIBwI7xFExG03bbkOkCvUPI= github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= github.com/go-kit/kit v0.8.0 h1:Wz+5lgoB0kkuqLEc6NVmwRknTKP6dTGbSqvhZtBI/j0= @@ -267,7 +271,10 @@ github.com/karlseguin/ccache v2.0.3+incompatible/go.mod h1:CM9tNPzT6EdRh14+jiW8m github.com/karlseguin/expect v1.0.1 h1:z4wy4npwwHSWKjGWH85WNJO42VQhovxTCZDSzhjo8hY= github.com/karlseguin/expect v1.0.1/go.mod h1:zNBxMY8P21owkeogJELCLeHIt+voOSduHYTFUbwRAV8= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/errcheck v1.2.0 h1:reN85Pxc5larApoH1keMBiu2GWtPqXQ1nc9gx+jOU+E= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/errcheck v1.4.0 h1:ueN6QYA+c7eDQo7ebpNdYR8mUJZThiGz9PEoJEMGPzA= +github.com/kisielk/errcheck v1.4.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/knq/sysutil v0.0.0-20181215143952-f05b59f0f307 h1:vl4eIlySbjertFaNwiMjXsGrFVK25aOWLq7n+3gh2ls= @@ -622,6 +629,8 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1: github.com/xeipuuv/gojsonschema v1.1.0 h1:ngVtJC9TY/lg0AA/1k48FYhBrhRoFlEmWzsehpNAaZg= github.com/xeipuuv/gojsonschema v1.1.0/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.1 h1:8dP3SGL7MPB94crU3bEPplMPe83FI4EouesJUeFHv50= go.opencensus.io v0.22.1/go.mod h1:Ap50jQcDJrx6rB6VgeeFPtuPIf3wMRvRfrfYDO6+BmA= @@ -641,10 +650,20 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4 h1:QmwruyY+bKbDDL0BaglrbZABEali68eoMFhTZpCjYVA= golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f h1:J5lckAjkw6qYlOZNj90mLYNTEKDvWeuc1yieZ8qUzUE= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -655,14 +674,21 @@ golang.org/x/net v0.0.0-20190227160552-c95aed5357e7/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0 h1:Jcxah/M+oLZ/R4/z5RzfPzGbPXnVDPkEDtf2JnuxN+U= golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344 h1:vGXIOMxbNfDTk/aXCmfdLgkrSV+Z2tcbze+pEc3v5W4= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -697,9 +723,18 @@ golang.org/x/tools v0.0.0-20181130052023-1c3d964395ce/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f h1:kDxGY2VmgABOe55qheT/TFqUMtcTHnomIPS1iv3G4Ms= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200716193322-f2c07d7d8ec1 h1:+L0anz7VPZcdhiFmfOYsyvU4q2cvemMri/ayLxr/5JE= +golang.org/x/tools v0.0.0-20200716193322-f2c07d7d8ec1/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= diff --git a/graphql/data/bindata.go b/graphql/data/bindata.go new file mode 100644 index 000000000..b7864c602 --- /dev/null +++ b/graphql/data/bindata.go @@ -0,0 +1,247 @@ +// Code generated by go-bindata. (@generated) DO NOT EDIT. + + //Package data generated by go-bindata.// sources: +// schema/schema.graphql +package data + +import ( + "bytes" + "compress/gzip" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + "strings" + "time" +) + +func bindataRead(data []byte, name string) ([]byte, error) { + gz, err := gzip.NewReader(bytes.NewBuffer(data)) + if err != nil { + return nil, fmt.Errorf("read %q: %v", name, err) + } + + var buf bytes.Buffer + _, err = io.Copy(&buf, gz) + clErr := gz.Close() + + if err != nil { + return nil, fmt.Errorf("read %q: %v", name, err) + } + if clErr != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +type asset struct { + bytes []byte + info os.FileInfo +} + +type bindataFileInfo struct { + name string + size int64 + mode os.FileMode + modTime time.Time +} + +// Name return file name +func (fi bindataFileInfo) Name() string { + return fi.name +} + +// Size return file size +func (fi bindataFileInfo) Size() int64 { + return fi.size +} + +// Mode return file mode +func (fi bindataFileInfo) Mode() os.FileMode { + return fi.mode +} + +// ModTime return file modify time +func (fi bindataFileInfo) ModTime() time.Time { + return fi.modTime +} + +// IsDir return file whether a directory +func (fi bindataFileInfo) IsDir() bool { + return fi.mode&os.ModeDir != 0 +} + +// Sys return file is sys mode +func (fi bindataFileInfo) Sys() interface{} { + return nil +} + +var _schemaSchemaGraphql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x58\x49\x6f\xdb\xc8\x12\xbe\xfb\x57\x94\x33\x97\x04\xb0\x25\x63\xe6\x26\x20\x07\x45\x56\xde\x18\xe3\x25\x91\x94\x99\x83\x11\x18\x2d\x76\x51\xec\x67\xb2\x9b\xe9\x45\x32\x27\x98\xff\xfe\x50\xbd\x48\x24\x45\xe9\x61\x4e\x96\x7b\xab\xfd\xab\xaf\xf8\xee\xdd\xbb\x8b\x29\x18\xb1\x91\xc8\xe1\xe6\x0d\x94\xe6\xa8\x81\x95\x4a\x6e\x60\x27\x6c\x01\x46\x55\x08\x8c\x73\x61\x85\x92\xac\x84\x0a\x2d\xe3\xcc\x32\x60\x6b\xe5\x2c\xd8\x02\xe3\x9d\x5d\x21\xb2\x02\x84\x01\xa9\x2c\xd4\x4c\x5b\x50\xb9\xdf\xbe\x79\x83\x5a\x2b\xab\x32\x55\x82\xa9\x31\x13\xb9\xc8\x18\xbd\x36\xba\x20\xe9\xb6\xa9\x11\x9e\xe8\x89\xbf\x84\x2d\x1e\xd2\xf3\x3f\x2f\x00\x00\xb2\x82\x09\x79\xc7\x27\xb0\xb4\x5a\xc8\xcd\xa5\x5f\xc4\xb7\xac\x60\x72\x83\x53\xce\x35\x1a\xd3\xdd\xac\xd8\x2b\xea\x33\x3b\xc6\xa0\xbd\x65\x96\x9d\xda\x9b\x56\xca\x49\x3b\xb0\xfb\x19\xf1\xdc\xe5\xcf\x88\xdd\x55\x7b\x52\x11\x7b\x46\x11\x7b\x56\x11\x7b\x5e\x11\x3b\xa8\x88\x41\xc9\x4f\x68\x92\x23\x2e\x30\x13\xb5\x40\x69\x07\x0f\xe0\x5b\x2d\xb4\x0f\xd6\x4a\x54\xb8\xc4\x4c\x49\xde\x3b\x62\x58\xd9\xd3\x92\xb2\x89\x59\xa7\x7b\x7a\x50\xb0\xe9\xef\xaa\x40\x28\x98\x29\xae\x62\xca\x64\x4c\xc2\x1a\xc1\x19\xe4\x60\x15\x38\x29\x7e\x38\x2c\x1b\x10\x1c\xa5\x15\x79\x03\x4c\x86\x14\x1b\x75\x9e\xa1\x27\x4e\x0b\xd0\x58\x31\x21\x85\xdc\x00\xf3\x7e\x4c\xc9\xe8\x63\x05\x8c\xfc\x17\xc5\x17\x2c\xa4\x6c\x83\x16\xd6\x88\x12\x72\x51\x96\xc8\xbb\xc2\x68\x8d\xad\x4b\x5c\x9d\x0c\xcf\x3f\x17\x3e\x9b\xa7\x12\x50\xba\x0a\x32\x25\x6d\x52\xa0\x2c\x5b\x65\x92\x0b\x2c\xb9\x81\x5c\xa5\x8a\xc9\x45\x69\x51\x1b\x60\x92\x8f\x95\x06\xa3\xb4\xa5\x5b\xc2\x80\x71\x75\xad\xb4\x25\x5d\xe8\x69\xff\xae\x2f\x94\xcf\xf4\x46\xac\x10\x72\x43\xbb\x54\x86\x2a\xe4\xa8\x30\x06\xea\x61\xb0\x0c\x86\xb3\xbf\xb3\x7a\x94\xeb\x03\x29\x3e\x98\xd9\xc3\x09\xdd\x59\x3d\x4e\xdf\x53\x59\x7b\x3a\x59\xf7\x39\x7a\x36\x8e\x29\x7c\x94\x3a\xaf\x42\x72\x4a\x97\x4c\x55\x35\xd3\xc2\x28\x49\x69\x99\x32\x54\x48\x60\x31\x66\xad\xb0\x7c\xf6\x0b\x7f\xd0\xcd\x10\x96\xf9\xd7\x6f\xd3\x7b\xff\xeb\xf1\x69\xf5\x72\xf8\xef\x3f\x8b\xf9\x74\x35\x5f\xb4\x7f\xbf\x3c\x2d\x5a\x07\xee\xe7\xcb\xe5\xfe\xc7\x61\xab\xa5\x1f\x17\x1a\x33\xb2\x92\xd4\xa2\x74\x01\x21\x47\x30\x35\x19\x4a\x4e\x99\x53\x21\x93\x06\x4a\xb5\x43\x63\xe9\x48\x21\x36\x05\x1a\x3b\x82\x5b\xec\x9d\x89\x3b\x74\x28\x1c\x6f\x59\xb4\x54\xda\xde\xee\x25\x05\xa3\xa6\xcb\x99\xff\x7b\x3b\x5f\xce\xda\x1a\x6d\x59\xe9\x90\x5e\x09\x7e\xf1\x8d\x63\x04\x0f\xce\x50\x45\xf9\xdc\x37\xac\x42\xf0\x48\xcf\x8c\x5f\xf0\x65\x00\x8d\x72\xc0\x34\xc6\x7b\xa4\xd8\xba\x09\x3a\x98\x8c\x95\x4c\x47\xbf\xfe\x49\xef\xc7\xfa\x4a\x32\x54\x04\x05\x33\x82\x59\x0b\x40\x84\x84\x1f\x0e\xb5\x40\x43\xfa\x28\x59\x36\xa0\xd1\x3a\x9d\x4e\x83\x2d\x98\x85\x0a\xd1\x42\x86\x9a\x4a\x14\x32\x2d\x48\x38\x0b\x82\x85\xac\x9d\x4d\x65\xe6\x25\xfd\x8c\x99\x83\x25\x9f\xb4\xea\x2f\x60\x0e\x25\xcb\xa4\x15\xfe\xb0\xea\x1d\x32\x69\x6b\x7f\x00\x88\x10\x32\xaf\x0d\x19\x4c\x40\xf0\xff\x0d\x21\x38\xd1\xaa\x8d\x23\x42\x46\xfc\xd0\x68\x5c\x69\x8d\xf7\x63\x30\x35\x01\x46\xcb\x14\x8a\xe6\x79\x43\xf6\x59\x35\xe9\x86\xfe\xb2\x1d\xe8\x75\xa9\xb2\x57\x90\xae\x5a\x13\x88\x4a\x1e\x17\x08\x83\xbc\x21\xa4\x5e\xc9\x2c\xe5\x54\xd8\xf1\xde\x26\x84\xf5\xc8\x5a\x6b\x95\xa1\x21\xeb\xd6\x0d\x3c\xa0\x29\x5a\x0c\xe0\xde\x5f\xfb\xe4\x6f\x05\x45\x83\x98\x2e\xc4\x77\x41\x3f\x6a\x36\x0b\x58\x6b\xc8\x4b\xb9\xd8\xb8\x80\x01\xa0\x6a\xfa\xe3\x81\x15\xb6\x4c\x0b\xe5\x0c\x18\xcb\x6c\x00\xdf\x9e\xf8\xa5\xdf\x08\x82\xb7\xa8\x4d\x70\x44\x4b\x72\xed\xd6\x4b\xb7\x5e\xa9\x5a\x64\xdd\x0d\x4d\xf8\xf4\xf7\x56\xb9\x5e\x5f\xac\x11\xf5\xdd\x6d\xaf\x9d\xda\x02\x35\xba\x6a\xe6\xb1\xfa\x76\x02\x77\xd2\x86\x9d\xf2\x60\xfe\xa4\xed\x8b\xcb\xe4\x8a\x2f\x88\xda\xb4\x2e\x48\x57\xf9\x10\x0e\xae\xdd\xc9\xac\x74\x54\xe8\x0b\xac\xd4\x16\x79\xeb\x8c\xb1\x4c\xdb\xa7\x7c\xe6\xb4\x46\x69\xbf\xad\x66\xb7\xac\x39\x52\x72\xf1\x65\xb6\xc0\x1f\x0e\x8d\x35\x4b\x94\xf6\x4e\xf6\x8e\xef\x5f\x8b\x67\x99\xc5\x7b\x51\x09\x3b\x27\x04\x46\x9e\xee\xb6\x0e\x56\xec\x6d\xde\x81\xe7\x4e\x14\x7d\x08\xbe\x3a\xd4\x4d\x0c\x41\xea\xbb\x0b\x9f\xd0\xa6\x4d\x33\x89\x94\x7a\x48\x09\x54\x12\x79\x24\x13\x4a\x83\x74\x65\x09\x22\x07\xa9\x52\x91\x50\xac\x9d\xe4\xe9\x56\x48\xc6\xa2\xdb\xdb\xfd\xd1\xf7\x9d\xcc\xfa\x30\x39\x66\xa4\x83\x7a\x31\x09\x4c\x6b\xd6\x50\xbf\x68\x03\x8c\x61\x56\x98\xbc\x19\xc0\x98\x23\xc9\xe6\xbd\xff\xdd\x5e\xf7\x18\x8b\x16\x75\x25\x24\xb6\x8d\x8f\x24\x26\x96\xfc\x08\xee\x72\xa8\x94\x26\x88\x25\x8e\x24\x31\x62\x8b\x4f\x7c\x32\xbe\xd6\x6a\x2b\x38\xf2\xab\x3d\x4a\xec\x90\x10\xc6\x78\x5a\x41\x55\x68\x0b\xdc\x8b\xcc\x85\x36\xfb\xdb\xfe\x9f\x2b\xda\x97\x74\x8e\xc9\x06\x8c\x5b\x1b\x8a\xac\x4c\x87\xcc\x08\x3e\x35\xc0\x31\x67\xae\xb4\x57\xc9\x01\x04\x44\x07\x01\x1e\x1b\xa8\x69\xee\x7b\x4f\x8b\xcb\xf5\x8d\xa6\x6b\x13\x78\xde\x43\xd6\xe5\x77\xf8\x08\xcf\x3f\x13\x66\x85\x40\xb7\x90\x6a\xba\x9c\xc1\x3f\xdf\x07\x9f\x9a\x02\x51\x3c\x95\x27\x7e\x35\x82\x27\x6a\x06\x7b\x5f\xa6\x4e\xc0\x6c\x56\x78\x8a\x96\x78\xd8\x4e\x94\x25\xf9\x48\xf8\x1a\x0a\x48\xdc\x71\xfa\xc1\x64\x90\xaa\xe5\xbc\x48\xe3\x74\x00\xf0\x61\x03\xe3\xa9\x64\x63\x68\x10\xc1\xca\x61\x33\x56\x9e\xb3\xbe\x89\xca\x55\x09\x77\x5b\xa9\xa6\xce\x2a\x7a\x1b\xb4\xf4\xe7\x7e\xbd\x19\x56\xa8\xa4\xb2\xf5\x75\x0a\x1f\xe1\xd7\x1b\xbf\xfe\x21\xa9\xd7\x4e\xff\xcb\xef\x97\x27\x2b\x33\x0b\xe8\x10\xd0\xb5\x9b\xe2\x7e\x69\x12\xe0\xb5\xd5\x02\xfb\xf3\x66\x96\x29\xed\x93\xc3\x2a\xff\xe2\xf3\xf0\xc4\xf8\xfd\x7d\x61\x6d\x6d\x26\xe3\xf1\x46\xd8\xc2\xad\x47\x99\xaa\xc6\x37\x6f\x5f\xb4\xfa\x2f\x66\x76\x7c\xf3\x76\x9d\xee\x5d\x77\xee\x8d\xd7\xa5\x5a\x8f\x2b\x66\x2c\xea\xf1\xf6\xb7\xf1\xf6\xb7\xee\xfe\xa8\xe2\xbf\x78\x4d\xae\x2b\x34\x86\x6d\xf0\x3a\x57\xba\x62\xf6\x43\xbb\x91\x3e\xe2\xce\x7b\xa5\x3f\x9a\x1e\xc0\xb0\x3f\x97\xc6\x1f\x43\x83\xe9\xc0\xd6\x61\xa6\xfb\xd4\x58\x3c\xda\x4a\x03\xc7\x27\xb1\x79\xf4\x89\x70\x72\x36\xed\x5f\xf7\x13\x61\xef\x9a\x3d\xad\x4d\x7f\x3c\x6d\x3d\x77\x3c\x9d\x0e\x3d\x7b\x52\x1b\x7b\x4a\x9b\xde\x88\xda\x51\x67\x70\x46\xed\x9c\x38\x31\xa4\xf6\x65\xf8\x39\xb5\xbf\x78\x18\x55\xa3\x9e\x2d\xb6\x93\x30\x33\xa2\x2e\xe3\x3c\x74\x57\xa8\x9c\x0d\x69\x03\xa1\xd1\xa2\x89\x5c\x2c\xd6\xe5\x0e\x35\x52\x4e\x63\x4d\x20\x48\xfc\xa3\xbb\x4d\x24\x00\x34\x52\xce\x26\xae\xe6\x3b\xe0\x34\x49\x58\x44\xc9\x3f\x8f\xe6\xda\x08\x6a\x6d\x08\xeb\x48\x1b\xc1\x34\xc9\x4d\xd2\x22\x9e\xed\x08\xe9\xa2\x3a\xa1\xea\x70\x8b\xd2\x1e\x0e\x60\x25\x2c\xdd\x13\x79\x08\x56\x81\x42\xfb\xfa\x75\x06\x42\x62\xf7\x6a\x3b\xc9\x9c\xc0\x73\x12\xea\xd5\x0f\xda\xf7\x01\xe3\x9c\xf6\xc9\x17\x57\x11\xcc\x3c\x12\xf8\x08\x30\x3f\x7e\x15\xd8\x74\x0f\x8e\x60\x11\x7f\x75\xcc\xa4\x39\x7e\x1d\x1a\x5a\x34\xb7\xab\x71\xba\x3e\x81\xe7\x74\xbf\xa7\x71\x22\x23\x03\x06\x0d\x44\x23\xf8\x31\xd8\xc1\xcc\xde\x21\x6d\x33\xd2\xf7\xb2\x81\xce\x3f\x40\x32\xba\x2e\xfb\xab\xf0\x84\xd1\x53\x1b\xd5\xfe\xd6\x26\x0c\x48\xdc\x8d\x60\x89\x7e\x78\xb3\xda\x21\xf1\x1e\x5b\x08\x43\x7b\x61\xc0\xa2\x66\x6e\x05\xcd\x5d\xb4\x4c\x7c\x17\xa4\xe2\xfe\xdb\xcb\x21\x39\xf7\x6f\x86\x88\x4a\x0e\x39\x2b\x0d\x82\x22\xc1\x3b\x61\xb0\xab\xb7\x30\x8f\xb8\x9b\xc0\x27\xa5\x4a\x64\xf2\xe0\xae\x01\x6f\x0e\xb8\xcb\x73\x81\x58\x4d\x81\x05\xc0\x03\x6b\x28\xf7\x12\x73\xb3\xe9\x54\xa6\x5c\xc9\x63\x3c\xfd\x24\xee\x6c\x3f\x98\x81\xb1\xfd\x9e\xbe\x7f\x9c\x89\xcb\xa1\xd4\x4e\xc5\xa0\xeb\xf7\x29\x54\x2c\x2b\x84\xc4\x6b\x8d\x8c\xb3\x75\x49\x2a\x70\xea\xb4\xdc\x37\x0c\xb9\x81\x5d\xd1\xb4\x49\x69\x5b\x08\xac\xc8\xdf\xe1\x82\x01\x8e\xb1\xd9\xd9\xc0\x15\xd2\x7c\xb7\x6e\x88\x9d\x6d\x34\xab\xc2\x84\xc2\xea\xba\x8c\xdd\x28\x2c\x84\x84\xc6\x2d\xea\x58\x7d\x9e\xc4\x2a\x67\x61\xad\x91\xbd\xfa\x61\x99\x65\xaf\x3b\xa6\xb9\xb9\xf6\xdf\x2a\xac\x58\x8b\x52\xd8\xa6\x6b\x26\x29\x32\xe9\x06\x68\xa6\x38\xf6\x2d\x2e\x5c\xc5\xe4\xc1\xde\xd8\x07\xff\x95\xc9\xe9\x4e\xc5\x9a\xa8\x72\xc8\x19\x09\xb9\x23\x8c\x05\x8d\x25\x32\x83\xc1\xbe\xf8\xa5\x38\x53\x5b\xd4\xc1\x1f\x27\xcc\x81\x8d\x63\x9a\x49\x8b\x7d\xfc\x89\xf2\x8e\xbf\xc1\x25\x9c\x21\x5a\x57\x2b\x63\x44\x8a\xa0\xe9\x90\xa5\x81\xa4\x1d\xc1\xa3\xb2\x18\xa9\x21\x31\xeb\x70\x2b\x41\x24\xe3\x1c\xf9\x45\xe4\x28\xb9\x90\x2c\xf0\x13\x2a\xc4\xf0\x9d\xe3\x39\x51\x21\x5f\x6e\x5c\x65\xa6\x45\x59\x14\x57\xd9\x48\xe9\xcd\x49\xf2\x52\xa1\x29\xc6\x7f\xa3\x56\xf8\x36\xf6\x5e\xde\xb2\x52\x70\x66\x95\xfe\xa5\x7e\xdd\x5c\xd3\x10\x4b\xc1\x31\x1f\x2e\x68\x82\x65\x50\x0a\xb3\xb7\x33\x28\x1a\xc5\x97\x0d\xd9\xe7\xa8\x7a\xf7\x1f\x74\x8e\x32\x20\x7d\xa9\x5a\xfd\xfe\xb2\xf8\x32\x7b\x59\xcc\xbf\x7e\x9b\x2f\x57\x2f\x9f\xa7\x77\xf7\xf3\x5b\xbf\x75\xf7\xf8\xe7\xf4\xfe\xee\xf6\xe5\x61\xfa\xc7\x7c\xf1\x32\x5d\x2e\xe7\xab\x97\xe9\xc3\xd3\xb7\xc7\x55\x67\x7b\x75\xbc\x9d\x70\xe1\x21\x76\xca\x1e\x18\x4c\x39\x37\x7e\x5e\x51\x3a\xb8\xf9\x40\x68\xc3\x5c\xde\x69\x33\xa9\x2b\xbe\x57\x71\xe0\x7d\x4e\x54\xec\xf2\xfb\xe5\x15\xd4\x42\x4a\x82\xf4\x08\x4a\xf0\xd1\xe3\xe1\x87\xc9\x51\x3b\xa5\x04\xf9\x5f\x00\x00\x00\xff\xff\xb8\xab\x81\xf0\xf0\x18\x00\x00") + +func schemaSchemaGraphqlBytes() ([]byte, error) { + return bindataRead( + _schemaSchemaGraphql, + "schema/schema.graphql", + ) +} + +func schemaSchemaGraphql() (*asset, error) { + bytes, err := schemaSchemaGraphqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "schema/schema.graphql", size: 6384, mode: os.FileMode(420), modTime: time.Unix(1594938402, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + +// Asset loads and returns the asset for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func Asset(name string) ([]byte, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err) + } + return a.bytes, nil + } + return nil, fmt.Errorf("Asset %s not found", name) +} + +// MustAsset is like Asset but panics when Asset would return an error. +// It simplifies safe initialization of global variables. +func MustAsset(name string) []byte { + a, err := Asset(name) + if err != nil { + panic("asset: Asset(" + name + "): " + err.Error()) + } + + return a +} + +// AssetInfo loads and returns the asset info for the given name. +// It returns an error if the asset could not be found or +// could not be loaded. +func AssetInfo(name string) (os.FileInfo, error) { + cannonicalName := strings.Replace(name, "\\", "/", -1) + if f, ok := _bindata[cannonicalName]; ok { + a, err := f() + if err != nil { + return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err) + } + return a.info, nil + } + return nil, fmt.Errorf("AssetInfo %s not found", name) +} + +// AssetNames returns the names of the assets. +func AssetNames() []string { + names := make([]string, 0, len(_bindata)) + for name := range _bindata { + names = append(names, name) + } + return names +} + +// _bindata is a table, holding each asset generator, mapped to its name. +var _bindata = map[string]func() (*asset, error){ + "schema/schema.graphql": schemaSchemaGraphql, +} + +// AssetDir returns the file names below a certain +// directory embedded in the file by go-bindata. +// For example if you run go-bindata on data/... and data contains the +// following hierarchy: +// data/ +// foo.txt +// img/ +// a.png +// b.png +// then AssetDir("data") would return []string{"foo.txt", "img"} +// AssetDir("data/img") would return []string{"a.png", "b.png"} +// AssetDir("foo.txt") and AssetDir("notexist") would return an error +// AssetDir("") will return []string{"data"}. +func AssetDir(name string) ([]string, error) { + node := _bintree + if len(name) != 0 { + cannonicalName := strings.Replace(name, "\\", "/", -1) + pathList := strings.Split(cannonicalName, "/") + for _, p := range pathList { + node = node.Children[p] + if node == nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + } + } + if node.Func != nil { + return nil, fmt.Errorf("Asset %s not found", name) + } + rv := make([]string, 0, len(node.Children)) + for childName := range node.Children { + rv = append(rv, childName) + } + return rv, nil +} + +type bintree struct { + Func func() (*asset, error) + Children map[string]*bintree +} + +var _bintree = &bintree{nil, map[string]*bintree{ + "schema": &bintree{nil, map[string]*bintree{ + "schema.graphql": &bintree{schemaSchemaGraphql, map[string]*bintree{}}, + }}, +}} + +// RestoreAsset restores an asset under the given directory +func RestoreAsset(dir, name string) error { + data, err := Asset(name) + if err != nil { + return err + } + info, err := AssetInfo(name) + if err != nil { + return err + } + err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755)) + if err != nil { + return err + } + err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) + if err != nil { + return err + } + err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) + if err != nil { + return err + } + return nil +} + +// RestoreAssets restores an asset under the given directory recursively +func RestoreAssets(dir, name string) error { + children, err := AssetDir(name) + // File + if err != nil { + return RestoreAsset(dir, name) + } + // Dir + for _, child := range children { + err = RestoreAssets(dir, filepath.Join(name, child)) + if err != nil { + return err + } + } + return nil +} + +func _filePath(dir, name string) string { + cannonicalName := strings.Replace(name, "\\", "/", -1) + return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) +} diff --git a/graphql/schema.go b/graphql/schema.go index ce51129cc..2a4e3bce4 100644 --- a/graphql/schema.go +++ b/graphql/schema.go @@ -2,169 +2,17 @@ package graphql import ( "github.com/0xProject/0x-mesh/core" + "github.com/0xProject/0x-mesh/graphql/data" graphql "github.com/graph-gophers/graphql-go" ) -// TODO(albrow): Consider moving this schema to a file and loading with gobindata. -// That way we would benefit from syntax highlighting and static analysis. -const schemaString = ` -""" -A signed 0x order along with some additional metadata about the order which is not part of the 0x protocol specification. -""" -type OrderWithMetadata { - chainId: String! - exchangeAddress: String! - makerAddress: String! - makerAssetData: String! - makerAssetAmount: String! - makerFeeAssetData: String! - makerFee: String! - takerAddress: String! - takerAssetData: String! - takerAssetAmount: String! - takerFeeAssetData: String! - takerFee: String! - senderAddress: String! - feeRecipientAddress: String! - expirationTimeSeconds: String! - salt: String! - signature: String! - """ - The hash, which can be used to uniquely identify an order. - """ - hash: String! - """ - The remaining amount of the maker asset which has not yet been filled. - """ - fillableTakerAssetAmount: String! -} - -""" -An enum containing all the order fields for which filters and/or sorting is supported. -""" -enum OrderField { - hash - chainId - exchangeAddress - makerAddress - makerAssetData - makerAssetAmount - makerFeeAssetData - makerFee - takerAddress - takerAssetData - takerAssetAmount - takerFeeAssetData - takerFee - senderAddress - feeRecipientAddress - expirationTimeSeconds - salt - fillableTakerAssetAmount -} - -""" -The kind of comparison to be used in a filter. -""" -enum FilterKind { - EQUAL - NOT_EQUAL - GREATER - GREATER_OR_EQUAL - LESS - LESS_OR_EQUAL -} - -""" -The direction to sort in. Ascending means lowest to highest. Descending means highest to lowest. -""" -enum SortDirection { - ASC - DESC -} - -""" -The value to filter with. Must be the same type as the field you are filtering by. -""" -scalar FilterValue - -""" -A filter on orders. Can be used in queries to only return orders that meet certain criteria. -""" -input OrderFilter { - field: OrderField! - kind: FilterKind! - value: FilterValue! -} - -""" -A sort ordering for orders. Can be used in queries to control the order in which results are returned. -""" -input OrderSort { - field: OrderField! - direction: SortDirection! -} - -""" -The block number and block hash for the latest block that has been processed by Mesh. -""" -type LatestBlock { - number: String! - hash: String! -} - -""" -Contains configuration options and various stats for Mesh. -""" -type Stats { - version: String! - pubSubTopic: String! - rendezvous: String! - peerID: String! - ethereumChainID: Int! - latestBlock: LatestBlock! - numPeers: Int! - numOrders: Int! - numOrdersIncludingRemoved: Int! - startOfCurrentUTCDay: String! - ethRPCRequestsSentInCurrentUTCDay: Int! - ethRPCRateLimitExpiredRequests: Int! - maxExpirationTime: String! -} - -type Query { - """ - Returns the order with the specified hash, or null if no order is found with that hash. - """ - order(hash: String!): OrderWithMetadata - """ - Returns an array of orders that satisfy certain criteria. - """ - orders( - """ - Determines the order of the results. If more than one sort option is provided, results we be sorted by the - first option first, then by any subsequent options. By default, orders are sorted by hash in ascending order. - """ - sort: [OrderSort!] = [{ field: hash, direction: ASC }] - """ - A set of filters. Only the orders that match all filters will be included in the results. By default no - filters are used. - """ - filters: [OrderFilter!] = [] - """ - The maximum number of orders to be included in the results. Defaults to 20. - """ - limit: Int = 20 - ): [OrderWithMetadata!]! - """ - Returns the current stats. - """ - stats: Stats -} -` - +//go:generate go-bindata -pkg data -o ./data/bindata.go ./schema/... func NewSchema(app *core.App) (*graphql.Schema, error) { + schema, err := data.Asset("schema/schema.graphql") + if err != nil { + return nil, err + } // TODO(albrow): Look into more schema options. var opts = []graphql.SchemaOpt{graphql.UseFieldResolvers(), graphql.UseStringDescriptions()} - return graphql.ParseSchema(schemaString, &resolver{app: app}, opts...) + return graphql.ParseSchema(string(schema), &resolver{app: app}, opts...) } diff --git a/graphql/schema/schema.graphql b/graphql/schema/schema.graphql new file mode 100644 index 000000000..d1e5434a9 --- /dev/null +++ b/graphql/schema/schema.graphql @@ -0,0 +1,243 @@ +""" +A signed 0x order along with some additional metadata about the order which is not part of the 0x protocol specification. +""" +type OrderWithMetadata { + chainId: String! + exchangeAddress: String! + makerAddress: String! + makerAssetData: String! + makerAssetAmount: String! + makerFeeAssetData: String! + makerFee: String! + takerAddress: String! + takerAssetData: String! + takerAssetAmount: String! + takerFeeAssetData: String! + takerFee: String! + senderAddress: String! + feeRecipientAddress: String! + expirationTimeSeconds: String! + salt: String! + signature: String! + """ + The hash, which can be used to uniquely identify an order. + """ + hash: String! + """ + The remaining amount of the maker asset which has not yet been filled. + """ + fillableTakerAssetAmount: String! +} + +""" +An enum containing all the order fields for which filters and/or sorting is supported. +""" +enum OrderField { + hash + chainId + exchangeAddress + makerAddress + makerAssetData + makerAssetAmount + makerFeeAssetData + makerFee + takerAddress + takerAssetData + takerAssetAmount + takerFeeAssetData + takerFee + senderAddress + feeRecipientAddress + expirationTimeSeconds + salt + fillableTakerAssetAmount +} + +""" +The kind of comparison to be used in a filter. +""" +enum FilterKind { + EQUAL + NOT_EQUAL + GREATER + GREATER_OR_EQUAL + LESS + LESS_OR_EQUAL +} + +""" +The direction to sort in. Ascending means lowest to highest. Descending means highest to lowest. +""" +enum SortDirection { + ASC + DESC +} + +""" +The value to filter with. Must be the same type as the field you are filtering by. +""" +scalar FilterValue + +""" +A filter on orders. Can be used in queries to only return orders that meet certain criteria. +""" +input OrderFilter { + field: OrderField! + kind: FilterKind! + value: FilterValue! +} + +""" +A sort ordering for orders. Can be used in queries to control the order in which results are returned. +""" +input OrderSort { + field: OrderField! + direction: SortDirection! +} + +""" +The block number and block hash for the latest block that has been processed by Mesh. +""" +type LatestBlock { + number: String! + hash: String! +} + +""" +Contains configuration options and various stats for Mesh. +""" +type Stats { + version: String! + pubSubTopic: String! + rendezvous: String! + peerID: String! + ethereumChainID: Int! + latestBlock: LatestBlock! + numPeers: Int! + numOrders: Int! + numOrdersIncludingRemoved: Int! + startOfCurrentUTCDay: String! + ethRPCRequestsSentInCurrentUTCDay: Int! + ethRPCRateLimitExpiredRequests: Int! + maxExpirationTime: String! +} + +type Query { + """ + Returns the order with the specified hash, or null if no order is found with that hash. + """ + order(hash: String!): OrderWithMetadata + """ + Returns an array of orders that satisfy certain criteria. + """ + orders( + """ + Determines the order of the results. If more than one sort option is provided, results we be sorted by the + first option first, then by any subsequent options. By default, orders are sorted by hash in ascending order. + """ + sort: [OrderSort!] = [{ field: hash, direction: ASC }] + """ + A set of filters. Only the orders that match all filters will be included in the results. By default no + filters are used. + """ + filters: [OrderFilter!] = [] + """ + The maximum number of orders to be included in the results. Defaults to 20. + """ + limit: Int = 20 + ): [OrderWithMetadata!]! + """ + Returns the current stats. + """ + stats: Stats +} + +""" +A signed 0x order according to the [protocol specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md#order-message-format). +""" +input NewOrder { + chainId: Int! + exchangeAddress: Address! + makerAddress: Address! + makerAssetData: Bytes! + makerAssetAmount: BigNumber! + makerFeeAssetData: Bytes! + makerFee: BigNumber! + takerAddress: Address! + takerAssetData: Bytes! + takerAssetAmount: BigNumber! + takerFeeAssetData: Bytes! + takerFee: BigNumber! + senderAddress: Address! + feeRecipientAddress: Address! + expirationTimeSeconds: BigNumber! + salt: BigNumber! + signature: Bytes! +} + +""" +The results of the addOrders mutation. Includes which orders were accepted and which orders where rejected. +""" +type AddOrdersResults { + """ + The set of orders that were accepted. Accepted orders will be watched and order events will be emitted if + their status changes. + """ + accepted: [AcceptedOrderResult!]! + """ + The set of orders that were rejected, including the reason they were rejected. Rejected orders will not be + watched. + """ + rejected: [RejectedOrderResult!]! +} + +type AcceptedOrderResult { + """ + The order that was accepted, including metadata. + """ + order: OrderWithMetadata! + """ + Whether or not the order is new. Set to true if this is the first time this Mesh node has accepted the order + and false otherwise. + """ + isNew: Boolean! +} + +type RejectedOrderResult { + """ + The hash of the order. May be null if the hash could not be computed. + """ + hash: Hash + """ + The order that was rejected. + """ + order: Order! + """ + A machine-readable code indicating why the order was rejected. This code is designed to + be used by programs and applications and will never change without breaking backwards-compatibility. + """ + code: RejectedOrderCode! + """ + A human-readable message indicating why the order was rejected. This message may change + in future releases and is not covered by backwards-compatibility guarantees. + """ + message: String! +} + +""" +A set of all possible codes included in RejectedOrderResult. Note that more codes will be added +to the final spec. See the [current Mesh docs](https://godoc.org/github.com/0xProject/0x-mesh/zeroex/ordervalidator#pkg-variables) +for a list of all codes currently in use. +""" +enum RejectedOrderCode { + ETH_RPC_REQUEST_FAILED + INVALID_MAKER_ASSET_AMOUNT + INVALID_TAKER_ASSET_AMOUNT +} + +type Mutation { + """ + Adds one or more orders to Mesh. + """ + addOrders(orders: [NewOrder!]!, pinned: Boolean = true): AddOrdersResults! +}