Integrate graphql server (#5)
* WIP: migrating the nameservice module * WIP: migrating the nameservice module from dxns to ethermint * refactor: move the proto package version from `v1` to `v1beta1` for vulcanize modules * refactor: added bond module dependency to nameserivce module * feat: added graphql for bond module * feat: added auction module dependency to nameservice module * refactor: refactored the nameservice module * refactor: add human-readable attributes output to cli nameservice `list` * WIP: add grpc query test cases * fix: fix the sub names authority storing issue * WIP: add the test cases * refactor: removed legacyCodec from nameservice * fix: fix the responses for `authority-expiry` and `records-expiry` commands query result * refactor: sort the imports in app * WIP: add test cases for cli query, tx for nameservice module * feat: add test cases for grpc of nameservice module 1. renamed grpc gateway routes from ethermint to vulcanize * refactor: refactored the test cases for grpc lookup of nameservice * refactor: refactored the test cases for bond module * feat: add node status for gql * feat: add get actions by ids in gql * feat: add lookup authorities,resolve name, lookup name queries to gql * updated readme file
This commit is contained in:
parent
34cc262218
commit
5a6e2ec46f
@ -120,6 +120,9 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
|
||||
// add rosetta
|
||||
rootCmd.AddCommand(sdkserver.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Marshaler))
|
||||
|
||||
// Add flags for GQL server.
|
||||
rootCmd = srvflags.AddGQLFlags(rootCmd)
|
||||
|
||||
return rootCmd, encodingConfig
|
||||
}
|
||||
|
||||
@ -228,6 +231,8 @@ func (a appCreator) newApp(logger tmlog.Logger, db dbm.DB, traceStore io.Writer,
|
||||
baseapp.SetSnapshotKeepRecent(cast.ToUint32(appOpts.Get(sdkserver.FlagStateSyncSnapshotKeepRecent))),
|
||||
)
|
||||
|
||||
// Start
|
||||
//go gql.Server(ethermintApp.BaseApp, ethermintApp.AppCodec(), ethermintApp.AccountKeeper, ethermintApp.BondKeeper)
|
||||
return ethermintApp
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
8
go.mod
8
go.mod
@ -3,11 +3,13 @@ module github.com/tharsis/ethermint
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/99designs/gqlgen v0.14.0
|
||||
github.com/btcsuite/btcd v0.22.0-beta
|
||||
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
|
||||
github.com/cosmos/cosmos-sdk v0.44.0
|
||||
github.com/cosmos/go-bip39 v1.0.0
|
||||
github.com/cosmos/ibc-go v1.2.0
|
||||
github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea
|
||||
github.com/ethereum/go-ethereum v1.10.3
|
||||
github.com/gibson042/canonicaljson-go v1.0.3
|
||||
github.com/gogo/protobuf v1.3.3
|
||||
@ -27,12 +29,14 @@ require (
|
||||
github.com/rs/zerolog v1.25.0
|
||||
github.com/spf13/cast v1.4.1
|
||||
github.com/spf13/cobra v1.2.1
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/spf13/viper v1.8.1
|
||||
github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/tendermint/tendermint v0.34.13
|
||||
github.com/tendermint/tm-db v0.6.4
|
||||
github.com/tyler-smith/go-bip39 v1.1.0
|
||||
github.com/vektah/gqlparser/v2 v2.2.0
|
||||
go.etcd.io/bbolt v1.3.6 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
|
||||
golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f // indirect
|
||||
@ -55,6 +59,7 @@ require (
|
||||
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
|
||||
github.com/VictoriaMetrics/fastcache v1.5.7 // indirect
|
||||
github.com/Workiva/go-datastructures v1.0.52 // indirect
|
||||
github.com/agnivade/levenshtein v1.1.0 // indirect
|
||||
github.com/aokoli/goutils v1.1.1 // indirect
|
||||
github.com/armon/go-metrics v0.3.9 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
@ -68,7 +73,6 @@ require (
|
||||
github.com/cosmos/ledger-go v0.9.2 // indirect
|
||||
github.com/danieljoos/wincred v1.0.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea // indirect
|
||||
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
|
||||
github.com/dgraph-io/badger/v2 v2.2007.2 // indirect
|
||||
github.com/dgraph-io/ristretto v0.0.3 // indirect
|
||||
@ -129,7 +133,6 @@ require (
|
||||
github.com/mtibben/percent v0.2.1 // indirect
|
||||
github.com/multiformats/go-base32 v0.0.3 // indirect
|
||||
github.com/multiformats/go-multibase v0.0.1 // indirect
|
||||
github.com/multiformats/go-varint v0.0.5 // indirect
|
||||
github.com/mwitkow/go-proto-validators v0.3.2 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/pelletier/go-toml v1.9.3 // indirect
|
||||
@ -149,7 +152,6 @@ require (
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
github.com/spf13/afero v1.6.0 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/subosito/gotenv v1.2.0 // indirect
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954 // indirect
|
||||
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
|
||||
|
50
go.sum
50
go.sum
@ -43,6 +43,8 @@ collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
filippo.io/edwards25519 v1.0.0-beta.2 h1:/BZRNzm8N4K4eWfK28dL4yescorxtO7YG1yun8fy+pI=
|
||||
filippo.io/edwards25519 v1.0.0-beta.2/go.mod h1:X+pm78QAUPtFLi1z9PYIlS/bdDnvbCOGKtZ+ACWEf7o=
|
||||
github.com/99designs/gqlgen v0.14.0 h1:Wg8aNYQUjMR/4v+W3xD+7SizOy6lSvVeQ06AobNQAXI=
|
||||
github.com/99designs/gqlgen v0.14.0/go.mod h1:S7z4boV+Nx4VvzMUpVrY/YuHjFX4n7rDyuTqvAkuoRE=
|
||||
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-storage-blob-go v0.7.0/go.mod h1:f9YQKtsG1nMisotuTPpO0tjNuEjKRYAcJU8/ydDI++4=
|
||||
@ -102,6 +104,9 @@ github.com/adlio/schema v1.1.13 h1:LeNMVg5Z1FX+Qgz8tJUijBLRdcpbFUElz+d1489On98=
|
||||
github.com/adlio/schema v1.1.13/go.mod h1:L5Z7tw+7lRK1Fnpi/LT/ooCP1elkXn0krMWBQHUhEDE=
|
||||
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.0 h1:n6qGwyHG61v3ABce1rPVZklEYRT8NFpCMrpZdBUbYGM=
|
||||
github.com/agnivade/levenshtein v1.1.0/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=
|
||||
@ -111,6 +116,7 @@ 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/aokoli/goutils v1.0.1/go.mod h1:SijmP0QR8LtwsmDs8Yii5Z/S4trXFGFC2oO5g9DP+DQ=
|
||||
@ -119,6 +125,8 @@ github.com/aokoli/goutils v1.1.1/go.mod h1:SijmP0QR8LtwsmDs8Yii5Z/S4trXFGFC2oO5g
|
||||
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/aristanetworks/fsnotify v1.4.2/go.mod h1:D/rtu7LpjYM8tRJphJ0hUBYpjai8SfX+aSNsWDTq/Ks=
|
||||
github.com/aristanetworks/glog v0.0.0-20191112221043-67e8567f59f3/go.mod h1:KASm+qXFKs/xjSoWn30NrWBBvdTTQq+UjkhjEJHfSFA=
|
||||
github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ=
|
||||
@ -276,6 +284,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/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
|
||||
@ -478,9 +488,11 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU=
|
||||
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
|
||||
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
|
||||
github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
||||
@ -684,14 +696,17 @@ github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOS
|
||||
github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM=
|
||||
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 v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
||||
github.com/lucasjones/reggen v0.0.0-20180717132126-cdb49ff09d77/go.mod h1:5ELEyG+X8f+meRWHuqUOewBOhvHkl7M76pdGEansxW4=
|
||||
github.com/lyft/protoc-gen-star v0.5.1/go.mod h1:9toiA3cC7z5uVbODF7kEQ91Xn7XNFkVUl+SrEe+ZORU=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
|
||||
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
||||
github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ=
|
||||
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.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
|
||||
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc=
|
||||
@ -699,6 +714,7 @@ github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HN
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA=
|
||||
@ -733,6 +749,7 @@ github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eI
|
||||
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
|
||||
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 v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag=
|
||||
@ -760,7 +777,6 @@ github.com/multiformats/go-multibase v0.0.1/go.mod h1:bja2MqRZ3ggyXtZSEDKpl0uO/g
|
||||
github.com/multiformats/go-multihash v0.0.1/go.mod h1:w/5tugSrLEbWqlcgJabL3oHFKTwfvkofsjW2Qa1ct4U=
|
||||
github.com/multiformats/go-multihash v0.0.10 h1:lMoNbh2Ssd9PUF74Nz008KGzGPlfeV6wH3rit5IIGCM=
|
||||
github.com/multiformats/go-multihash v0.0.10/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew=
|
||||
github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
@ -935,6 +951,7 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
||||
github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
||||
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
||||
github.com/rs/cors v1.8.0 h1:P2KMzcFwrPoSjkF1WLRPsp3UMLyql8L4v9hQpVeK5so=
|
||||
github.com/rs/cors v1.8.0/go.mod h1:EBwu+T5AvHOcXwvZIkQFjUN6s8Czyqw12GL/Y0tUyRM=
|
||||
@ -958,10 +975,14 @@ 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 v2.20.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
|
||||
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/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
@ -1024,6 +1045,7 @@ github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/testify v0.0.0-20170130113145-4d4bfba8f1d1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
@ -1083,7 +1105,11 @@ github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs
|
||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
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.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
|
||||
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
|
||||
github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U=
|
||||
github.com/vektah/gqlparser/v2 v2.2.0 h1:bAc3slekAAJW6sZTi07aGq0OrfaCjj4jxARAaC7g2EM=
|
||||
github.com/vektah/gqlparser/v2 v2.2.0/go.mod h1:i3mQIGIrbK2PD1RrCeMTlVbkF2FJ6WkU1KJlJlC+3F4=
|
||||
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
|
||||
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
|
||||
github.com/vmihailenco/msgpack/v5 v5.1.4/go.mod h1:C5gboKD0TJPqWDTVTtrQNfRbiBwHZGo8UTqP/9/XvLI=
|
||||
@ -1169,8 +1195,6 @@ golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWP
|
||||
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/crypto v0.0.0-20210920023735-84f357641f63 h1:kETrAMYZq6WVGPa8IIixL0CaEcIUNi+1WX7grUoi3y8=
|
||||
golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
@ -1309,6 +1333,7 @@ golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||
golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190219092855-153ac476189d/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@ -1406,6 +1431,7 @@ golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba h1:O8mE0/t419eoIwhTFpKVkHiT
|
||||
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/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=
|
||||
@ -1414,6 +1440,7 @@ golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
@ -1557,20 +1584,8 @@ google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6D
|
||||
google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A=
|
||||
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
|
||||
google.golang.org/genproto v0.0.0-20210920155426-26f343e4c215 h1:bdVWLCdfDvdxf+qXZp5iip6vl2zJGgzhkULcsAiBNmE=
|
||||
google.golang.org/genproto v0.0.0-20210920155426-26f343e4c215/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20210921142501-181ce0d877f6 h1:2ncG/LajxmrclaZH+ppVi02rQxz4eXYJzGHdFN4Y9UA=
|
||||
google.golang.org/genproto v0.0.0-20210921142501-181ce0d877f6/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0 h1:5Tbluzus3QxoAJx4IefGt1W0HQZW4nuMrVk684jI74Q=
|
||||
google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20210929214142-896c89f843d2 h1:G7kbolbig6UyfoRItVUeBGV/38VzxjAZYTavVGbYYss=
|
||||
google.golang.org/genproto v0.0.0-20210929214142-896c89f843d2/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20210930144712-2e2e1008e8a3 h1:+F3FcO6LTrzNq5wp1Z6JtoBvnJzX6euyN70FoyMDXy4=
|
||||
google.golang.org/genproto v0.0.0-20210930144712-2e2e1008e8a3/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20211001223012-bfb93cce50d9 h1:eF1wcrhdz56Vugf8qNX5dD93ItkrhothojQyHXqloe0=
|
||||
google.golang.org/genproto v0.0.0-20211001223012-bfb93cce50d9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20211011165927-a5fb3255271e h1:B3r2Cb5u7Od6/WGb95VHDMp99VU/fuqPYZb6VM8IozI=
|
||||
google.golang.org/genproto v0.0.0-20211011165927-a5fb3255271e/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20211005153810-c76a74d43a8e h1:Im71rbA1N3CbIag/PumYhQcNR8bLNmuOtRIyOnnLsT8=
|
||||
google.golang.org/genproto v0.0.0-20211005153810-c76a74d43a8e/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20211013025323-ce878158c4d4 h1:NBxB1XxiWpGqkPUiJ9PoBXkHV5A9+GohMOA+EmWoPbU=
|
||||
google.golang.org/genproto v0.0.0-20211013025323-ce878158c4d4/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o=
|
||||
@ -1655,3 +1670,4 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
|
||||
sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k=
|
||||
|
351
gql/README.md
Normal file
351
gql/README.md
Normal file
@ -0,0 +1,351 @@
|
||||
# Vulcanize dxns gql
|
||||
|
||||
> Browser : http://localhost:9473 for gql
|
||||
|
||||
## Start server
|
||||
|
||||
```shell
|
||||
./build/ethermintd 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: "wrn: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: ["wrn://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:
|
||||
- vulcanize/dxns/*.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"`
|
||||
}
|
335
gql/resolver.go
Normal file
335
gql/resolver.go
Normal file
@ -0,0 +1,335 @@
|
||||
package gql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
auctiontypes "github.com/tharsis/ethermint/x/auction/types"
|
||||
bondtypes "github.com/tharsis/ethermint/x/bond/types"
|
||||
nstypes "github.com/tharsis/ethermint/x/nameservice/types"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// 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.ResolveWrn(context.Background(), &nstypes.QueryResolveWrn{Wrn: name})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
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.LookupWrn(context.Background(), &nstypes.QueryLookupWrn{Wrn: name})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
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{})
|
||||
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, err
|
||||
}
|
||||
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
|
||||
}
|
44
gql/server.go
Normal file
44
gql/server.go
Normal file
@ -0,0 +1,44 @@
|
||||
package gql
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"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"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
99
gql/status.go
Normal file
99
gql/status.go
Normal file
@ -0,0 +1,99 @@
|
||||
package gql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// NodeDataPath is the path to the ethermintd data folder.
|
||||
var NodeDataPath = os.ExpandEnv("$HOME/.ethermintd/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
|
||||
}
|
||||
|
||||
peers := netInfo.Peers
|
||||
peersInfo := make([]*PeerInfo, len(peers))
|
||||
for index, peer := range peers {
|
||||
peersInfo[index] = &PeerInfo{
|
||||
Node: &NodeInfo{
|
||||
ID: string(peer.NodeInfo.ID()),
|
||||
Moniker: peer.NodeInfo.Moniker,
|
||||
Network: peer.NodeInfo.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
|
||||
}
|
267
gql/util.go
Normal file
267
gql/util.go
Normal file
@ -0,0 +1,267 @@
|
||||
package gql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
auctiontypes "github.com/tharsis/ethermint/x/auction/types"
|
||||
bondtypes "github.com/tharsis/ethermint/x/bond/types"
|
||||
nstypes "github.com/tharsis/ethermint/x/nameservice/types"
|
||||
"reflect"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// 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: strconv.FormatInt(coin.Amount.Int64(), 10),
|
||||
}
|
||||
|
||||
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().String(),
|
||||
ExpiryTime: record.GetExpiryTime().String(),
|
||||
Owners: record.GetOwners(),
|
||||
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
|
||||
}
|
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"
|
260
gql/vulcanize/dxns/schema.graphql
Normal file
260
gql/vulcanize/dxns/schema.graphql
Normal file
@ -0,0 +1,260 @@
|
||||
# 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 DXNS 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]
|
||||
}
|
@ -69,3 +69,15 @@ func AddTxFlags(cmd *cobra.Command) *cobra.Command {
|
||||
cmd.MarkFlagRequired(flags.FlagChainID)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package server
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/tharsis/ethermint/gql"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
@ -400,6 +401,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()
|
||||
|
@ -3,6 +3,7 @@
|
||||
## Build the Chain
|
||||
|
||||
The following command builds the Ethermint daemon and places the binary in the `build` directory
|
||||
|
||||
```
|
||||
make build
|
||||
|
||||
@ -35,6 +36,7 @@ The following steps need to be followed only before running the chain for the fi
|
||||
```
|
||||
|
||||
The chain can now be started using:
|
||||
|
||||
```
|
||||
./build/ethermintd start
|
||||
```
|
||||
@ -42,6 +44,7 @@ The chain can now be started using:
|
||||
## Querying the Params
|
||||
|
||||
The following command will dislay the default params for the `auction` module:
|
||||
|
||||
```
|
||||
# ./build/ethermintd q auction params -o json | jq
|
||||
|
||||
|
@ -78,6 +78,27 @@ func (bondID BondID) Generate() string {
|
||||
return hex.EncodeToString(hasher.Sum(nil))
|
||||
}
|
||||
|
||||
// MatchBonds - get all matching bonds.
|
||||
func (k Keeper) MatchBonds(ctx sdk.Context, matchFn func(*types.Bond) bool) []*types.Bond {
|
||||
var bonds []*types.Bond
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, prefixIDToBondIndex)
|
||||
defer itr.Close()
|
||||
for ; itr.Valid(); itr.Next() {
|
||||
bz := store.Get(itr.Key())
|
||||
if bz != nil {
|
||||
var obj types.Bond
|
||||
k.cdc.MustUnmarshal(bz, &obj)
|
||||
if matchFn(&obj) {
|
||||
bonds = append(bonds, &obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bonds
|
||||
}
|
||||
|
||||
// CreateBond creates a new bond.
|
||||
func (k Keeper) CreateBond(ctx sdk.Context, ownerAddress sdk.AccAddress, coins sdk.Coins) (*types.Bond, error) {
|
||||
// Check if account has funds.
|
||||
|
Loading…
Reference in New Issue
Block a user