diff --git a/.gitignore b/.gitignore index 9942d37a..8d7f4f2d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,7 @@ release/ .idea/ .vscode/ .DS_Store -build \ No newline at end of file +build + +#TODO: remove +develop.sh \ No newline at end of file diff --git a/Makefile b/Makefile index 0f2388fe..b95b447c 100644 --- a/Makefile +++ b/Makefile @@ -250,3 +250,12 @@ test-app-benchmark-invariants: @echo "Running simulation invariant benchmarks..." @go test -mod=readonly $(SIMAPP) -benchmem -bench=BenchmarkFullAppSimulation -run=NOOP \ -Enabled=true -NumBlocks=1000 -BlockSize=200 -Period=1 -Commit=true -Seed=57 -v -timeout 24h + +# TODO: remove +start: + ${MAKE} build + ./scripts/single-node.sh + sleep 4 + ./develop.sh + +.PHONY: start \ No newline at end of file diff --git a/app/app.go b/app/app.go index 284b8d9b..3182583b 100644 --- a/app/app.go +++ b/app/app.go @@ -95,12 +95,16 @@ import ( ibcporttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" + ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" "github.com/spf13/cast" "github.com/ojo-network/ojo/util/genmap" "github.com/ojo-network/ojo/x/oracle" oraclekeeper "github.com/ojo-network/ojo/x/oracle/keeper" oracletypes "github.com/ojo-network/ojo/x/oracle/types" + "github.com/ojo-network/ojo/x/relayoracle" + relayoraclekeeper "github.com/ojo-network/ojo/x/relayoracle/keeper" + relayoracletypes "github.com/ojo-network/ojo/x/relayoracle/types" "github.com/ojo-network/ojo/x/airdrop" airdropkeeper "github.com/ojo-network/ojo/x/airdrop/keeper" @@ -156,14 +160,17 @@ var ( transfer.AppModuleBasic{}, vesting.AppModuleBasic{}, oracle.AppModuleBasic{}, + relayoracle.AppModuleBasic{}, airdrop.AppModuleBasic{}, consensus.AppModuleBasic{}, + ibctm.AppModuleBasic{}, ) // module account permissions maccPerms = map[string][]string{ authtypes.FeeCollectorName: nil, distrtypes.ModuleName: nil, + relayoracletypes.ModuleName: nil, minttypes.ModuleName: {authtypes.Minter}, stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, @@ -225,13 +232,15 @@ type App struct { FeeGrantKeeper feegrantkeeper.Keeper GroupKeeper groupkeeper.Keeper OracleKeeper oraclekeeper.Keeper + RelayOracle relayoraclekeeper.Keeper AirdropKeeper airdropkeeper.Keeper ConsensusParamsKeeper consensusparamkeeper.Keeper // make scoped keepers public for test purposes - ScopedIBCKeeper capabilitykeeper.ScopedKeeper - ScopedTransferKeeper capabilitykeeper.ScopedKeeper - ScopedICAHostKeeper capabilitykeeper.ScopedKeeper + ScopedIBCKeeper capabilitykeeper.ScopedKeeper + ScopedTransferKeeper capabilitykeeper.ScopedKeeper + ScopedRelayOracleKeeper capabilitykeeper.ScopedKeeper + ScopedICAHostKeeper capabilitykeeper.ScopedKeeper // mm is the module manager mm *module.Manager @@ -275,6 +284,7 @@ func New( govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, consensusparamtypes.StoreKey, group.StoreKey, oracletypes.StoreKey, airdroptypes.StoreKey, + relayoracletypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -316,6 +326,7 @@ func New( // grant capabilities for the ibc and ibc-transfer modules scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) + scopedRelayOracleKeeper := app.CapabilityKeeper.ScopeToModule(relayoracletypes.ModuleName) // add keepers app.AccountKeeper = authkeeper.NewAccountKeeper( @@ -453,6 +464,18 @@ func New( scopedIBCKeeper, ) + app.RelayOracle = relayoraclekeeper.NewKeeper( + appCodec, + keys[relayoracletypes.ModuleName], + app.GetSubspace(relayoracletypes.ModuleName), + app.OracleKeeper, + app.IBCKeeper.ChannelKeeper, + &app.IBCKeeper.PortKeeper, + scopedRelayOracleKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + relayOracleIBCModule := relayoracle.NewIBCModule(app.RelayOracle) + // Create Transfer Keepers app.TransferKeeper = ibctransferkeeper.NewKeeper( appCodec, @@ -507,6 +530,7 @@ func New( // Create static IBC router, add transfer route, then set and seal it ibcRouter := ibcporttypes.NewRouter() ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule) + ibcRouter.AddRoute(relayoracletypes.ModuleName, relayOracleIBCModule) app.IBCKeeper.SetRouter(ibcRouter) /**** Module Options ****/ @@ -544,6 +568,7 @@ func New( params.NewAppModule(app.ParamsKeeper), transferModule, oracle.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper), + relayoracle.NewAppModule(appCodec, app.RelayOracle), airdrop.NewAppModule(appCodec, app.AirdropKeeper, app.AccountKeeper, app.BankKeeper), consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), ) @@ -575,6 +600,7 @@ func New( vestingtypes.ModuleName, oracletypes.ModuleName, airdroptypes.ModuleName, + relayoracletypes.ModuleName, consensusparamtypes.ModuleName, ) @@ -600,6 +626,7 @@ func New( vestingtypes.ModuleName, oracletypes.ModuleName, airdroptypes.ModuleName, + relayoracletypes.ModuleName, consensusparamtypes.ModuleName, ) @@ -614,7 +641,7 @@ func New( minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, ibctransfertypes.ModuleName, ibcexported.ModuleName, evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, - oracletypes.ModuleName, airdroptypes.ModuleName, consensusparamtypes.ModuleName, + oracletypes.ModuleName, airdroptypes.ModuleName, relayoracletypes.ModuleName, consensusparamtypes.ModuleName, } app.mm.SetOrderInitGenesis(genesisModuleOrder...) app.mm.SetOrderExportGenesis(genesisModuleOrder...) @@ -685,6 +712,7 @@ func New( app.ScopedIBCKeeper = scopedIBCKeeper app.ScopedTransferKeeper = scopedTransferKeeper + app.ScopedRelayOracleKeeper = scopedRelayOracleKeeper return app } @@ -881,6 +909,7 @@ func initParamsKeeper( paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibcexported.ModuleName) paramsKeeper.Subspace(oracletypes.ModuleName) + paramsKeeper.Subspace(relayoracletypes.ModuleName) return paramsKeeper } diff --git a/app/test_helpers.go b/app/test_helpers.go index 7bd2abc9..63e417cc 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -230,9 +230,10 @@ func IntegrationTestNetworkConfig() network.Config { // execute ballot voting and thus clear out previous exchange rates, since we // are not running a price-feeder. oracleGenState.Params.VotePeriod = 1000 - oracleGenState.ExchangeRates = append(oracleGenState.ExchangeRates, sdk.NewDecCoinFromDec( - params.DisplayDenom, sdk.MustNewDecFromStr("34.21"), - )) + + oracleGenState.ExchangeRates = append(oracleGenState.ExchangeRates, *oracletypes.NewPriceStamp( + sdk.MustNewDecFromStr("34.21"), params.DisplayDenom, 0), + ) bz, err := cdc.MarshalJSON(&oracleGenState) if err != nil { diff --git a/client/query/oracle.go b/client/query/oracle.go index f09e2c07..40733dc4 100644 --- a/client/query/oracle.go +++ b/client/query/oracle.go @@ -3,7 +3,6 @@ package query import ( "context" - sdk "github.com/cosmos/cosmos-sdk/types" oracletypes "github.com/ojo-network/ojo/x/oracle/types" ) @@ -26,7 +25,7 @@ func (c *Client) QueryParams() (oracletypes.Params, error) { } // QueryExchangeRates returns the exchange rates from the oracle module -func (c *Client) QueryExchangeRates() ([]sdk.DecCoin, error) { +func (c *Client) QueryExchangeRates() ([]oracletypes.PriceStamp, error) { ctx, cancel := context.WithTimeout(context.Background(), queryTimeout) defer cancel() diff --git a/config.yml b/config.yml index 9ad1d70b..de61e050 100644 --- a/config.yml +++ b/config.yml @@ -5,27 +5,32 @@ build: proto: path: proto third_party_paths: - - third_party/proto - - proto_vendor + - third_party/proto + - proto_vendor accounts: -- name: alice - coins: - - 39000000000000uojo - mnemonic: entry garbage bike poem grunt negative easily annual miss happy license - blur false fringe program picture inner tape dismiss eagle include quality drill - master -- name: bob - coins: - - 5500000000000uojo -- name: faucet - coins: - - 5500000000000uojo + - name: alice + coins: + - 39000000000000uojo + mnemonic: entry garbage bike poem grunt negative easily annual miss happy license + blur false fringe program picture inner tape dismiss eagle include quality drill + master + - name: bob + coins: + - 5500000000000uojo + - name: relayer + coins: + - 39000000000000uojo + mnemonic: pony glide frown crisp unfold lawn cup loan trial govern usual matrix theory + wash fresh address pioneer between meadow visa buffalo keep gallery swear + - name: faucet + coins: + - 5500000000000uojo faucet: name: faucet coins: - - 5500000000000uojo + - 5500000000000uojo coins_max: - - 1000000000uojo + - 1000000000uojo host: 0.0.0.0:4500 port: 4500 genesis: @@ -35,5 +40,10 @@ genesis: bond_denom: uojo chain_id: ojo-testnet validators: -- name: alice - bonded: 33500000000000uojo + - name: alice + bonded: 33500000000000uojo + app: + grpc: + address: :9093 + grpc-web: + address: :9094 diff --git a/go.mod b/go.mod index 2fb0d003..5a752051 100644 --- a/go.mod +++ b/go.mod @@ -20,6 +20,7 @@ require ( github.com/golangci/golangci-lint v1.54.2 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 + github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 github.com/mgechev/revive v1.3.3 github.com/ory/dockertest/v3 v3.10.0 github.com/rs/zerolog v1.30.0 @@ -27,8 +28,9 @@ require ( github.com/spf13/cobra v1.7.0 github.com/spf13/viper v1.16.0 github.com/stretchr/testify v1.8.4 - google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 + google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d google.golang.org/grpc v1.58.0 + gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 mvdan.cc/gofumpt v0.5.0 ) @@ -36,8 +38,8 @@ require ( require ( 4d63.com/gocheckcompilerdirectives v1.2.1 // indirect 4d63.com/gochecknoglobals v0.2.1 // indirect - cloud.google.com/go v0.110.4 // indirect - cloud.google.com/go/compute v1.21.0 // indirect + cloud.google.com/go v0.110.6 // indirect + cloud.google.com/go/compute v1.23.0 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect cloud.google.com/go/iam v1.1.1 // indirect cloud.google.com/go/storage v1.30.1 // indirect @@ -119,6 +121,7 @@ require ( github.com/firefart/nonamedreturns v1.0.4 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect + github.com/ghodss/yaml v1.0.0 // indirect github.com/go-critic/go-critic v0.9.0 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect @@ -300,25 +303,24 @@ require ( go.uber.org/goleak v1.1.12 // indirect go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.12.0 // indirect + golang.org/x/crypto v0.13.0 // indirect golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 // indirect golang.org/x/mod v0.12.0 // indirect - golang.org/x/net v0.14.0 // indirect - golang.org/x/oauth2 v0.10.0 // indirect + golang.org/x/net v0.15.0 // indirect + golang.org/x/oauth2 v0.12.0 // indirect golang.org/x/sync v0.3.0 // indirect - golang.org/x/sys v0.11.0 // indirect - golang.org/x/term v0.11.0 // indirect - golang.org/x/text v0.12.0 // indirect + golang.org/x/sys v0.12.0 // indirect + golang.org/x/term v0.12.0 // indirect + golang.org/x/text v0.13.0 // indirect golang.org/x/tools v0.12.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.126.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect honnef.co/go/tools v0.4.5 // indirect mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed // indirect mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect diff --git a/go.sum b/go.sum index cec85416..a933a43c 100644 --- a/go.sum +++ b/go.sum @@ -38,8 +38,8 @@ cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w9 cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU= cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRYtA= -cloud.google.com/go v0.110.4 h1:1JYyxKMN9hd5dR2MYTPWkGUgcoxVVhg0LKNKEo0qvmk= -cloud.google.com/go v0.110.4/go.mod h1:+EYjdK8e5RME/VY/qLCAtuyALQ9q67dvuum8i+H5xsI= +cloud.google.com/go v0.110.6 h1:8uYAkj3YHTP/1iwReuHPxLSbdcyc+dSBbzFMrVwDR6Q= +cloud.google.com/go v0.110.6/go.mod h1:+EYjdK8e5RME/VY/qLCAtuyALQ9q67dvuum8i+H5xsI= cloud.google.com/go/aiplatform v1.22.0/go.mod h1:ig5Nct50bZlzV6NvKaTwmplLLddFx0YReh9WfTO5jKw= cloud.google.com/go/aiplatform v1.24.0/go.mod h1:67UUvRBKG6GTayHKV8DBv2RtR1t93YRu5B1P3x99mYY= cloud.google.com/go/analytics v0.11.0/go.mod h1:DjEWCu41bVbYcKyvlws9Er60YE4a//bK6mnhWvQeFNI= @@ -77,8 +77,8 @@ cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= cloud.google.com/go/compute v1.10.0/go.mod h1:ER5CLbMxl90o2jtNbGSbtfOpQKR0t15FOtRsugnLrlU= -cloud.google.com/go/compute v1.21.0 h1:JNBsyXVoOoNJtTQcnEY5uYpZIbeCTYIeDe0Xh1bySMk= -cloud.google.com/go/compute v1.21.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= +cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY= +cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/containeranalysis v0.5.1/go.mod h1:1D92jd8gRR/c0fGMlymRgxWD3Qw9C1ff6/T7mLgVL8I= @@ -579,6 +579,7 @@ github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlya github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= @@ -842,6 +843,8 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgf github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 h1:RtRsiaGvWxcwd8y3BiRZxsylPT8hLWZ5SPcfI+3IDNk= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0/go.mod h1:TzP6duP4Py2pHLVPPQp42aoYI92+PCrVotyR5e8Vqlk= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= @@ -1548,8 +1551,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= -golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= +golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= +golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1674,8 +1677,8 @@ golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= -golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1701,8 +1704,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8= -golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI= +golang.org/x/oauth2 v0.12.0 h1:smVPGxink+n1ZI5pkQa8y6fZT0RW0MgCO5bFpepy4B4= +golang.org/x/oauth2 v0.12.0/go.mod h1:A74bZ3aGXgCY0qaIC9Ahg6Lglin4AMAco8cIv9baba4= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1841,8 +1844,8 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1850,8 +1853,8 @@ golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= -golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= +golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= +golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1865,8 +1868,8 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -2142,12 +2145,12 @@ google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e/go.mod h1:3526vdqw google.golang.org/genproto v0.0.0-20221014173430-6e2ab493f96b/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= -google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 h1:Z0hjGZePRE0ZBWotvtrwxFNrNE9CUAGtplaDK5NNI/g= -google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98/go.mod h1:S7mY02OqCJTD0E1OiQy1F72PWFB4bZJ87cAtLPYgDR0= -google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 h1:FmF5cCW94Ij59cfpoLiwTgodWmm60eEV0CjlsVg2fuw= -google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= +google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 h1:L6iMMGrtzgHsWofoFcihmDEMYeDR9KN/ThbPWGrh++g= +google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5/go.mod h1:oH/ZOT02u4kWEp7oYBGYFFkCdKS/uYR9Z7+0/xuuFp8= +google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d h1:DoPTO70H+bcDXcd39vOqb2viZxgqeBeSGtZ55yZU4/Q= +google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= diff --git a/proto/ojo/oracle/v1/events.proto b/proto/ojo/oracle/v1/events.proto index e286f63e..dd1379fc 100644 --- a/proto/ojo/oracle/v1/events.proto +++ b/proto/ojo/oracle/v1/events.proto @@ -26,4 +26,7 @@ message EventSetFxRate { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; + + // block num on which exchange rate was updated + uint64 block_num = 3; } diff --git a/proto/ojo/oracle/v1/genesis.proto b/proto/ojo/oracle/v1/genesis.proto index f1a18c0a..c132460f 100644 --- a/proto/ojo/oracle/v1/genesis.proto +++ b/proto/ojo/oracle/v1/genesis.proto @@ -14,10 +14,7 @@ message GenesisState { Params params = 1 [ (gogoproto.nullable) = false ]; repeated FeederDelegation feeder_delegations = 2 [ (gogoproto.nullable) = false ]; - repeated cosmos.base.v1beta1.DecCoin exchange_rates = 3 [ - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", - (gogoproto.nullable) = false - ]; + repeated PriceStamp exchange_rates = 3 [ (gogoproto.nullable) = false ]; repeated MissCounter miss_counters = 4 [ (gogoproto.nullable) = false ]; repeated AggregateExchangeRatePrevote aggregate_exchange_rate_prevotes = 5 [ (gogoproto.nullable) = false ]; diff --git a/proto/ojo/oracle/v1/query.proto b/proto/ojo/oracle/v1/query.proto index 061770b6..c70b7c6e 100644 --- a/proto/ojo/oracle/v1/query.proto +++ b/proto/ojo/oracle/v1/query.proto @@ -114,10 +114,7 @@ message QueryExchangeRates { message QueryExchangeRatesResponse { // exchange_rates defines a list of the exchange rate for all whitelisted // denoms. - repeated cosmos.base.v1beta1.DecCoin exchange_rates = 1 [ - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", - (gogoproto.nullable) = false - ]; + repeated PriceStamp exchange_rates = 1 [(gogoproto.nullable) = false]; } // QueryActiveExchangeRates is the request type for the diff --git a/proto/ojo/relayoracle/v1/events.proto b/proto/ojo/relayoracle/v1/events.proto new file mode 100644 index 00000000..430e6e32 --- /dev/null +++ b/proto/ojo/relayoracle/v1/events.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package ojo.relayoracle.v1; + +import "ojo/relayoracle/v1/packet.proto"; + +option go_package = "github.com/ojo-network/ojo/x/relayoracle/types"; + +message EventNewRequest{ + string client_id = 1; + uint64 request_id = 2; + uint64 request_height = 3; +} + +message EventRequestResolve{ + uint64 request_id = 1; + ResolveStatus status = 2; +} + +message EventPackedSendFailed{ + string error = 1; +} \ No newline at end of file diff --git a/proto/ojo/relayoracle/v1/genesis.proto b/proto/ojo/relayoracle/v1/genesis.proto new file mode 100644 index 00000000..bce750a0 --- /dev/null +++ b/proto/ojo/relayoracle/v1/genesis.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +package ojo.relayoracle.v1; + +import "gogoproto/gogo.proto"; +import "ojo/relayoracle/v1/params.proto"; +import "ojo/relayoracle/v1/oracle.proto"; + +option go_package = "github.com/ojo-network/ojo/x/relayoracle/types"; + +// GenesisState defines the relayoracle module's genesis state. +message GenesisState { + Params params = 1 [(gogoproto.nullable) = false]; + string port_id = 2; + repeated Request requests = 3 [(gogoproto.nullable) = false]; + repeated Result results = 4 [(gogoproto.nullable) = false]; + repeated uint64 pending_request_ids = 5; +} \ No newline at end of file diff --git a/proto/ojo/relayoracle/v1/oracle.proto b/proto/ojo/relayoracle/v1/oracle.proto new file mode 100644 index 00000000..e8b42adf --- /dev/null +++ b/proto/ojo/relayoracle/v1/oracle.proto @@ -0,0 +1,39 @@ +syntax = "proto3"; +package ojo.relayoracle.v1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "ojo/relayoracle/v1/packet.proto"; + +option go_package = "github.com/ojo-network/ojo/x/relayoracle/types"; + +message Request{ + // TODO: should extract out request id + uint64 request_id = 1 [(gogoproto.customname) = "RequestID"]; + bytes request_calldata = 2 [(gogoproto.customname) = "RequestCallData"]; + string client_id = 3 [(gogoproto.customname) = "ClientID"]; + int64 request_height = 4; + int64 request_time = 5; + IBCChannel ibc_channel = 6 [(gogoproto.customname) = "IBCChannel"]; +} + +message Result{ + // TODO: should extract out request id? + uint64 request_id = 1 [(gogoproto.customname) = "RequestID"]; + bytes request_calldata = 2 [(gogoproto.customname) = "RequestCallData"]; + string client_id = 3 [(gogoproto.customname) = "ClientID"]; + int64 request_height = 4; + int64 request_time = 5; + ResolveStatus status =6 ; + bytes result = 7; +} + +message IBCChannel { + option (gogoproto.equal) = true; + string channel_id = 1; + string port_id = 2; +} + +message PendingRequestList{ + repeated uint64 request_ids = 1; +} diff --git a/proto/ojo/relayoracle/v1/packet.proto b/proto/ojo/relayoracle/v1/packet.proto new file mode 100644 index 00000000..6b340092 --- /dev/null +++ b/proto/ojo/relayoracle/v1/packet.proto @@ -0,0 +1,58 @@ +syntax = "proto3"; +package ojo.relayoracle.v1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/ojo-network/ojo/x/relayoracle/types"; + +message OracleRequestPacketData { + option (gogoproto.equal) = true; + string client_id = 1 [(gogoproto.customname) = "ClientID"]; + bytes calldata = 3; +} + +message OracleResponsePacketData { + option (gogoproto.equal) = true; + string client_id = 1 [(gogoproto.customname) = "ClientID"]; + uint64 request_id = 2 [(gogoproto.customname) = "RequestID"]; + int64 request_time = 3; + int64 resolve_time = 4; + ResolveStatus resolve_status = 5; + bytes result = 6; +} + +enum ResolveStatus { + option (gogoproto.goproto_enum_prefix) = false; + RESOLVE_STATUS_OPEN_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "RESOLVE_STATUS_OPEN"]; + RESOLVE_STATUS_SUCCESS = 1 [(gogoproto.enumvalue_customname) = "RESOLVE_STATUS_SUCCESS"]; + RESOLVE_STATUS_FAILURE = 2 [(gogoproto.enumvalue_customname) = "RESOLVE_STATUS_FAILURE"]; + RESOLVE_STATUS_EXPIRED = 3 [(gogoproto.enumvalue_customname) = "RESOLVE_STATUS_EXPIRED"]; +} + +message RequestPrice{ + repeated string denoms = 1; + PriceRequestType request= 2; +} + +enum PriceRequestType{ + option (gogoproto.goproto_enum_prefix) = false; + PRICE_REQUEST_RATE = 0 [(gogoproto.enumvalue_customname) = "PRICE_REQUEST_RATE"]; + PRICE_REQUEST_MEDIAN = 1 [(gogoproto.enumvalue_customname) = "PRICE_REQUEST_MEDIAN"]; + PRICE_REQUEST_DEVIATION = 2 [(gogoproto.enumvalue_customname) = "PRICE_REQUEST_DEVIATION"]; +} + +message OracleRequestResult { + repeated OracleData price_data=1 [(gogoproto.nullable) = false]; +} + +message OracleData { + repeated cosmos.base.v1beta1.DecCoin exchange_rate = 2 [(gogoproto.nullable) = false]; + repeated uint64 block_num = 3; +} + +message OracleRequestPacketAcknowledgement { + option (gogoproto.equal) = true; + uint64 request_id = 1 [(gogoproto.customname) = "RequestID"]; + bytes data = 2; +} diff --git a/proto/ojo/relayoracle/v1/params.proto b/proto/ojo/relayoracle/v1/params.proto new file mode 100644 index 00000000..dd0d9935 --- /dev/null +++ b/proto/ojo/relayoracle/v1/params.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package ojo.relayoracle.v1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/ojo-network/ojo/x/relayoracle/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; + option (gogoproto.equal) = true; + + bool IbcRequestEnabled =1; + uint64 PacketTimeout = 2; + uint64 MaxAllowedDenomsHistoricalQuery = 3; + uint64 MaxAllowedDenomsExchangeQuery = 4; +} diff --git a/proto/ojo/relayoracle/v1/tx.proto b/proto/ojo/relayoracle/v1/tx.proto new file mode 100644 index 00000000..9ca39799 --- /dev/null +++ b/proto/ojo/relayoracle/v1/tx.proto @@ -0,0 +1,35 @@ +syntax = "proto3"; +package ojo.relayoracle.v1; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/msg/v1/msg.proto"; +import "ojo/relayoracle/v1/params.proto"; + +option go_package = "github.com/ojo-network/ojo/x/relayoracle/types"; + + +// Msg defines the Msg service. +service Msg { + rpc GovUpdateParams(MsgGovUpdateParams) + returns (MsgGovUpdateParamsResponse); +} + + +// MsgGovUpdateParams defines the Msg/GovUpdateParams request type. +message MsgGovUpdateParams { + option (gogoproto.equal) = true; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + option (cosmos.msg.v1.signer) = "authority"; + + // authority is the address of the governance account. + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string title = 2; + string description = 3; + repeated string keys = 4; + Params changes = 5 [ (gogoproto.nullable) = false ]; +} + +// MsgGovUpdateParamsResponse defines the Msg/GovUpdateParams response type. +message MsgGovUpdateParamsResponse {} diff --git a/scripts/single-node.sh b/scripts/single-node.sh index 911fef6d..323ef200 100755 --- a/scripts/single-node.sh +++ b/scripts/single-node.sh @@ -17,7 +17,7 @@ CWD="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" NODE_BIN="${1:-$CWD/../build/ojod}" # These options can be overridden by env -CHAIN_ID="${CHAIN_ID:-ojotest-1}" +CHAIN_ID="${CHAIN_ID:-ojo-testnet}" CHAIN_DIR="${CHAIN_DIR:-$CWD/node-data}" DENOM="${DENOM:-uojo}" STAKE_DENOM="${STAKE_DENOM:-$DENOM}" @@ -88,11 +88,11 @@ if [[ ! -d "$hdir" ]]; then # Build genesis file and create accounts if [[ "$STAKE_DENOM" != "$DENOM" ]]; then - coins="1000000$SCALE_FACTOR$STAKE_DENOM,1000000$SCALE_FACTOR$DENOM" + coins="1000000000000000000$SCALE_FACTOR$STAKE_DENOM,1000000000000000000$SCALE_FACTOR$DENOM" else - coins="1000000$SCALE_FACTOR$DENOM" + coins="1000000000000000000$SCALE_FACTOR$DENOM" fi - coins_user="1000000$SCALE_FACTOR$DENOM" + coins_user="1000000000000000000$SCALE_FACTOR$DENOM" echo "--- Initializing home..." @@ -177,7 +177,7 @@ echo echo "Command Line Access:" echo " * $NODE_BIN --home $hdir status" -$NODE_BIN $home0 start --api.enable true --grpc.address="0.0.0.0:9090" --grpc-web.enable=false --log_level trace > $log_path 2>&1 & +$NODE_BIN $home0 start --grpc.address="0.0.0.0:9090" --p2p.laddr "tcp://0.0.0.0:26679" --rpc.laddr "tcp://127.0.0.1:26657" --grpc-web.enable=false --log_level trace > $log_path 2>&1 & # Adds 1 sec to create the log and makes it easier to debug it on CI sleep 1 diff --git a/tests/grpc/historical.go b/tests/grpc/historical.go index 63f719cf..c2dff9bb 100644 --- a/tests/grpc/historical.go +++ b/tests/grpc/historical.go @@ -6,9 +6,10 @@ import ( "strings" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/rs/zerolog" + "github.com/ojo-network/ojo/client" "github.com/ojo-network/ojo/x/oracle/types" - "github.com/rs/zerolog" ) // MedianCheck waits for availability of all exchange rates from the denom accept list, @@ -29,11 +30,11 @@ func MedianCheck(val1Client *client.OjoClient) error { return err } - var exchangeRates sdk.DecCoins + var exchangeRates types.PriceStamps var missingDenoms []string for i := 0; i < 40; i++ { exchangeRates, err = val1Client.QueryClient.QueryExchangeRates() - missingDenoms = findMissingDenoms(exchangeRates, params.MandatoryList) + missingDenoms = findMissingDenoms(exchangeRates.ExchangeRates(), params.MandatoryList) if err == nil && len(missingDenoms) == 0 { break } diff --git a/tests/grpc/price_listener.go b/tests/grpc/price_listener.go index 4085f98b..3590f511 100644 --- a/tests/grpc/price_listener.go +++ b/tests/grpc/price_listener.go @@ -3,9 +3,10 @@ package grpc import ( "fmt" + "github.com/rs/zerolog/log" + "github.com/ojo-network/ojo/client" oracletypes "github.com/ojo-network/ojo/x/oracle/types" - "github.com/rs/zerolog/log" ) // listenFofPrices listens for price updates at the correct blocks based @@ -29,13 +30,13 @@ func listenForPrices( for i := 0; i < int(params.MedianStampPeriod); i++ { height := <-chainHeight.HeightChanged if isPeriodFirstBlock(height, params.HistoricStampPeriod) { - exchangeRates, err := ojoClient.QueryClient.QueryExchangeRates() - log.Info().Msgf("block %d stamp: %+v", height, exchangeRates) + priceStamps, err := ojoClient.QueryClient.QueryExchangeRates() + log.Info().Msgf("block %d stamp: %+v", height, priceStamps) if err != nil { return nil, err } - for _, rate := range exchangeRates { - priceStore.addStamp(rate.Denom, rate.Amount) + for _, priceStamp := range priceStamps { + priceStore.addStamp(priceStamp.ExchangeRate.Denom, priceStamp.ExchangeRate.Amount) } } } diff --git a/tools/tools.go b/tools/tools.go index ed7e85ad..d07d4264 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -1,14 +1,14 @@ //go:build tools -// +build tools -// This file uses the recommended method for tracking developer tools in a Go -// module. -// -// REF: https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module package tools import ( + _ "github.com/cosmos/gogoproto/protoc-gen-gocosmos" + _ "github.com/golang/protobuf/protoc-gen-go" _ "github.com/golangci/golangci-lint/cmd/golangci-lint" + _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway" + _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger" + _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2" _ "github.com/mgechev/revive" _ "mvdan.cc/gofumpt" ) diff --git a/x/oracle/abci_test.go b/x/oracle/abci_test.go index 0b3989c7..bd9b39cb 100644 --- a/x/oracle/abci_test.go +++ b/x/oracle/abci_test.go @@ -170,7 +170,7 @@ func (s *IntegrationTestSuite) TestEndBlockerVoteThreshold() { for _, denom := range app.OracleKeeper.AcceptList(ctx) { rate, err := app.OracleKeeper.GetExchangeRate(ctx, denom.SymbolDenom) s.Require().NoError(err) - s.Require().Equal(sdk.MustNewDecFromStr("1.0"), rate) + s.Require().Equal(sdk.MustNewDecFromStr("1.0"), rate.ExchangeRate.Amount) } // Test: only val2 votes (has 39% vote power). @@ -190,7 +190,7 @@ func (s *IntegrationTestSuite) TestEndBlockerVoteThreshold() { for _, denom := range app.OracleKeeper.AcceptList(ctx) { rate, err := app.OracleKeeper.GetExchangeRate(ctx, denom.SymbolDenom) s.Require().ErrorIs(err, types.ErrUnknownDenom.Wrap(denom.SymbolDenom)) - s.Require().Equal(sdk.ZeroDec(), rate) + s.Require().Nil(rate.ExchangeRate) } // Test: val2 and val3 votes. @@ -212,7 +212,7 @@ func (s *IntegrationTestSuite) TestEndBlockerVoteThreshold() { for _, denom := range app.OracleKeeper.AcceptList(ctx) { rate, err := app.OracleKeeper.GetExchangeRate(ctx, denom.SymbolDenom) s.Require().NoError(err) - s.Require().Equal(sdk.MustNewDecFromStr("0.5"), rate) + s.Require().Equal(sdk.MustNewDecFromStr("0.5"), rate.ExchangeRate.Amount) } // Test: val1 and val2 vote again @@ -240,10 +240,10 @@ func (s *IntegrationTestSuite) TestEndBlockerVoteThreshold() { rate, err := app.OracleKeeper.GetExchangeRate(ctx, "ojo") s.Require().NoError(err) - s.Require().Equal(sdk.MustNewDecFromStr("1.0"), rate) + s.Require().Equal(sdk.MustNewDecFromStr("1.0"), rate.ExchangeRate.Amount) rate, err = app.OracleKeeper.GetExchangeRate(ctx, "atom") s.Require().ErrorIs(err, types.ErrUnknownDenom.Wrap("atom")) - s.Require().Equal(sdk.ZeroDec(), rate) + s.Require().Nil(rate.ExchangeRate) } func (s *IntegrationTestSuite) TestEndBlockerValidatorRewards() { diff --git a/x/oracle/client/tests/suite.go b/x/oracle/client/tests/suite.go index cac3de0a..2c7df335 100644 --- a/x/oracle/client/tests/suite.go +++ b/x/oracle/client/tests/suite.go @@ -176,8 +176,8 @@ func (s *IntegrationTestSuite) TestQueryExchangeRates() { s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) s.Require().Len(res.ExchangeRates, 1) - s.Require().Equal(res.ExchangeRates[0].Denom, appparams.DisplayDenom) - s.Require().False(res.ExchangeRates[0].Amount.IsZero()) + s.Require().Equal(res.ExchangeRates[0].ExchangeRate.Denom, appparams.DisplayDenom) + s.Require().False(res.ExchangeRates[0].ExchangeRate.Amount.IsZero()) } func (s *IntegrationTestSuite) TestQueryParams() { diff --git a/x/oracle/genesis.go b/x/oracle/genesis.go index 3fd4dc48..7d46b327 100644 --- a/x/oracle/genesis.go +++ b/x/oracle/genesis.go @@ -27,7 +27,7 @@ func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, genState types.GenesisSt } for _, ex := range genState.ExchangeRates { - keeper.SetExchangeRate(ctx, ex.Denom, ex.Amount) + keeper.SetExchangeRate(ctx, ex) } for _, mc := range genState.MissCounters { @@ -97,12 +97,9 @@ func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { return false }) - exchangeRates := sdk.DecCoins{} - keeper.IterateExchangeRates(ctx, func(denom string, rate sdk.Dec) (stop bool) { - exchangeRates = append(exchangeRates, sdk.DecCoin{ - Denom: denom, - Amount: rate, - }) + exchangeRates := []types.PriceStamp{} + keeper.IterateExchangeRates(ctx, func(denom string, priceStamp types.PriceStamp) (stop bool) { + exchangeRates = append(exchangeRates, priceStamp) return false }) diff --git a/x/oracle/keeper/ballot_test.go b/x/oracle/keeper/ballot_test.go index a80dbc9e..10f13371 100644 --- a/x/oracle/keeper/ballot_test.go +++ b/x/oracle/keeper/ballot_test.go @@ -8,7 +8,7 @@ import ( func (s *IntegrationTestSuite) TestBallot_OrganizeBallotByDenom() { require := s.Require() - s.app.OracleKeeper.SetExchangeRate(s.ctx, displayDenom, sdk.OneDec()) + s.app.OracleKeeper.SetExchangeRate(s.ctx, *types.NewPriceStamp(sdk.OneDec(), displayDenom, 0)) claimMap := make(map[string]types.Claim) // Empty Map diff --git a/x/oracle/keeper/grpc_query.go b/x/oracle/keeper/grpc_query.go index f6f429e3..9017a130 100644 --- a/x/oracle/keeper/grpc_query.go +++ b/x/oracle/keeper/grpc_query.go @@ -50,23 +50,22 @@ func (q querier) ExchangeRates( ctx := sdk.UnwrapSDKContext(goCtx) - var exchangeRates sdk.DecCoins - + priceStamps := types.PriceStamps{} if len(req.Denom) > 0 { - exchangeRate, err := q.GetExchangeRate(ctx, req.Denom) + priceStamp, err := q.GetExchangeRate(ctx, req.Denom) if err != nil { return nil, err } - exchangeRates = exchangeRates.Add(sdk.NewDecCoinFromDec(req.Denom, exchangeRate)) + priceStamps = append(priceStamps, priceStamp) } else { - q.IterateExchangeRates(ctx, func(denom string, rate sdk.Dec) (stop bool) { - exchangeRates = exchangeRates.Add(sdk.NewDecCoinFromDec(denom, rate)) + q.IterateExchangeRates(ctx, func(denom string, priceStamp types.PriceStamp) (stop bool) { + priceStamps = append(priceStamps, priceStamp) return false }) } - return &types.QueryExchangeRatesResponse{ExchangeRates: exchangeRates}, nil + return &types.QueryExchangeRatesResponse{ExchangeRates: priceStamps}, nil } // ActiveExchangeRates queries all denoms for which exchange rates exist. @@ -81,8 +80,8 @@ func (q querier) ActiveExchangeRates( ctx := sdk.UnwrapSDKContext(goCtx) denoms := []string{} - q.IterateExchangeRates(ctx, func(denom string, _ sdk.Dec) (stop bool) { - denoms = append(denoms, denom) + q.IterateExchangeRates(ctx, func(denom string, priceStamp types.PriceStamp) (stop bool) { + denoms = append(denoms, priceStamp.ExchangeRate.Denom) return false }) diff --git a/x/oracle/keeper/grpc_query_test.go b/x/oracle/keeper/grpc_query_test.go index c1100b7d..489a630b 100644 --- a/x/oracle/keeper/grpc_query_test.go +++ b/x/oracle/keeper/grpc_query_test.go @@ -12,19 +12,19 @@ import ( ) func (s *IntegrationTestSuite) TestQuerier_ActiveExchangeRates() { - s.app.OracleKeeper.SetExchangeRate(s.ctx, displayDenom, sdk.OneDec()) + s.app.OracleKeeper.SetExchangeRate(s.ctx, *types.NewPriceStamp(sdk.OneDec(), displayDenom, 0)) res, err := s.queryClient.ActiveExchangeRates(s.ctx.Context(), &types.QueryActiveExchangeRates{}) s.Require().NoError(err) s.Require().Equal([]string{displayDenom}, res.ActiveRates) } func (s *IntegrationTestSuite) TestQuerier_ExchangeRates() { - s.app.OracleKeeper.SetExchangeRate(s.ctx, displayDenom, sdk.OneDec()) + s.app.OracleKeeper.SetExchangeRate(s.ctx, *types.NewPriceStamp(sdk.OneDec(), displayDenom, 0)) res, err := s.queryClient.ExchangeRates(s.ctx.Context(), &types.QueryExchangeRates{}) s.Require().NoError(err) s.Require().Equal(sdk.DecCoins{ sdk.NewDecCoinFromDec(displayDenom, sdk.OneDec()), - }, res.ExchangeRates) + }, types.PriceStamps(res.ExchangeRates).ExchangeRates()) res, err = s.queryClient.ExchangeRates(s.ctx.Context(), &types.QueryExchangeRates{ Denom: displayDenom, @@ -32,7 +32,7 @@ func (s *IntegrationTestSuite) TestQuerier_ExchangeRates() { s.Require().NoError(err) s.Require().Equal(sdk.DecCoins{ sdk.NewDecCoinFromDec(displayDenom, sdk.OneDec()), - }, res.ExchangeRates) + }, types.PriceStamps(res.ExchangeRates).ExchangeRates()) } func (s *IntegrationTestSuite) TestQuerier_FeeederDelegation() { @@ -194,7 +194,7 @@ func (s *IntegrationTestSuite) TestQuerier_AggregatePrevotesAppendVotes() { func (s *IntegrationTestSuite) TestQuerier_AggregateVotesAppendVotes() { s.app.OracleKeeper.SetAggregateExchangeRateVote(s.ctx, valAddr, types.NewAggregateExchangeRateVote( - types.DefaultGenesisState().ExchangeRates, + types.PriceStamps(types.DefaultGenesisState().ExchangeRates).ExchangeRates(), valAddr, )) diff --git a/x/oracle/keeper/historic_price.go b/x/oracle/keeper/historic_price.go index 628f4a73..af7609c1 100644 --- a/x/oracle/keeper/historic_price.go +++ b/x/oracle/keeper/historic_price.go @@ -363,3 +363,43 @@ func (k Keeper) PruneMedianDeviationsBeforeBlock(ctx sdk.Context, blockNum uint6 return false }) } + +func (k Keeper) IterateHistoricPricesForDenoms( + ctx sdk.Context, + prefix []byte, + denoms []string, + numStamps uint, +) types.PriceStamps { + store := ctx.KVStore(k.storeKey) + prices := types.PriceStamps{} + // make sure we have one zero byte to correctly separate denoms + for _, denom := range denoms { + prefix := util.ConcatBytes(1, prefix, []byte(denom)) + iter := sdk.KVStoreReversePrefixIteratorPaginated(store, prefix, 1, numStamps) + defer iter.Close() + + for ; iter.Valid(); iter.Next() { + denom, block := types.ParseDenomAndBlockFromKey(iter.Key(), types.KeyPrefixMedian) + decProto := sdk.DecProto{} + k.cdc.MustUnmarshal(iter.Value(), &decProto) + price := types.NewPriceStamp(decProto.Dec, denom, block) + prices = append(prices, *price) + } + } + + return prices +} + +func (k Keeper) HasActiveHistoricalRates(ctx sdk.Context, denoms []string) (bool, error) { + store := ctx.KVStore(k.storeKey) + blockHeight := uint64(ctx.BlockHeight()) + for _, denom := range denoms { + // last updated block height for historic price update + found := store.Has(types.KeyHistoricPrice(denom, blockHeight-blockHeight%k.GetParams(ctx).HistoricStampPeriod)) + if !found { + return false, types.ErrUnknownDenom.Wrap(denom) + } + } + + return true, nil +} diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index 6cc0bafb..390a98ab 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -79,18 +79,18 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // GetExchangeRate gets the consensus exchange rate of USD denominated in the // denom asset from the store. -func (k Keeper) GetExchangeRate(ctx sdk.Context, symbol string) (sdk.Dec, error) { +func (k Keeper) GetExchangeRate(ctx sdk.Context, symbol string) (types.PriceStamp, error) { store := ctx.KVStore(k.storeKey) symbol = strings.ToUpper(symbol) b := store.Get(types.GetExchangeRateKey(symbol)) if b == nil { - return sdk.ZeroDec(), types.ErrUnknownDenom.Wrap(symbol) + return types.PriceStamp{}, types.ErrUnknownDenom.Wrap(symbol) } - decProto := sdk.DecProto{} - k.cdc.MustUnmarshal(b, &decProto) + priceStamp := types.PriceStamp{} + k.cdc.MustUnmarshal(b, &priceStamp) - return decProto.Dec, nil + return priceStamp, nil } // GetExchangeRateBase gets the consensus exchange rate of an asset @@ -111,36 +111,38 @@ func (k Keeper) GetExchangeRateBase(ctx sdk.Context, denom string) (sdk.Dec, err return sdk.ZeroDec(), types.ErrUnknownDenom.Wrap(denom) } - exchangeRate, err := k.GetExchangeRate(ctx, symbol) + priceStamp, err := k.GetExchangeRate(ctx, symbol) if err != nil { return sdk.ZeroDec(), err } powerReduction := ten.Power(exponent) - return exchangeRate.Quo(powerReduction), nil + return priceStamp.ExchangeRate.Amount.Quo(powerReduction), nil } // SetExchangeRate sets the consensus exchange rate of USD denominated in the // denom asset to the store. -func (k Keeper) SetExchangeRate(ctx sdk.Context, denom string, exchangeRate sdk.Dec) { +func (k Keeper) SetExchangeRate(ctx sdk.Context, priceStamp types.PriceStamp) { store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshal(&sdk.DecProto{Dec: exchangeRate}) - denom = strings.ToUpper(denom) - store.Set(types.GetExchangeRateKey(denom), bz) - go metrics.RecordExchangeRate(denom, exchangeRate) + priceStamp.ExchangeRate.Denom = strings.ToUpper(priceStamp.ExchangeRate.Denom) + bz := k.cdc.MustMarshal(&priceStamp) + + store.Set(types.GetExchangeRateKey(priceStamp.ExchangeRate.Denom), bz) + go metrics.RecordExchangeRate(priceStamp.ExchangeRate.Denom, priceStamp.ExchangeRate.Amount) } // SetExchangeRateWithEvent sets an consensus // exchange rate to the store with ABCI event func (k Keeper) SetExchangeRateWithEvent(ctx sdk.Context, denom string, exchangeRate sdk.Dec) error { - k.SetExchangeRate(ctx, denom, exchangeRate) + blockNum := uint64(ctx.BlockHeight()) + k.SetExchangeRate(ctx, *types.NewPriceStamp(exchangeRate, denom, blockNum)) return ctx.EventManager().EmitTypedEvent(&types.EventSetFxRate{ - Denom: denom, Rate: exchangeRate, + Denom: denom, Rate: exchangeRate, BlockNum: blockNum, }) } // IterateExchangeRates iterates over USD rates in the store. -func (k Keeper) IterateExchangeRates(ctx sdk.Context, handler func(string, sdk.Dec) bool) { +func (k Keeper) IterateExchangeRates(ctx sdk.Context, handler func(string, types.PriceStamp) bool) { store := ctx.KVStore(k.storeKey) iter := sdk.KVStorePrefixIterator(store, types.KeyPrefixExchangeRate) @@ -149,15 +151,32 @@ func (k Keeper) IterateExchangeRates(ctx sdk.Context, handler func(string, sdk.D for ; iter.Valid(); iter.Next() { key := iter.Key() denom := string(key[len(types.KeyPrefixExchangeRate) : len(key)-1]) - dp := sdk.DecProto{} + priceStamp := types.PriceStamp{} - k.cdc.MustUnmarshal(iter.Value(), &dp) - if handler(denom, dp.Dec) { + k.cdc.MustUnmarshal(iter.Value(), &priceStamp) + if handler(denom, priceStamp) { break } } } +func (k Keeper) HasActiveExchangeRate(ctx sdk.Context, denom string) bool { + store := ctx.KVStore(k.storeKey) + return store.Has(types.GetExchangeRateKey(denom)) +} + +func (k Keeper) HasActiveExchangeRates(ctx sdk.Context, denoms []string) (bool, error) { + store := ctx.KVStore(k.storeKey) + for _, denom := range denoms { + found := store.Has(types.GetExchangeRateKey(denom)) + if !found { + return false, types.ErrUnknownDenom.Wrap(denom) + } + } + + return true, nil +} + func (k Keeper) ClearExchangeRates(ctx sdk.Context) { store := ctx.KVStore(k.storeKey) iter := sdk.KVStorePrefixIterator(store, types.KeyPrefixExchangeRate) @@ -353,3 +372,21 @@ func (k Keeper) ValidateFeeder(ctx sdk.Context, feederAddr sdk.AccAddress, valAd return nil } + +func (k Keeper) IterateExchangeRatesForDenoms(ctx sdk.Context, denoms []string) (types.PriceStamps, error) { + prices := types.PriceStamps{} + store := ctx.KVStore(k.storeKey) + for _, symbol := range denoms { + symbol = strings.ToUpper(symbol) + b := store.Get(types.GetExchangeRateKey(symbol)) + if b == nil { + return nil, types.ErrUnknownDenom.Wrap(symbol) + } + + priceStamp := types.PriceStamp{} + k.cdc.MustUnmarshal(b, &priceStamp) + prices = append(prices, priceStamp) + } + + return prices, nil +} diff --git a/x/oracle/keeper/keeper_test.go b/x/oracle/keeper/keeper_test.go index 7e50ff58..4113a1c8 100644 --- a/x/oracle/keeper/keeper_test.go +++ b/x/oracle/keeper/keeper_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "fmt" - "strings" "testing" "github.com/cometbft/cometbft/crypto/secp256k1" @@ -206,7 +205,7 @@ func (s *IntegrationTestSuite) TestSetExchangeRateWithEvent() { s.Require().NoError(err) rate, err := app.OracleKeeper.GetExchangeRate(ctx, displayDenom) s.Require().NoError(err) - s.Require().Equal(rate, sdk.OneDec()) + s.Require().Equal(rate.ExchangeRate.Amount, sdk.OneDec()) } func (s *IntegrationTestSuite) TestGetExchangeRate_InvalidDenom() { @@ -226,15 +225,15 @@ func (s *IntegrationTestSuite) TestGetExchangeRate_NotSet() { func (s *IntegrationTestSuite) TestGetExchangeRate_Valid() { app, ctx := s.app, s.ctx - app.OracleKeeper.SetExchangeRate(ctx, displayDenom, sdk.OneDec()) + app.OracleKeeper.SetExchangeRate(ctx, *types.NewPriceStamp(sdk.OneDec(), displayDenom, 0)) rate, err := app.OracleKeeper.GetExchangeRate(ctx, displayDenom) s.Require().NoError(err) - s.Require().Equal(rate, sdk.OneDec()) + s.Require().EqualValues(rate.ExchangeRate.Amount, sdk.OneDec()) - app.OracleKeeper.SetExchangeRate(ctx, strings.ToLower(displayDenom), sdk.OneDec()) + app.OracleKeeper.SetExchangeRate(ctx, *types.NewPriceStamp(sdk.OneDec(), displayDenom, 0)) rate, err = app.OracleKeeper.GetExchangeRate(ctx, displayDenom) s.Require().NoError(err) - s.Require().Equal(rate, sdk.OneDec()) + s.Require().EqualValues(rate.ExchangeRate.Amount, sdk.OneDec()) } func (s *IntegrationTestSuite) TestGetExchangeRateBase() { @@ -249,12 +248,12 @@ func (s *IntegrationTestSuite) TestGetExchangeRateBase() { power := sdk.MustNewDecFromStr("10").Power(exponent) - s.app.OracleKeeper.SetExchangeRate(s.ctx, displayDenom, sdk.OneDec()) + s.app.OracleKeeper.SetExchangeRate(s.ctx, *types.NewPriceStamp(sdk.OneDec(), displayDenom, 0)) rate, err := s.app.OracleKeeper.GetExchangeRateBase(s.ctx, bondDenom) s.Require().NoError(err) s.Require().Equal(rate.Mul(power), sdk.OneDec()) - s.app.OracleKeeper.SetExchangeRate(s.ctx, strings.ToLower(displayDenom), sdk.OneDec()) + s.app.OracleKeeper.SetExchangeRate(s.ctx, *types.NewPriceStamp(sdk.OneDec(), displayDenom, 0)) rate, err = s.app.OracleKeeper.GetExchangeRateBase(s.ctx, bondDenom) s.Require().NoError(err) s.Require().Equal(rate.Mul(power), sdk.OneDec()) @@ -263,7 +262,7 @@ func (s *IntegrationTestSuite) TestGetExchangeRateBase() { func (s *IntegrationTestSuite) TestClearExchangeRate() { app, ctx := s.app, s.ctx - app.OracleKeeper.SetExchangeRate(ctx, displayDenom, sdk.OneDec()) + app.OracleKeeper.SetExchangeRate(ctx, *types.NewPriceStamp(sdk.OneDec(), displayDenom, 0)) app.OracleKeeper.ClearExchangeRates(ctx) _, err := app.OracleKeeper.GetExchangeRate(ctx, displayDenom) s.Require().Error(err) diff --git a/x/oracle/types/events.pb.go b/x/oracle/types/events.pb.go index 5d9321a0..578337ba 100644 --- a/x/oracle/types/events.pb.go +++ b/x/oracle/types/events.pb.go @@ -72,6 +72,8 @@ type EventSetFxRate struct { Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` // Exchange rate (based to USD) Rate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=rate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"rate"` + // block num on which exchange rate was updated + BlockNum uint64 `protobuf:"varint,3,opt,name=block_num,json=blockNum,proto3" json:"block_num,omitempty"` } func (m *EventSetFxRate) Reset() { *m = EventSetFxRate{} } @@ -115,27 +117,29 @@ func init() { func init() { proto.RegisterFile("ojo/oracle/v1/events.proto", fileDescriptor_6b8914220a86f2fd) } var fileDescriptor_6b8914220a86f2fd = []byte{ - // 312 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,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, - 0x74, 0xe7, 0x61, 0x64, 0xc0, 0xad, 0xd1, 0x1d, 0x01, 0x12, 0x27, 0x76, 0x75, 0x68, 0x13, 0xf7, - 0x8e, 0x6e, 0xab, 0x5f, 0xf2, 0x65, 0xba, 0x6e, 0x38, 0x1f, 0xeb, 0xc6, 0x49, 0x32, 0x30, 0x8f, - 0x4f, 0xfd, 0x20, 0xc6, 0x49, 0x75, 0xeb, 0xea, 0xf0, 0xb5, 0x18, 0x71, 0xf3, 0x32, 0x05, 0x1d, - 0x74, 0x20, 0x5e, 0x2d, 0x7c, 0x5a, 0xf9, 0xe8, 0x40, 0x1c, 0x96, 0xa4, 0xf6, 0x6d, 0xfa, 0xc5, - 0x9c, 0x34, 0x63, 0x64, 0x99, 0x31, 0xf2, 0x99, 0x31, 0xf2, 0x96, 0x33, 0x67, 0x99, 0x33, 0xe7, - 0x3d, 0x67, 0xce, 0xfd, 0xd9, 0x1f, 0x32, 0x0e, 0xd1, 0x97, 0x60, 0x9e, 0x51, 0x8d, 0x8a, 0x98, - 0xcf, 0x37, 0xbf, 0x52, 0x2e, 0xe8, 0xef, 0x96, 0x4f, 0x7a, 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, - 0x57, 0xbb, 0xd8, 0x83, 0xb0, 0x01, 0x00, 0x00, + // 340 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0x3f, 0x4f, 0xfa, 0x40, + 0x18, 0xc7, 0x7b, 0xbf, 0x1f, 0x1a, 0xb8, 0x44, 0x87, 0x86, 0xa1, 0x62, 0x72, 0x10, 0x06, 0x83, + 0x43, 0xdb, 0x10, 0x1d, 0x5d, 0x44, 0xc4, 0xcd, 0x98, 0xb2, 0xb9, 0x90, 0xd2, 0x3e, 0xa9, 0xfc, + 0xe9, 0x3d, 0xe4, 0xee, 0x40, 0x7c, 0x03, 0xce, 0x2e, 0xbe, 0x13, 0x5e, 0x04, 0x23, 0x61, 0x32, + 0x0e, 0x44, 0xe9, 0x1b, 0x31, 0xed, 0x15, 0x75, 0x73, 0xba, 0xe7, 0xcf, 0xf7, 0xf9, 0x7c, 0x9f, + 0xbb, 0xa3, 0x15, 0x1c, 0xa2, 0x8b, 0xc2, 0x0f, 0xc6, 0xe0, 0xce, 0x9a, 0x2e, 0xcc, 0x80, 0x2b, + 0xe9, 0x4c, 0x04, 0x2a, 0x34, 0x0f, 0x70, 0x88, 0x8e, 0xee, 0x39, 0xb3, 0x66, 0xe5, 0x28, 0x40, + 0x19, 0xa3, 0xec, 0x65, 0x4d, 0x57, 0x27, 0x5a, 0x59, 0x29, 0x47, 0x18, 0xa1, 0xae, 0xa7, 0x91, + 0xae, 0xd6, 0x9f, 0x09, 0xb5, 0xae, 0x53, 0x60, 0x1b, 0xc6, 0x10, 0xf9, 0x0a, 0x3a, 0x00, 0xe1, + 0x15, 0x72, 0x09, 0x5c, 0x99, 0xe7, 0xb4, 0x88, 0x13, 0x10, 0xbe, 0x42, 0x61, 0x91, 0x1a, 0x69, + 0x94, 0x5a, 0xd6, 0x7a, 0x61, 0x97, 0x73, 0xec, 0x65, 0x18, 0x0a, 0x90, 0xb2, 0xab, 0xc4, 0x80, + 0x47, 0xde, 0xb7, 0x32, 0x9d, 0x0a, 0x73, 0x98, 0xf5, 0xef, 0xaf, 0xa9, 0x9d, 0xb2, 0xfe, 0x4a, + 0xe8, 0x61, 0xb6, 0x48, 0x17, 0x54, 0x67, 0xee, 0xf9, 0x0a, 0xcc, 0x32, 0xdd, 0x0b, 0x81, 0x63, + 0xac, 0xbd, 0x3d, 0x9d, 0x98, 0x77, 0xb4, 0x20, 0x7e, 0xd0, 0x17, 0xcb, 0x4d, 0xd5, 0x78, 0xdf, + 0x54, 0x4f, 0xa2, 0x81, 0x7a, 0x98, 0xf6, 0x9d, 0x00, 0xe3, 0xfc, 0xda, 0xf9, 0x61, 0xcb, 0x70, + 0xe4, 0xaa, 0xa7, 0x09, 0x48, 0xa7, 0x0d, 0xc1, 0x7a, 0x61, 0xd3, 0x7c, 0x91, 0x36, 0x04, 0x5e, + 0x46, 0x32, 0x8f, 0x69, 0xa9, 0x3f, 0xc6, 0x60, 0xd4, 0xe3, 0xd3, 0xd8, 0xfa, 0x5f, 0x23, 0x8d, + 0x82, 0x57, 0xcc, 0x0a, 0xb7, 0xd3, 0xb8, 0x75, 0xb3, 0xfc, 0x64, 0xc6, 0x72, 0xcb, 0xc8, 0x6a, + 0xcb, 0xc8, 0xc7, 0x96, 0x91, 0x97, 0x84, 0x19, 0xab, 0x84, 0x19, 0x6f, 0x09, 0x33, 0xee, 0x4f, + 0x7f, 0xd9, 0xe2, 0x10, 0x6d, 0x0e, 0xea, 0x11, 0xc5, 0x28, 0x8d, 0xdd, 0xf9, 0xee, 0xcf, 0x32, + 0xf7, 0xfe, 0x7e, 0xf6, 0xe0, 0x67, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x1c, 0x70, 0xa6, 0x63, + 0xce, 0x01, 0x00, 0x00, } func (m *EventDelegateFeedConsent) Marshal() (dAtA []byte, err error) { @@ -195,6 +199,11 @@ func (m *EventSetFxRate) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.BlockNum != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.BlockNum)) + i-- + dAtA[i] = 0x18 + } { size := m.Rate.Size() i -= size @@ -255,6 +264,9 @@ func (m *EventSetFxRate) Size() (n int) { } l = m.Rate.Size() n += 1 + l + sovEvents(uint64(l)) + if m.BlockNum != 0 { + n += 1 + sovEvents(uint64(m.BlockNum)) + } return n } @@ -473,6 +485,25 @@ func (m *EventSetFxRate) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockNum", wireType) + } + m.BlockNum = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockNum |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go index 36b0153d..2b15450f 100644 --- a/x/oracle/types/genesis.go +++ b/x/oracle/types/genesis.go @@ -4,13 +4,12 @@ import ( "encoding/json" "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" ) // NewGenesisState creates a new GenesisState object func NewGenesisState( params Params, - rates sdk.DecCoins, + rates []PriceStamp, feederDelegations []FeederDelegation, missCounters []MissCounter, aggregateExchangeRatePrevotes []AggregateExchangeRatePrevote, @@ -37,7 +36,7 @@ func NewGenesisState( func DefaultGenesisState() *GenesisState { return &GenesisState{ Params: DefaultParams(), - ExchangeRates: sdk.DecCoins{}, + ExchangeRates: []PriceStamp{}, FeederDelegations: []FeederDelegation{}, MissCounters: []MissCounter{}, AggregateExchangeRatePrevotes: []AggregateExchangeRatePrevote{}, diff --git a/x/oracle/types/genesis.pb.go b/x/oracle/types/genesis.pb.go index 0a8c5880..35206a26 100644 --- a/x/oracle/types/genesis.pb.go +++ b/x/oracle/types/genesis.pb.go @@ -5,8 +5,7 @@ package types import ( fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types" proto "github.com/cosmos/gogoproto/proto" _ "github.com/gogo/protobuf/gogoproto" io "io" @@ -27,15 +26,15 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the oracle module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - FeederDelegations []FeederDelegation `protobuf:"bytes,2,rep,name=feeder_delegations,json=feederDelegations,proto3" json:"feeder_delegations"` - ExchangeRates github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,3,rep,name=exchange_rates,json=exchangeRates,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"exchange_rates"` - MissCounters []MissCounter `protobuf:"bytes,4,rep,name=miss_counters,json=missCounters,proto3" json:"miss_counters"` - AggregateExchangeRatePrevotes []AggregateExchangeRatePrevote `protobuf:"bytes,5,rep,name=aggregate_exchange_rate_prevotes,json=aggregateExchangeRatePrevotes,proto3" json:"aggregate_exchange_rate_prevotes"` - AggregateExchangeRateVotes []AggregateExchangeRateVote `protobuf:"bytes,6,rep,name=aggregate_exchange_rate_votes,json=aggregateExchangeRateVotes,proto3" json:"aggregate_exchange_rate_votes"` - Medians []PriceStamp `protobuf:"bytes,7,rep,name=medians,proto3" json:"medians"` - HistoricPrices []PriceStamp `protobuf:"bytes,8,rep,name=historic_prices,json=historicPrices,proto3" json:"historic_prices"` - MedianDeviations []PriceStamp `protobuf:"bytes,9,rep,name=medianDeviations,proto3" json:"medianDeviations"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + FeederDelegations []FeederDelegation `protobuf:"bytes,2,rep,name=feeder_delegations,json=feederDelegations,proto3" json:"feeder_delegations"` + ExchangeRates []PriceStamp `protobuf:"bytes,3,rep,name=exchange_rates,json=exchangeRates,proto3" json:"exchange_rates"` + MissCounters []MissCounter `protobuf:"bytes,4,rep,name=miss_counters,json=missCounters,proto3" json:"miss_counters"` + AggregateExchangeRatePrevotes []AggregateExchangeRatePrevote `protobuf:"bytes,5,rep,name=aggregate_exchange_rate_prevotes,json=aggregateExchangeRatePrevotes,proto3" json:"aggregate_exchange_rate_prevotes"` + AggregateExchangeRateVotes []AggregateExchangeRateVote `protobuf:"bytes,6,rep,name=aggregate_exchange_rate_votes,json=aggregateExchangeRateVotes,proto3" json:"aggregate_exchange_rate_votes"` + Medians []PriceStamp `protobuf:"bytes,7,rep,name=medians,proto3" json:"medians"` + HistoricPrices []PriceStamp `protobuf:"bytes,8,rep,name=historic_prices,json=historicPrices,proto3" json:"historic_prices"` + MedianDeviations []PriceStamp `protobuf:"bytes,9,rep,name=medianDeviations,proto3" json:"medianDeviations"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -161,43 +160,41 @@ func init() { func init() { proto.RegisterFile("ojo/oracle/v1/genesis.proto", fileDescriptor_88726d9a54067831) } var fileDescriptor_88726d9a54067831 = []byte{ - // 575 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcf, 0x6e, 0xd3, 0x4e, - 0x18, 0x8c, 0xdb, 0xfe, 0xd2, 0x5f, 0x37, 0x4d, 0x69, 0x57, 0x20, 0x99, 0x40, 0xdd, 0x52, 0x09, - 0x29, 0x28, 0xaa, 0xad, 0x34, 0x27, 0x8e, 0x4d, 0x53, 0x8a, 0x84, 0x90, 0xaa, 0x14, 0x71, 0x40, - 0x42, 0xd6, 0xc6, 0xde, 0x38, 0x9b, 0xc6, 0x5e, 0xb3, 0xdf, 0x36, 0x04, 0x9e, 0x82, 0x3b, 0x6f, - 0xc0, 0x93, 0xe4, 0xd8, 0x23, 0x27, 0xfe, 0x24, 0x2f, 0x82, 0xbc, 0x6b, 0x37, 0x89, 0x69, 0x51, - 0x4e, 0xb1, 0xbe, 0x99, 0x6f, 0x66, 0x27, 0x9a, 0x5d, 0xf4, 0x88, 0xf7, 0xb9, 0xc3, 0x05, 0xf1, - 0x06, 0xd4, 0x19, 0xd6, 0x9d, 0x80, 0x46, 0x14, 0x18, 0xd8, 0xb1, 0xe0, 0x92, 0xe3, 0x32, 0xef, - 0x73, 0x5b, 0x83, 0xf6, 0xb0, 0x5e, 0xb9, 0x1f, 0xf0, 0x80, 0x2b, 0xc4, 0x49, 0xbe, 0x34, 0xa9, - 0x52, 0x59, 0x54, 0x48, 0xe9, 0x1a, 0xb3, 0x3c, 0x0e, 0x21, 0x07, 0xa7, 0x43, 0x20, 0x01, 0x3b, -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0x6c, 0xfc, 0xdb, - 0x2a, 0x8c, 0x27, 0x96, 0x71, 0x3d, 0xb1, 0x8c, 0x5f, 0x13, 0xcb, 0xf8, 0x32, 0xb5, 0x0a, 0xd7, - 0x53, 0xab, 0xf0, 0x7d, 0x6a, 0x15, 0xde, 0x3d, 0x9b, 0xbb, 0x28, 0xbc, 0xcf, 0x0f, 0x23, 0x2a, - 0x3f, 0x72, 0x71, 0x99, 0x7c, 0x3b, 0xa3, 0xec, 0x5d, 0x51, 0xf7, 0xa5, 0x53, 0x54, 0x8f, 0x46, - 0xe3, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x16, 0xfe, 0x02, 0x6f, 0xb4, 0x04, 0x00, 0x00, + // 532 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xcd, 0x6e, 0xd3, 0x4e, + 0x14, 0xc5, 0xe3, 0x7e, 0xa4, 0xff, 0x4e, 0x3e, 0xfe, 0xe9, 0x08, 0x24, 0x13, 0x54, 0x37, 0x44, + 0x42, 0x0a, 0xaa, 0xb0, 0x95, 0x76, 0xc5, 0xb2, 0xa5, 0x1f, 0x48, 0x08, 0xa9, 0x4a, 0x11, 0x0b, + 0x24, 0x64, 0x4d, 0xec, 0x1b, 0x67, 0x42, 0xec, 0x31, 0x73, 0xa7, 0xa1, 0xf0, 0x14, 0x3c, 0x56, + 0x96, 0x5d, 0xb2, 0x42, 0x90, 0xac, 0x78, 0x0b, 0x64, 0x8f, 0xd3, 0x24, 0xa6, 0x45, 0xd9, 0x59, + 0xf7, 0x9c, 0xf3, 0x3b, 0x57, 0xd6, 0xd5, 0x90, 0xc7, 0x62, 0x20, 0x1c, 0x21, 0x99, 0x37, 0x04, + 0x67, 0xd4, 0x76, 0x02, 0x88, 0x00, 0x39, 0xda, 0xb1, 0x14, 0x4a, 0xd0, 0x8a, 0x18, 0x08, 0x5b, + 0x8b, 0xf6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x6e, 0xa6, 0x56, + 0xe1, 0xfb, 0xd4, 0x2a, 0xbc, 0x7f, 0x16, 0x70, 0xd5, 0xbf, 0xea, 0xda, 0x9e, 0x08, 0x1d, 0x31, + 0x10, 0xcf, 0x23, 0x50, 0x9f, 0x85, 0xfc, 0x98, 0x7c, 0x3b, 0xd7, 0xb3, 0x57, 0x42, 0x7d, 0x89, + 0x01, 0xbb, 0xc5, 0xf4, 0x09, 0x38, 0xfc, 0x13, 0x00, 0x00, 0xff, 0xff, 0x28, 0xe8, 0x12, 0x50, + 0x82, 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -651,7 +648,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ExchangeRates = append(m.ExchangeRates, types.DecCoin{}) + m.ExchangeRates = append(m.ExchangeRates, PriceStamp{}) if err := m.ExchangeRates[len(m.ExchangeRates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/oracle/types/genesis_test.go b/x/oracle/types/genesis_test.go index ace1992c..17fec8a1 100644 --- a/x/oracle/types/genesis_test.go +++ b/x/oracle/types/genesis_test.go @@ -62,7 +62,7 @@ func TestGenesisValidation(t *testing.T) { func TestGetGenesisStateFromAppState(t *testing.T) { emptyGenesis := GenesisState{ Params: Params{}, - ExchangeRates: sdk.DecCoins{}, + ExchangeRates: []PriceStamp{}, FeederDelegations: []FeederDelegation{}, MissCounters: []MissCounter{}, AggregateExchangeRatePrevotes: []AggregateExchangeRatePrevote{}, diff --git a/x/oracle/types/price_stamp.go b/x/oracle/types/price_stamp.go index 67616ade..a2b4d7ec 100644 --- a/x/oracle/types/price_stamp.go +++ b/x/oracle/types/price_stamp.go @@ -8,6 +8,11 @@ import ( type PriceStamps []PriceStamp +type AggegatedPriceStamp struct { + Rates []sdk.DecCoin + BlockNums []uint64 +} + func NewPriceStamp(exchangeRate sdk.Dec, denom string, blockNum uint64) *PriceStamp { return &PriceStamp{ ExchangeRate: &sdk.DecCoin{ @@ -80,3 +85,30 @@ func (p *PriceStamps) NewestBlockNum() uint64 { } return blockNum } + +func (p PriceStamps) ExchangeRates() sdk.DecCoins { + exchangeRates := sdk.DecCoins{} + for _, priceStamp := range p { + exchangeRates = exchangeRates.Add(*priceStamp.ExchangeRate) + } + + return exchangeRates +} + +func (p PriceStamps) MapDenoms() map[string]AggegatedPriceStamp { + aggregator := make(map[string]AggegatedPriceStamp) + for _, priceStamp := range p { + denom := priceStamp.ExchangeRate.Denom + aggPriceStamp, found := aggregator[denom] + if !found { + aggPriceStamp = AggegatedPriceStamp{} + } + + aggPriceStamp.Rates = append(aggPriceStamp.Rates, *priceStamp.ExchangeRate) + aggPriceStamp.BlockNums = append(aggPriceStamp.BlockNums, priceStamp.BlockNum) + + aggregator[denom] = aggPriceStamp + } + + return aggregator +} diff --git a/x/oracle/types/query.pb.go b/x/oracle/types/query.pb.go index cb68bd3e..c4f9d87f 100644 --- a/x/oracle/types/query.pb.go +++ b/x/oracle/types/query.pb.go @@ -6,8 +6,7 @@ package types import ( context "context" fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" _ "github.com/gogo/protobuf/gogoproto" @@ -76,7 +75,7 @@ var xxx_messageInfo_QueryExchangeRates proto.InternalMessageInfo type QueryExchangeRatesResponse struct { // exchange_rates defines a list of the exchange rate for all whitelisted // denoms. - ExchangeRates github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=exchange_rates,json=exchangeRates,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"exchange_rates"` + ExchangeRates []PriceStamp `protobuf:"bytes,1,rep,name=exchange_rates,json=exchangeRates,proto3" json:"exchange_rates"` } func (m *QueryExchangeRatesResponse) Reset() { *m = QueryExchangeRatesResponse{} } @@ -1095,84 +1094,81 @@ func init() { func init() { proto.RegisterFile("ojo/oracle/v1/query.proto", fileDescriptor_ac3bb5b34dcda556) } var fileDescriptor_ac3bb5b34dcda556 = []byte{ - // 1225 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x97, 0x5b, 0x4f, 0x1b, 0x47, - 0x14, 0xc7, 0xbd, 0x69, 0x2e, 0xcd, 0x71, 0xec, 0x38, 0x13, 0x68, 0x60, 0x01, 0x1b, 0x96, 0xa4, - 0x40, 0x09, 0xbb, 0x35, 0x44, 0x8d, 0xe8, 0x4d, 0xe5, 0xd6, 0x54, 0xbd, 0x48, 0xc4, 0xa8, 0x44, - 0xea, 0x43, 0xdd, 0xc1, 0x3b, 0x35, 0x4b, 0xec, 0x1d, 0x77, 0x67, 0x31, 0x44, 0x69, 0x54, 0x29, - 0x4f, 0x7d, 0x8c, 0x84, 0xd4, 0x97, 0x3e, 0x94, 0x4a, 0x79, 0x69, 0xd5, 0x0f, 0xc2, 0x63, 0xa4, - 0xbe, 0xf4, 0xa9, 0x17, 0xe8, 0x43, 0x3f, 0x46, 0xe5, 0x99, 0xf1, 0x78, 0x6f, 0xc6, 0x26, 0x4f, - 0xe0, 0x73, 0xce, 0x9c, 0xff, 0x6f, 0xcf, 0xec, 0xcc, 0xdf, 0x86, 0x61, 0xba, 0x43, 0x2d, 0xea, - 0xe1, 0x4a, 0x8d, 0x58, 0xcd, 0xa2, 0xf5, 0xcd, 0x2e, 0xf1, 0x1e, 0x99, 0x0d, 0x8f, 0xfa, 0x14, - 0x65, 0xe8, 0x0e, 0x35, 0x45, 0xca, 0x6c, 0x16, 0xf5, 0x81, 0x2a, 0xad, 0x52, 0x9e, 0xb1, 0x5a, - 0xff, 0x89, 0x22, 0x7d, 0xb4, 0x4a, 0x69, 0xb5, 0x46, 0x2c, 0xdc, 0x70, 0x2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, 0x84, 0x4b, 0x6d, 0xe3, 0x1e, - 0x49, 0x3c, 0xdd, 0x22, 0xa9, 0x4f, 0x9e, 0x92, 0x54, 0x5a, 0x33, 0x5c, 0x6b, 0x12, 0x4d, 0x70, - 0xad, 0x6d, 0x87, 0xf9, 0xb1, 0xdb, 0x52, 0x9a, 0x32, 0xfa, 0x51, 0x83, 0x5c, 0xcc, 0x90, 0x6f, - 0x76, 0x17, 0xe9, 0x54, 0x25, 0x1f, 0xb5, 0x6e, 0x1e, 0x1d, 0xb9, 0xbd, 0x4f, 0x61, 0x2a, 0xdb, - 0x1d, 0x90, 0xe7, 0x1a, 0xa0, 0xb8, 0x5b, 0xa2, 0xd7, 0x93, 0x94, 0xe3, 0x75, 0xba, 0xd9, 0x5f, - 0x9d, 0x62, 0x7c, 0x8b, 0x33, 0xbe, 0x89, 0xcc, 0xee, 0xaf, 0x71, 0xe7, 0x2d, 0xf6, 0xf8, 0xf2, - 0x32, 0x23, 0xfe, 0xf2, 0xbd, 0xa3, 0x7f, 0xf2, 0xa9, 0xa3, 0xe3, 0xbc, 0xf6, 0xe2, 0x38, 0xaf, - 0xfd, 0x7d, 0x9c, 0xd7, 0x9e, 0x9d, 0xe4, 0x53, 0x2f, 0x4e, 0xf2, 0xa9, 0x3f, 0x4e, 0xf2, 0xa9, - 0x2f, 0x66, 0x02, 0x3f, 0x58, 0xe9, 0x0e, 0x9d, 0x73, 0x89, 0xbf, 0x47, 0xbd, 0x87, 0x5c, 0x63, - 0xbf, 0xad, 0xc2, 0x7f, 0xb7, 0x6e, 0x5d, 0xe4, 0xbf, 0xba, 0x17, 0xfe, 0x0f, 0x00, 0x00, 0xff, - 0xff, 0x00, 0x8d, 0x37, 0xdf, 0x11, 0x10, 0x00, 0x00, + // 1183 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x97, 0xcf, 0x4f, 0x1b, 0x47, + 0x14, 0x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, 0x8f, 0xff, 0xcd, 0xa7, 0x8e, 0x4f, 0xf2, 0xda, 0xcb, 0x93, 0xbc, 0xf6, + 0xcf, 0x49, 0x5e, 0x7b, 0x7e, 0x9a, 0x4f, 0xbd, 0x3c, 0xcd, 0xa7, 0xfe, 0x3a, 0xcd, 0xa7, 0xbe, + 0x9e, 0xb7, 0x1d, 0x7f, 0x77, 0x7f, 0xa7, 0x58, 0xa5, 0xf5, 0x56, 0xdf, 0x45, 0x97, 0xf8, 0x07, + 0xd4, 0xfb, 0x9e, 0x6b, 0x3c, 0x6a, 0xab, 0xf8, 0x8f, 0x1b, 0x84, 0xed, 0x0c, 0xf0, 0x3f, 0xa1, + 0x97, 0x5f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x95, 0x88, 0xbd, 0x02, 0xde, 0x0f, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2987,7 +2983,7 @@ func (m *QueryExchangeRatesResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ExchangeRates = append(m.ExchangeRates, types.DecCoin{}) + m.ExchangeRates = append(m.ExchangeRates, PriceStamp{}) if err := m.ExchangeRates[len(m.ExchangeRates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/relayoracle/abci.go b/x/relayoracle/abci.go new file mode 100644 index 00000000..f4bca1c1 --- /dev/null +++ b/x/relayoracle/abci.go @@ -0,0 +1,19 @@ +package relayoracle + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/ojo-network/ojo/x/relayoracle/keeper" +) + +// Process all requests in the endblocker, after oracle module end blocker +// EndBlocker resolves all the pending requests +func EndBlocker(ctx sdk.Context, k keeper.Keeper) { + // Loops through all requests in the resolvable list to resolve all of them! + for _, reqID := range k.GetPendingRequestList(ctx) { + k.ResolveRequest(ctx, reqID) + } + + // Once all the requests are resolved, we can clear the list. + k.FlushPendingRequestList(ctx) +} diff --git a/x/relayoracle/client/cli/query.go b/x/relayoracle/client/cli/query.go new file mode 100644 index 00000000..e93ff136 --- /dev/null +++ b/x/relayoracle/client/cli/query.go @@ -0,0 +1,30 @@ +package cli + +import ( + "fmt" + // "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + // sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/ojo-network/ojo/x/relayoracle/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(queryRoute string) *cobra.Command { + // Group relayoracle queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdQueryParams()) + + return cmd +} diff --git a/x/relayoracle/client/cli/query_params.go b/x/relayoracle/client/cli/query_params.go new file mode 100644 index 00000000..4c15326f --- /dev/null +++ b/x/relayoracle/client/cli/query_params.go @@ -0,0 +1,36 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/ojo-network/ojo/x/relayoracle/types" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/relayoracle/genesis.go b/x/relayoracle/genesis.go new file mode 100644 index 00000000..5604ce65 --- /dev/null +++ b/x/relayoracle/genesis.go @@ -0,0 +1,53 @@ +package relayoracle + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/ojo-network/ojo/x/relayoracle/keeper" + "github.com/ojo-network/ojo/x/relayoracle/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +// TODO: export pending list and other state to genesis +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + k.SetPort(ctx, genState.PortId) + if !k.IsBound(ctx, genState.PortId) { + err := k.BindPort(ctx, genState.PortId) + if err != nil { + panic("could not claim port capability: " + err.Error()) + } + } + k.SetRequestCount(ctx, 0) + + k.SetParams(ctx, genState.Params) + + // set request ids + for _, request := range genState.Requests { + k.SetRequest(ctx, request.RequestID, request) + } + + // set results + for _, result := range genState.Results { + k.SetResult(ctx, result) + } + + // set pending list + var pending types.PendingRequestList + pending.RequestIds = genState.GetPendingRequestIds() + k.SetPendingList(ctx, pending) + +} + +// ExportGenesis returns the module's exported genesis +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + genesis.PortId = k.GetPort(ctx) + + // extract all results, requests and pending request ids + genesis.Results = k.AllResults(ctx) + genesis.Requests = k.AllRequests(ctx) + genesis.PendingRequestIds = k.GetPendingRequestList(ctx) + + return genesis +} diff --git a/x/relayoracle/genesis_test.go b/x/relayoracle/genesis_test.go new file mode 100644 index 00000000..f1242928 --- /dev/null +++ b/x/relayoracle/genesis_test.go @@ -0,0 +1,64 @@ +package relayoracle_test + +import ( + "fmt" + "testing" + + tmrand "github.com/cometbft/cometbft/libs/rand" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + + ojoapp "github.com/ojo-network/ojo/app" + "github.com/ojo-network/ojo/x/relayoracle" + "github.com/ojo-network/ojo/x/relayoracle/keeper" + + "github.com/ojo-network/ojo/x/relayoracle/types" +) + +type GenesisTestSuite struct { + suite.Suite + + ctx sdk.Context + k keeper.Keeper +} + +func (s *GenesisTestSuite) SetupTest() { + app := ojoapp.Setup(s.T()) + s.ctx = app.BaseApp.NewContext(false, tmproto.Header{ + ChainID: fmt.Sprintf("test-chain-%s", tmrand.Str(4)), + Height: 9, + }) + + s.k = app.RelayOracle +} + +func TestGenesisTestSuite(t *testing.T) { + suite.Run(t, new(GenesisTestSuite)) +} + +func (s *GenesisTestSuite) Test_InitGenesis() { + genesis := types.DefaultGenesis() + genesis.Params.PacketTimeout = 42 + genesis.PortId = "TestInit" + + // init gen state + relayoracle.InitGenesis(s.ctx, s.k, *genesis) + + s.Require().Equal(genesis.Params, s.k.GetParams(s.ctx), "Params mismatch after InitGenesis") + s.Require().Equal(genesis.PortId, s.k.GetPort(s.ctx), "Port ID mismatch after InitGenesis") +} + +func (s *GenesisTestSuite) Test_ExportGenesis() { + genesis := types.DefaultGenesis() + genesis.Params.PacketTimeout = 42 + genesis.PortId = "TestExport" + + // init gen state + relayoracle.InitGenesis(s.ctx, s.k, *genesis) + + // export gen state + exportedGenesis := relayoracle.ExportGenesis(s.ctx, s.k) + + s.Require().Equal(genesis, exportedGenesis, "Exported genesis should match the original") +} diff --git a/x/relayoracle/keeper/keeper.go b/x/relayoracle/keeper/keeper.go new file mode 100644 index 00000000..20c8ff94 --- /dev/null +++ b/x/relayoracle/keeper/keeper.go @@ -0,0 +1,160 @@ +package keeper + +import ( + "fmt" + + "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v7/modules/core/24-host" + "github.com/cosmos/ibc-go/v7/modules/core/exported" + + "github.com/ojo-network/ojo/x/relayoracle/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + paramstore paramtypes.Subspace + + oracleKeeper types.OracleKeeper + channelKeeper types.ChannelKeeper + portKeeper types.PortKeeper + scopedKeeper exported.ScopedKeeper + + // x/gov module account + authority string + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey storetypes.StoreKey, + ps paramtypes.Subspace, + oracleKeeper types.OracleKeeper, + channelKeeper types.ChannelKeeper, + portKeeper types.PortKeeper, + scopedKeeper exported.ScopedKeeper, + authority string, +) Keeper { + // set KeyTable if it has not already been set + if !ps.HasKeyTable() { + ps = ps.WithKeyTable(types.ParamKeyTable()) + } + + return Keeper{ + cdc: cdc, + storeKey: storeKey, + paramstore: ps, + oracleKeeper: oracleKeeper, + channelKeeper: channelKeeper, + portKeeper: portKeeper, + scopedKeeper: scopedKeeper, + authority: authority, + } +} + +// ---------------------------------------------------------------------------- +// IBC Keeper Logic +// ---------------------------------------------------------------------------- + +// ChanCloseInit defines a wrapper function for the channel Keeper's function. +func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string) error { + return nil +} + +// IsBound checks if the IBC app module is already bound to the desired port +func (k Keeper) IsBound(ctx sdk.Context, portID string) bool { + _, ok := k.scopedKeeper.GetCapability(ctx, host.PortPath(portID)) + return ok +} + +// BindPort defines a wrapper function for the port Keeper's function in +// order to expose it to module's InitGenesis function +func (k Keeper) BindPort(ctx sdk.Context, portID string) error { + cap := k.portKeeper.BindPort(ctx, portID) + return k.ClaimCapability(ctx, cap, host.PortPath(portID)) +} + +// GetPort returns the portID for the IBC app module. Used in ExportGenesis +func (k Keeper) GetPort(ctx sdk.Context) string { + store := ctx.KVStore(k.storeKey) + return string(store.Get(types.PortKey)) +} + +// SetPort sets the portID for the IBC app module. Used in InitGenesis +func (k Keeper) SetPort(ctx sdk.Context, portID string) { + store := ctx.KVStore(k.storeKey) + store.Set(types.PortKey, []byte(portID)) +} + +// AuthenticateCapability wraps the scopedKeeper's AuthenticateCapability function +func (k Keeper) AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool { + return k.scopedKeeper.AuthenticateCapability(ctx, cap, name) +} + +// ClaimCapability allows the IBC app module to claim a capability that core IBC +// passes to it +func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error { + return k.scopedKeeper.ClaimCapability(ctx, cap, name) +} + +func (k Keeper) OnRecvPacket( + ctx sdk.Context, + packet channeltypes.Packet, + data types.OracleRequestPacketData, +) (uint64, types.PriceRequestType, error) { + if err := data.ValidateBasic(); err != nil { + return 0, 0, err + } + + // check if there is a active denom + var request types.RequestPrice + err := k.cdc.Unmarshal(data.GetCalldata(), &request) + if err != nil { + return 0, 0, err + } + + //TODO: testing + ctx.Logger().Error("request received", "request", request.String()) + + if len(request.GetDenoms()) == 0 { + return 0, 0, types.ErrNoDenoms + } + + switch request.Request { + case types.PRICE_REQUEST_RATE: + if len(request.GetDenoms()) > int(k.GetMaxQueryForExchangeRate(ctx)) { + return 0, 0, types.ErrTooManyDenoms + } + + found, err := k.oracleKeeper.HasActiveExchangeRates(ctx, request.GetDenoms()) + if !found { + return 0, 0, err + } + + default: + if len(request.GetDenoms()) > int(k.GetMaxQueryForHistorical(ctx)) { + return 0, 0, types.ErrTooManyDenoms + } + + found, err := k.oracleKeeper.HasActiveHistoricalRates(ctx, request.GetDenoms()) + if !found { + return 0, 0, err + } + } + + ibcChannel := types.NewIbcChannel(packet.DestinationPort, packet.DestinationChannel) + id, err := k.PrepareRequest(ctx, ibcChannel, &data) + + return id, request.Request, err +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} diff --git a/x/relayoracle/keeper/keeper_suite_test.go b/x/relayoracle/keeper/keeper_suite_test.go new file mode 100644 index 00000000..ede97b22 --- /dev/null +++ b/x/relayoracle/keeper/keeper_suite_test.go @@ -0,0 +1,99 @@ +package keeper_test + +import ( + "fmt" + "testing" + + "github.com/cometbft/cometbft/crypto/secp256k1" + tmrand "github.com/cometbft/cometbft/libs/rand" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/baseapp" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + sdk "github.com/cosmos/cosmos-sdk/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/cosmos/cosmos-sdk/x/staking" + stakingtestutil "github.com/cosmos/cosmos-sdk/x/staking/testutil" + "github.com/stretchr/testify/suite" + + ojoapp "github.com/ojo-network/ojo/app" + appparams "github.com/ojo-network/ojo/app/params" + "github.com/ojo-network/ojo/x/relayoracle/keeper" + "github.com/ojo-network/ojo/x/relayoracle/types" +) + +const ( + displayDenom string = appparams.DisplayDenom + bondDenom string = appparams.BondDenom + + initialPower = int64(10000000000) +) + +// Test addresses +var ( + valPubKeys = simtestutil.CreateTestPubKeys(2) + + valPubKey = valPubKeys[0] + pubKey = secp256k1.GenPrivKey().PubKey() + addr = sdk.AccAddress(pubKey.Address()) + valAddr = sdk.ValAddress(pubKey.Address()) + + valPubKey2 = valPubKeys[1] + pubKey2 = secp256k1.GenPrivKey().PubKey() + addr2 = sdk.AccAddress(pubKey2.Address()) + valAddr2 = sdk.ValAddress(pubKey2.Address()) + + initTokens = sdk.TokensFromConsensusPower(initialPower, sdk.DefaultPowerReduction) + initCoins = sdk.NewCoins(sdk.NewCoin(appparams.BondDenom, initTokens)) +) + +type IntegrationTestSuite struct { + suite.Suite + + ctx sdk.Context + app *ojoapp.App + queryClient types.QueryClient + msgServer types.MsgServer +} + +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} + +func (s *IntegrationTestSuite) SetupSuite() { + require := s.Require() + isCheckTx := false + + config := sdk.GetConfig() + config.SetBech32PrefixForAccount(appparams.AccountAddressPrefix, appparams.AccountPubKeyPrefix) + config.SetBech32PrefixForValidator(appparams.ValidatorAddressPrefix, appparams.ValidatorPubKeyPrefix) + config.SetBech32PrefixForConsensusNode(appparams.ConsNodeAddressPrefix, appparams.ConsNodePubKeyPrefix) + + app := ojoapp.Setup(s.T()) + ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{ + ChainID: fmt.Sprintf("test-chain-%s", tmrand.Str(4)), + Height: 9, + }) + + queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, keeper.NewQuerier(app.RelayOracle)) + + sh := stakingtestutil.NewHelper(s.T(), ctx, app.StakingKeeper) + sh.Denom = bondDenom + amt := sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction) + + // mint and send coins to validators + require.NoError(app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, initCoins)) + require.NoError(app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, initCoins)) + require.NoError(app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, initCoins)) + require.NoError(app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr2, initCoins)) + + sh.CreateValidator(valAddr, valPubKey, amt, true) + sh.CreateValidator(valAddr2, valPubKey2, amt, true) + + staking.EndBlocker(ctx, app.StakingKeeper) + + s.app = app + s.ctx = ctx + s.queryClient = types.NewQueryClient(queryHelper) + s.msgServer = keeper.NewMsgServerImpl(app.RelayOracle) +} diff --git a/x/relayoracle/keeper/msg_server.go b/x/relayoracle/keeper/msg_server.go new file mode 100644 index 00000000..5c0203ee --- /dev/null +++ b/x/relayoracle/keeper/msg_server.go @@ -0,0 +1,59 @@ +package keeper + +import ( + "context" + "fmt" + + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + "github.com/ojo-network/ojo/x/relayoracle/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the relayoracle MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +func (ms msgServer) GovUpdateParams( + goCtx context.Context, + msg *types.MsgGovUpdateParams, +) (*types.MsgGovUpdateParamsResponse, error) { + if ms.authority != msg.Authority { + err := errors.Wrapf( + govtypes.ErrInvalidSigner, + "invalid authority; expected %s, got %s", + ms.authority, + msg.Authority, + ) + return nil, err + } + + ctx := sdk.UnwrapSDKContext(goCtx) + for _, key := range msg.Keys { + switch key { + case string(types.KeyIbcRequestEnabled): + ms.SetIbcRequestEnabled(ctx, msg.Changes.IbcRequestEnabled) + + case string(types.KeyPacketTimeout): + ms.SetPacketTimeout(ctx, msg.Changes.PacketTimeout) + + case string(types.KeyMaxExchange): + ms.SetMaxQueryForExchangeRate(ctx, msg.Changes.MaxAllowedDenomsExchangeQuery) + + case string(types.KeyMaxHistorical): + ms.SetMaxQueryForHistorical(ctx, msg.Changes.MaxAllowedDenomsHistoricalQuery) + + default: + return nil, fmt.Errorf("%s is not a relay oracle param key", key) + } + } + + return &types.MsgGovUpdateParamsResponse{}, nil +} diff --git a/x/relayoracle/keeper/msg_server_test.go b/x/relayoracle/keeper/msg_server_test.go new file mode 100644 index 00000000..1e6232d3 --- /dev/null +++ b/x/relayoracle/keeper/msg_server_test.go @@ -0,0 +1,157 @@ +package keeper_test + +import ( + "github.com/ojo-network/ojo/x/relayoracle/types" +) + +func (s *IntegrationTestSuite) TestMsgServer_UpdateGovParams() { + govAccAddr := s.app.GovKeeper.GetGovernanceAccount(s.ctx).GetAddress().String() + + testCases := []struct { + name string + req *types.MsgGovUpdateParams + expectErr bool + errMsg string + }{ + { + "valid max historical change", + &types.MsgGovUpdateParams{ + Authority: govAccAddr, + Title: "test", + Description: "test", + Keys: []string{string(types.KeyMaxHistorical)}, + Changes: types.Params{ + MaxAllowedDenomsHistoricalQuery: 30, + }, + }, + false, + "", + }, + { + "valid max exchange query change", + &types.MsgGovUpdateParams{ + Authority: govAccAddr, + Title: "test", + Description: "test", + Keys: []string{string(types.KeyMaxExchange)}, + Changes: types.Params{ + MaxAllowedDenomsExchangeQuery: 30, + }, + }, + false, + "", + }, + { + "valid packet timeout change", + &types.MsgGovUpdateParams{ + Authority: govAccAddr, + Title: "test", + Description: "test", + Keys: []string{string(types.KeyPacketTimeout)}, + Changes: types.Params{ + PacketTimeout: 30, + }, + }, + false, + "", + }, + { + "valid ibc request enabled change", + &types.MsgGovUpdateParams{ + Authority: govAccAddr, + Title: "test", + Description: "test", + Keys: []string{string(types.KeyIbcRequestEnabled)}, + Changes: types.Params{ + IbcRequestEnabled: true, + }, + }, + false, + "", + }, + + { + "multiple valid ibc changes", + &types.MsgGovUpdateParams{ + Authority: govAccAddr, + Title: "test", + Description: "test", + Keys: []string{ + string(types.KeyIbcRequestEnabled), + string(types.KeyPacketTimeout), + string(types.KeyMaxExchange), + string(types.KeyMaxHistorical), + }, + Changes: types.Params{ + IbcRequestEnabled: true, + PacketTimeout: 10, + MaxAllowedDenomsHistoricalQuery: 11, + MaxAllowedDenomsExchangeQuery: 12, + }, + }, + false, + "", + }, + { + "invalid key", + &types.MsgGovUpdateParams{ + Authority: govAccAddr, + Title: "test", + Description: "test", + Keys: []string{"test"}, + Changes: types.Params{}, + }, + true, + "test is not a relay oracle param key", + }, + + { + "bad authority", + &types.MsgGovUpdateParams{ + Authority: "ojo1zypqa76je7pxsdwkfah6mu9a583sju6xzthge3", + Title: "test", + Description: "test", + Keys: []string{string(types.KeyIbcRequestEnabled)}, + Changes: types.Params{ + IbcRequestEnabled: true, + }, + }, + true, + "expected gov account as only signer for proposal message", + }, + } + + for _, tc := range testCases { + // reset params + s.app.RelayOracle.SetParams(s.ctx, types.DefaultParams()) + + s.Run(tc.name, func() { + err := tc.req.ValidateBasic() + if err == nil { + _, err = s.msgServer.GovUpdateParams(s.ctx, tc.req) + } + + if tc.expectErr { + s.Require().ErrorContains(err, tc.errMsg) + } else { + s.Require().NoError(err) + + // check new params + params := s.app.RelayOracle.GetParams(s.ctx) + for _, key := range tc.req.Keys { + s.T().Log(tc.name, params, tc.req.Changes) + switch key { + case string(types.KeyMaxHistorical): + s.Require().EqualValues(params.MaxAllowedDenomsHistoricalQuery, tc.req.Changes.MaxAllowedDenomsHistoricalQuery) + case string(types.KeyMaxExchange): + s.Require().EqualValues(params.MaxAllowedDenomsExchangeQuery, tc.req.Changes.MaxAllowedDenomsExchangeQuery) + case string(types.KeyPacketTimeout): + s.Require().EqualValues(params.PacketTimeout, tc.req.Changes.PacketTimeout) + case string(types.KeyIbcRequestEnabled): + s.Require().EqualValues(params.IbcRequestEnabled, tc.req.Changes.IbcRequestEnabled) + } + } + } + }) + } +} diff --git a/x/relayoracle/keeper/params.go b/x/relayoracle/keeper/params.go new file mode 100644 index 00000000..311c6236 --- /dev/null +++ b/x/relayoracle/keeper/params.go @@ -0,0 +1,54 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/ojo-network/ojo/x/relayoracle/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + k.paramstore.GetParamSet(ctx, ¶ms) + return +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramstore.SetParamSet(ctx, ¶ms) +} + +func (k Keeper) SetIbcRequestEnabled(ctx sdk.Context, enabled bool) { + k.paramstore.Set(ctx, types.KeyIbcRequestEnabled, enabled) +} + +func (k Keeper) SetPacketTimeout(ctx sdk.Context, expiry uint64) { + k.paramstore.Set(ctx, types.KeyPacketTimeout, expiry) +} + +func (k Keeper) SetMaxQueryForExchangeRate(ctx sdk.Context, maxRequests uint64) { + k.paramstore.Set(ctx, types.KeyMaxExchange, maxRequests) +} + +func (k Keeper) SetMaxQueryForHistorical(ctx sdk.Context, expiry uint64) { + k.paramstore.Set(ctx, types.KeyMaxHistorical, expiry) +} + +func (k Keeper) GetMaxQueryForExchangeRate(ctx sdk.Context) (limit uint64) { + k.paramstore.Get(ctx, types.KeyMaxExchange, &limit) + return +} + +func (k Keeper) GetMaxQueryForHistorical(ctx sdk.Context) (limit uint64) { + k.paramstore.Get(ctx, types.KeyMaxHistorical, &limit) + return +} + +func (k Keeper) IbcRequestEnabled(ctx sdk.Context) (enabled bool) { + k.paramstore.Get(ctx, types.KeyIbcRequestEnabled, &enabled) + return +} + +func (k Keeper) PacketTimeout(ctx sdk.Context) (expiry uint64) { + k.paramstore.Get(ctx, types.KeyPacketTimeout, &expiry) + return +} diff --git a/x/relayoracle/keeper/params_test.go b/x/relayoracle/keeper/params_test.go new file mode 100644 index 00000000..2404ed3d --- /dev/null +++ b/x/relayoracle/keeper/params_test.go @@ -0,0 +1,19 @@ +package keeper_test + +import ( + "time" + + "github.com/ojo-network/ojo/x/relayoracle/types" +) + +func (s *IntegrationTestSuite) TestGetParams() { + app, ctx := s.app, s.ctx + + params := types.DefaultParams() + params.PacketTimeout = uint64(10 * time.Minute) + params.IbcRequestEnabled = false + + app.RelayOracle.SetParams(ctx, params) + s.Require().Equal(app.RelayOracle.IbcRequestEnabled(ctx), params.IbcRequestEnabled) + s.Require().Equal(app.RelayOracle.PacketTimeout(ctx), params.PacketTimeout) +} diff --git a/x/relayoracle/keeper/query_params.go b/x/relayoracle/keeper/query_params.go new file mode 100644 index 00000000..851bc676 --- /dev/null +++ b/x/relayoracle/keeper/query_params.go @@ -0,0 +1,33 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/ojo-network/ojo/x/relayoracle/types" +) + +var _ types.QueryServer = querier{} + +// Querier implements a QueryServer for the x/relayoracle module. +type querier struct { + Keeper +} + +// NewQuerier returns an implementation of the relayoracle QueryServer interface +// for the provided Keeper. +func NewQuerier(keeper Keeper) types.QueryServer { + return &querier{Keeper: keeper} +} + +func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request.go") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} diff --git a/x/relayoracle/keeper/query_params_test.go b/x/relayoracle/keeper/query_params_test.go new file mode 100644 index 00000000..1b56739c --- /dev/null +++ b/x/relayoracle/keeper/query_params_test.go @@ -0,0 +1,3 @@ +package keeper_test + +func (s *IntegrationTestSuite) Test_Params() {} diff --git a/x/relayoracle/keeper/request.go b/x/relayoracle/keeper/request.go new file mode 100644 index 00000000..7148a2c6 --- /dev/null +++ b/x/relayoracle/keeper/request.go @@ -0,0 +1,299 @@ +package keeper + +import ( + "fmt" + + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + host "github.com/cosmos/ibc-go/v7/modules/core/24-host" + + oracleTypes "github.com/ojo-network/ojo/x/oracle/types" + "github.com/ojo-network/ojo/x/relayoracle/types" +) + +func (k Keeper) AddRequest(ctx sdk.Context, req types.Request) { + k.SetRequest(ctx, req.RequestID, req) + k.AddRequestIDToPendingList(ctx, req.RequestID) +} + +func (k Keeper) GetNextRequestID(ctx sdk.Context) uint64 { + requestNumber := k.GetRequestCount(ctx) + k.SetRequestCount(ctx, requestNumber+1) + return requestNumber + 1 +} + +func (k Keeper) GetRequestCount(ctx sdk.Context) uint64 { + store := ctx.KVStore(k.storeKey) + return sdk.BigEndianToUint64(store.Get(types.RequestCountKey)) +} + +func (k Keeper) SetRequestCount(ctx sdk.Context, count uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(types.RequestCountKey, sdk.Uint64ToBigEndian(count)) +} + +func (k Keeper) SetRequest(ctx sdk.Context, id uint64, request types.Request) { + ctx.KVStore(k.storeKey).Set(types.RequestStoreKey(id), k.cdc.MustMarshal(&request)) +} + +func (k Keeper) GetRequest(ctx sdk.Context, id uint64) (types.Request, error) { + var request types.Request + bz := ctx.KVStore(k.storeKey).Get(types.RequestStoreKey(id)) + if bz == nil { + return request, sdkerrors.Wrapf(types.ErrRequestNotFound, "id %d", id) + } + + k.cdc.MustUnmarshal(bz, &request) + + return request, nil +} + +func (k Keeper) SetResult(ctx sdk.Context, result types.Result) { + ctx.KVStore(k.storeKey).Set(types.ResultStoreKey(result.RequestID), k.cdc.MustMarshal(&result)) +} + +// DeleteRequest removes the given data request from the store. +func (k Keeper) DeleteRequest(ctx sdk.Context, id uint64) { + ctx.KVStore(k.storeKey).Delete(types.RequestStoreKey(id)) +} + +func (k Keeper) PrepareRequest( + ctx sdk.Context, + ibcChannel *types.IBCChannel, + data *types.OracleRequestPacketData, +) (uint64, error) { + id := k.GetNextRequestID(ctx) + req := types.NewRequest(id, data.GetCalldata(), data.GetClientID(), ibcChannel) + k.AddRequest(ctx, req) + return id, nil +} + +func (k Keeper) GetPendingRequestList(ctx sdk.Context) []uint64 { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.PendingRequestListKey) + if len(bz) == 0 { + return []uint64{} + } + + var pending types.PendingRequestList + k.cdc.MustUnmarshal(bz, &pending) + + return pending.RequestIds +} + +func (k Keeper) SetPendingRequestList(ctx sdk.Context, reqIDS []uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(types.PendingRequestListKey, k.cdc.MustMarshal(&types.PendingRequestList{RequestIds: reqIDS})) +} + +func (k Keeper) AddRequestIDToPendingList(ctx sdk.Context, reqID uint64) { + var pending types.PendingRequestList + k.cdc.MustUnmarshal(ctx.KVStore(k.storeKey).Get(types.PendingRequestListKey), &pending) + pending.RequestIds = append(pending.RequestIds, reqID) + + k.SetPendingList(ctx, pending) +} + +func (k Keeper) SetPendingList(ctx sdk.Context, pending types.PendingRequestList) { + ctx.KVStore(k.storeKey).Set(types.PendingRequestListKey, k.cdc.MustMarshal(&pending)) +} + +func (k Keeper) FlushPendingRequestList(ctx sdk.Context) { + ctx.KVStore(k.storeKey).Delete(types.PendingRequestListKey) +} + +func (k Keeper) ResolveRequest(ctx sdk.Context, reqID uint64) { + req, err := k.GetRequest(ctx, reqID) + if err != nil { + panic(err) + } + + result, status := k.ProcessRequestCalldata(ctx, req.GetRequestCallData()) + k.ProcessResult(ctx, reqID, status, result) + + err = ctx.EventManager().EmitTypedEvents(&types.EventRequestResolve{ + RequestId: reqID, + Status: status, + }) + + if err != nil { + panic(err) + } +} + +func (k Keeper) ProcessResult(ctx sdk.Context, requestID uint64, status types.ResolveStatus, result []byte) { + req, err := k.GetRequest(ctx, requestID) + if err != nil { + panic(err) + } + + k.SetResult(ctx, types.Result{ + RequestID: requestID, + RequestCallData: req.RequestCallData, + ClientID: req.ClientID, + RequestHeight: req.RequestHeight, + RequestTime: req.RequestHeight, + Status: status, + Result: result, + }) + + expiry := k.PacketTimeout(ctx) + if req.IBCChannel != nil { + sourceChannel := req.IBCChannel.ChannelId + sourcePort := req.IBCChannel.PortId + + channelCap, ok := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(sourcePort, sourceChannel)) + if !ok { + err = ctx.EventManager().EmitTypedEvent(&types.EventPackedSendFailed{ + Error: fmt.Sprintf("channel not found for port ID (%s) channel ID (%s)", sourcePort, sourceChannel), + }) + if err != nil { + panic(err) + } + } + + packetData := types.NewOracleResponsePacketData( + req.ClientID, requestID, req.RequestTime, ctx.BlockTime().Unix(), status, result, + ) + + if _, err := k.channelKeeper.SendPacket( + ctx, + channelCap, + sourcePort, + sourceChannel, + clienttypes.NewHeight(0, 0), + uint64(ctx.BlockTime().UnixNano()+int64(expiry)), + packetData.ToBytes(), + ); err != nil { + err = ctx.EventManager().EmitTypedEvents(&types.EventPackedSendFailed{ + Error: fmt.Sprintf("unable to send packet %s", err), + }) + + if err != nil { + panic(err) + } + } + } +} + +func (k Keeper) ProcessRequestCalldata( + ctx sdk.Context, + requestEncoded []byte, +) (resultEncoded []byte, status types.ResolveStatus) { + var request types.RequestPrice + err := k.cdc.Unmarshal(requestEncoded, &request) + if err != nil { + return nil, types.RESOLVE_STATUS_FAILURE + } + + switch request.Request { + case types.PRICE_REQUEST_RATE: + priceStamps, err := k.oracleKeeper.IterateExchangeRatesForDenoms(ctx, request.GetDenoms()) + if err != nil { + return nil, types.RESOLVE_STATUS_FAILURE + } + + result := types.OracleRequestResult{} + for _, price := range priceStamps { + result.PriceData = append(result.PriceData, types.OracleData{ + ExchangeRate: []sdk.DecCoin{*price.ExchangeRate}, + BlockNum: []uint64{price.BlockNum}, + }) + } + + resultEncoded, err = result.Marshal() + if err != nil { + return nil, types.RESOLVE_STATUS_FAILURE + } + + case types.PRICE_REQUEST_MEDIAN: + numStamps := k.oracleKeeper.MaximumMedianStamps(ctx) + mediansPriceStamps := k.oracleKeeper.IterateHistoricPricesForDenoms( + ctx, + oracleTypes.KeyPrefixMedian, + request.GetDenoms(), + uint(numStamps), + ) + mediansPriceStamps.Sort() + medianData := mediansPriceStamps.MapDenoms() + + result := types.OracleRequestResult{} + for _, medians := range medianData { + result.PriceData = append(result.PriceData, types.OracleData{ + ExchangeRate: medians.Rates, + BlockNum: medians.BlockNums, + }) + } + + resultEncoded, err = result.Marshal() + if err != nil { + return nil, types.RESOLVE_STATUS_FAILURE + } + + case types.PRICE_REQUEST_DEVIATION: + numStamps := k.oracleKeeper.MaximumMedianStamps(ctx) + deviationsPriceStamps := k.oracleKeeper.IterateHistoricPricesForDenoms( + ctx, + oracleTypes.KeyPrefixMedianDeviation, + request.GetDenoms(), + uint(numStamps), + ) + deviationsPriceStamps.Sort() + deviationData := deviationsPriceStamps.MapDenoms() + + result := types.OracleRequestResult{} + for _, deviations := range deviationData { + result.PriceData = append(result.PriceData, types.OracleData{ + ExchangeRate: deviations.Rates, + BlockNum: deviations.BlockNums, + }) + } + + resultEncoded, err = result.Marshal() + if err != nil { + return nil, types.RESOLVE_STATUS_FAILURE + } + + default: + return nil, types.RESOLVE_STATUS_FAILURE + } + + return resultEncoded, types.RESOLVE_STATUS_SUCCESS +} + +// AllResults iterates and returns over all stored results +func (k Keeper) AllResults(ctx sdk.Context) []types.Result { + var results []types.Result + store := ctx.KVStore(k.storeKey) + + iter := sdk.KVStorePrefixIterator(store, types.ResultStoreKeyPrefix) + defer iter.Close() + + for ; iter.Valid(); iter.Next() { + var result types.Result + k.cdc.MustUnmarshal(iter.Value(), &result) + + results = append(results, result) + } + + return results +} + +// AllRequests iterates and returns over all stored requests +func (k Keeper) AllRequests(ctx sdk.Context) []types.Request { + var requests []types.Request + store := ctx.KVStore(k.storeKey) + + iter := sdk.KVStorePrefixIterator(store, types.RequestStoreKeyPrefix) + defer iter.Close() + + for ; iter.Valid(); iter.Next() { + var request types.Request + k.cdc.MustUnmarshal(iter.Value(), &request) + + requests = append(requests, request) + } + + return requests +} diff --git a/x/relayoracle/keeper/request_test.go b/x/relayoracle/keeper/request_test.go new file mode 100644 index 00000000..408baaca --- /dev/null +++ b/x/relayoracle/keeper/request_test.go @@ -0,0 +1,134 @@ +package keeper_test + +import "github.com/ojo-network/ojo/x/relayoracle/types" + +func (s *IntegrationTestSuite) TestAddRequest() { + req := types.Request{ + RequestCallData: nil, + ClientID: "", + RequestHeight: 0, + RequestTime: 0, + IBCChannel: nil, + } + + id := s.app.RelayOracle.AddRequest(s.ctx, req) + + s.Require().EqualValues(1, id) + + storedReq, err := s.app.RelayOracle.GetRequest(s.ctx, id) + s.Require().NoError(err) + s.Require().Equal(req, storedReq) + + // check pending list + reqIds := s.app.RelayOracle.GetPendingRequestList(s.ctx) + s.Require().Len(reqIds, 1) + + s.Require().EqualValues(reqIds[0], 1) +} + +func (s *IntegrationTestSuite) TestGetSetRequestCount() { + s.app.RelayOracle.SetRequestCount(s.ctx, 5) + + count := s.app.RelayOracle.GetRequestCount(s.ctx) + s.Require().Equal(uint64(5), count) +} + +func (s *IntegrationTestSuite) TestSetGetRequest() { + req := types.Request{ + RequestCallData: nil, + ClientID: "", + RequestHeight: 0, + RequestTime: 0, + IBCChannel: nil, + } + + s.app.RelayOracle.SetRequest(s.ctx, 1, req) + + storedReq, err := s.app.RelayOracle.GetRequest(s.ctx, 1) + s.Require().NoError(err) + s.Require().Equal(req, storedReq) +} + +func (s *IntegrationTestSuite) TestDeleteRequest() { + req := types.Request{ + RequestCallData: nil, + ClientID: "", + RequestHeight: 0, + RequestTime: 0, + IBCChannel: nil, + } + + s.app.RelayOracle.SetRequest(s.ctx, 1, req) + s.app.RelayOracle.DeleteRequest(s.ctx, 1) + + _, err := s.app.RelayOracle.GetRequest(s.ctx, 1) + s.Require().ErrorIs(err, types.ErrRequestNotFound) +} + +func (s *IntegrationTestSuite) TestSetGetResult() { + res := types.Result{ + RequestID: 100, + RequestCallData: nil, + ClientID: "", + RequestHeight: 0, + RequestTime: 0, + Status: 0, + Result: nil, + } + + s.app.RelayOracle.SetResult(s.ctx, res) + storedResBz := s.ctx.KVStore(s.app.GetKey(types.StoreKey)).Get(types.ResultStoreKey(res.RequestID)) + + var storedRes types.Result + s.app.AppCodec().MustUnmarshal(storedResBz, &storedRes) + + s.Require().Equal(res, storedRes) +} + +func (s *IntegrationTestSuite) TestAddRequestIDToPendingList() { + reqID := uint64(1) + s.app.RelayOracle.AddRequestIDToPendingList(s.ctx, reqID) + + pendingRequestIds := s.app.RelayOracle.GetPendingRequestList(s.ctx) + + s.Require().Contains(pendingRequestIds, reqID) +} + +func (s *IntegrationTestSuite) TestFlushPendingRequestList() { + reqID := uint64(1) + s.app.RelayOracle.AddRequestIDToPendingList(s.ctx, reqID) + + s.app.RelayOracle.FlushPendingRequestList(s.ctx) + + // Try to get the pending request list from the store + storedPendingBz := s.ctx.KVStore(s.app.GetKey(types.StoreKey)).Get(types.PendingRequestListKey) + s.Require().Nil(storedPendingBz) + + pendingRequestIds := s.app.RelayOracle.GetPendingRequestList(s.ctx) + s.Require().Empty(pendingRequestIds) +} + +func (s *IntegrationTestSuite) TestProcessResult() { + req := types.Request{ + RequestCallData: nil, + ClientID: "", + RequestHeight: 0, + RequestTime: 0, + IBCChannel: nil, + } + + id := s.app.RelayOracle.AddRequest(s.ctx, req) + + status := types.RESOLVE_STATUS_SUCCESS + resultData := []byte("dummyResult") + + s.app.RelayOracle.ProcessResult(s.ctx, id, status, resultData) + storedResBz := s.ctx.KVStore(s.app.GetKey(types.StoreKey)).Get(types.ResultStoreKey(id)) + + var storedRes types.Result + s.app.AppCodec().MustUnmarshal(storedResBz, &storedRes) + + s.Require().Equal(id, storedRes.RequestID) + s.Require().Equal(status, storedRes.Status) + s.Require().Equal(resultData, storedRes.Result) +} diff --git a/x/relayoracle/module.go b/x/relayoracle/module.go new file mode 100644 index 00000000..0209ace6 --- /dev/null +++ b/x/relayoracle/module.go @@ -0,0 +1,145 @@ +package relayoracle + +import ( + "context" + "encoding/json" + "fmt" + + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "github.com/ojo-network/ojo/x/relayoracle/client/cli" + "github.com/ojo-network/ojo/x/relayoracle/keeper" + "github.com/ojo-network/ojo/x/relayoracle/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ porttypes.IBCModule = IBCModule{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for x/relayoracle module +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the name of the module as a string +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec for the for x/relayoracle module +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns the x/relayoracle module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err != nil { + panic(err) + } +} + +// GetTxCmd returns the root Tx command for the x/relayoracle module. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return nil +} + +// GetQueryCmd returns the root query command for the x/relayoracle module. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerier(am.keeper)) +} + +// RegisterInvariants registers the invariants of the for x/relayoracle module +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the module's genesis initialization. It returns no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion is a sequence number for state-breaking change of the for x/relayoracle module +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock contains the logic that is automatically triggered at the beginning of each block +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock contains the logic that is automatically triggered at the end of each block +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + EndBlocker(ctx, am.keeper) + return []abci.ValidatorUpdate{} +} diff --git a/x/relayoracle/module_ibc.go b/x/relayoracle/module_ibc.go new file mode 100644 index 00000000..fc6bcd71 --- /dev/null +++ b/x/relayoracle/module_ibc.go @@ -0,0 +1,191 @@ +package relayoracle + +import ( + "strings" + + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerror "github.com/cosmos/cosmos-sdk/types/errors" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" + host "github.com/cosmos/ibc-go/v7/modules/core/24-host" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + + "github.com/ojo-network/ojo/x/relayoracle/keeper" + "github.com/ojo-network/ojo/x/relayoracle/types" +) + +type IBCModule struct { + keeper keeper.Keeper +} + +func NewIBCModule(k keeper.Keeper) IBCModule { + return IBCModule{ + keeper: k, + } +} + +// OnChanOpenInit implements the IBCModule interface +func (im IBCModule) OnChanOpenInit( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID string, + channelID string, + chanCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + version string, +) (string, error) { + // Require portID is the portID module is bound to + boundPort := im.keeper.GetPort(ctx) + if boundPort != portID { + return "", sdkerrors.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) + } + + if strings.TrimSpace(version) == "" { + version = types.Version + } + + if version != types.Version { + return "", sdkerrors.Wrapf(types.ErrInvalidVersion, "got %s, expected %s", version, types.Version) + } + + // Claim channel capability passed back by IBC module + if err := im.keeper.ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)); err != nil { + return "", err + } + + return version, nil +} + +// OnChanOpenTry implements the IBCModule interface +func (im IBCModule) OnChanOpenTry( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID, + channelID string, + chanCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + counterpartyVersion string, +) (string, error) { + // Require portID is the portID module is bound to + boundPort := im.keeper.GetPort(ctx) + if boundPort != portID { + return "", sdkerrors.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) + } + + if counterpartyVersion != types.Version { + return "", sdkerrors.Wrapf( + types.ErrInvalidVersion, + "invalid counterparty version: got: %s, expected %s", counterpartyVersion, types.Version, + ) + } + + // Module may have already claimed capability in OnChanOpenInit in the case of crossing hellos + // (ie chainA and chainB both call ChanOpenInit before one of them calls ChanOpenTry) + // If module can already authenticate the capability then module already owns it so we don't need to claim + // Otherwise, module does not have channel capability and we must claim it from IBC + if !im.keeper.AuthenticateCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)) { + // Only claim channel capability passed back by IBC module if we do not already own it + if err := im.keeper.ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)); err != nil { + return "", err + } + } + + return types.Version, nil +} + +// OnChanOpenAck implements the IBCModule interface +func (im IBCModule) OnChanOpenAck( + ctx sdk.Context, + portID, + channelID string, + _, + counterpartyVersion string, +) error { + if counterpartyVersion != types.Version { + return sdkerrors.Wrapf( + types.ErrInvalidVersion, + "invalid counterparty version: %s, expected %s", counterpartyVersion, types.Version, + ) + } + + return nil +} + +// OnChanOpenConfirm implements the IBCModule interface +func (im IBCModule) OnChanOpenConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + return nil +} + +// OnChanCloseInit implements the IBCModule interface +func (im IBCModule) OnChanCloseInit( + ctx sdk.Context, + portID, + channelID string, +) error { + // Disallow user-initiated channel closing for channels + return sdkerrors.Wrap(sdkerror.ErrInvalidRequest, "user cannot close channel") +} + +// OnChanCloseConfirm implements the IBCModule interface +func (im IBCModule) OnChanCloseConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + return nil +} + +// OnRecvPacket implements the IBCModule interface +func (im IBCModule) OnRecvPacket( + ctx sdk.Context, + modulePacket channeltypes.Packet, + relayer sdk.AccAddress, +) ibcexported.Acknowledgement { + if !im.keeper.IbcRequestEnabled(ctx) { + return channeltypes.NewErrorAcknowledgement(types.ErrIbcRequestDisabled) + } + + var modulePacketData types.OracleRequestPacketData + if err := modulePacketData.Unmarshal(modulePacket.GetData()); err != nil { + return channeltypes.NewErrorAcknowledgement( + sdkerrors.Wrapf(sdkerror.ErrUnknownRequest, "cannot unmarshal packet data: %s", err.Error()), + ) + } + + // process module packet data + id, requestType, err := im.keeper.OnRecvPacket(ctx, modulePacket, modulePacketData) + if err != nil { + return channeltypes.NewErrorAcknowledgement(err) + } + + // NOTE: acknowledgement will be written synchronously during IBC handler execution. + return channeltypes.NewResultAcknowledgement( + types.ModuleCdc.MustMarshal(types.NewRequestOracleAcknowledgement(id, requestType))) +} + +// OnAcknowledgementPacket implements the IBCModule interface +func (im IBCModule) OnAcknowledgementPacket( + ctx sdk.Context, + modulePacket channeltypes.Packet, + acknowledgement []byte, + relayer sdk.AccAddress, +) error { + return nil +} + +// OnTimeoutPacket implements the IBCModule interface +func (im IBCModule) OnTimeoutPacket( + ctx sdk.Context, + modulePacket channeltypes.Packet, + relayer sdk.AccAddress, +) error { + return nil +} diff --git a/x/relayoracle/module_ibc_test.go b/x/relayoracle/module_ibc_test.go new file mode 100644 index 00000000..00efeefd --- /dev/null +++ b/x/relayoracle/module_ibc_test.go @@ -0,0 +1 @@ +package relayoracle_test diff --git a/x/relayoracle/module_simulation.go b/x/relayoracle/module_simulation.go new file mode 100644 index 00000000..affa8195 --- /dev/null +++ b/x/relayoracle/module_simulation.go @@ -0,0 +1,61 @@ +package relayoracle + +// +// import ( +// "math/rand" +// +// "github.com/ojo-network/ojo/testutil/sample" +// relayoraclesimulation "github.com/ojo-network/ojo/x/relayoracle/simulation" +// "github.com/ojo-network/ojo/x/relayoracle/types" +// "github.com/cosmos/cosmos-sdk/baseapp" +// sdk "github.com/cosmos/cosmos-sdk/types" +// "github.com/cosmos/cosmos-sdk/types/module" +// simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +// "github.com/cosmos/cosmos-sdk/x/simulation" +//) +// +//// avoid unused import issue +// var ( +// _ = sample.AccAddress +// _ = relayoraclesimulation.FindAccount +// _ = simulation.MsgEntryKind +// _ = baseapp.Paramspace +// _ = rand.Rand{} +//) +// +// const ( +//) +// +//// GenerateGenesisState creates a randomized GenState of the module. +// func (AppModule) GenerateGenesisState(simState *module.SimulationState) { +// accs := make([]string, len(simState.Accounts)) +// for i, acc := range simState.Accounts { +// accs[i] = acc.Address.String() +// } +// relayoracleGenesis := types.GenesisState{ +// Params: types.DefaultParams(), +// PortId: types.PortID, +// } +// simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&relayoracleGenesis) +//} +// +//// RegisterStoreDecoder registers a decoder. +// func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} +// +//// ProposalContents doesn't return any content functions for governance proposals. +// func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { +// return nil +//} +// +//// WeightedOperations returns the all the gov module operations with their respective weights. +// func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { +// operations := make([]simtypes.WeightedOperation, 0) +// +// return operations +//} +// +//// ProposalMsgs returns msgs used for governance proposals for simulations. +// func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { +// return []simtypes.WeightedProposalMsg{ +// } +//} diff --git a/x/relayoracle/simulation/helpers.go b/x/relayoracle/simulation/helpers.go new file mode 100644 index 00000000..92c437c0 --- /dev/null +++ b/x/relayoracle/simulation/helpers.go @@ -0,0 +1,15 @@ +package simulation + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +// FindAccount find a specific address from an account list +func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { + creator, err := sdk.AccAddressFromBech32(address) + if err != nil { + panic(err) + } + return simtypes.FindAccount(accs, creator) +} diff --git a/x/relayoracle/types/codec.go b/x/relayoracle/types/codec.go new file mode 100644 index 00000000..e6736d8d --- /dev/null +++ b/x/relayoracle/types/codec.go @@ -0,0 +1,32 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) + +func init() { + RegisterCodec(amino) + cryptocodec.RegisterCrypto(amino) + amino.Seal() +} + +func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgGovUpdateParams{}, "ojo/relayoracle/MsgGovUpdateParams", nil) +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgGovUpdateParams{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} diff --git a/x/relayoracle/types/encoding.go b/x/relayoracle/types/encoding.go new file mode 100644 index 00000000..ab1254f4 --- /dev/null +++ b/x/relayoracle/types/encoding.go @@ -0,0 +1 @@ +package types diff --git a/x/relayoracle/types/errors.go b/x/relayoracle/types/errors.go new file mode 100644 index 00000000..d8297f48 --- /dev/null +++ b/x/relayoracle/types/errors.go @@ -0,0 +1,17 @@ +package types + +// DONTCOVER + +import ( + sdkerrors "cosmossdk.io/errors" +) + +// x/relayoracle module sentinel errors +var ( + ErrInvalidPacketTimeout = sdkerrors.Register(ModuleName, 1, "invalid packet timeout") + ErrInvalidVersion = sdkerrors.Register(ModuleName, 2, "invalid version") + ErrIbcRequestDisabled = sdkerrors.Register(ModuleName, 3, "ibc request.go disabled") + ErrRequestNotFound = sdkerrors.Register(ModuleName, 4, "request not found") + ErrTooManyDenoms = sdkerrors.Register(ModuleName, 5, "total denoms exceeds threshold") + ErrNoDenoms = sdkerrors.Register(ModuleName, 6, "no denoms in request") +) diff --git a/x/relayoracle/types/events.pb.go b/x/relayoracle/types/events.pb.go new file mode 100644 index 00000000..7d71ed7e --- /dev/null +++ b/x/relayoracle/types/events.pb.go @@ -0,0 +1,753 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ojo/relayoracle/v1/events.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type EventNewRequest struct { + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + RequestId uint64 `protobuf:"varint,2,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + RequestHeight uint64 `protobuf:"varint,3,opt,name=request_height,json=requestHeight,proto3" json:"request_height,omitempty"` +} + +func (m *EventNewRequest) Reset() { *m = EventNewRequest{} } +func (m *EventNewRequest) String() string { return proto.CompactTextString(m) } +func (*EventNewRequest) ProtoMessage() {} +func (*EventNewRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_1e80a4c874608eff, []int{0} +} +func (m *EventNewRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventNewRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventNewRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EventNewRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventNewRequest.Merge(m, src) +} +func (m *EventNewRequest) XXX_Size() int { + return m.Size() +} +func (m *EventNewRequest) XXX_DiscardUnknown() { + xxx_messageInfo_EventNewRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_EventNewRequest proto.InternalMessageInfo + +func (m *EventNewRequest) GetClientId() string { + if m != nil { + return m.ClientId + } + return "" +} + +func (m *EventNewRequest) GetRequestId() uint64 { + if m != nil { + return m.RequestId + } + return 0 +} + +func (m *EventNewRequest) GetRequestHeight() uint64 { + if m != nil { + return m.RequestHeight + } + return 0 +} + +type EventRequestResolve struct { + RequestId uint64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + Status ResolveStatus `protobuf:"varint,2,opt,name=status,proto3,enum=ojo.relayoracle.v1.ResolveStatus" json:"status,omitempty"` +} + +func (m *EventRequestResolve) Reset() { *m = EventRequestResolve{} } +func (m *EventRequestResolve) String() string { return proto.CompactTextString(m) } +func (*EventRequestResolve) ProtoMessage() {} +func (*EventRequestResolve) Descriptor() ([]byte, []int) { + return fileDescriptor_1e80a4c874608eff, []int{1} +} +func (m *EventRequestResolve) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventRequestResolve) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventRequestResolve.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EventRequestResolve) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventRequestResolve.Merge(m, src) +} +func (m *EventRequestResolve) XXX_Size() int { + return m.Size() +} +func (m *EventRequestResolve) XXX_DiscardUnknown() { + xxx_messageInfo_EventRequestResolve.DiscardUnknown(m) +} + +var xxx_messageInfo_EventRequestResolve proto.InternalMessageInfo + +func (m *EventRequestResolve) GetRequestId() uint64 { + if m != nil { + return m.RequestId + } + return 0 +} + +func (m *EventRequestResolve) GetStatus() ResolveStatus { + if m != nil { + return m.Status + } + return RESOLVE_STATUS_OPEN +} + +type EventPackedSendFailed struct { + Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` +} + +func (m *EventPackedSendFailed) Reset() { *m = EventPackedSendFailed{} } +func (m *EventPackedSendFailed) String() string { return proto.CompactTextString(m) } +func (*EventPackedSendFailed) ProtoMessage() {} +func (*EventPackedSendFailed) Descriptor() ([]byte, []int) { + return fileDescriptor_1e80a4c874608eff, []int{2} +} +func (m *EventPackedSendFailed) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventPackedSendFailed) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventPackedSendFailed.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *EventPackedSendFailed) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventPackedSendFailed.Merge(m, src) +} +func (m *EventPackedSendFailed) XXX_Size() int { + return m.Size() +} +func (m *EventPackedSendFailed) XXX_DiscardUnknown() { + xxx_messageInfo_EventPackedSendFailed.DiscardUnknown(m) +} + +var xxx_messageInfo_EventPackedSendFailed proto.InternalMessageInfo + +func (m *EventPackedSendFailed) GetError() string { + if m != nil { + return m.Error + } + return "" +} + +func init() { + proto.RegisterType((*EventNewRequest)(nil), "ojo.relayoracle.v1.EventNewRequest") + proto.RegisterType((*EventRequestResolve)(nil), "ojo.relayoracle.v1.EventRequestResolve") + proto.RegisterType((*EventPackedSendFailed)(nil), "ojo.relayoracle.v1.EventPackedSendFailed") +} + +func init() { proto.RegisterFile("ojo/relayoracle/v1/events.proto", fileDescriptor_1e80a4c874608eff) } + +var fileDescriptor_1e80a4c874608eff = []byte{ + // 305 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x50, 0xcd, 0x4a, 0xf3, 0x40, + 0x14, 0xed, 0x7c, 0x9f, 0x16, 0x3b, 0x60, 0x85, 0xa8, 0x50, 0x14, 0xc7, 0x5a, 0x10, 0xba, 0xe9, + 0x84, 0xea, 0xca, 0xad, 0xa0, 0xb4, 0x1b, 0x91, 0x74, 0xe7, 0x46, 0xd2, 0xcc, 0xa5, 0x4d, 0x1b, + 0x73, 0xeb, 0xcc, 0x6d, 0x6a, 0xdf, 0xc2, 0xc7, 0x72, 0xd9, 0xa5, 0x4b, 0x69, 0x5e, 0x44, 0x32, + 0x19, 0x41, 0xab, 0xbb, 0x99, 0x73, 0xcf, 0x0f, 0xe7, 0xf0, 0x53, 0x9c, 0xa0, 0xaf, 0x21, 0x09, + 0x97, 0xa8, 0xc3, 0x28, 0x01, 0x3f, 0xeb, 0xfa, 0x90, 0x41, 0x4a, 0x46, 0xce, 0x34, 0x12, 0x7a, + 0x1e, 0x4e, 0x50, 0x7e, 0x23, 0xc8, 0xac, 0x7b, 0xf4, 0x97, 0x68, 0x16, 0x46, 0x53, 0xa0, 0x52, + 0xd4, 0x22, 0xbe, 0x77, 0x53, 0x98, 0xdc, 0xc1, 0x22, 0x80, 0xe7, 0x39, 0x18, 0xf2, 0x8e, 0x79, + 0x2d, 0x4a, 0x62, 0x48, 0xe9, 0x31, 0x56, 0x0d, 0xd6, 0x64, 0xed, 0x5a, 0xb0, 0x53, 0x02, 0x7d, + 0xe5, 0x9d, 0x70, 0xae, 0x4b, 0x5e, 0x71, 0xfd, 0xd7, 0x64, 0xed, 0xad, 0xa0, 0xe6, 0x90, 0xbe, + 0xf2, 0xce, 0x79, 0xfd, 0xeb, 0x3c, 0x86, 0x78, 0x34, 0xa6, 0xc6, 0x7f, 0x4b, 0xd9, 0x75, 0x68, + 0xcf, 0x82, 0x2d, 0xe4, 0xfb, 0x36, 0xd5, 0x45, 0x06, 0x60, 0x30, 0xc9, 0x60, 0xc3, 0x9c, 0x6d, + 0x9a, 0x5f, 0xf1, 0xaa, 0xa1, 0x90, 0xe6, 0xc6, 0xe6, 0xd6, 0x2f, 0xce, 0xe4, 0xef, 0xc6, 0xd2, + 0x79, 0x0d, 0x2c, 0x31, 0x70, 0x82, 0x56, 0x87, 0x1f, 0xda, 0xc0, 0xfb, 0xa2, 0xbb, 0x1a, 0x40, + 0xaa, 0x6e, 0xc3, 0x38, 0x01, 0xe5, 0x1d, 0xf0, 0x6d, 0xd0, 0x1a, 0xb5, 0x2b, 0x5a, 0x7e, 0xae, + 0x7b, 0x6f, 0x6b, 0xc1, 0x56, 0x6b, 0xc1, 0x3e, 0xd6, 0x82, 0xbd, 0xe6, 0xa2, 0xb2, 0xca, 0x45, + 0xe5, 0x3d, 0x17, 0x95, 0x07, 0x39, 0x8a, 0x69, 0x3c, 0x1f, 0xca, 0x08, 0x9f, 0x7c, 0x9c, 0x60, + 0x27, 0x05, 0x5a, 0xa0, 0x9e, 0x16, 0x6f, 0xff, 0xe5, 0xc7, 0xd2, 0xb4, 0x9c, 0x81, 0x19, 0x56, + 0xed, 0xcc, 0x97, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xdb, 0x0a, 0x35, 0x99, 0xbe, 0x01, 0x00, + 0x00, +} + +func (m *EventNewRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EventNewRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventNewRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.RequestHeight != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.RequestHeight)) + i-- + dAtA[i] = 0x18 + } + if m.RequestId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.RequestId)) + i-- + dAtA[i] = 0x10 + } + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventRequestResolve) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EventRequestResolve) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventRequestResolve) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Status != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x10 + } + if m.RequestId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.RequestId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *EventPackedSendFailed) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *EventPackedSendFailed) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventPackedSendFailed) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Error) > 0 { + i -= len(m.Error) + copy(dAtA[i:], m.Error) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Error))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { + offset -= sovEvents(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *EventNewRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.RequestId != 0 { + n += 1 + sovEvents(uint64(m.RequestId)) + } + if m.RequestHeight != 0 { + n += 1 + sovEvents(uint64(m.RequestHeight)) + } + return n +} + +func (m *EventRequestResolve) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.RequestId != 0 { + n += 1 + sovEvents(uint64(m.RequestId)) + } + if m.Status != 0 { + n += 1 + sovEvents(uint64(m.Status)) + } + return n +} + +func (m *EventPackedSendFailed) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Error) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func sovEvents(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvents(x uint64) (n int) { + return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *EventNewRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventNewRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventNewRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestId", wireType) + } + m.RequestId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestHeight", wireType) + } + m.RequestHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventRequestResolve) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventRequestResolve: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventRequestResolve: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestId", wireType) + } + m.RequestId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= ResolveStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventPackedSendFailed) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventPackedSendFailed: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventPackedSendFailed: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Error = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipEvents(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEvents + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEvents + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEvents + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthEvents + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEvents + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEvents + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEvents = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEvents = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEvents = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/relayoracle/types/expected_ibc_keeper.go b/x/relayoracle/types/expected_ibc_keeper.go new file mode 100644 index 00000000..fb2f6a18 --- /dev/null +++ b/x/relayoracle/types/expected_ibc_keeper.go @@ -0,0 +1,36 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" +) + +// ChannelKeeper defines the expected IBC channel keeper. +type ChannelKeeper interface { + GetChannel(ctx sdk.Context, portID, channelID string) (channeltypes.Channel, bool) + GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) + SendPacket( + ctx sdk.Context, + channelCap *capabilitytypes.Capability, + sourcePort string, + sourceChannel string, + timeoutHeight clienttypes.Height, + timeoutTimestamp uint64, + data []byte, + ) (uint64, error) + ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capabilitytypes.Capability) error +} + +// PortKeeper defines the expected IBC port keeper. +type PortKeeper interface { + BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability +} + +// ScopedKeeper defines the expected IBC scoped keeper. +type ScopedKeeper interface { + GetCapability(ctx sdk.Context, name string) (*capabilitytypes.Capability, bool) + AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool + ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error +} diff --git a/x/relayoracle/types/expected_keepers.go b/x/relayoracle/types/expected_keepers.go new file mode 100644 index 00000000..594718b1 --- /dev/null +++ b/x/relayoracle/types/expected_keepers.go @@ -0,0 +1,28 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" + + oracleTypes "github.com/ojo-network/ojo/x/oracle/types" +) + +type OracleKeeper interface { + IterateExchangeRatesForDenoms(ctx sdk.Context, denoms []string) (oracleTypes.PriceStamps, error) + IterateHistoricPricesForDenoms(ctx sdk.Context, prefix []byte, denoms []string, numStamps uint) oracleTypes.PriceStamps + HasActiveExchangeRates(ctx sdk.Context, denom []string) (bool, error) + HasActiveHistoricalRates(ctx sdk.Context, denom []string) (bool, error) + MaximumMedianStamps(ctx sdk.Context) (res uint64) +} + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + // Methods imported from account should be defined here +} + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + // Methods imported from bank should be defined here +} diff --git a/x/relayoracle/types/genesis.go b/x/relayoracle/types/genesis.go new file mode 100644 index 00000000..6d7125f8 --- /dev/null +++ b/x/relayoracle/types/genesis.go @@ -0,0 +1,52 @@ +package types + +import ( + "fmt" + + host "github.com/cosmos/ibc-go/v7/modules/core/24-host" +) + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + PortId: PortID, + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + if err := host.PortIdentifierValidator(gs.PortId); err != nil { + return err + } + + err := gs.Params.Validate() + if err != nil { + return err + } + + requestIds := make(map[uint64]struct{}) + for _, request := range gs.Requests { + if _, found := requestIds[request.RequestID]; found { + return fmt.Errorf("duplicated request id: %d", request.RequestID) + } + + requestIds[request.RequestID] = struct{}{} + } + + // check if all pending requests and results have a valid request object + for _, pending := range gs.GetPendingRequestIds() { + if _, found := requestIds[pending]; !found { + return fmt.Errorf("pending request id not found: %d", pending) + } + } + + for _, result := range gs.GetResults() { + if _, found := requestIds[result.RequestID]; !found { + return fmt.Errorf("result request id not found: %d", result.RequestID) + } + } + + return nil +} diff --git a/x/relayoracle/types/genesis.pb.go b/x/relayoracle/types/genesis.pb.go new file mode 100644 index 00000000..572a32e0 --- /dev/null +++ b/x/relayoracle/types/genesis.pb.go @@ -0,0 +1,612 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ojo/relayoracle/v1/genesis.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + _ "github.com/gogo/protobuf/gogoproto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the relayoracle module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + PortId string `protobuf:"bytes,2,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + Requests []Request `protobuf:"bytes,3,rep,name=requests,proto3" json:"requests"` + Results []Result `protobuf:"bytes,4,rep,name=results,proto3" json:"results"` + PendingRequestIds []uint64 `protobuf:"varint,5,rep,packed,name=pending_request_ids,json=pendingRequestIds,proto3" json:"pending_request_ids,omitempty"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_9e4d4e856904e0ef, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func (m *GenesisState) GetPortId() string { + if m != nil { + return m.PortId + } + return "" +} + +func (m *GenesisState) GetRequests() []Request { + if m != nil { + return m.Requests + } + return nil +} + +func (m *GenesisState) GetResults() []Result { + if m != nil { + return m.Results + } + return nil +} + +func (m *GenesisState) GetPendingRequestIds() []uint64 { + if m != nil { + return m.PendingRequestIds + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "ojo.relayoracle.v1.GenesisState") +} + +func init() { proto.RegisterFile("ojo/relayoracle/v1/genesis.proto", fileDescriptor_9e4d4e856904e0ef) } + +var fileDescriptor_9e4d4e856904e0ef = []byte{ + // 316 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0xb1, 0x4e, 0xeb, 0x30, + 0x14, 0x86, 0xe3, 0xb6, 0xb7, 0xbd, 0xb8, 0x2c, 0x18, 0x24, 0xa2, 0x20, 0xb9, 0x11, 0x53, 0x16, + 0x6c, 0xb5, 0x2c, 0x08, 0x89, 0xa5, 0x0b, 0x74, 0x43, 0x61, 0x63, 0xa9, 0xd2, 0xc6, 0x0a, 0x29, + 0x6d, 0x4e, 0xb0, 0xdd, 0x42, 0xdf, 0x81, 0x81, 0xc7, 0xea, 0xd8, 0x91, 0x09, 0xa1, 0xe4, 0x45, + 0x50, 0x12, 0x83, 0x40, 0x44, 0x6c, 0xc7, 0x3a, 0xdf, 0xff, 0x1d, 0xeb, 0xc7, 0x2e, 0xcc, 0x80, + 0x4b, 0x31, 0x0f, 0xd6, 0x20, 0x83, 0xe9, 0x5c, 0xf0, 0x55, 0x9f, 0x47, 0x22, 0x11, 0x2a, 0x56, + 0x2c, 0x95, 0xa0, 0x81, 0x10, 0x98, 0x01, 0xfb, 0x46, 0xb0, 0x55, 0xdf, 0x39, 0x88, 0x20, 0x82, + 0x72, 0xcd, 0x8b, 0xa9, 0x22, 0x9d, 0x5e, 0x8d, 0x2b, 0x0d, 0x64, 0xb0, 0x50, 0x7f, 0x00, 0x46, + 0x5a, 0x02, 0xc7, 0xcf, 0x0d, 0xbc, 0x7b, 0x59, 0x5d, 0xbf, 0xd1, 0x81, 0x16, 0xe4, 0x0c, 0xb7, + 0x2b, 0x83, 0x8d, 0x5c, 0xe4, 0x75, 0x07, 0x0e, 0xfb, 0xfd, 0x1b, 0x76, 0x5d, 0x12, 0xc3, 0xd6, + 0xe6, 0xad, 0x67, 0xf9, 0x86, 0x27, 0x87, 0xb8, 0x93, 0x82, 0xd4, 0xe3, 0x38, 0xb4, 0x1b, 0x2e, + 0xf2, 0x76, 0xfc, 0x76, 0xf1, 0x1c, 0x85, 0xe4, 0x02, 0xff, 0x97, 0xe2, 0x61, 0x29, 0x94, 0x56, + 0x76, 0xd3, 0x6d, 0x7a, 0xdd, 0xc1, 0x51, 0x9d, 0xd4, 0xaf, 0x18, 0x63, 0xfd, 0x8a, 0x90, 0x73, + 0xdc, 0x91, 0x42, 0x2d, 0xe7, 0x5a, 0xd9, 0xad, 0x32, 0xed, 0xd4, 0xa7, 0x0b, 0xc4, 0x84, 0x3f, + 0x03, 0x84, 0xe1, 0xfd, 0x54, 0x24, 0x61, 0x9c, 0x44, 0x63, 0xe3, 0x1b, 0xc7, 0xa1, 0xb2, 0xff, + 0xb9, 0x4d, 0xaf, 0xe5, 0xef, 0x99, 0x95, 0x39, 0x3c, 0x0a, 0xd5, 0xf0, 0x6a, 0x93, 0x51, 0xb4, + 0xcd, 0x28, 0x7a, 0xcf, 0x28, 0x7a, 0xc9, 0xa9, 0xb5, 0xcd, 0xa9, 0xf5, 0x9a, 0x53, 0xeb, 0x96, + 0x45, 0xb1, 0xbe, 0x5b, 0x4e, 0xd8, 0x14, 0x16, 0x1c, 0x66, 0x70, 0x92, 0x08, 0xfd, 0x08, 0xf2, + 0xbe, 0x98, 0xf9, 0xd3, 0x8f, 0x8a, 0xf5, 0x3a, 0x15, 0x6a, 0xd2, 0x2e, 0xfb, 0x3d, 0xfd, 0x08, + 0x00, 0x00, 0xff, 0xff, 0x5f, 0x10, 0x1c, 0xdf, 0xef, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PendingRequestIds) > 0 { + dAtA2 := make([]byte, len(m.PendingRequestIds)*10) + var j1 int + for _, num := range m.PendingRequestIds { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintGenesis(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0x2a + } + if len(m.Results) > 0 { + for iNdEx := len(m.Results) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Results[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Requests) > 0 { + for iNdEx := len(m.Requests) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Requests[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0x12 + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.Requests) > 0 { + for _, e := range m.Requests { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Results) > 0 { + for _, e := range m.Results { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.PendingRequestIds) > 0 { + l = 0 + for _, e := range m.PendingRequestIds { + l += sovGenesis(uint64(e)) + } + n += 1 + sovGenesis(uint64(l)) + l + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Requests", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Requests = append(m.Requests, Request{}) + if err := m.Requests[len(m.Requests)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Results", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Results = append(m.Results, Result{}) + if err := m.Results[len(m.Results)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PendingRequestIds = append(m.PendingRequestIds, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.PendingRequestIds) == 0 { + m.PendingRequestIds = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PendingRequestIds = append(m.PendingRequestIds, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field PendingRequestIds", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/relayoracle/types/genesis_test.go b/x/relayoracle/types/genesis_test.go new file mode 100644 index 00000000..be372c78 --- /dev/null +++ b/x/relayoracle/types/genesis_test.go @@ -0,0 +1,40 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/ojo-network/ojo/x/relayoracle/types" +) + +func TestGenesisState_Validate(t *testing.T) { + tests := []struct { + desc string + genState *types.GenesisState + valid bool + }{ + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "valid genesis state", + genState: &types.GenesisState{ + PortId: types.PortID, + }, + valid: true, + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/relayoracle/types/keys.go b/x/relayoracle/types/keys.go new file mode 100644 index 00000000..83c36206 --- /dev/null +++ b/x/relayoracle/types/keys.go @@ -0,0 +1,48 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + // ModuleName defines the module name + ModuleName = "relayoracle" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_relayoracle" + + // Version defines the current version the IBC module supports + Version = "relayoracle-1" + + // PortID is the default port id that module binds to + PortID = "relayoracle" +) + +var ( + // PortKey defines the key to store the port ID in store + PortKey = KeyPrefix("relayoracle-port-") + RequestIDKey = KeyPrefix("relayoracle-request-") + + RequestStoreKeyPrefix = []byte{0x01} + ResultStoreKeyPrefix = []byte{0x02} + RequestCountKey = []byte{0x03} + PendingRequestListKey = []byte{0x04} +) + +func KeyPrefix(p string) []byte { + return []byte(p) +} + +func RequestStoreKey(requestID uint64) []byte { + return append(RequestStoreKeyPrefix, sdk.Uint64ToBigEndian(requestID)...) +} + +func ResultStoreKey(requestID uint64) []byte { + return append(ResultStoreKeyPrefix, sdk.Uint64ToBigEndian(requestID)...) +} diff --git a/x/relayoracle/types/msgs.go b/x/relayoracle/types/msgs.go new file mode 100644 index 00000000..70193ab3 --- /dev/null +++ b/x/relayoracle/types/msgs.go @@ -0,0 +1,75 @@ +package types + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "gopkg.in/yaml.v3" + + "github.com/ojo-network/ojo/util/checkers" +) + +var ( + _ sdk.Msg = &MsgGovUpdateParams{} +) + +// NewMsgUpdateParams will creates a new MsgUpdateParams instance +func NewMsgUpdateParams(authority, title, description string, keys []string, changes Params) *MsgGovUpdateParams { + return &MsgGovUpdateParams{ + Title: title, + Description: description, + Authority: authority, + Keys: keys, + Changes: changes, + } +} + +// Type implements Msg interface +func (msg MsgGovUpdateParams) Type() string { return sdk.MsgTypeURL(&msg) } + +// String implements the Stringer interface. +func (msg MsgGovUpdateParams) String() string { + out, _ := yaml.Marshal(msg) + return string(out) +} + +// GetSignBytes implements Msg +func (msg MsgGovUpdateParams) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} + +// GetSigners implements Msg +func (msg MsgGovUpdateParams) GetSigners() []sdk.AccAddress { + return checkers.Signers(msg.Authority) +} + +// ValidateBasic implements Msg and validates params for each param key +// specified in the proposal. If one param is invalid, the whole proposal +// will fail to go through. +func (msg MsgGovUpdateParams) ValidateBasic() error { + if err := checkers.ValidateProposal(msg.Title, msg.Description, msg.Authority); err != nil { + return err + } + + for _, key := range msg.Keys { + switch key { + case string(KeyIbcRequestEnabled): + return validateBool(msg.Changes.IbcRequestEnabled) + + case string(KeyPacketTimeout): + return validateUint64(msg.Changes.PacketTimeout) + + case string(KeyMaxHistorical): + return validateUint64(msg.Changes.MaxAllowedDenomsHistoricalQuery) + + case string(KeyMaxExchange): + return validateUint64(msg.Changes.MaxAllowedDenomsExchangeQuery) + + default: + return fmt.Errorf("%s is not a relay oracle param key", key) + } + } + + return nil +} diff --git a/x/relayoracle/types/oracle.pb.go b/x/relayoracle/types/oracle.pb.go new file mode 100644 index 00000000..22075f15 --- /dev/null +++ b/x/relayoracle/types/oracle.pb.go @@ -0,0 +1,1448 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ojo/relayoracle/v1/oracle.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types" + proto "github.com/cosmos/gogoproto/proto" + _ "github.com/gogo/protobuf/gogoproto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Request struct { + RequestID uint64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + RequestCallData []byte `protobuf:"bytes,2,opt,name=request_calldata,json=requestCalldata,proto3" json:"request_calldata,omitempty"` + ClientID string `protobuf:"bytes,3,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + RequestHeight int64 `protobuf:"varint,4,opt,name=request_height,json=requestHeight,proto3" json:"request_height,omitempty"` + RequestTime int64 `protobuf:"varint,5,opt,name=request_time,json=requestTime,proto3" json:"request_time,omitempty"` + IBCChannel *IBCChannel `protobuf:"bytes,6,opt,name=ibc_channel,json=ibcChannel,proto3" json:"ibc_channel,omitempty"` +} + +func (m *Request) Reset() { *m = Request{} } +func (m *Request) String() string { return proto.CompactTextString(m) } +func (*Request) ProtoMessage() {} +func (*Request) Descriptor() ([]byte, []int) { + return fileDescriptor_aec1d0741e06b9d2, []int{0} +} +func (m *Request) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Request.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Request) XXX_Merge(src proto.Message) { + xxx_messageInfo_Request.Merge(m, src) +} +func (m *Request) XXX_Size() int { + return m.Size() +} +func (m *Request) XXX_DiscardUnknown() { + xxx_messageInfo_Request.DiscardUnknown(m) +} + +var xxx_messageInfo_Request proto.InternalMessageInfo + +func (m *Request) GetRequestID() uint64 { + if m != nil { + return m.RequestID + } + return 0 +} + +func (m *Request) GetRequestCallData() []byte { + if m != nil { + return m.RequestCallData + } + return nil +} + +func (m *Request) GetClientID() string { + if m != nil { + return m.ClientID + } + return "" +} + +func (m *Request) GetRequestHeight() int64 { + if m != nil { + return m.RequestHeight + } + return 0 +} + +func (m *Request) GetRequestTime() int64 { + if m != nil { + return m.RequestTime + } + return 0 +} + +func (m *Request) GetIBCChannel() *IBCChannel { + if m != nil { + return m.IBCChannel + } + return nil +} + +type Result struct { + RequestID uint64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + RequestCallData []byte `protobuf:"bytes,2,opt,name=request_calldata,json=requestCalldata,proto3" json:"request_calldata,omitempty"` + ClientID string `protobuf:"bytes,3,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + RequestHeight int64 `protobuf:"varint,4,opt,name=request_height,json=requestHeight,proto3" json:"request_height,omitempty"` + RequestTime int64 `protobuf:"varint,5,opt,name=request_time,json=requestTime,proto3" json:"request_time,omitempty"` + Status ResolveStatus `protobuf:"varint,6,opt,name=status,proto3,enum=ojo.relayoracle.v1.ResolveStatus" json:"status,omitempty"` + Result []byte `protobuf:"bytes,7,opt,name=result,proto3" json:"result,omitempty"` +} + +func (m *Result) Reset() { *m = Result{} } +func (m *Result) String() string { return proto.CompactTextString(m) } +func (*Result) ProtoMessage() {} +func (*Result) Descriptor() ([]byte, []int) { + return fileDescriptor_aec1d0741e06b9d2, []int{1} +} +func (m *Result) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Result) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Result.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Result) XXX_Merge(src proto.Message) { + xxx_messageInfo_Result.Merge(m, src) +} +func (m *Result) XXX_Size() int { + return m.Size() +} +func (m *Result) XXX_DiscardUnknown() { + xxx_messageInfo_Result.DiscardUnknown(m) +} + +var xxx_messageInfo_Result proto.InternalMessageInfo + +func (m *Result) GetRequestID() uint64 { + if m != nil { + return m.RequestID + } + return 0 +} + +func (m *Result) GetRequestCallData() []byte { + if m != nil { + return m.RequestCallData + } + return nil +} + +func (m *Result) GetClientID() string { + if m != nil { + return m.ClientID + } + return "" +} + +func (m *Result) GetRequestHeight() int64 { + if m != nil { + return m.RequestHeight + } + return 0 +} + +func (m *Result) GetRequestTime() int64 { + if m != nil { + return m.RequestTime + } + return 0 +} + +func (m *Result) GetStatus() ResolveStatus { + if m != nil { + return m.Status + } + return RESOLVE_STATUS_OPEN +} + +func (m *Result) GetResult() []byte { + if m != nil { + return m.Result + } + return nil +} + +type IBCChannel struct { + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + PortId string `protobuf:"bytes,2,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` +} + +func (m *IBCChannel) Reset() { *m = IBCChannel{} } +func (m *IBCChannel) String() string { return proto.CompactTextString(m) } +func (*IBCChannel) ProtoMessage() {} +func (*IBCChannel) Descriptor() ([]byte, []int) { + return fileDescriptor_aec1d0741e06b9d2, []int{2} +} +func (m *IBCChannel) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IBCChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IBCChannel.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *IBCChannel) XXX_Merge(src proto.Message) { + xxx_messageInfo_IBCChannel.Merge(m, src) +} +func (m *IBCChannel) XXX_Size() int { + return m.Size() +} +func (m *IBCChannel) XXX_DiscardUnknown() { + xxx_messageInfo_IBCChannel.DiscardUnknown(m) +} + +var xxx_messageInfo_IBCChannel proto.InternalMessageInfo + +func (m *IBCChannel) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *IBCChannel) GetPortId() string { + if m != nil { + return m.PortId + } + return "" +} + +type PendingRequestList struct { + RequestIds []uint64 `protobuf:"varint,1,rep,packed,name=request_ids,json=requestIds,proto3" json:"request_ids,omitempty"` +} + +func (m *PendingRequestList) Reset() { *m = PendingRequestList{} } +func (m *PendingRequestList) String() string { return proto.CompactTextString(m) } +func (*PendingRequestList) ProtoMessage() {} +func (*PendingRequestList) Descriptor() ([]byte, []int) { + return fileDescriptor_aec1d0741e06b9d2, []int{3} +} +func (m *PendingRequestList) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PendingRequestList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PendingRequestList.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PendingRequestList) XXX_Merge(src proto.Message) { + xxx_messageInfo_PendingRequestList.Merge(m, src) +} +func (m *PendingRequestList) XXX_Size() int { + return m.Size() +} +func (m *PendingRequestList) XXX_DiscardUnknown() { + xxx_messageInfo_PendingRequestList.DiscardUnknown(m) +} + +var xxx_messageInfo_PendingRequestList proto.InternalMessageInfo + +func (m *PendingRequestList) GetRequestIds() []uint64 { + if m != nil { + return m.RequestIds + } + return nil +} + +func init() { + proto.RegisterType((*Request)(nil), "ojo.relayoracle.v1.Request") + proto.RegisterType((*Result)(nil), "ojo.relayoracle.v1.Result") + proto.RegisterType((*IBCChannel)(nil), "ojo.relayoracle.v1.IBCChannel") + proto.RegisterType((*PendingRequestList)(nil), "ojo.relayoracle.v1.PendingRequestList") +} + +func init() { proto.RegisterFile("ojo/relayoracle/v1/oracle.proto", fileDescriptor_aec1d0741e06b9d2) } + +var fileDescriptor_aec1d0741e06b9d2 = []byte{ + // 503 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x93, 0xc1, 0x8e, 0xd3, 0x3c, + 0x14, 0x85, 0xeb, 0xb6, 0x7f, 0x3a, 0x71, 0x3b, 0x9d, 0x5f, 0x06, 0x41, 0x34, 0x12, 0x49, 0xa6, + 0x12, 0x52, 0x90, 0x20, 0x51, 0x07, 0xb1, 0x80, 0x05, 0x8b, 0xb4, 0x8b, 0x09, 0x42, 0x02, 0x19, + 0x56, 0x6c, 0x46, 0x4e, 0x62, 0xa5, 0xee, 0xa4, 0x71, 0x89, 0xdd, 0xc2, 0xbc, 0x05, 0x8f, 0xc0, + 0x8b, 0xc0, 0x9a, 0xe5, 0x2c, 0x59, 0x55, 0x28, 0xdd, 0xf0, 0x18, 0x28, 0x8e, 0x4b, 0x07, 0x31, + 0x6f, 0xc0, 0xee, 0xdc, 0x73, 0x3f, 0xfb, 0xca, 0xe7, 0xca, 0xd0, 0xe1, 0x73, 0x1e, 0x94, 0x34, + 0x27, 0x97, 0xbc, 0x24, 0x49, 0x4e, 0x83, 0xf5, 0x38, 0x68, 0x94, 0xbf, 0x2c, 0xb9, 0xe4, 0x08, + 0xf1, 0x39, 0xf7, 0xaf, 0x01, 0xfe, 0x7a, 0x7c, 0x7c, 0x3b, 0xe3, 0x19, 0x57, 0xed, 0xa0, 0x56, + 0x0d, 0x79, 0x6c, 0x27, 0x5c, 0x2c, 0xb8, 0x08, 0x62, 0x22, 0xea, 0x6b, 0x62, 0x2a, 0xc9, 0x38, + 0x48, 0x38, 0x2b, 0x74, 0xff, 0xa6, 0x51, 0x4b, 0x92, 0x5c, 0x50, 0xd9, 0x00, 0xa3, 0x2f, 0x6d, + 0xd8, 0xc3, 0xf4, 0xfd, 0x8a, 0x0a, 0x89, 0x1e, 0x42, 0x58, 0x36, 0xf2, 0x9c, 0xa5, 0x16, 0x70, + 0x81, 0xd7, 0x0d, 0x0f, 0xab, 0x8d, 0x63, 0x6a, 0x20, 0x9a, 0x62, 0x53, 0x03, 0x51, 0x8a, 0x9e, + 0xc3, 0xff, 0x77, 0x74, 0x42, 0xf2, 0x3c, 0x25, 0x92, 0x58, 0x6d, 0x17, 0x78, 0x83, 0xf0, 0x56, + 0xb5, 0x71, 0x8e, 0xf4, 0x99, 0x09, 0xc9, 0xf3, 0x29, 0x91, 0x04, 0x1f, 0x95, 0x7b, 0xa3, 0x66, + 0xd1, 0x03, 0x68, 0x26, 0x39, 0xa3, 0x85, 0x1a, 0xd6, 0x71, 0x81, 0x67, 0x86, 0x83, 0x6a, 0xe3, + 0x1c, 0x4c, 0x94, 0x19, 0x4d, 0xf1, 0x41, 0xd3, 0x8e, 0x52, 0x74, 0x1f, 0x0e, 0x77, 0xa3, 0x66, + 0x94, 0x65, 0x33, 0x69, 0x75, 0x5d, 0xe0, 0x75, 0xf0, 0xa1, 0x76, 0xcf, 0x94, 0x89, 0x4e, 0xe0, + 0x60, 0x87, 0x49, 0xb6, 0xa0, 0xd6, 0x7f, 0x0a, 0xea, 0x6b, 0xef, 0x2d, 0x5b, 0x50, 0xf4, 0x0a, + 0xf6, 0x59, 0x9c, 0x9c, 0x27, 0x33, 0x52, 0x14, 0x34, 0xb7, 0x0c, 0x17, 0x78, 0xfd, 0x53, 0xdb, + 0xff, 0x3b, 0x6f, 0x3f, 0x0a, 0x27, 0x93, 0x86, 0x0a, 0x87, 0xd5, 0xc6, 0x81, 0xfb, 0x1a, 0x43, + 0x16, 0x27, 0x5a, 0x8f, 0xbe, 0xb6, 0xa1, 0x81, 0xa9, 0x58, 0xe5, 0xff, 0x44, 0x7c, 0x4f, 0xa1, + 0x21, 0x24, 0x91, 0x2b, 0xa1, 0x92, 0x1b, 0x9e, 0x9e, 0xdc, 0x94, 0x1c, 0xa6, 0x82, 0xe7, 0x6b, + 0xfa, 0x46, 0x81, 0x58, 0x1f, 0x40, 0x77, 0xa0, 0x51, 0xaa, 0x9c, 0xac, 0x5e, 0xfd, 0x4a, 0xac, + 0xab, 0xd1, 0x0b, 0x78, 0x2d, 0x5a, 0x74, 0x0f, 0x42, 0xbd, 0x9b, 0x5d, 0x86, 0x26, 0x36, 0xb5, + 0x13, 0xa5, 0xe8, 0x2e, 0xec, 0x2d, 0x79, 0xa9, 0x9e, 0xdc, 0x56, 0x3d, 0xa3, 0x2e, 0xa3, 0xf4, + 0x59, 0xf7, 0xe7, 0x67, 0x07, 0x8c, 0x9e, 0x40, 0xf4, 0x9a, 0x16, 0x29, 0x2b, 0x32, 0x1d, 0xdf, + 0x4b, 0x26, 0x24, 0x72, 0x60, 0x7f, 0xbf, 0x17, 0x61, 0x01, 0xb7, 0xe3, 0x75, 0x31, 0xfc, 0xbd, + 0x09, 0x11, 0x9e, 0x7d, 0xab, 0x6c, 0x70, 0x55, 0xd9, 0xe0, 0x47, 0x65, 0x83, 0x4f, 0x5b, 0xbb, + 0x75, 0xb5, 0xb5, 0x5b, 0xdf, 0xb7, 0x76, 0xeb, 0x9d, 0x9f, 0x31, 0x39, 0x5b, 0xc5, 0x7e, 0xc2, + 0x17, 0x01, 0x9f, 0xf3, 0x47, 0x05, 0x95, 0x1f, 0x78, 0x79, 0x51, 0xeb, 0xe0, 0xe3, 0x1f, 0xff, + 0x4a, 0x5e, 0x2e, 0xa9, 0x88, 0x0d, 0xf5, 0xa9, 0x1e, 0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x95, + 0xc6, 0x7b, 0xbc, 0xe2, 0x03, 0x00, 0x00, +} + +func (this *IBCChannel) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*IBCChannel) + if !ok { + that2, ok := that.(IBCChannel) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ChannelId != that1.ChannelId { + return false + } + if this.PortId != that1.PortId { + return false + } + return true +} +func (m *Request) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Request) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Request) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IBCChannel != nil { + { + size, err := m.IBCChannel.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOracle(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + if m.RequestTime != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.RequestTime)) + i-- + dAtA[i] = 0x28 + } + if m.RequestHeight != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.RequestHeight)) + i-- + dAtA[i] = 0x20 + } + if len(m.ClientID) > 0 { + i -= len(m.ClientID) + copy(dAtA[i:], m.ClientID) + i = encodeVarintOracle(dAtA, i, uint64(len(m.ClientID))) + i-- + dAtA[i] = 0x1a + } + if len(m.RequestCallData) > 0 { + i -= len(m.RequestCallData) + copy(dAtA[i:], m.RequestCallData) + i = encodeVarintOracle(dAtA, i, uint64(len(m.RequestCallData))) + i-- + dAtA[i] = 0x12 + } + if m.RequestID != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.RequestID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Result) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Result) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Result) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Result) > 0 { + i -= len(m.Result) + copy(dAtA[i:], m.Result) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Result))) + i-- + dAtA[i] = 0x3a + } + if m.Status != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x30 + } + if m.RequestTime != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.RequestTime)) + i-- + dAtA[i] = 0x28 + } + if m.RequestHeight != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.RequestHeight)) + i-- + dAtA[i] = 0x20 + } + if len(m.ClientID) > 0 { + i -= len(m.ClientID) + copy(dAtA[i:], m.ClientID) + i = encodeVarintOracle(dAtA, i, uint64(len(m.ClientID))) + i-- + dAtA[i] = 0x1a + } + if len(m.RequestCallData) > 0 { + i -= len(m.RequestCallData) + copy(dAtA[i:], m.RequestCallData) + i = encodeVarintOracle(dAtA, i, uint64(len(m.RequestCallData))) + i-- + dAtA[i] = 0x12 + } + if m.RequestID != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.RequestID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *IBCChannel) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *IBCChannel) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IBCChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintOracle(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0x12 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintOracle(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PendingRequestList) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PendingRequestList) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PendingRequestList) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RequestIds) > 0 { + dAtA3 := make([]byte, len(m.RequestIds)*10) + var j2 int + for _, num := range m.RequestIds { + for num >= 1<<7 { + dAtA3[j2] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j2++ + } + dAtA3[j2] = uint8(num) + j2++ + } + i -= j2 + copy(dAtA[i:], dAtA3[:j2]) + i = encodeVarintOracle(dAtA, i, uint64(j2)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintOracle(dAtA []byte, offset int, v uint64) int { + offset -= sovOracle(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Request) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.RequestID != 0 { + n += 1 + sovOracle(uint64(m.RequestID)) + } + l = len(m.RequestCallData) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + l = len(m.ClientID) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + if m.RequestHeight != 0 { + n += 1 + sovOracle(uint64(m.RequestHeight)) + } + if m.RequestTime != 0 { + n += 1 + sovOracle(uint64(m.RequestTime)) + } + if m.IBCChannel != nil { + l = m.IBCChannel.Size() + n += 1 + l + sovOracle(uint64(l)) + } + return n +} + +func (m *Result) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.RequestID != 0 { + n += 1 + sovOracle(uint64(m.RequestID)) + } + l = len(m.RequestCallData) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + l = len(m.ClientID) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + if m.RequestHeight != 0 { + n += 1 + sovOracle(uint64(m.RequestHeight)) + } + if m.RequestTime != 0 { + n += 1 + sovOracle(uint64(m.RequestTime)) + } + if m.Status != 0 { + n += 1 + sovOracle(uint64(m.Status)) + } + l = len(m.Result) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + return n +} + +func (m *IBCChannel) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + return n +} + +func (m *PendingRequestList) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.RequestIds) > 0 { + l = 0 + for _, e := range m.RequestIds { + l += sovOracle(uint64(e)) + } + n += 1 + sovOracle(uint64(l)) + l + } + return n +} + +func sovOracle(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozOracle(x uint64) (n int) { + return sovOracle(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Request) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Request: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Request: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestID", wireType) + } + m.RequestID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestCallData", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RequestCallData = append(m.RequestCallData[:0], dAtA[iNdEx:postIndex]...) + if m.RequestCallData == nil { + m.RequestCallData = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestHeight", wireType) + } + m.RequestHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestTime", wireType) + } + m.RequestTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IBCChannel", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.IBCChannel == nil { + m.IBCChannel = &IBCChannel{} + } + if err := m.IBCChannel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Result) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Result: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Result: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestID", wireType) + } + m.RequestID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestCallData", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RequestCallData = append(m.RequestCallData[:0], dAtA[iNdEx:postIndex]...) + if m.RequestCallData == nil { + m.RequestCallData = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestHeight", wireType) + } + m.RequestHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestTime", wireType) + } + m.RequestTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= ResolveStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Result = append(m.Result[:0], dAtA[iNdEx:postIndex]...) + if m.Result == nil { + m.Result = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *IBCChannel) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: IBCChannel: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IBCChannel: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PendingRequestList) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PendingRequestList: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PendingRequestList: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.RequestIds = append(m.RequestIds, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.RequestIds) == 0 { + m.RequestIds = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.RequestIds = append(m.RequestIds, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field RequestIds", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipOracle(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowOracle + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowOracle + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowOracle + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthOracle + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupOracle + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthOracle + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthOracle = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowOracle = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupOracle = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/relayoracle/types/packet.pb.go b/x/relayoracle/types/packet.pb.go new file mode 100644 index 00000000..0d923153 --- /dev/null +++ b/x/relayoracle/types/packet.pb.go @@ -0,0 +1,1812 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ojo/relayoracle/v1/packet.proto + +package types + +import ( + bytes "bytes" + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" + proto "github.com/cosmos/gogoproto/proto" + _ "github.com/gogo/protobuf/gogoproto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ResolveStatus int32 + +const ( + RESOLVE_STATUS_OPEN ResolveStatus = 0 + RESOLVE_STATUS_SUCCESS ResolveStatus = 1 + RESOLVE_STATUS_FAILURE ResolveStatus = 2 + RESOLVE_STATUS_EXPIRED ResolveStatus = 3 +) + +var ResolveStatus_name = map[int32]string{ + 0: "RESOLVE_STATUS_OPEN_UNSPECIFIED", + 1: "RESOLVE_STATUS_SUCCESS", + 2: "RESOLVE_STATUS_FAILURE", + 3: "RESOLVE_STATUS_EXPIRED", +} + +var ResolveStatus_value = map[string]int32{ + "RESOLVE_STATUS_OPEN_UNSPECIFIED": 0, + "RESOLVE_STATUS_SUCCESS": 1, + "RESOLVE_STATUS_FAILURE": 2, + "RESOLVE_STATUS_EXPIRED": 3, +} + +func (x ResolveStatus) String() string { + return proto.EnumName(ResolveStatus_name, int32(x)) +} + +func (ResolveStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_7244ae751175b020, []int{0} +} + +type PriceRequestType int32 + +const ( + PRICE_REQUEST_RATE PriceRequestType = 0 + PRICE_REQUEST_MEDIAN PriceRequestType = 1 + PRICE_REQUEST_DEVIATION PriceRequestType = 2 +) + +var PriceRequestType_name = map[int32]string{ + 0: "PRICE_REQUEST_RATE", + 1: "PRICE_REQUEST_MEDIAN", + 2: "PRICE_REQUEST_DEVIATION", +} + +var PriceRequestType_value = map[string]int32{ + "PRICE_REQUEST_RATE": 0, + "PRICE_REQUEST_MEDIAN": 1, + "PRICE_REQUEST_DEVIATION": 2, +} + +func (x PriceRequestType) String() string { + return proto.EnumName(PriceRequestType_name, int32(x)) +} + +func (PriceRequestType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_7244ae751175b020, []int{1} +} + +type OracleRequestPacketData struct { + ClientID string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + Calldata []byte `protobuf:"bytes,3,opt,name=calldata,proto3" json:"calldata,omitempty"` +} + +func (m *OracleRequestPacketData) Reset() { *m = OracleRequestPacketData{} } +func (m *OracleRequestPacketData) String() string { return proto.CompactTextString(m) } +func (*OracleRequestPacketData) ProtoMessage() {} +func (*OracleRequestPacketData) Descriptor() ([]byte, []int) { + return fileDescriptor_7244ae751175b020, []int{0} +} +func (m *OracleRequestPacketData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OracleRequestPacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OracleRequestPacketData.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *OracleRequestPacketData) XXX_Merge(src proto.Message) { + xxx_messageInfo_OracleRequestPacketData.Merge(m, src) +} +func (m *OracleRequestPacketData) XXX_Size() int { + return m.Size() +} +func (m *OracleRequestPacketData) XXX_DiscardUnknown() { + xxx_messageInfo_OracleRequestPacketData.DiscardUnknown(m) +} + +var xxx_messageInfo_OracleRequestPacketData proto.InternalMessageInfo + +func (m *OracleRequestPacketData) GetClientID() string { + if m != nil { + return m.ClientID + } + return "" +} + +func (m *OracleRequestPacketData) GetCalldata() []byte { + if m != nil { + return m.Calldata + } + return nil +} + +type OracleResponsePacketData struct { + ClientID string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + RequestID uint64 `protobuf:"varint,2,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + RequestTime int64 `protobuf:"varint,3,opt,name=request_time,json=requestTime,proto3" json:"request_time,omitempty"` + ResolveTime int64 `protobuf:"varint,4,opt,name=resolve_time,json=resolveTime,proto3" json:"resolve_time,omitempty"` + ResolveStatus ResolveStatus `protobuf:"varint,5,opt,name=resolve_status,json=resolveStatus,proto3,enum=ojo.relayoracle.v1.ResolveStatus" json:"resolve_status,omitempty"` + Result []byte `protobuf:"bytes,6,opt,name=result,proto3" json:"result,omitempty"` +} + +func (m *OracleResponsePacketData) Reset() { *m = OracleResponsePacketData{} } +func (m *OracleResponsePacketData) String() string { return proto.CompactTextString(m) } +func (*OracleResponsePacketData) ProtoMessage() {} +func (*OracleResponsePacketData) Descriptor() ([]byte, []int) { + return fileDescriptor_7244ae751175b020, []int{1} +} +func (m *OracleResponsePacketData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OracleResponsePacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OracleResponsePacketData.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *OracleResponsePacketData) XXX_Merge(src proto.Message) { + xxx_messageInfo_OracleResponsePacketData.Merge(m, src) +} +func (m *OracleResponsePacketData) XXX_Size() int { + return m.Size() +} +func (m *OracleResponsePacketData) XXX_DiscardUnknown() { + xxx_messageInfo_OracleResponsePacketData.DiscardUnknown(m) +} + +var xxx_messageInfo_OracleResponsePacketData proto.InternalMessageInfo + +func (m *OracleResponsePacketData) GetClientID() string { + if m != nil { + return m.ClientID + } + return "" +} + +func (m *OracleResponsePacketData) GetRequestID() uint64 { + if m != nil { + return m.RequestID + } + return 0 +} + +func (m *OracleResponsePacketData) GetRequestTime() int64 { + if m != nil { + return m.RequestTime + } + return 0 +} + +func (m *OracleResponsePacketData) GetResolveTime() int64 { + if m != nil { + return m.ResolveTime + } + return 0 +} + +func (m *OracleResponsePacketData) GetResolveStatus() ResolveStatus { + if m != nil { + return m.ResolveStatus + } + return RESOLVE_STATUS_OPEN +} + +func (m *OracleResponsePacketData) GetResult() []byte { + if m != nil { + return m.Result + } + return nil +} + +type RequestPrice struct { + Denoms []string `protobuf:"bytes,1,rep,name=denoms,proto3" json:"denoms,omitempty"` + Request PriceRequestType `protobuf:"varint,2,opt,name=request,proto3,enum=ojo.relayoracle.v1.PriceRequestType" json:"request,omitempty"` +} + +func (m *RequestPrice) Reset() { *m = RequestPrice{} } +func (m *RequestPrice) String() string { return proto.CompactTextString(m) } +func (*RequestPrice) ProtoMessage() {} +func (*RequestPrice) Descriptor() ([]byte, []int) { + return fileDescriptor_7244ae751175b020, []int{2} +} +func (m *RequestPrice) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RequestPrice) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RequestPrice.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RequestPrice) XXX_Merge(src proto.Message) { + xxx_messageInfo_RequestPrice.Merge(m, src) +} +func (m *RequestPrice) XXX_Size() int { + return m.Size() +} +func (m *RequestPrice) XXX_DiscardUnknown() { + xxx_messageInfo_RequestPrice.DiscardUnknown(m) +} + +var xxx_messageInfo_RequestPrice proto.InternalMessageInfo + +func (m *RequestPrice) GetDenoms() []string { + if m != nil { + return m.Denoms + } + return nil +} + +func (m *RequestPrice) GetRequest() PriceRequestType { + if m != nil { + return m.Request + } + return PRICE_REQUEST_RATE +} + +type OracleRequestResult struct { + PriceData []OracleData `protobuf:"bytes,1,rep,name=price_data,json=priceData,proto3" json:"price_data"` +} + +func (m *OracleRequestResult) Reset() { *m = OracleRequestResult{} } +func (m *OracleRequestResult) String() string { return proto.CompactTextString(m) } +func (*OracleRequestResult) ProtoMessage() {} +func (*OracleRequestResult) Descriptor() ([]byte, []int) { + return fileDescriptor_7244ae751175b020, []int{3} +} +func (m *OracleRequestResult) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OracleRequestResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OracleRequestResult.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *OracleRequestResult) XXX_Merge(src proto.Message) { + xxx_messageInfo_OracleRequestResult.Merge(m, src) +} +func (m *OracleRequestResult) XXX_Size() int { + return m.Size() +} +func (m *OracleRequestResult) XXX_DiscardUnknown() { + xxx_messageInfo_OracleRequestResult.DiscardUnknown(m) +} + +var xxx_messageInfo_OracleRequestResult proto.InternalMessageInfo + +func (m *OracleRequestResult) GetPriceData() []OracleData { + if m != nil { + return m.PriceData + } + return nil +} + +type OracleData struct { + ExchangeRate []types.DecCoin `protobuf:"bytes,2,rep,name=exchange_rate,json=exchangeRate,proto3" json:"exchange_rate"` + BlockNum []uint64 `protobuf:"varint,3,rep,packed,name=block_num,json=blockNum,proto3" json:"block_num,omitempty"` +} + +func (m *OracleData) Reset() { *m = OracleData{} } +func (m *OracleData) String() string { return proto.CompactTextString(m) } +func (*OracleData) ProtoMessage() {} +func (*OracleData) Descriptor() ([]byte, []int) { + return fileDescriptor_7244ae751175b020, []int{4} +} +func (m *OracleData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OracleData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OracleData.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *OracleData) XXX_Merge(src proto.Message) { + xxx_messageInfo_OracleData.Merge(m, src) +} +func (m *OracleData) XXX_Size() int { + return m.Size() +} +func (m *OracleData) XXX_DiscardUnknown() { + xxx_messageInfo_OracleData.DiscardUnknown(m) +} + +var xxx_messageInfo_OracleData proto.InternalMessageInfo + +func (m *OracleData) GetExchangeRate() []types.DecCoin { + if m != nil { + return m.ExchangeRate + } + return nil +} + +func (m *OracleData) GetBlockNum() []uint64 { + if m != nil { + return m.BlockNum + } + return nil +} + +type OracleRequestPacketAcknowledgement struct { + RequestID uint64 `protobuf:"varint,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *OracleRequestPacketAcknowledgement) Reset() { *m = OracleRequestPacketAcknowledgement{} } +func (m *OracleRequestPacketAcknowledgement) String() string { return proto.CompactTextString(m) } +func (*OracleRequestPacketAcknowledgement) ProtoMessage() {} +func (*OracleRequestPacketAcknowledgement) Descriptor() ([]byte, []int) { + return fileDescriptor_7244ae751175b020, []int{5} +} +func (m *OracleRequestPacketAcknowledgement) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OracleRequestPacketAcknowledgement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OracleRequestPacketAcknowledgement.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *OracleRequestPacketAcknowledgement) XXX_Merge(src proto.Message) { + xxx_messageInfo_OracleRequestPacketAcknowledgement.Merge(m, src) +} +func (m *OracleRequestPacketAcknowledgement) XXX_Size() int { + return m.Size() +} +func (m *OracleRequestPacketAcknowledgement) XXX_DiscardUnknown() { + xxx_messageInfo_OracleRequestPacketAcknowledgement.DiscardUnknown(m) +} + +var xxx_messageInfo_OracleRequestPacketAcknowledgement proto.InternalMessageInfo + +func (m *OracleRequestPacketAcknowledgement) GetRequestID() uint64 { + if m != nil { + return m.RequestID + } + return 0 +} + +func (m *OracleRequestPacketAcknowledgement) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + +func init() { + proto.RegisterEnum("ojo.relayoracle.v1.ResolveStatus", ResolveStatus_name, ResolveStatus_value) + proto.RegisterEnum("ojo.relayoracle.v1.PriceRequestType", PriceRequestType_name, PriceRequestType_value) + proto.RegisterType((*OracleRequestPacketData)(nil), "ojo.relayoracle.v1.OracleRequestPacketData") + proto.RegisterType((*OracleResponsePacketData)(nil), "ojo.relayoracle.v1.OracleResponsePacketData") + proto.RegisterType((*RequestPrice)(nil), "ojo.relayoracle.v1.RequestPrice") + proto.RegisterType((*OracleRequestResult)(nil), "ojo.relayoracle.v1.OracleRequestResult") + proto.RegisterType((*OracleData)(nil), "ojo.relayoracle.v1.OracleData") + proto.RegisterType((*OracleRequestPacketAcknowledgement)(nil), "ojo.relayoracle.v1.OracleRequestPacketAcknowledgement") +} + +func init() { proto.RegisterFile("ojo/relayoracle/v1/packet.proto", fileDescriptor_7244ae751175b020) } + +var fileDescriptor_7244ae751175b020 = []byte{ + // 759 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xcf, 0x6e, 0xe3, 0x44, + 0x18, 0x8f, 0x13, 0x53, 0x92, 0xd9, 0xa4, 0xb2, 0x66, 0x57, 0xad, 0xe5, 0x45, 0x8e, 0x37, 0xe2, + 0x10, 0x56, 0x60, 0xab, 0x41, 0x42, 0x08, 0x21, 0xa4, 0x24, 0xf6, 0x52, 0x4b, 0x25, 0x09, 0xe3, + 0xa4, 0x42, 0xbd, 0x58, 0x8e, 0x33, 0x4d, 0xdd, 0xd8, 0x9e, 0x60, 0x4f, 0xfa, 0xe7, 0x0d, 0x50, + 0x4e, 0xbc, 0x40, 0x24, 0x10, 0xef, 0xc0, 0x33, 0xf4, 0xd8, 0x23, 0xa7, 0x0a, 0xa5, 0x17, 0xde, + 0x81, 0x0b, 0xf2, 0xd8, 0xa1, 0x4d, 0x71, 0x85, 0xb4, 0x37, 0xcf, 0xef, 0xcf, 0x37, 0x9f, 0xbf, + 0xef, 0xa7, 0x01, 0x75, 0x72, 0x4e, 0xb4, 0x08, 0xfb, 0xce, 0x35, 0x89, 0x1c, 0xd7, 0xc7, 0xda, + 0xc5, 0x81, 0x36, 0x77, 0xdc, 0x19, 0xa6, 0xea, 0x3c, 0x22, 0x94, 0x40, 0x48, 0xce, 0x89, 0xfa, + 0x48, 0xa0, 0x5e, 0x1c, 0x48, 0xaf, 0xa6, 0x64, 0x4a, 0x18, 0xad, 0x25, 0x5f, 0xa9, 0x52, 0x92, + 0x5d, 0x12, 0x07, 0x24, 0xd6, 0xc6, 0x4e, 0x9c, 0x94, 0x19, 0x63, 0xea, 0x1c, 0x68, 0x2e, 0xf1, + 0xc2, 0x94, 0x6f, 0x9c, 0x82, 0xfd, 0x3e, 0x2b, 0x81, 0xf0, 0x8f, 0x0b, 0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0x81, + 0x46, 0xce, 0xc9, 0x67, 0x21, 0xa6, 0x97, 0x24, 0x9a, 0x25, 0xdf, 0xda, 0xd5, 0xd6, 0x33, 0x4c, + 0xaf, 0xe7, 0x38, 0x1e, 0xef, 0xb0, 0x97, 0xf3, 0xf3, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x46, + 0xb0, 0xed, 0xaf, 0xa6, 0x05, 0x00, 0x00, +} + +func (this *OracleRequestPacketData) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*OracleRequestPacketData) + if !ok { + that2, ok := that.(OracleRequestPacketData) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ClientID != that1.ClientID { + return false + } + if !bytes.Equal(this.Calldata, that1.Calldata) { + return false + } + return true +} +func (this *OracleResponsePacketData) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*OracleResponsePacketData) + if !ok { + that2, ok := that.(OracleResponsePacketData) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ClientID != that1.ClientID { + return false + } + if this.RequestID != that1.RequestID { + return false + } + if this.RequestTime != that1.RequestTime { + return false + } + if this.ResolveTime != that1.ResolveTime { + return false + } + if this.ResolveStatus != that1.ResolveStatus { + return false + } + if !bytes.Equal(this.Result, that1.Result) { + return false + } + return true +} +func (this *OracleRequestPacketAcknowledgement) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*OracleRequestPacketAcknowledgement) + if !ok { + that2, ok := that.(OracleRequestPacketAcknowledgement) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.RequestID != that1.RequestID { + return false + } + if !bytes.Equal(this.Data, that1.Data) { + return false + } + return true +} +func (m *OracleRequestPacketData) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OracleRequestPacketData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OracleRequestPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Calldata) > 0 { + i -= len(m.Calldata) + copy(dAtA[i:], m.Calldata) + i = encodeVarintPacket(dAtA, i, uint64(len(m.Calldata))) + i-- + dAtA[i] = 0x1a + } + if len(m.ClientID) > 0 { + i -= len(m.ClientID) + copy(dAtA[i:], m.ClientID) + i = encodeVarintPacket(dAtA, i, uint64(len(m.ClientID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OracleResponsePacketData) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OracleResponsePacketData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OracleResponsePacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Result) > 0 { + i -= len(m.Result) + copy(dAtA[i:], m.Result) + i = encodeVarintPacket(dAtA, i, uint64(len(m.Result))) + i-- + dAtA[i] = 0x32 + } + if m.ResolveStatus != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.ResolveStatus)) + i-- + dAtA[i] = 0x28 + } + if m.ResolveTime != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.ResolveTime)) + i-- + dAtA[i] = 0x20 + } + if m.RequestTime != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.RequestTime)) + i-- + dAtA[i] = 0x18 + } + if m.RequestID != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.RequestID)) + i-- + dAtA[i] = 0x10 + } + if len(m.ClientID) > 0 { + i -= len(m.ClientID) + copy(dAtA[i:], m.ClientID) + i = encodeVarintPacket(dAtA, i, uint64(len(m.ClientID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RequestPrice) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RequestPrice) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RequestPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Request != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.Request)) + i-- + dAtA[i] = 0x10 + } + if len(m.Denoms) > 0 { + for iNdEx := len(m.Denoms) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Denoms[iNdEx]) + copy(dAtA[i:], m.Denoms[iNdEx]) + i = encodeVarintPacket(dAtA, i, uint64(len(m.Denoms[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *OracleRequestResult) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OracleRequestResult) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OracleRequestResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PriceData) > 0 { + for iNdEx := len(m.PriceData) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PriceData[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPacket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *OracleData) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OracleData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OracleData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BlockNum) > 0 { + dAtA2 := make([]byte, len(m.BlockNum)*10) + var j1 int + for _, num := range m.BlockNum { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintPacket(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0x1a + } + if len(m.ExchangeRate) > 0 { + for iNdEx := len(m.ExchangeRate) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ExchangeRate[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPacket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + return len(dAtA) - i, nil +} + +func (m *OracleRequestPacketAcknowledgement) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OracleRequestPacketAcknowledgement) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OracleRequestPacketAcknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintPacket(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x12 + } + if m.RequestID != 0 { + i = encodeVarintPacket(dAtA, i, uint64(m.RequestID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintPacket(dAtA []byte, offset int, v uint64) int { + offset -= sovPacket(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *OracleRequestPacketData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientID) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + l = len(m.Calldata) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + return n +} + +func (m *OracleResponsePacketData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientID) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + if m.RequestID != 0 { + n += 1 + sovPacket(uint64(m.RequestID)) + } + if m.RequestTime != 0 { + n += 1 + sovPacket(uint64(m.RequestTime)) + } + if m.ResolveTime != 0 { + n += 1 + sovPacket(uint64(m.ResolveTime)) + } + if m.ResolveStatus != 0 { + n += 1 + sovPacket(uint64(m.ResolveStatus)) + } + l = len(m.Result) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + return n +} + +func (m *RequestPrice) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Denoms) > 0 { + for _, s := range m.Denoms { + l = len(s) + n += 1 + l + sovPacket(uint64(l)) + } + } + if m.Request != 0 { + n += 1 + sovPacket(uint64(m.Request)) + } + return n +} + +func (m *OracleRequestResult) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PriceData) > 0 { + for _, e := range m.PriceData { + l = e.Size() + n += 1 + l + sovPacket(uint64(l)) + } + } + return n +} + +func (m *OracleData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ExchangeRate) > 0 { + for _, e := range m.ExchangeRate { + l = e.Size() + n += 1 + l + sovPacket(uint64(l)) + } + } + if len(m.BlockNum) > 0 { + l = 0 + for _, e := range m.BlockNum { + l += sovPacket(uint64(e)) + } + n += 1 + sovPacket(uint64(l)) + l + } + return n +} + +func (m *OracleRequestPacketAcknowledgement) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.RequestID != 0 { + n += 1 + sovPacket(uint64(m.RequestID)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + return n +} + +func sovPacket(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPacket(x uint64) (n int) { + return sovPacket(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *OracleRequestPacketData) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OracleRequestPacketData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OracleRequestPacketData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Calldata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Calldata = append(m.Calldata[:0], dAtA[iNdEx:postIndex]...) + if m.Calldata == nil { + m.Calldata = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPacket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPacket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OracleResponsePacketData) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OracleResponsePacketData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OracleResponsePacketData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestID", wireType) + } + m.RequestID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestTime", wireType) + } + m.RequestTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ResolveTime", wireType) + } + m.ResolveTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ResolveTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ResolveStatus", wireType) + } + m.ResolveStatus = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ResolveStatus |= ResolveStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Result = append(m.Result[:0], dAtA[iNdEx:postIndex]...) + if m.Result == nil { + m.Result = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPacket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPacket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RequestPrice) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RequestPrice: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RequestPrice: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denoms", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denoms = append(m.Denoms, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Request", wireType) + } + m.Request = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Request |= PriceRequestType(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipPacket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPacket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OracleRequestResult) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OracleRequestResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OracleRequestResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PriceData", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PriceData = append(m.PriceData, OracleData{}) + if err := m.PriceData[len(m.PriceData)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPacket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPacket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OracleData) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OracleData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OracleData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExchangeRate", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ExchangeRate = append(m.ExchangeRate, types.DecCoin{}) + if err := m.ExchangeRate[len(m.ExchangeRate)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.BlockNum = append(m.BlockNum, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.BlockNum) == 0 { + m.BlockNum = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.BlockNum = append(m.BlockNum, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field BlockNum", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipPacket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPacket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OracleRequestPacketAcknowledgement) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OracleRequestPacketAcknowledgement: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OracleRequestPacketAcknowledgement: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestID", wireType) + } + m.RequestID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RequestID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPacket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPacket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPacket(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPacket + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPacket + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPacket + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthPacket + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPacket + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPacket + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPacket = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPacket = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPacket = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/relayoracle/types/params.go b/x/relayoracle/types/params.go new file mode 100644 index 00000000..3e04256b --- /dev/null +++ b/x/relayoracle/types/params.go @@ -0,0 +1,86 @@ +package types + +import ( + "fmt" + "time" + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "gopkg.in/yaml.v2" +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +const ( + DefaultIbcRequestEnabled = true + DefaultPacketTimeout = uint64(10 * time.Minute) + DefaultMaxAllowedDenoms = uint64(10) +) + +var ( + KeyIbcRequestEnabled = []byte("IbcRequestEnabled") + KeyPacketTimeout = []byte("PacketTimeout") + KeyMaxHistorical = []byte("MaxAllowedDenomsHistoricalQuery") + KeyMaxExchange = []byte("MaxAllowedDenomsExchangeQuery") +) + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new Params instance +func NewParams() Params { + return Params{ + IbcRequestEnabled: DefaultIbcRequestEnabled, + PacketTimeout: DefaultPacketTimeout, + MaxAllowedDenomsExchangeQuery: DefaultMaxAllowedDenoms, + MaxAllowedDenomsHistoricalQuery: DefaultMaxAllowedDenoms, + } +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams() +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyIbcRequestEnabled, &p.IbcRequestEnabled, validateBool), + paramtypes.NewParamSetPair(KeyPacketTimeout, &p.PacketTimeout, validateUint64), + paramtypes.NewParamSetPair(KeyMaxHistorical, &p.MaxAllowedDenomsHistoricalQuery, validateUint64), + paramtypes.NewParamSetPair(KeyMaxExchange, &p.MaxAllowedDenomsExchangeQuery, validateUint64), + } +} + +// Validate validates the set of params +func (p Params) Validate() error { + return nil +} + +func validateBool(value interface{}) error { + _, ok := value.(bool) + if !ok { + return fmt.Errorf("invalid value: %T", value) + } + + return nil +} + +func validateUint64(value interface{}) error { + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", value) + } + if v <= 0 { + return fmt.Errorf("value must be positive: %T", value) + } + + return nil +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} diff --git a/x/relayoracle/types/params.pb.go b/x/relayoracle/types/params.pb.go new file mode 100644 index 00000000..737e9098 --- /dev/null +++ b/x/relayoracle/types/params.pb.go @@ -0,0 +1,451 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ojo/relayoracle/v1/params.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + _ "github.com/gogo/protobuf/gogoproto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +type Params struct { + IbcRequestEnabled bool `protobuf:"varint,1,opt,name=IbcRequestEnabled,proto3" json:"IbcRequestEnabled,omitempty"` + PacketTimeout uint64 `protobuf:"varint,2,opt,name=PacketTimeout,proto3" json:"PacketTimeout,omitempty"` + MaxAllowedDenomsHistoricalQuery uint64 `protobuf:"varint,3,opt,name=MaxAllowedDenomsHistoricalQuery,proto3" json:"MaxAllowedDenomsHistoricalQuery,omitempty"` + MaxAllowedDenomsExchangeQuery uint64 `protobuf:"varint,4,opt,name=MaxAllowedDenomsExchangeQuery,proto3" json:"MaxAllowedDenomsExchangeQuery,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_b9695752790fd08e, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetIbcRequestEnabled() bool { + if m != nil { + return m.IbcRequestEnabled + } + return false +} + +func (m *Params) GetPacketTimeout() uint64 { + if m != nil { + return m.PacketTimeout + } + return 0 +} + +func (m *Params) GetMaxAllowedDenomsHistoricalQuery() uint64 { + if m != nil { + return m.MaxAllowedDenomsHistoricalQuery + } + return 0 +} + +func (m *Params) GetMaxAllowedDenomsExchangeQuery() uint64 { + if m != nil { + return m.MaxAllowedDenomsExchangeQuery + } + return 0 +} + +func init() { + proto.RegisterType((*Params)(nil), "ojo.relayoracle.v1.Params") +} + +func init() { proto.RegisterFile("ojo/relayoracle/v1/params.proto", fileDescriptor_b9695752790fd08e) } + +var fileDescriptor_b9695752790fd08e = []byte{ + // 286 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcf, 0xcf, 0xca, 0xd7, + 0x2f, 0x4a, 0xcd, 0x49, 0xac, 0xcc, 0x2f, 0x4a, 0x4c, 0xce, 0x49, 0xd5, 0x2f, 0x33, 0xd4, 0x2f, + 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0xca, 0xcf, 0xca, + 0xd7, 0x43, 0x52, 0xa0, 0x57, 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x96, 0xd6, 0x07, + 0xb1, 0x20, 0x2a, 0x95, 0xbe, 0x31, 0x72, 0xb1, 0x05, 0x80, 0xb5, 0x0a, 0xe9, 0x70, 0x09, 0x7a, + 0x26, 0x25, 0x07, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0xb8, 0xe6, 0x25, 0x26, 0xe5, 0xa4, 0xa6, + 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x04, 0x61, 0x4a, 0x08, 0xa9, 0x70, 0xf1, 0x06, 0x24, 0x26, + 0x67, 0xa7, 0x96, 0x84, 0x64, 0xe6, 0xa6, 0xe6, 0x97, 0x96, 0x48, 0x30, 0x29, 0x30, 0x6a, 0xb0, + 0x04, 0xa1, 0x0a, 0x0a, 0x79, 0x70, 0xc9, 0xfb, 0x26, 0x56, 0x38, 0xe6, 0xe4, 0xe4, 0x97, 0xa7, + 0xa6, 0xb8, 0xa4, 0xe6, 0xe5, 0xe7, 0x16, 0x7b, 0x64, 0x16, 0x97, 0xe4, 0x17, 0x65, 0x26, 0x27, + 0xe6, 0x04, 0x96, 0xa6, 0x16, 0x55, 0x4a, 0x30, 0x83, 0xf5, 0x11, 0x52, 0x26, 0xe4, 0xc2, 0x25, + 0x8b, 0xae, 0xc4, 0xb5, 0x22, 0x39, 0x23, 0x31, 0x2f, 0x3d, 0x15, 0x62, 0x0e, 0x0b, 0xd8, 0x1c, + 0xfc, 0x8a, 0xac, 0x38, 0x66, 0x2c, 0x90, 0x67, 0x78, 0xb1, 0x40, 0x9e, 0xd1, 0xc9, 0xe3, 0xc4, + 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, + 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xf4, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, + 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xf3, 0xb3, 0xf2, 0x75, 0xf3, 0x52, 0x4b, 0xca, 0xf3, 0x8b, 0xb2, + 0x41, 0x6c, 0xfd, 0x0a, 0x94, 0x60, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x87, 0xa4, + 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x97, 0x68, 0xd3, 0x78, 0x96, 0x01, 0x00, 0x00, +} + +func (this *Params) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Params) + if !ok { + that2, ok := that.(Params) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.IbcRequestEnabled != that1.IbcRequestEnabled { + return false + } + if this.PacketTimeout != that1.PacketTimeout { + return false + } + if this.MaxAllowedDenomsHistoricalQuery != that1.MaxAllowedDenomsHistoricalQuery { + return false + } + if this.MaxAllowedDenomsExchangeQuery != that1.MaxAllowedDenomsExchangeQuery { + return false + } + return true +} +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.MaxAllowedDenomsExchangeQuery != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MaxAllowedDenomsExchangeQuery)) + i-- + dAtA[i] = 0x20 + } + if m.MaxAllowedDenomsHistoricalQuery != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MaxAllowedDenomsHistoricalQuery)) + i-- + dAtA[i] = 0x18 + } + if m.PacketTimeout != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.PacketTimeout)) + i-- + dAtA[i] = 0x10 + } + if m.IbcRequestEnabled { + i-- + if m.IbcRequestEnabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.IbcRequestEnabled { + n += 2 + } + if m.PacketTimeout != 0 { + n += 1 + sovParams(uint64(m.PacketTimeout)) + } + if m.MaxAllowedDenomsHistoricalQuery != 0 { + n += 1 + sovParams(uint64(m.MaxAllowedDenomsHistoricalQuery)) + } + if m.MaxAllowedDenomsExchangeQuery != 0 { + n += 1 + sovParams(uint64(m.MaxAllowedDenomsExchangeQuery)) + } + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IbcRequestEnabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IbcRequestEnabled = bool(v != 0) + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketTimeout", wireType) + } + m.PacketTimeout = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PacketTimeout |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxAllowedDenomsHistoricalQuery", wireType) + } + m.MaxAllowedDenomsHistoricalQuery = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxAllowedDenomsHistoricalQuery |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxAllowedDenomsExchangeQuery", wireType) + } + m.MaxAllowedDenomsExchangeQuery = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxAllowedDenomsExchangeQuery |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/relayoracle/types/query.pb.go b/x/relayoracle/types/query.pb.go new file mode 100644 index 00000000..b35bed10 --- /dev/null +++ b/x/relayoracle/types/query.pb.go @@ -0,0 +1,538 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ojo/relayoracle/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "github.com/gogo/protobuf/gogoproto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is request.go type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_864a733e70c1379a, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_864a733e70c1379a, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "ojo.relayoracle.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "ojo.relayoracle.QueryParamsResponse") +} + +func init() { proto.RegisterFile("ojo/relayoracle/query.proto", fileDescriptor_864a733e70c1379a) } + +var fileDescriptor_864a733e70c1379a = []byte{ + // 306 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0x31, 0x4b, 0x33, 0x31, + 0x18, 0xc7, 0x2f, 0x2f, 0xaf, 0x1d, 0xe2, 0x20, 0xc4, 0x82, 0x52, 0x25, 0x4a, 0xab, 0x20, 0x8a, + 0x09, 0xad, 0xf8, 0x05, 0x3a, 0x39, 0x38, 0x68, 0x47, 0xb7,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0xb5, 0xf7, 0x37, 0x54, 0xd6, 0x6a, 0x1f, 0x3d, 0xbe, 0x7e, 0xbe, 0xfc, 0xdb, 0x27, 0x1d, 0x0e, + 0x23, 0x38, 0xd6, 0xd2, 0xdf, 0x81, 0xbd, 0xe1, 0xbf, 0x9f, 0xdd, 0x3f, 0x9b, 0x66, 0x14, 0xcd, + 0x32, 0x8a, 0x3e, 0x32, 0x8a, 0x9e, 0x73, 0x1a, 0xcc, 0x72, 0x1a, 0xbc, 0xe5, 0x34, 0xb8, 0x62, + 0x2a, 0xf2, 0xd7, 0x49, 0xc8, 0x86, 0x10, 0xd7, 0x44, 0xf7, 0x0b, 0x2a, 0x9f, 0x1a, 0xe9, 0xc2, + 0x46, 0xf1, 0x83, 0x27, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x77, 0xab, 0xe0, 0x5c, 0xef, 0x01, + 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/ojo.relayoracle.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ojo.relayoracle.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ojo.relayoracle.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ojo/relayoracle/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/relayoracle/types/query.pb.gw.go b/x/relayoracle/types/query.pb.gw.go new file mode 100644 index 00000000..b571c410 --- /dev/null +++ b/x/relayoracle/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: ojo/relayoracle/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ojo-network", "ojo", "relayoracle", "params"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage +) diff --git a/x/relayoracle/types/tx.pb.go b/x/relayoracle/types/tx.pb.go new file mode 100644 index 00000000..5d7a950c --- /dev/null +++ b/x/relayoracle/types/tx.pb.go @@ -0,0 +1,755 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ojo/relayoracle/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "github.com/gogo/protobuf/gogoproto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgGovUpdateParams defines the Msg/GovUpdateParams request type. +type MsgGovUpdateParams struct { + // authority is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + Keys []string `protobuf:"bytes,4,rep,name=keys,proto3" json:"keys,omitempty"` + Changes Params `protobuf:"bytes,5,opt,name=changes,proto3" json:"changes"` +} + +func (m *MsgGovUpdateParams) Reset() { *m = MsgGovUpdateParams{} } +func (*MsgGovUpdateParams) ProtoMessage() {} +func (*MsgGovUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_c6c83bb585b4bc3b, []int{0} +} +func (m *MsgGovUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgGovUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgGovUpdateParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgGovUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgGovUpdateParams.Merge(m, src) +} +func (m *MsgGovUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgGovUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgGovUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgGovUpdateParams proto.InternalMessageInfo + +// MsgGovUpdateParamsResponse defines the Msg/GovUpdateParams response type. +type MsgGovUpdateParamsResponse struct { +} + +func (m *MsgGovUpdateParamsResponse) Reset() { *m = MsgGovUpdateParamsResponse{} } +func (m *MsgGovUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgGovUpdateParamsResponse) ProtoMessage() {} +func (*MsgGovUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c6c83bb585b4bc3b, []int{1} +} +func (m *MsgGovUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgGovUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgGovUpdateParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgGovUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgGovUpdateParamsResponse.Merge(m, src) +} +func (m *MsgGovUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgGovUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgGovUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgGovUpdateParamsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgGovUpdateParams)(nil), "ojo.relayoracle.v1.MsgGovUpdateParams") + proto.RegisterType((*MsgGovUpdateParamsResponse)(nil), "ojo.relayoracle.v1.MsgGovUpdateParamsResponse") +} + +func init() { proto.RegisterFile("ojo/relayoracle/v1/tx.proto", fileDescriptor_c6c83bb585b4bc3b) } + +var fileDescriptor_c6c83bb585b4bc3b = []byte{ + // 395 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xbf, 0x8e, 0xda, 0x40, + 0x10, 0xc6, 0xbd, 0x01, 0x12, 0xb1, 0x14, 0x91, 0x56, 0x48, 0x71, 0x9c, 0xc8, 0xb6, 0x28, 0x22, + 0x14, 0x89, 0xb5, 0x20, 0x52, 0x0a, 0xba, 0xd0, 0x24, 0x0d, 0x52, 0xe4, 0x28, 0x4d, 0x9a, 0xc8, + 0xd8, 0xab, 0xc5, 0x80, 0x3d, 0xd6, 0xee, 0x42, 0x70, 0x9b, 0x2a, 0x65, 0xca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0x69, 0xd7, 0xdd, 0x3c, 0x26, 0x7d, 0xfc, 0xcc, 0x1f, 0x7b, 0x31, 0x67, + 0x52, 0xaf, 0xd9, 0xa8, 0xdd, 0xe8, 0x19, 0xf4, 0x74, 0x57, 0xb4, 0x18, 0x78, 0x50, 0x5d, 0x5f, + 0x5a, 0x9a, 0xbb, 0x17, 0xf4, 0x8d, 0x5f, 0x2b, 0x4b, 0xfb, 0xb3, 0xb2, 0xb4, 0x9b, 0x95, 0x85, + 0x7e, 0x5e, 0xff, 0x7d, 0x7b, 0x98, 0xb1, 0xf5, 0x1a, 0x1b, 0xa7, 0x3f, 0x76, 0x99, 0x4c, 0x20, + 0x96, 0xac, 0x97, 0xe0, 0xca, 0x50, 0x72, 0x12, 0xe2, 0xe7, 0x0f, 0x77, 0xf2, 0xe6, 0x9c, 0xfd, + 0x69, 0x27, 0x83, 0x3e, 0xae, 0x6e, 0xef, 0x38, 0xf8, 0xb4, 0xde, 0x9a, 0x68, 0xb3, 0x35, 0xd1, + 0xd5, 0xd6, 0x44, 0xbf, 0x77, 0xa6, 0xb6, 0xd9, 0x99, 0xda, 0xc5, 0xce, 0xd4, 0xbe, 0x51, 0x1e, + 0xaa, 0xf1, 0x7c, 0x44, 0x7d, 0x88, 0x1c, 0x98, 0x40, 0x27, 0x66, 0xea, 0x07, 0x88, 0x69, 0x16, + 0x3b, 0xcb, 0x7b, 0x67, 0x55, 0x69, 0xc2, 0xe4, 0xe8, 0x69, 0x7e, 0xd3, 0x77, 0x77, 0x01, 0x00, + 0x00, 0xff, 0xff, 0x33, 0xa1, 0xc8, 0xad, 0x71, 0x02, 0x00, 0x00, +} + +func (this *MsgGovUpdateParams) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgGovUpdateParams) + if !ok { + that2, ok := that.(MsgGovUpdateParams) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Authority != that1.Authority { + return false + } + if this.Title != that1.Title { + return false + } + if this.Description != that1.Description { + return false + } + if len(this.Keys) != len(that1.Keys) { + return false + } + for i := range this.Keys { + if this.Keys[i] != that1.Keys[i] { + return false + } + } + if !this.Changes.Equal(&that1.Changes) { + return false + } + return true +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + GovUpdateParams(ctx context.Context, in *MsgGovUpdateParams, opts ...grpc.CallOption) (*MsgGovUpdateParamsResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) GovUpdateParams(ctx context.Context, in *MsgGovUpdateParams, opts ...grpc.CallOption) (*MsgGovUpdateParamsResponse, error) { + out := new(MsgGovUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/ojo.relayoracle.v1.Msg/GovUpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + GovUpdateParams(context.Context, *MsgGovUpdateParams) (*MsgGovUpdateParamsResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) GovUpdateParams(ctx context.Context, req *MsgGovUpdateParams) (*MsgGovUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GovUpdateParams not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_GovUpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgGovUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).GovUpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ojo.relayoracle.v1.Msg/GovUpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).GovUpdateParams(ctx, req.(*MsgGovUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ojo.relayoracle.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GovUpdateParams", + Handler: _Msg_GovUpdateParams_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ojo/relayoracle/v1/tx.proto", +} + +func (m *MsgGovUpdateParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgGovUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgGovUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Changes.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + if len(m.Keys) > 0 { + for iNdEx := len(m.Keys) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Keys[iNdEx]) + copy(dAtA[i:], m.Keys[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Keys[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintTx(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x1a + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintTx(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0x12 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgGovUpdateParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgGovUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgGovUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgGovUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Title) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Keys) > 0 { + for _, s := range m.Keys { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + l = m.Changes.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgGovUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgGovUpdateParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgGovUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgGovUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Keys = append(m.Keys, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Changes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Changes.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgGovUpdateParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgGovUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgGovUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/relayoracle/types/types.go b/x/relayoracle/types/types.go new file mode 100644 index 00000000..132e74fd --- /dev/null +++ b/x/relayoracle/types/types.go @@ -0,0 +1,55 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + protobuftypes "github.com/gogo/protobuf/types" +) + +func (packet *OracleRequestPacketData) ValidateBasic() error { + return nil +} + +func NewIbcChannel(port, channel string) *IBCChannel { + return &IBCChannel{ + ChannelId: channel, + PortId: port, + } +} + +func NewRequest(id uint64, calldata []byte, clientID string, channel *IBCChannel) Request { + return Request{ + RequestID: id, + RequestCallData: calldata, + ClientID: clientID, + IBCChannel: channel, + } +} + +func NewRequestOracleAcknowledgement(id uint64, requestType PriceRequestType) *OracleRequestPacketAcknowledgement { + return &OracleRequestPacketAcknowledgement{ + RequestID: id, + Data: ModuleCdc.MustMarshalLengthPrefixed(&protobuftypes.Int32Value{Value: int32(requestType)}), + } +} + +func NewOracleResponsePacketData( + clientID string, + requestID uint64, + requestTime, + resolveTime int64, + resolveStatus ResolveStatus, + result []byte, +) *OracleResponsePacketData { + return &OracleResponsePacketData{ + ClientID: clientID, + RequestID: requestID, + RequestTime: requestTime, + ResolveTime: resolveTime, + ResolveStatus: resolveStatus, + Result: result, + } +} + +func (o *OracleResponsePacketData) ToBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(o)) +}