add gql
This commit is contained in:
parent
11e16a01a8
commit
8d29064d08
@ -130,6 +130,9 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
|
||||
// add rosetta
|
||||
rootCmd.AddCommand(sdkserver.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Codec))
|
||||
|
||||
// Add flags for GQL server.
|
||||
rootCmd = srvflags.AddGQLFlags(rootCmd)
|
||||
|
||||
return rootCmd, encodingConfig
|
||||
}
|
||||
|
||||
|
5
go.mod
5
go.mod
@ -4,6 +4,7 @@ go 1.18
|
||||
|
||||
require (
|
||||
cosmossdk.io/math v1.0.0-beta.3
|
||||
github.com/99designs/gqlgen v0.17.20
|
||||
github.com/armon/go-metrics v0.4.1
|
||||
github.com/btcsuite/btcd v0.22.1
|
||||
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
|
||||
@ -40,6 +41,7 @@ require (
|
||||
github.com/tendermint/tendermint v0.34.21
|
||||
github.com/tendermint/tm-db v0.6.7
|
||||
github.com/tyler-smith/go-bip39 v1.1.0
|
||||
github.com/vektah/gqlparser/v2 v2.5.1
|
||||
golang.org/x/net v0.0.0-20220909164309-bea034e7d591
|
||||
golang.org/x/text v0.3.7
|
||||
google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e
|
||||
@ -61,6 +63,7 @@ require (
|
||||
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
|
||||
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
|
||||
github.com/Workiva/go-datastructures v1.0.53 // indirect
|
||||
github.com/agnivade/levenshtein v1.1.1 // indirect
|
||||
github.com/aws/aws-sdk-go v1.40.45 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
|
||||
@ -142,7 +145,7 @@ require (
|
||||
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
|
||||
github.com/magiconair/properties v1.8.6 // indirect
|
||||
github.com/manifoldco/promptui v0.9.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.12 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.16 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.9 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
|
||||
|
35
go.sum
35
go.sum
@ -75,6 +75,8 @@ filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmG
|
||||
filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
|
||||
git.sr.ht/~sircmpwn/getopt v0.0.0-20191230200459-23622cc906b3/go.mod h1:wMEGFFFNuPos7vHmWXfszqImLppbc0wEhh6JBfJIUgw=
|
||||
git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9/go.mod h1:BVJwbDfVjCjoFiKrhkei6NdGcZYpkDkdyCdg1ukytRA=
|
||||
github.com/99designs/gqlgen v0.17.20 h1:O7WzccIhKB1dm+7g6dhQcULINftfiLSBg2l/mwbpJMw=
|
||||
github.com/99designs/gqlgen v0.17.20/go.mod h1:Mja2HI23kWT1VRH09hvWshFgOzKswpO20o4ScpJIES4=
|
||||
github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4=
|
||||
github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM=
|
||||
@ -93,6 +95,7 @@ github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN
|
||||
github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc=
|
||||
github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg=
|
||||
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4=
|
||||
@ -118,6 +121,9 @@ github.com/Zilliqa/gozilliqa-sdk v1.2.1-0.20201201074141-dd0ecada1be6/go.mod h1:
|
||||
github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I=
|
||||
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
|
||||
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
|
||||
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
|
||||
github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8=
|
||||
github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
|
||||
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
@ -127,11 +133,14 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk5
|
||||
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
|
||||
github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKSc=
|
||||
github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
|
||||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
|
||||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/apache/arrow/go/arrow v0.0.0-20191024131854-af6fa24be0db/go.mod h1:VTxUBvSJ3s3eHAg65PNgrsn5BtqCRPdmyXh6rAfdxN0=
|
||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
|
||||
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
|
||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
||||
@ -271,6 +280,7 @@ github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6p
|
||||
github.com/cosmos/ledger-go v0.9.2/go.mod h1:oZJ2hHAZROdlHiwTg4t7kP+GKIIkBT+o6c9QWFanOyI=
|
||||
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/creachadair/taskgroup v0.3.2 h1:zlfutDS+5XG40AOxcHDSThxKzns8Tnr9jnr6VqkYlkM=
|
||||
github.com/creachadair/taskgroup v0.3.2/go.mod h1:wieWwecHVzsidg2CsUnFinW1faVN4+kq+TDlRJQ0Wbk=
|
||||
@ -309,6 +319,8 @@ github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUn
|
||||
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y=
|
||||
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||
github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g=
|
||||
github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
|
||||
github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
||||
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91 h1:Izz0+t1Z5nI16/II7vuEo/nHjodOg0p7+OiDpjX5t1E=
|
||||
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
||||
@ -613,6 +625,7 @@ github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09
|
||||
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
||||
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs=
|
||||
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||
@ -705,6 +718,7 @@ github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E
|
||||
github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0=
|
||||
github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
|
||||
github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
|
||||
github.com/kevinmbeaulieu/eq-go v1.0.0/go.mod h1:G3S8ajA56gKBZm4UB9AOyoOS37JO3roToPzKNM8dtdM=
|
||||
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM=
|
||||
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
@ -747,6 +761,7 @@ github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6
|
||||
github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg=
|
||||
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
|
||||
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
|
||||
github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc=
|
||||
github.com/lucasjones/reggen v0.0.0-20180717132126-cdb49ff09d77/go.mod h1:5ELEyG+X8f+meRWHuqUOewBOhvHkl7M76pdGEansxW4=
|
||||
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
@ -757,14 +772,16 @@ github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN
|
||||
github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA=
|
||||
github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg=
|
||||
github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ=
|
||||
github.com/matryer/moq v0.2.7/go.mod h1:kITsx543GOENm48TUAQyJ9+SAvFSr7iGQXPoth/VUBk=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
|
||||
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc=
|
||||
github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
@ -808,6 +825,7 @@ github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS4
|
||||
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
|
||||
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.3.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||
@ -1000,6 +1018,8 @@ github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KR
|
||||
github.com/segmentio/kafka-go v0.1.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo=
|
||||
github.com/segmentio/kafka-go v0.2.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo=
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU=
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
@ -1104,9 +1124,12 @@ github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oW
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
|
||||
github.com/urfave/cli/v2 v2.8.1/go.mod h1:Z41J9TPoffeoqP0Iza0YbAhGvymRdZAd2uPmZ5JxRdY=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
|
||||
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||
github.com/vektah/gqlparser/v2 v2.5.1 h1:ZGu+bquAY23jsxDRcYpWjttRZrUz07LbiY77gUOHcr4=
|
||||
github.com/vektah/gqlparser/v2 v2.5.1/go.mod h1:mPgqFBu/woKTVYWyNk8cO3kh4S/f4aRFZrvOnp3hmCs=
|
||||
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
|
||||
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
|
||||
github.com/warpfork/go-wish v0.0.0-20180510122957-5ad1f5abf436/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=
|
||||
@ -1117,12 +1140,15 @@ github.com/willf/bitset v1.1.3/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPyS
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg=
|
||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
||||
github.com/ybbus/jsonrpc v2.1.2+incompatible/go.mod h1:XJrh1eMSzdIYFbM08flv0wp5G35eRniyeGut1z+LSiE=
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM=
|
||||
github.com/zondax/hid v0.9.1-0.20220302062450-5552068d2266 h1:O9XLFXGkVswDFmH9LaYpqu+r/AAFWqr0DL6V00KEVFg=
|
||||
github.com/zondax/hid v0.9.1-0.20220302062450-5552068d2266/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM=
|
||||
@ -1173,6 +1199,7 @@ golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWP
|
||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2 h1:x8vtB3zMecnlqZIwJNUUpwYKYSqCz5jXbiyv0ZJJZeI=
|
||||
golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
@ -1218,6 +1245,8 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@ -1281,6 +1310,7 @@ golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su
|
||||
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.0.0-20220909164309-bea034e7d591 h1:D0B/7al0LLrVC8aWF4+oxpv/m8bc7ViFfVS8/gXGdqI=
|
||||
golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
@ -1424,6 +1454,7 @@ golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220908150016-7ac13a9a928d h1:RoyzQTK76Rktm3p4xyZslc8T8I1tBz4UEjZCzeh57mM=
|
||||
golang.org/x/sys v0.0.0-20220908150016-7ac13a9a928d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@ -1512,6 +1543,8 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
353
gql/README.md
Normal file
353
gql/README.md
Normal file
@ -0,0 +1,353 @@
|
||||
# Cerc-io laconic gql
|
||||
|
||||
> Browser : http://localhost:9473 for gql
|
||||
|
||||
## Start server
|
||||
|
||||
```shell
|
||||
./build/laconicd start --gql-playground --gql-server
|
||||
```
|
||||
|
||||
Basic node status:
|
||||
|
||||
```graphql
|
||||
{
|
||||
getStatus {
|
||||
version
|
||||
node {
|
||||
id
|
||||
network
|
||||
moniker
|
||||
}
|
||||
sync {
|
||||
latest_block_height
|
||||
catching_up
|
||||
}
|
||||
num_peers
|
||||
peers {
|
||||
is_outbound
|
||||
remote_ip
|
||||
}
|
||||
disk_usage
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Full node status:
|
||||
|
||||
```graphql
|
||||
{
|
||||
getStatus {
|
||||
version
|
||||
node {
|
||||
id
|
||||
network
|
||||
moniker
|
||||
}
|
||||
sync {
|
||||
latest_block_hash
|
||||
latest_block_time
|
||||
latest_block_height
|
||||
catching_up
|
||||
}
|
||||
validator {
|
||||
address
|
||||
voting_power
|
||||
proposer_priority
|
||||
}
|
||||
validators {
|
||||
address
|
||||
voting_power
|
||||
proposer_priority
|
||||
}
|
||||
num_peers
|
||||
peers {
|
||||
node {
|
||||
id
|
||||
network
|
||||
moniker
|
||||
}
|
||||
is_outbound
|
||||
remote_ip
|
||||
}
|
||||
disk_usage
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Get records by IDs.
|
||||
|
||||
```graphql
|
||||
{
|
||||
getRecordsByIds(ids: ["QmYDtNCKtTu6u6jaHaFAC5PWZXcj7fAmry6NoWwMaixFHz"]) {
|
||||
id
|
||||
names
|
||||
bondId
|
||||
createTime
|
||||
expiryTime
|
||||
owners
|
||||
attributes {
|
||||
key
|
||||
value {
|
||||
string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Query records.
|
||||
|
||||
```graphql
|
||||
{
|
||||
queryRecords(attributes: [{ key: "type", value: { string: "crn:bot" } }]) {
|
||||
id
|
||||
names
|
||||
bondId
|
||||
createTime
|
||||
expiryTime
|
||||
owners
|
||||
attributes {
|
||||
key
|
||||
value {
|
||||
string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Get account details:
|
||||
|
||||
```graphql
|
||||
{
|
||||
getAccounts(addresses: ["cosmos1wh8vvd0ymc5nt37h29z8kk2g2ays45ct2qu094"]) {
|
||||
address
|
||||
pubKey
|
||||
number
|
||||
sequence
|
||||
balance {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Query bonds:
|
||||
|
||||
```graphql
|
||||
{
|
||||
queryBonds(
|
||||
attributes: [
|
||||
{
|
||||
key: "owner"
|
||||
value: { string: "cosmos1wh8vvd0ymc5nt37h29z8kk2g2ays45ct2qu094" }
|
||||
}
|
||||
]
|
||||
) {
|
||||
id
|
||||
owner
|
||||
balance {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Get bonds by IDs.
|
||||
|
||||
```graphql
|
||||
{
|
||||
getBondsByIds(
|
||||
ids: [
|
||||
"1c2b677cb2a27c88cc6bf8acf675c94b69051125b40c4fd073153b10f046dd87"
|
||||
"c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440"
|
||||
]
|
||||
) {
|
||||
id
|
||||
owner
|
||||
balance {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Query Bonds by Owner
|
||||
|
||||
```graphql
|
||||
{
|
||||
queryBondsByOwner(
|
||||
ownerAddresses: ["ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk"]
|
||||
) {
|
||||
owner
|
||||
bonds {
|
||||
id
|
||||
owner
|
||||
balance {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Query auctions by ids
|
||||
|
||||
```graphql
|
||||
{
|
||||
getAuctionsByIds(
|
||||
ids: ["be98f2073c246194276554eefdb4c95b682a35a0f06fbe619a6da57c10c93e90"]
|
||||
) {
|
||||
id
|
||||
ownerAddress
|
||||
createTime
|
||||
minimumBid {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
commitFee {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
commitsEndTime
|
||||
revealFee {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
revealsEndTime
|
||||
winnerBid {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
winnerPrice {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
winnerAddress
|
||||
bids {
|
||||
bidderAddress
|
||||
commitHash
|
||||
commitTime
|
||||
commitFee {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
revealFee {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
revealTime
|
||||
bidAmount {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
status
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
LookUp Authorities
|
||||
|
||||
```graphql
|
||||
{
|
||||
lookupAuthorities(names: []) {
|
||||
ownerAddress
|
||||
ownerAddress
|
||||
height
|
||||
bondId
|
||||
status
|
||||
expiryTime
|
||||
auction {
|
||||
id
|
||||
ownerAddress
|
||||
createTime
|
||||
minimumBid {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
commitFee {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
commitsEndTime
|
||||
revealFee {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
revealsEndTime
|
||||
winnerBid {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
winnerPrice {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
winnerAddress
|
||||
bids {
|
||||
bidderAddress
|
||||
commitHash
|
||||
commitTime
|
||||
commitFee {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
revealFee {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
revealTime
|
||||
bidAmount {
|
||||
type
|
||||
quantity
|
||||
}
|
||||
status
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
LookUp Names
|
||||
|
||||
```graphql
|
||||
{
|
||||
lookupNames(names: ["crn://hello/test"]) {
|
||||
latest {
|
||||
id
|
||||
height
|
||||
}
|
||||
history {
|
||||
id
|
||||
height
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Resolve Names
|
||||
|
||||
```graphql
|
||||
{
|
||||
resolveNames(names: ["asd"]) {
|
||||
id
|
||||
names
|
||||
bondId
|
||||
createTime
|
||||
expiryTime
|
||||
owners
|
||||
attributes {
|
||||
key
|
||||
value {
|
||||
string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
8781
gql/generated.go
Normal file
8781
gql/generated.go
Normal file
File diff suppressed because it is too large
Load Diff
14
gql/gqlgen.yml
Normal file
14
gql/gqlgen.yml
Normal file
@ -0,0 +1,14 @@
|
||||
# .gqlgen.yml example
|
||||
#
|
||||
# Refer to https://gqlgen.com/config/
|
||||
# for detailed .gqlgen.yml documentation.
|
||||
|
||||
schema:
|
||||
- cerc-io/laconicd/*.graphql
|
||||
exec:
|
||||
filename: generated.go
|
||||
model:
|
||||
filename: models_gen.go
|
||||
resolver:
|
||||
filename: resolver.go
|
||||
type: Resolver
|
160
gql/models_gen.go
Normal file
160
gql/models_gen.go
Normal file
@ -0,0 +1,160 @@
|
||||
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
|
||||
|
||||
package gql
|
||||
|
||||
type Account struct {
|
||||
Address string `json:"address"`
|
||||
PubKey *string `json:"pubKey"`
|
||||
Number string `json:"number"`
|
||||
Sequence string `json:"sequence"`
|
||||
Balance []*Coin `json:"balance"`
|
||||
}
|
||||
|
||||
type Auction struct {
|
||||
ID string `json:"id"`
|
||||
Status string `json:"status"`
|
||||
OwnerAddress string `json:"ownerAddress"`
|
||||
CreateTime string `json:"createTime"`
|
||||
CommitsEndTime string `json:"commitsEndTime"`
|
||||
RevealsEndTime string `json:"revealsEndTime"`
|
||||
CommitFee *Coin `json:"commitFee"`
|
||||
RevealFee *Coin `json:"revealFee"`
|
||||
MinimumBid *Coin `json:"minimumBid"`
|
||||
WinnerAddress string `json:"winnerAddress"`
|
||||
WinnerBid *Coin `json:"winnerBid"`
|
||||
WinnerPrice *Coin `json:"winnerPrice"`
|
||||
Bids []*AuctionBid `json:"bids"`
|
||||
}
|
||||
|
||||
type AuctionBid struct {
|
||||
BidderAddress string `json:"bidderAddress"`
|
||||
Status string `json:"status"`
|
||||
CommitHash string `json:"commitHash"`
|
||||
CommitTime string `json:"commitTime"`
|
||||
CommitFee *Coin `json:"commitFee"`
|
||||
RevealTime string `json:"revealTime"`
|
||||
RevealFee *Coin `json:"revealFee"`
|
||||
BidAmount *Coin `json:"bidAmount"`
|
||||
}
|
||||
|
||||
type AuthorityRecord struct {
|
||||
OwnerAddress string `json:"ownerAddress"`
|
||||
OwnerPublicKey string `json:"ownerPublicKey"`
|
||||
Height string `json:"height"`
|
||||
Status string `json:"status"`
|
||||
BondID string `json:"bondId"`
|
||||
ExpiryTime string `json:"expiryTime"`
|
||||
Auction *Auction `json:"auction"`
|
||||
}
|
||||
|
||||
type Bond struct {
|
||||
ID string `json:"id"`
|
||||
Owner string `json:"owner"`
|
||||
Balance []*Coin `json:"balance"`
|
||||
}
|
||||
|
||||
type Coin struct {
|
||||
Type string `json:"type"`
|
||||
Quantity string `json:"quantity"`
|
||||
}
|
||||
|
||||
type KeyValue struct {
|
||||
Key string `json:"key"`
|
||||
Value *Value `json:"value"`
|
||||
}
|
||||
|
||||
type KeyValueInput struct {
|
||||
Key string `json:"key"`
|
||||
Value *ValueInput `json:"value"`
|
||||
}
|
||||
|
||||
type NameRecord struct {
|
||||
Latest *NameRecordEntry `json:"latest"`
|
||||
History []*NameRecordEntry `json:"history"`
|
||||
}
|
||||
|
||||
type NameRecordEntry struct {
|
||||
ID string `json:"id"`
|
||||
Height string `json:"height"`
|
||||
}
|
||||
|
||||
type NodeInfo struct {
|
||||
ID string `json:"id"`
|
||||
Network string `json:"network"`
|
||||
Moniker string `json:"moniker"`
|
||||
}
|
||||
|
||||
type OwnerBonds struct {
|
||||
Owner string `json:"owner"`
|
||||
Bonds []*Bond `json:"bonds"`
|
||||
}
|
||||
|
||||
type PeerInfo struct {
|
||||
Node *NodeInfo `json:"node"`
|
||||
IsOutbound bool `json:"is_outbound"`
|
||||
RemoteIP string `json:"remote_ip"`
|
||||
}
|
||||
|
||||
type Record struct {
|
||||
ID string `json:"id"`
|
||||
Names []string `json:"names"`
|
||||
BondID string `json:"bondId"`
|
||||
CreateTime string `json:"createTime"`
|
||||
ExpiryTime string `json:"expiryTime"`
|
||||
Owners []string `json:"owners"`
|
||||
Attributes []*KeyValue `json:"attributes"`
|
||||
References []*Record `json:"references"`
|
||||
}
|
||||
|
||||
type Reference struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
type ReferenceInput struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
type Status struct {
|
||||
Version string `json:"version"`
|
||||
Node *NodeInfo `json:"node"`
|
||||
Sync *SyncInfo `json:"sync"`
|
||||
Validator *ValidatorInfo `json:"validator"`
|
||||
Validators []*ValidatorInfo `json:"validators"`
|
||||
NumPeers string `json:"num_peers"`
|
||||
Peers []*PeerInfo `json:"peers"`
|
||||
DiskUsage string `json:"disk_usage"`
|
||||
}
|
||||
|
||||
type SyncInfo struct {
|
||||
LatestBlockHash string `json:"latest_block_hash"`
|
||||
LatestBlockHeight string `json:"latest_block_height"`
|
||||
LatestBlockTime string `json:"latest_block_time"`
|
||||
CatchingUp bool `json:"catching_up"`
|
||||
}
|
||||
|
||||
type ValidatorInfo struct {
|
||||
Address string `json:"address"`
|
||||
VotingPower string `json:"voting_power"`
|
||||
ProposerPriority *string `json:"proposer_priority"`
|
||||
}
|
||||
|
||||
type Value struct {
|
||||
Null *bool `json:"null"`
|
||||
Int *int `json:"int"`
|
||||
Float *float64 `json:"float"`
|
||||
String *string `json:"string"`
|
||||
Boolean *bool `json:"boolean"`
|
||||
JSON *string `json:"json"`
|
||||
Reference *Reference `json:"reference"`
|
||||
Values []*Value `json:"values"`
|
||||
}
|
||||
|
||||
type ValueInput struct {
|
||||
Null *bool `json:"null"`
|
||||
Int *int `json:"int"`
|
||||
Float *float64 `json:"float"`
|
||||
String *string `json:"string"`
|
||||
Boolean *bool `json:"boolean"`
|
||||
Reference *ReferenceInput `json:"reference"`
|
||||
Values []*ValueInput `json:"values"`
|
||||
}
|
348
gql/resolver.go
Normal file
348
gql/resolver.go
Normal file
@ -0,0 +1,348 @@
|
||||
package gql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"strconv"
|
||||
|
||||
auctiontypes "github.com/cerc-io/laconicd/x/auction/types"
|
||||
bondtypes "github.com/cerc-io/laconicd/x/bond/types"
|
||||
nstypes "github.com/cerc-io/laconicd/x/nameservice/types"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
// DefaultLogNumLines is the number of log lines to tail by default.
|
||||
const DefaultLogNumLines = 50
|
||||
|
||||
// MaxLogNumLines is the max number of log lines that can be tailed.
|
||||
const MaxLogNumLines = 1000
|
||||
|
||||
type Resolver struct {
|
||||
ctx client.Context
|
||||
logFile string
|
||||
}
|
||||
|
||||
// Query is the entry point to query execution.
|
||||
func (r *Resolver) Query() QueryResolver {
|
||||
return &queryResolver{r}
|
||||
}
|
||||
|
||||
type queryResolver struct{ *Resolver }
|
||||
|
||||
func (q queryResolver) LookupAuthorities(ctx context.Context, names []string) ([]*AuthorityRecord, error) {
|
||||
nsQueryClient := nstypes.NewQueryClient(q.ctx)
|
||||
auctionQueryClient := auctiontypes.NewQueryClient(q.ctx)
|
||||
var gqlResponse []*AuthorityRecord
|
||||
|
||||
for _, name := range names {
|
||||
res, err := nsQueryClient.Whois(context.Background(), &nstypes.QueryWhoisRequest{Name: name})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nameAuthority := res.GetNameAuthority()
|
||||
gqlNameAuthorityRecord, err := GetGQLNameAuthorityRecord(&nameAuthority)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if nameAuthority.AuctionId != "" {
|
||||
auctionResp, err := auctionQueryClient.GetAuction(context.Background(), &auctiontypes.AuctionRequest{Id: nameAuthority.GetAuctionId()})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bidsResp, err := auctionQueryClient.GetBids(context.Background(), &auctiontypes.BidsRequest{AuctionId: nameAuthority.GetAuctionId()})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlAuctionRecord, err := GetGQLAuction(auctionResp.GetAuction(), bidsResp.GetBids())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlNameAuthorityRecord.Auction = gqlAuctionRecord
|
||||
}
|
||||
|
||||
gqlResponse = append(gqlResponse, gqlNameAuthorityRecord)
|
||||
}
|
||||
|
||||
return gqlResponse, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) ResolveNames(ctx context.Context, names []string) ([]*Record, error) {
|
||||
nsQueryClient := nstypes.NewQueryClient(q.ctx)
|
||||
var gqlResponse []*Record
|
||||
for _, name := range names {
|
||||
res, err := nsQueryClient.ResolveCrn(context.Background(), &nstypes.QueryResolveCrn{Crn: name})
|
||||
if err != nil {
|
||||
// Return nil for record not found.
|
||||
gqlResponse = append(gqlResponse, nil)
|
||||
} else {
|
||||
gqlRecord, err := getGQLRecord(context.Background(), q, *res.GetRecord())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlResponse = append(gqlResponse, gqlRecord)
|
||||
}
|
||||
}
|
||||
|
||||
return gqlResponse, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) LookupNames(ctx context.Context, names []string) ([]*NameRecord, error) {
|
||||
nsQueryClient := nstypes.NewQueryClient(q.ctx)
|
||||
var gqlResponse []*NameRecord
|
||||
|
||||
for _, name := range names {
|
||||
res, err := nsQueryClient.LookupCrn(context.Background(), &nstypes.QueryLookupCrn{Crn: name})
|
||||
if err != nil {
|
||||
// Return nil for name not found.
|
||||
gqlResponse = append(gqlResponse, nil)
|
||||
} else {
|
||||
gqlRecord, err := getGQLNameRecord(res.GetName())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlResponse = append(gqlResponse, gqlRecord)
|
||||
}
|
||||
}
|
||||
|
||||
return gqlResponse, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) QueryRecords(ctx context.Context, attributes []*KeyValueInput, all *bool) ([]*Record, error) {
|
||||
nsQueryClient := nstypes.NewQueryClient(q.ctx)
|
||||
|
||||
res, err := nsQueryClient.ListRecords(
|
||||
context.Background(),
|
||||
&nstypes.QueryListRecordsRequest{
|
||||
Attributes: parseRequestAttributes(attributes),
|
||||
All: (all != nil && *all),
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
records := res.GetRecords()
|
||||
gqlResponse := make([]*Record, len(records))
|
||||
|
||||
for i, record := range records {
|
||||
gqlRecord, err := getGQLRecord(context.Background(), q, record)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
gqlResponse[i] = gqlRecord
|
||||
}
|
||||
|
||||
return gqlResponse, nil
|
||||
|
||||
}
|
||||
|
||||
func (q queryResolver) GetRecordsByIds(ctx context.Context, ids []string) ([]*Record, error) {
|
||||
nsQueryClient := nstypes.NewQueryClient(q.ctx)
|
||||
gqlResponse := make([]*Record, len(ids))
|
||||
|
||||
for i, id := range ids {
|
||||
res, err := nsQueryClient.GetRecord(context.Background(), &nstypes.QueryRecordByIdRequest{Id: id})
|
||||
if err != nil {
|
||||
// Return nil for record not found.
|
||||
gqlResponse[i] = nil
|
||||
} else {
|
||||
record, err := getGQLRecord(context.Background(), q, res.GetRecord())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
gqlResponse[i] = record
|
||||
}
|
||||
}
|
||||
|
||||
return gqlResponse, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) GetStatus(ctx context.Context) (*Status, error) {
|
||||
nodeInfo, syncInfo, validatorInfo, err := getStatusInfo(q.ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
numPeers, peers, err := getNetInfo(q.ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
validatorSet, err := getValidatorSet(q.ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
diskUsage, err := GetDiskUsage(NodeDataPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Status{
|
||||
Version: NameServiceVersion,
|
||||
Node: nodeInfo,
|
||||
Sync: syncInfo,
|
||||
Validator: validatorInfo,
|
||||
Validators: validatorSet,
|
||||
NumPeers: numPeers,
|
||||
Peers: peers,
|
||||
DiskUsage: diskUsage,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) GetAccounts(ctx context.Context, addresses []string) ([]*Account, error) {
|
||||
accounts := make([]*Account, len(addresses))
|
||||
for index, address := range addresses {
|
||||
account, err := q.GetAccount(ctx, address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
accounts[index] = account
|
||||
}
|
||||
return accounts, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) GetAccount(ctx context.Context, address string) (*Account, error) {
|
||||
authQueryClient := authtypes.NewQueryClient(q.ctx)
|
||||
accountResponse, err := authQueryClient.Account(ctx, &authtypes.QueryAccountRequest{Address: address})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var account authtypes.AccountI
|
||||
err = q.ctx.Codec.UnpackAny(accountResponse.GetAccount(), &account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var pubKey *string
|
||||
if account.GetPubKey() != nil {
|
||||
pubKeyStr := base64.StdEncoding.EncodeToString(account.GetPubKey().Bytes())
|
||||
pubKey = &pubKeyStr
|
||||
}
|
||||
|
||||
// Get the account balance
|
||||
bankQueryClient := banktypes.NewQueryClient(q.ctx)
|
||||
balance, err := bankQueryClient.AllBalances(ctx, &banktypes.QueryAllBalancesRequest{Address: address})
|
||||
|
||||
accNum := strconv.FormatUint(account.GetAccountNumber(), 10)
|
||||
seq := strconv.FormatUint(account.GetSequence(), 10)
|
||||
|
||||
return &Account{
|
||||
Address: address,
|
||||
Number: accNum,
|
||||
Sequence: seq,
|
||||
PubKey: pubKey,
|
||||
Balance: getGQLCoins(balance.GetBalances()),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) GetBondsByIds(ctx context.Context, ids []string) ([]*Bond, error) {
|
||||
bonds := make([]*Bond, len(ids))
|
||||
for index, id := range ids {
|
||||
bondObj, err := q.GetBond(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bonds[index] = bondObj
|
||||
}
|
||||
|
||||
return bonds, nil
|
||||
}
|
||||
|
||||
func (q *queryResolver) GetBond(ctx context.Context, id string) (*Bond, error) {
|
||||
bondQueryClient := bondtypes.NewQueryClient(q.ctx)
|
||||
bondResp, err := bondQueryClient.GetBondById(context.Background(), &bondtypes.QueryGetBondByIdRequest{Id: id})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bond := bondResp.GetBond()
|
||||
if bond == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return getGQLBond(bondResp.GetBond())
|
||||
}
|
||||
|
||||
func (q queryResolver) QueryBonds(ctx context.Context, attributes []*KeyValueInput) ([]*Bond, error) {
|
||||
bondQueryClient := bondtypes.NewQueryClient(q.ctx)
|
||||
bonds, err := bondQueryClient.Bonds(context.Background(), &bondtypes.QueryGetBondsRequest{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlResponse := make([]*Bond, len(bonds.GetBonds()))
|
||||
for i, bondObj := range bonds.GetBonds() {
|
||||
gqlBond, err := getGQLBond(bondObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
gqlResponse[i] = gqlBond
|
||||
}
|
||||
|
||||
return gqlResponse, nil
|
||||
}
|
||||
|
||||
// QueryBondsByOwner will return bonds by owner
|
||||
func (q queryResolver) QueryBondsByOwner(ctx context.Context, ownerAddresses []string) ([]*OwnerBonds, error) {
|
||||
ownerBonds := make([]*OwnerBonds, len(ownerAddresses))
|
||||
for index, ownerAddress := range ownerAddresses {
|
||||
bondsObj, err := q.GetBondsByOwner(ctx, ownerAddress)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ownerBonds[index] = bondsObj
|
||||
}
|
||||
|
||||
return ownerBonds, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) GetBondsByOwner(ctx context.Context, address string) (*OwnerBonds, error) {
|
||||
bondQueryClient := bondtypes.NewQueryClient(q.ctx)
|
||||
bondResp, err := bondQueryClient.GetBondsByOwner(context.Background(), &bondtypes.QueryGetBondsByOwnerRequest{Owner: address})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ownerBonds := make([]*Bond, len(bondResp.GetBonds()))
|
||||
for i, bond := range bondResp.GetBonds() {
|
||||
bondObj, err := getGQLBond(&bond)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ownerBonds[i] = bondObj
|
||||
}
|
||||
|
||||
return &OwnerBonds{Bonds: ownerBonds, Owner: address}, nil
|
||||
}
|
||||
|
||||
func (q queryResolver) GetAuctionsByIds(ctx context.Context, ids []string) ([]*Auction, error) {
|
||||
auctionQueryClient := auctiontypes.NewQueryClient(q.ctx)
|
||||
gqlAuctionResponse := make([]*Auction, len(ids))
|
||||
for i, id := range ids {
|
||||
auctionObj, err := auctionQueryClient.GetAuction(context.Background(), &auctiontypes.AuctionRequest{Id: id})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bidsObj, err := auctionQueryClient.GetBids(context.Background(), &auctiontypes.BidsRequest{AuctionId: id})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlAuction, err := GetGQLAuction(auctionObj.GetAuction(), bidsObj.GetBids())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gqlAuctionResponse[i] = gqlAuction
|
||||
}
|
||||
|
||||
return gqlAuctionResponse, nil
|
||||
}
|
45
gql/server.go
Normal file
45
gql/server.go
Normal file
@ -0,0 +1,45 @@
|
||||
package gql
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/99designs/gqlgen/graphql/handler"
|
||||
"github.com/99designs/gqlgen/graphql/playground"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// Server configures and starts the GQL server.
|
||||
func Server(ctx client.Context) {
|
||||
if !viper.GetBool("gql-server") {
|
||||
return
|
||||
}
|
||||
logFile := viper.GetString("log-file")
|
||||
|
||||
port := viper.GetString("gql-port")
|
||||
|
||||
srv := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: &Resolver{
|
||||
ctx: ctx,
|
||||
logFile: logFile,
|
||||
}}))
|
||||
|
||||
http.Handle("/", playground.Handler("GraphQL playground", "/api"))
|
||||
|
||||
if viper.GetBool("gql-playground") {
|
||||
apiBase := viper.GetString("gql-playground-api-base")
|
||||
|
||||
http.Handle("/webui", playground.Handler("GraphQL playground", apiBase+"/api"))
|
||||
http.Handle("/console", playground.Handler("GraphQL playground", apiBase+"/graphql"))
|
||||
}
|
||||
|
||||
http.Handle("/api", srv)
|
||||
http.Handle("/graphql", srv)
|
||||
|
||||
log.Info("Connect to GraphQL playground", "url", fmt.Sprintf("http://localhost:%s", port))
|
||||
err := http.ListenAndServe(":"+port, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
100
gql/status.go
Normal file
100
gql/status.go
Normal file
@ -0,0 +1,100 @@
|
||||
package gql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
)
|
||||
|
||||
// NodeDataPath is the path to the laconicd data folder.
|
||||
var NodeDataPath = os.ExpandEnv("$HOME/.laconicd/data")
|
||||
|
||||
func getStatusInfo(client client.Context) (*NodeInfo, *SyncInfo, *ValidatorInfo, error) {
|
||||
nodeClient, err := client.GetNode()
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
nodeStatus, err := nodeClient.Status(context.Background())
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
return &NodeInfo{
|
||||
ID: string(nodeStatus.NodeInfo.ID()),
|
||||
Network: nodeStatus.NodeInfo.Network,
|
||||
Moniker: nodeStatus.NodeInfo.Moniker,
|
||||
}, &SyncInfo{
|
||||
LatestBlockHash: nodeStatus.SyncInfo.LatestBlockHash.String(),
|
||||
LatestBlockHeight: strconv.FormatInt(nodeStatus.SyncInfo.LatestBlockHeight, 10),
|
||||
LatestBlockTime: nodeStatus.SyncInfo.LatestBlockTime.String(),
|
||||
CatchingUp: nodeStatus.SyncInfo.CatchingUp,
|
||||
}, &ValidatorInfo{
|
||||
Address: nodeStatus.ValidatorInfo.Address.String(),
|
||||
VotingPower: strconv.FormatInt(nodeStatus.ValidatorInfo.VotingPower, 10),
|
||||
ProposerPriority: nil,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getNetInfo(client client.Context) (string, []*PeerInfo, error) {
|
||||
nodeClient, err := client.GetNode()
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
netInfo, err := nodeClient.NetInfo(context.Background())
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
|
||||
peersInfo := make([]*PeerInfo, netInfo.NPeers)
|
||||
// TODO: find a way to get the peer information from nodeClient
|
||||
for index, peer := range netInfo.Peers {
|
||||
peersInfo[index] = &PeerInfo{
|
||||
Node: &NodeInfo{
|
||||
ID: string(peer.NodeInfo.ID()),
|
||||
// Moniker: peer.Node.Moniker,
|
||||
// Network: peer.Node.Network,
|
||||
},
|
||||
// IsOutbound: peer.IsOutbound,
|
||||
// RemoteIP: peer.RemoteIP,
|
||||
}
|
||||
}
|
||||
|
||||
return strconv.FormatInt(int64(netInfo.NPeers), 10), peersInfo, nil
|
||||
}
|
||||
|
||||
func getValidatorSet(client client.Context) ([]*ValidatorInfo, error) {
|
||||
nodeClient, err := client.GetNode()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res, err := nodeClient.Validators(context.Background(), nil, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
validatorSet := make([]*ValidatorInfo, len(res.Validators))
|
||||
for index, validator := range res.Validators {
|
||||
proposerPriority := strconv.FormatInt(validator.ProposerPriority, 10)
|
||||
validatorSet[index] = &ValidatorInfo{
|
||||
Address: validator.Address.String(),
|
||||
VotingPower: strconv.FormatInt(validator.VotingPower, 10),
|
||||
ProposerPriority: &proposerPriority,
|
||||
}
|
||||
}
|
||||
|
||||
return validatorSet, nil
|
||||
}
|
||||
|
||||
// GetDiskUsage returns disk usage for the given path.
|
||||
func GetDiskUsage(dirPath string) (string, error) {
|
||||
out, err := exec.Command("du", "-sh", dirPath).Output()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return strings.Fields(string(out))[0], nil
|
||||
}
|
315
gql/util.go
Normal file
315
gql/util.go
Normal file
@ -0,0 +1,315 @@
|
||||
package gql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"strconv"
|
||||
|
||||
auctiontypes "github.com/cerc-io/laconicd/x/auction/types"
|
||||
bondtypes "github.com/cerc-io/laconicd/x/bond/types"
|
||||
nstypes "github.com/cerc-io/laconicd/x/nameservice/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// OwnerAttributeName denotes the owner attribute name for a bond.
|
||||
const OwnerAttributeName = "owner"
|
||||
|
||||
// BondIDAttributeName denotes the record bond ID.
|
||||
const BondIDAttributeName = "bondId"
|
||||
|
||||
// ExpiryTimeAttributeName denotes the record expiry time.
|
||||
const ExpiryTimeAttributeName = "expiryTime"
|
||||
|
||||
func getGQLCoin(coin sdk.Coin) *Coin {
|
||||
gqlCoin := Coin{
|
||||
Type: coin.Denom,
|
||||
Quantity: coin.Amount.BigInt().String(),
|
||||
}
|
||||
|
||||
return &gqlCoin
|
||||
}
|
||||
|
||||
func getGQLCoins(coins sdk.Coins) []*Coin {
|
||||
gqlCoins := make([]*Coin, len(coins))
|
||||
for index, coin := range coins {
|
||||
gqlCoins[index] = getGQLCoin(coin)
|
||||
}
|
||||
|
||||
return gqlCoins
|
||||
}
|
||||
func GetGQLNameAuthorityRecord(record *nstypes.NameAuthority) (*AuthorityRecord, error) {
|
||||
if record == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return &AuthorityRecord{
|
||||
OwnerAddress: record.OwnerAddress,
|
||||
OwnerPublicKey: record.OwnerPublicKey,
|
||||
Height: strconv.FormatUint(record.Height, 10),
|
||||
Status: record.Status,
|
||||
BondID: record.GetBondId(),
|
||||
ExpiryTime: record.GetExpiryTime().String(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getGQLRecord(ctx context.Context, resolver QueryResolver, record nstypes.Record) (*Record, error) {
|
||||
// Nil record.
|
||||
if record.Deleted {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
recordType := record.ToRecordType()
|
||||
attributes, err := getAttributes(&recordType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
references, err := getReferences(ctx, resolver, &recordType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Record{
|
||||
ID: record.Id,
|
||||
BondID: record.GetBondId(),
|
||||
CreateTime: record.GetCreateTime(),
|
||||
ExpiryTime: record.GetExpiryTime(),
|
||||
Owners: record.GetOwners(),
|
||||
Names: record.GetNames(),
|
||||
Attributes: attributes,
|
||||
References: references,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getGQLNameRecord(record *nstypes.NameRecord) (*NameRecord, error) {
|
||||
if record == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
records := make([]*NameRecordEntry, len(record.History))
|
||||
for index, entry := range record.History {
|
||||
records[index] = getNameRecordEntry(entry)
|
||||
}
|
||||
|
||||
return &NameRecord{
|
||||
Latest: getNameRecordEntry(record.Latest),
|
||||
History: records,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getNameRecordEntry(record *nstypes.NameRecordEntry) *NameRecordEntry {
|
||||
return &NameRecordEntry{
|
||||
ID: record.Id,
|
||||
Height: strconv.FormatUint(record.Height, 10),
|
||||
}
|
||||
}
|
||||
|
||||
func getGQLBond(bondObj *bondtypes.Bond) (*Bond, error) {
|
||||
// Nil record.
|
||||
if bondObj == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return &Bond{
|
||||
ID: bondObj.Id,
|
||||
Owner: bondObj.Owner,
|
||||
Balance: getGQLCoins(bondObj.Balance),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func matchBondOnAttributes(bondObj *bondtypes.Bond, attributes []*KeyValueInput) bool {
|
||||
for _, attr := range attributes {
|
||||
switch attr.Key {
|
||||
case OwnerAttributeName:
|
||||
{
|
||||
if attr.Value.String == nil || bondObj.Owner != *attr.Value.String {
|
||||
return false
|
||||
}
|
||||
}
|
||||
default:
|
||||
{
|
||||
// Only attributes explicitly listed in the switch are queryable.
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func getAuctionBid(bid *auctiontypes.Bid) *AuctionBid {
|
||||
return &AuctionBid{
|
||||
BidderAddress: bid.BidderAddress,
|
||||
Status: bid.Status,
|
||||
CommitHash: bid.CommitHash,
|
||||
CommitTime: bid.GetCommitTime(),
|
||||
RevealTime: bid.GetRevealTime(),
|
||||
CommitFee: getGQLCoin(bid.CommitFee),
|
||||
RevealFee: getGQLCoin(bid.RevealFee),
|
||||
BidAmount: getGQLCoin(bid.BidAmount),
|
||||
}
|
||||
}
|
||||
|
||||
func GetGQLAuction(auction *auctiontypes.Auction, bids []*auctiontypes.Bid) (*Auction, error) {
|
||||
if auction == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
gqlAuction := Auction{
|
||||
ID: auction.Id,
|
||||
Status: auction.Status,
|
||||
OwnerAddress: auction.OwnerAddress,
|
||||
CreateTime: auction.GetCreateTime(),
|
||||
CommitsEndTime: auction.GetCommitsEndTime(),
|
||||
RevealsEndTime: auction.GetRevealsEndTime(),
|
||||
CommitFee: getGQLCoin(auction.CommitFee),
|
||||
RevealFee: getGQLCoin(auction.RevealFee),
|
||||
MinimumBid: getGQLCoin(auction.MinimumBid),
|
||||
WinnerAddress: auction.WinnerAddress,
|
||||
WinnerBid: getGQLCoin(auction.WinningBid),
|
||||
WinnerPrice: getGQLCoin(auction.WinningPrice),
|
||||
}
|
||||
|
||||
auctionBids := make([]*AuctionBid, len(bids))
|
||||
for index, entry := range bids {
|
||||
auctionBids[index] = getAuctionBid(entry)
|
||||
}
|
||||
|
||||
gqlAuction.Bids = auctionBids
|
||||
|
||||
return &gqlAuction, nil
|
||||
}
|
||||
|
||||
func getReferences(ctx context.Context, resolver QueryResolver, r *nstypes.RecordType) ([]*Record, error) {
|
||||
var ids []string
|
||||
|
||||
for _, value := range r.Attributes {
|
||||
switch value.(type) {
|
||||
case interface{}:
|
||||
if obj, ok := value.(map[string]interface{}); ok {
|
||||
if _, ok := obj["/"]; ok && len(obj) == 1 {
|
||||
if _, ok := obj["/"].(string); ok {
|
||||
ids = append(ids, obj["/"].(string))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resolver.GetRecordsByIds(ctx, ids)
|
||||
}
|
||||
|
||||
func getAttributes(r *nstypes.RecordType) ([]*KeyValue, error) {
|
||||
return mapToKeyValuePairs(r.Attributes)
|
||||
}
|
||||
|
||||
func mapToKeyValuePairs(attrs map[string]interface{}) ([]*KeyValue, error) {
|
||||
var kvPairs []*KeyValue
|
||||
|
||||
trueVal := true
|
||||
falseVal := false
|
||||
|
||||
for key, value := range attrs {
|
||||
kvPair := &KeyValue{
|
||||
Key: key,
|
||||
Value: &Value{},
|
||||
}
|
||||
|
||||
switch val := value.(type) {
|
||||
case nil:
|
||||
kvPair.Value.Null = &trueVal
|
||||
case int:
|
||||
kvPair.Value.Int = &val
|
||||
case float64:
|
||||
kvPair.Value.Float = &val
|
||||
case string:
|
||||
kvPair.Value.String = &val
|
||||
case bool:
|
||||
kvPair.Value.Boolean = &val
|
||||
case interface{}:
|
||||
if obj, ok := value.(map[string]interface{}); ok {
|
||||
if _, ok := obj["/"]; ok && len(obj) == 1 {
|
||||
if _, ok := obj["/"].(string); ok {
|
||||
kvPair.Value.Reference = &Reference{
|
||||
ID: obj["/"].(string),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bytes, err := json.Marshal(obj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
jsonStr := string(bytes)
|
||||
kvPair.Value.JSON = &jsonStr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if kvPair.Value.Null == nil {
|
||||
kvPair.Value.Null = &falseVal
|
||||
}
|
||||
|
||||
valueType := reflect.ValueOf(value)
|
||||
if valueType.Kind() == reflect.Slice {
|
||||
bytes, err := json.Marshal(value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
jsonStr := string(bytes)
|
||||
kvPair.Value.JSON = &jsonStr
|
||||
}
|
||||
|
||||
kvPairs = append(kvPairs, kvPair)
|
||||
}
|
||||
|
||||
return kvPairs, nil
|
||||
}
|
||||
|
||||
func parseRequestAttributes(attrs []*KeyValueInput) []*nstypes.QueryListRecordsRequest_KeyValueInput {
|
||||
kvPairs := []*nstypes.QueryListRecordsRequest_KeyValueInput{}
|
||||
|
||||
for _, value := range attrs {
|
||||
kvPair := &nstypes.QueryListRecordsRequest_KeyValueInput{
|
||||
Key: value.Key,
|
||||
Value: &nstypes.QueryListRecordsRequest_ValueInput{},
|
||||
}
|
||||
|
||||
if value.Value.String != nil {
|
||||
kvPair.Value.String_ = *value.Value.String
|
||||
kvPair.Value.Type = "string"
|
||||
}
|
||||
|
||||
if value.Value.Int != nil {
|
||||
kvPair.Value.Int = int64(*value.Value.Int)
|
||||
kvPair.Value.Type = "int"
|
||||
}
|
||||
|
||||
if value.Value.Float != nil {
|
||||
kvPair.Value.Float = *value.Value.Float
|
||||
kvPair.Value.Type = "float"
|
||||
}
|
||||
|
||||
if value.Value.Boolean != nil {
|
||||
kvPair.Value.Boolean = *value.Value.Boolean
|
||||
kvPair.Value.Type = "boolean"
|
||||
}
|
||||
|
||||
if value.Value.Reference != nil {
|
||||
reference := &nstypes.QueryListRecordsRequest_ReferenceInput{
|
||||
Id: value.Value.Reference.ID,
|
||||
}
|
||||
|
||||
kvPair.Value.Reference = reference
|
||||
kvPair.Value.Type = "reference"
|
||||
}
|
||||
|
||||
// TODO: Handle arrays.
|
||||
|
||||
kvPairs = append(kvPairs, kvPair)
|
||||
}
|
||||
|
||||
return kvPairs
|
||||
}
|
4
gql/version.go
Normal file
4
gql/version.go
Normal file
@ -0,0 +1,4 @@
|
||||
package gql
|
||||
|
||||
// NameServiceVersion is the registry API version.
|
||||
const NameServiceVersion = "0.3.0"
|
238
gql/vulcanize/chiba-clonk/schema.graphql
Normal file
238
gql/vulcanize/chiba-clonk/schema.graphql
Normal file
@ -0,0 +1,238 @@
|
||||
# Reference to another record.
|
||||
type Reference {
|
||||
id: String! # ID of linked record.
|
||||
}
|
||||
|
||||
# Reference to another record.
|
||||
input ReferenceInput {
|
||||
id: String!
|
||||
}
|
||||
|
||||
# Bonds contain funds that are used to pay rent on record registration and renewal.
|
||||
type Bond {
|
||||
id: String! # Primary key, auto-generated by the server.
|
||||
owner: String! # Bond owner cosmos-sdk address.
|
||||
balance: [Coin!] # Current balance for each coin type.
|
||||
}
|
||||
|
||||
# OwnerBonds contains the bonds related the owner
|
||||
type OwnerBonds {
|
||||
owner: String!
|
||||
bonds: [Bond!]
|
||||
}
|
||||
|
||||
# Mutations require payment in coins (e.g. 100wire).
|
||||
# Used by the wallet to get the account balance for display and mutations.
|
||||
type Coin {
|
||||
type: String! # e.g. 'WIRE'
|
||||
quantity: String! # e.g. 1000000
|
||||
}
|
||||
# Represents an account on the blockchain.
|
||||
# Mutations have to be signed by a particular account.
|
||||
type Account {
|
||||
address: String! # Blockchain address.
|
||||
pubKey: String # Public key.
|
||||
number: String! # Account number.
|
||||
sequence: String! # Sequence number used to prevent replays.
|
||||
balance: [Coin!] # Current balance for each coin type.
|
||||
}
|
||||
|
||||
# Value of a given type.
|
||||
type Value {
|
||||
null: Boolean
|
||||
|
||||
int: Int
|
||||
float: Float
|
||||
string: String
|
||||
boolean: Boolean
|
||||
json: String
|
||||
|
||||
reference: Reference
|
||||
|
||||
values: [Value]
|
||||
}
|
||||
# Value of a given type used as input to queries.
|
||||
input ValueInput {
|
||||
null: Boolean
|
||||
|
||||
int: Int
|
||||
float: Float
|
||||
string: String
|
||||
boolean: Boolean
|
||||
|
||||
reference: ReferenceInput
|
||||
|
||||
values: [ValueInput]
|
||||
}
|
||||
|
||||
# Key/value pair.
|
||||
type KeyValue {
|
||||
key: String!
|
||||
value: Value!
|
||||
}
|
||||
|
||||
# Key/value pair for inputs.
|
||||
input KeyValueInput {
|
||||
key: String!
|
||||
value: ValueInput!
|
||||
}
|
||||
|
||||
# Status information about a node (https://docs.tendermint.com/master/rpc/#/Info/status).
|
||||
type NodeInfo {
|
||||
id: String! # Tendermint Node ID.
|
||||
network: String! # Name of the network/blockchain.
|
||||
moniker: String! # Name of the node.
|
||||
}
|
||||
|
||||
# Node sync status.
|
||||
type SyncInfo {
|
||||
latest_block_hash: String!
|
||||
latest_block_height: String!
|
||||
latest_block_time: String!
|
||||
catching_up: Boolean!
|
||||
}
|
||||
|
||||
# Validator set info (https://docs.tendermint.com/master/rpc/#/Info/validators).
|
||||
type ValidatorInfo {
|
||||
address: String!
|
||||
voting_power: String!
|
||||
proposer_priority: String
|
||||
}
|
||||
|
||||
# Network/peer info (https://docs.tendermint.com/master/rpc/#/Info/net_info).
|
||||
type PeerInfo {
|
||||
node: NodeInfo!
|
||||
is_outbound: Boolean!
|
||||
remote_ip: String!
|
||||
}
|
||||
|
||||
# Vulcanize laconic status.
|
||||
type Status {
|
||||
version: String!
|
||||
node: NodeInfo!
|
||||
sync: SyncInfo!
|
||||
validator: ValidatorInfo
|
||||
validators: [ValidatorInfo]!
|
||||
num_peers: String!
|
||||
peers: [PeerInfo]
|
||||
disk_usage: String!
|
||||
}
|
||||
|
||||
# An auction bid.
|
||||
type AuctionBid {
|
||||
bidderAddress: String!
|
||||
status: String!
|
||||
commitHash: String!
|
||||
commitTime: String!
|
||||
commitFee: Coin!
|
||||
revealTime: String!
|
||||
revealFee: Coin!
|
||||
bidAmount: Coin!
|
||||
}
|
||||
|
||||
# A sealed-bid, 2nd price auction.
|
||||
type Auction {
|
||||
id: String! # Auction ID.
|
||||
status: String! # Auction status (commit, reveal, expired).
|
||||
ownerAddress: String! # Auction owner time.
|
||||
createTime: String! # Create time.
|
||||
commitsEndTime: String! # Commit phase end time.
|
||||
revealsEndTime: String! # Reveal phase end time.
|
||||
commitFee: Coin! # Fee required to bid/participate in the auction.
|
||||
revealFee: Coin! # Reveal fee (paid back to bidders only if they unseal/reveal the bid).
|
||||
minimumBid: Coin! # Minimum bid amount.
|
||||
winnerAddress: String! # Winner address.
|
||||
winnerBid: Coin! # The winning bid amount.
|
||||
winnerPrice: Coin! # The price that the winner actually pays (2nd highest bid).
|
||||
bids: [AuctionBid] # Bids make in the auction.
|
||||
}
|
||||
|
||||
# Record defines the basic properties of an entity in the graph database.
|
||||
type Record {
|
||||
id: String! # Computed attribute: Multibase encoded content hash (https://github.com/multiformats/multibase).
|
||||
names: [String!] # Names pointing to this CID (reverse lookup).
|
||||
bondId: String! # Associated bond ID.
|
||||
createTime: String! # Record create time.
|
||||
expiryTime: String! # Record expiry time.
|
||||
owners: [String!] # Addresses of record owners.
|
||||
attributes: [KeyValue] # Record attributes.
|
||||
references: [Record] # Record references.
|
||||
}
|
||||
|
||||
# Name authority record.
|
||||
type AuthorityRecord {
|
||||
ownerAddress: String! # Owner address.
|
||||
ownerPublicKey: String! # Owner public key.
|
||||
height: String! # Height at which record was created.
|
||||
status: String! # Status (active, auction, expired).
|
||||
bondId: String! # Associated bond ID.
|
||||
expiryTime: String! # Authority expiry time.
|
||||
auction: Auction # Authority auction.
|
||||
}
|
||||
|
||||
# Name record entry, created at a particular height.
|
||||
type NameRecordEntry {
|
||||
id: String! # Target record ID.
|
||||
height: String! # Height at which record was created.
|
||||
}
|
||||
|
||||
# Name record stores the latest and historical name -> record ID mappings.
|
||||
type NameRecord {
|
||||
latest: NameRecordEntry! # Latest mame record entry.
|
||||
history: [NameRecordEntry] # Historical name record entries.
|
||||
}
|
||||
|
||||
type Query {
|
||||
#
|
||||
# Status API.
|
||||
#
|
||||
getStatus: Status!
|
||||
|
||||
# Get blockchain accounts.
|
||||
getAccounts(addresses: [String!]): [Account]
|
||||
|
||||
# Get bonds by IDs.
|
||||
getBondsByIds(ids: [String!]): [Bond]
|
||||
|
||||
# Query bonds.
|
||||
queryBonds(attributes: [KeyValueInput]): [Bond]
|
||||
|
||||
# Query bonds by owner.
|
||||
queryBondsByOwner(ownerAddresses: [String!]): [OwnerBonds]
|
||||
|
||||
#
|
||||
# GraphDB API.
|
||||
#
|
||||
|
||||
# Get records by IDs.
|
||||
getRecordsByIds(ids: [String!]): [Record]
|
||||
|
||||
# Query records.
|
||||
queryRecords(
|
||||
# Multiple attribute conditions are in a logical AND.
|
||||
attributes: [KeyValueInput]
|
||||
|
||||
# Whether to query all records, not just named ones (false by default).
|
||||
all: Boolean
|
||||
): [Record]
|
||||
|
||||
#
|
||||
# Naming API.
|
||||
#
|
||||
|
||||
# Lookup authority information.
|
||||
lookupAuthorities(names: [String!]): [AuthorityRecord]!
|
||||
|
||||
# Lookup name to record mapping information.
|
||||
lookupNames(names: [String!]): [NameRecord]!
|
||||
|
||||
# Resolve names to records.
|
||||
resolveNames(names: [String!]): [Record]!
|
||||
|
||||
#
|
||||
# Auctions API.
|
||||
#
|
||||
|
||||
# Get auctions by IDs.
|
||||
getAuctionsByIds(ids: [String!]): [Auction]
|
||||
}
|
@ -5,7 +5,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
)
|
||||
|
||||
// Tendermint/cosmos-sdk full-node start flags
|
||||
@ -74,8 +73,6 @@ func AddTxFlags(cmd *cobra.Command) (*cobra.Command, error) {
|
||||
cmd.PersistentFlags().Float64(flags.FlagGasAdjustment, flags.DefaultGasAdjustment, "adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored ") //nolint:lll
|
||||
cmd.PersistentFlags().StringP(flags.FlagBroadcastMode, "b", flags.BroadcastSync, "Transaction broadcasting mode (sync|async|block)")
|
||||
cmd.PersistentFlags().String(flags.FlagKeyringBackend, keyring.BackendOS, "Select keyring's backend")
|
||||
cmd.PersistentFlags().BoolP(flags.FlagSkipConfirmation, "y", false, "Skip tx broadcasting prompt confirmation")
|
||||
cmd.Flags().StringP(tmcli.OutputFlag, "o", "text", "Output format (text|json)")
|
||||
|
||||
// --gas can accept integers and "simulate"
|
||||
// cmd.PersistentFlags().Var(&flags.GasFlagVar, "gas", fmt.Sprintf(
|
||||
@ -92,3 +89,15 @@ func AddTxFlags(cmd *cobra.Command) (*cobra.Command, error) {
|
||||
}
|
||||
return cmd, nil
|
||||
}
|
||||
|
||||
// AddGQLFlags adds gql flags for
|
||||
func AddGQLFlags(cmd *cobra.Command) *cobra.Command {
|
||||
// Add flags for GQL server.
|
||||
cmd.PersistentFlags().Bool("gql-server", false, "Start GQL server.")
|
||||
cmd.PersistentFlags().Bool("gql-playground", false, "Enable GQL playground.")
|
||||
cmd.PersistentFlags().String("gql-playground-api-base", "", "GQL API base path to use in GQL playground.")
|
||||
cmd.PersistentFlags().String("gql-port", "9473", "Port to use for the GQL server.")
|
||||
cmd.PersistentFlags().String("log-file", "", "File to tail for GQL 'getLogs' API.")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/server/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
|
||||
"github.com/cerc-io/laconicd/gql"
|
||||
"github.com/cerc-io/laconicd/indexer"
|
||||
ethdebug "github.com/cerc-io/laconicd/rpc/namespaces/ethereum/debug"
|
||||
"github.com/cerc-io/laconicd/server/config"
|
||||
@ -509,6 +510,9 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator ty
|
||||
}
|
||||
}
|
||||
|
||||
// Start the GQL Server
|
||||
go gql.Server(clientCtx)
|
||||
|
||||
defer func() {
|
||||
if tmNode.IsRunning() {
|
||||
_ = tmNode.Stop()
|
||||
|
@ -1,10 +1,9 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"github.com/cerc-io/laconicd/server/flags"
|
||||
|
||||
"github.com/cerc-io/laconicd/x/bond/types"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/spf13/cobra"
|
||||
@ -51,8 +50,7 @@ func NewCreateBondCmd() *cobra.Command {
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
// flags.AddTxFlagsToCmd(cmd)
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -77,8 +75,7 @@ func RefillBondCmd() *cobra.Command {
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
flags.AddTxFlags(cmd)
|
||||
// flags.AddTxFlagsToCmd(cmd)
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
@ -104,8 +101,7 @@ func WithdrawBondCmd() *cobra.Command {
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
flags.AddTxFlags(cmd)
|
||||
// flags.AddTxFlagsToCmd(cmd)
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
@ -126,8 +122,7 @@ func CancelBondCmd() *cobra.Command {
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
flags.AddTxFlags(cmd)
|
||||
// flags.AddTxFlagsToCmd(cmd)
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user