diff --git a/Makefile b/Makefile index 97839045..14df4445 100755 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ SIMAPP = ./app HTTPS_GIT := https://github.com/tharsis/ethermint.git DOCKER := $(shell which docker) DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf +PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git) export GO111MODULE = on @@ -422,25 +423,35 @@ format-fix: ### Protobuf ### ############################################################################### -containerProtoVer=v0.2 -containerProtoImage=tendermintdev/sdk-proto-gen:$(containerProtoVer) -containerProtoGen=cosmos-sdk-proto-gen-$(containerProtoVer) -containerProtoGenSwagger=cosmos-sdk-proto-gen-swagger-$(containerProtoVer) -containerProtoFmt=cosmos-sdk-proto-fmt-$(containerProtoVer) +protoVer=v0.2 +protoImageName=tendermintdev/sdk-proto-gen:$(protoVer) +containerProtoGen=$(PROJECT_NAME)-proto-gen-$(protoVer) +containerProtoGenAny=$(PROJECT_NAME)-proto-gen-any-$(protoVer) +containerProtoGenSwagger=$(PROJECT_NAME)-proto-gen-swagger-$(protoVer) +containerProtoFmt=$(PROJECT_NAME)-proto-fmt-$(protoVer) proto-all: proto-format proto-lint proto-gen proto-gen: @echo "Generating Protobuf files" - $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace tendermintdev/sdk-proto-gen sh ./scripts/protocgen.sh + @if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \ + sh ./scripts/protocgen.sh; fi + +# This generates the SDK's custom wrapper for google.protobuf.Any. It should only be run manually when needed +proto-gen-any: + @echo "Generating Protobuf Any" + @if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenAny}$$"; then docker start -a $(containerProtoGenAny); else docker run --name $(containerProtoGenAny) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \ + sh ./scripts/protocgen-any.sh; fi proto-swagger-gen: @echo "Generating Protobuf Swagger" - @./scripts/protoc-swagger-gen.sh + @if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenSwagger}$$"; then docker start -a $(containerProtoGenSwagger); else docker run --name $(containerProtoGenSwagger) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \ + sh ./scripts/protoc-swagger-gen.sh; fi proto-format: @echo "Formatting Protobuf files" - find ./ -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \; + @if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then docker start -a $(containerProtoFmt); else docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace tendermintdev/docker-build-proto \ + find ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \; ; fi proto-lint: @$(DOCKER_BUF) lint --error-format=json diff --git a/app/app.go b/app/app.go index 47ada7ee..3a463cf1 100644 --- a/app/app.go +++ b/app/app.go @@ -2,6 +2,9 @@ package app import ( "encoding/json" + "github.com/tharsis/ethermint/x/bond" + bondkeeper "github.com/tharsis/ethermint/x/bond/keeper" + bondtypes "github.com/tharsis/ethermint/x/bond/types" "io" "net/http" "os" @@ -150,6 +153,8 @@ var ( // Ethermint modules evm.AppModuleBasic{}, feemarket.AppModuleBasic{}, + // DXNS modules + bond.AppModuleBasic{}, ) // module account permissions @@ -162,6 +167,7 @@ var ( govtypes.ModuleName: {authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for secure addition and subtraction of balance using module account + bondtypes.ModuleName: nil, } // module accounts that are allowed to receive tokens @@ -218,6 +224,9 @@ type EthermintApp struct { EvmKeeper *evmkeeper.Keeper FeeMarketKeeper feemarketkeeper.Keeper + // DXNS keepers + BondKeeper bondkeeper.Keeper + // the module manager mm *module.Manager @@ -268,6 +277,8 @@ func NewEthermintApp( ibchost.StoreKey, ibctransfertypes.StoreKey, // ethermint keys evmtypes.StoreKey, feemarkettypes.StoreKey, + // dxns keys + bondtypes.StoreKey, ) // Add the EVM transient store key @@ -348,6 +359,9 @@ func NewEthermintApp( appCodec, keys[feemarkettypes.StoreKey], app.GetSubspace(feemarkettypes.ModuleName), ) + // Create DXNS keepers + app.BondKeeper = bondkeeper.NewKeeper(appCodec, app.AccountKeeper, app.BankKeeper, keys[bondtypes.StoreKey], app.GetSubspace(bondtypes.ModuleName)) + // Create IBC Keeper app.IBCKeeper = ibckeeper.NewKeeper( appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, @@ -428,6 +442,8 @@ func NewEthermintApp( // Ethermint app modules evm.NewAppModule(app.EvmKeeper, app.AccountKeeper), feemarket.NewAppModule(app.FeeMarketKeeper), + // DXNs modules + bond.NewAppModule(appCodec, app.BondKeeper), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -463,6 +479,8 @@ func NewEthermintApp( authz.ModuleName, feegrant.ModuleName, // Ethermint modules evmtypes.ModuleName, feemarkettypes.ModuleName, + // DXNS modules + bondtypes.ModuleName, // NOTE: crisis module must go at the end to check for invariants on each module crisistypes.ModuleName, @@ -705,5 +723,7 @@ func initParamsKeeper( // ethermint subspaces paramsKeeper.Subspace(evmtypes.ModuleName) paramsKeeper.Subspace(feemarkettypes.ModuleName) + // dxns subspaces + paramsKeeper.Subspace(bondtypes.ModuleName) return paramsKeeper } diff --git a/docs/api/proto-docs.md b/docs/api/proto-docs.md index 2b369491..30604611 100644 --- a/docs/api/proto-docs.md +++ b/docs/api/proto-docs.md @@ -80,6 +80,39 @@ - [ethermint/types/v1/web3.proto](#ethermint/types/v1/web3.proto) - [ExtensionOptionsWeb3Tx](#ethermint.types.v1.ExtensionOptionsWeb3Tx) +- [vulcanize/bond/v1beta1/bond.proto](#vulcanize/bond/v1beta1/bond.proto) + - [Bond](#vulcanize.bond.v1beta1.Bond) + - [Params](#vulcanize.bond.v1beta1.Params) + +- [vulcanize/bond/v1beta1/genesis.proto](#vulcanize/bond/v1beta1/genesis.proto) + - [GenesisState](#vulcanize.bond.v1beta1.GenesisState) + +- [vulcanize/bond/v1beta1/query.proto](#vulcanize/bond/v1beta1/query.proto) + - [QueryGetBondByIdRequest](#vulcanize.bond.v1beta1.QueryGetBondByIdRequest) + - [QueryGetBondByIdResponse](#vulcanize.bond.v1beta1.QueryGetBondByIdResponse) + - [QueryGetBondModuleBalanceRequest](#vulcanize.bond.v1beta1.QueryGetBondModuleBalanceRequest) + - [QueryGetBondModuleBalanceResponse](#vulcanize.bond.v1beta1.QueryGetBondModuleBalanceResponse) + - [QueryGetBondsByOwnerRequest](#vulcanize.bond.v1beta1.QueryGetBondsByOwnerRequest) + - [QueryGetBondsByOwnerResponse](#vulcanize.bond.v1beta1.QueryGetBondsByOwnerResponse) + - [QueryGetBondsRequest](#vulcanize.bond.v1beta1.QueryGetBondsRequest) + - [QueryGetBondsResponse](#vulcanize.bond.v1beta1.QueryGetBondsResponse) + - [QueryParamRequest](#vulcanize.bond.v1beta1.QueryParamRequest) + - [QueryParamsResponse](#vulcanize.bond.v1beta1.QueryParamsResponse) + + - [Query](#vulcanize.bond.v1beta1.Query) + +- [vulcanize/bond/v1beta1/tx.proto](#vulcanize/bond/v1beta1/tx.proto) + - [MsgCancelBond](#vulcanize.bond.v1beta1.MsgCancelBond) + - [MsgCancelBondResponse](#vulcanize.bond.v1beta1.MsgCancelBondResponse) + - [MsgCreateBond](#vulcanize.bond.v1beta1.MsgCreateBond) + - [MsgCreateBondResponse](#vulcanize.bond.v1beta1.MsgCreateBondResponse) + - [MsgRefillBond](#vulcanize.bond.v1beta1.MsgRefillBond) + - [MsgRefillBondResponse](#vulcanize.bond.v1beta1.MsgRefillBondResponse) + - [MsgWithdrawBond](#vulcanize.bond.v1beta1.MsgWithdrawBond) + - [MsgWithdrawBondResponse](#vulcanize.bond.v1beta1.MsgWithdrawBondResponse) + + - [Msg](#vulcanize.bond.v1beta1.Msg) + - [Scalar Value Types](#scalar-value-types) @@ -1134,6 +1167,399 @@ authtypes.BaseAccount type. It is compatible with the auth AccountKeeper. + +
+ +## vulcanize/bond/v1beta1/bond.proto + + + + + +### Bond +Bond represents funds deposited by an account for record rent payments. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `id` | [string](#string) | | id is unique identifier of the bond | +| `owner` | [string](#string) | | owner of the bond | +| `balance` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | balance of the bond | + + + + + + + + +### Params +Params defines the bond module parameters + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `max_bond_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | max_bond_amount is maximum amount to bond | + + + + + + + + + + + + + + + + + + +## vulcanize/bond/v1beta1/genesis.proto + + + + + +### GenesisState +GenesisState defines the bond module's genesis state. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#vulcanize.bond.v1beta1.Params) | | params defines all the parameters of the module. | +| `bonds` | [Bond](#vulcanize.bond.v1beta1.Bond) | repeated | bonds defines all the bonds | + + + + + + + + + + + + + + + + + + +## vulcanize/bond/v1beta1/query.proto + + + + + +### QueryGetBondByIdRequest +QueryGetBondById + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `id` | [string](#string) | | | + + + + + + + + +### QueryGetBondByIdResponse +QueryGetBondByIdResponse returns QueryGetBondById query response + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `bond` | [Bond](#vulcanize.bond.v1beta1.Bond) | | | + + + + + + + + +### QueryGetBondModuleBalanceRequest +QueryGetBondModuleBalanceRequest is request type for bond module balance rpc method + + + + + + + + +### QueryGetBondModuleBalanceResponse +QueryGetBondModuleBalanceResponse is response type for bond module balance rpc method + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `balance` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | + + + + + + + + +### QueryGetBondsByOwnerRequest +QueryGetBondsByOwnerRequest is request tyep for Query/GetBondsByOwner RPC Method + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `owner` | [string](#string) | | | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | + + + + + + + + +### QueryGetBondsByOwnerResponse +QueryGetBondsByOwnerResponse is response type for Query/GetBondsByOwner RPC Method + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `bonds` | [Bond](#vulcanize.bond.v1beta1.Bond) | repeated | | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | + + + + + + + + +### QueryGetBondsRequest +QueryGetBonds + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | + + + + + + + + +### QueryGetBondsResponse +QueryGetBondsResponse + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `bonds` | [Bond](#vulcanize.bond.v1beta1.Bond) | repeated | | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | + + + + + + + + +### QueryParamRequest +QueryParamRequest is request for query the bond module params + + + + + + + + +### QueryParamsResponse +QueryParamsResponse returns response type of bond module params + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#vulcanize.bond.v1beta1.Params) | | | + + + + + + + + + + + + + + +### Query +Query defines the gRPC querier service for bond module + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Params` | [QueryParamRequest](#vulcanize.bond.v1beta1.QueryParamRequest) | [QueryParamsResponse](#vulcanize.bond.v1beta1.QueryParamsResponse) | Bonds queries bonds list. | GET|/ethermint/bond/v1/params| +| `Bonds` | [QueryGetBondsRequest](#vulcanize.bond.v1beta1.QueryGetBondsRequest) | [QueryGetBondsResponse](#vulcanize.bond.v1beta1.QueryGetBondsResponse) | Bonds queries bonds list. | GET|/ethermint/bond/v1/bonds| +| `GetBondById` | [QueryGetBondByIdRequest](#vulcanize.bond.v1beta1.QueryGetBondByIdRequest) | [QueryGetBondByIdResponse](#vulcanize.bond.v1beta1.QueryGetBondByIdResponse) | GetBondById | GET|/ethermint/bond/v1/bonds/{id}| +| `GetBondsByOwner` | [QueryGetBondsByOwnerRequest](#vulcanize.bond.v1beta1.QueryGetBondsByOwnerRequest) | [QueryGetBondsByOwnerResponse](#vulcanize.bond.v1beta1.QueryGetBondsByOwnerResponse) | Get Bonds List by Owner | GET|/ethermint/bond/v1/bonds_by_owner| +| `GetBondsModuleBalance` | [QueryGetBondModuleBalanceRequest](#vulcanize.bond.v1beta1.QueryGetBondModuleBalanceRequest) | [QueryGetBondModuleBalanceResponse](#vulcanize.bond.v1beta1.QueryGetBondModuleBalanceResponse) | Get Bonds module balance | GET|/ethermint/bond/v1/balance| + + + + + + + + +## vulcanize/bond/v1beta1/tx.proto + + + + + +### MsgCancelBond +MsgCancelBond defines a SDK message for the cancel the bond. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `id` | [string](#string) | | | +| `signer` | [string](#string) | | | + + + + + + + + +### MsgCancelBondResponse +MsgCancelBondResponse defines the MsgCancelBond response type. + + + + + + + + +### MsgCreateBond +MsgCreateBond defines a SDK message for creating a new bond. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `signer` | [string](#string) | | | +| `coins` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | + + + + + + + + +### MsgCreateBondResponse +MsgCreateBondResponse defines the Msg/CreateBond response type. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `id` | [string](#string) | | | + + + + + + + + +### MsgRefillBond +MsgRefillBond defines a SDK message for refill the amount for bond. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `id` | [string](#string) | | | +| `signer` | [string](#string) | | | +| `coins` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | + + + + + + + + +### MsgRefillBondResponse +MsgRefillBondResponse defines the Msg/RefillBond response type. + + + + + + + + +### MsgWithdrawBond +MsgWithdrawBond defines a SDK message for withdrawing amount from bond. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `id` | [string](#string) | | | +| `signer` | [string](#string) | | | +| `coins` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | + + + + + + + + +### MsgWithdrawBondResponse +MsgWithdrawBondResponse defines the MsgWithdrawBond response type. + + + + + + + + + + + + + + +### Msg +Msg defines the bond Msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `CreateBond` | [MsgCreateBond](#vulcanize.bond.v1beta1.MsgCreateBond) | [MsgCreateBondResponse](#vulcanize.bond.v1beta1.MsgCreateBondResponse) | CreateBond defines a method for creating a new bond. | | +| `RefillBond` | [MsgRefillBond](#vulcanize.bond.v1beta1.MsgRefillBond) | [MsgRefillBondResponse](#vulcanize.bond.v1beta1.MsgRefillBondResponse) | RefillBond defines a method for refilling amount for bond. | | +| `WithdrawBond` | [MsgWithdrawBond](#vulcanize.bond.v1beta1.MsgWithdrawBond) | [MsgWithdrawBondResponse](#vulcanize.bond.v1beta1.MsgWithdrawBondResponse) | WithdrawBond defines a method for withdrawing amount from bond. | | +| `CancelBond` | [MsgCancelBond](#vulcanize.bond.v1beta1.MsgCancelBond) | [MsgCancelBondResponse](#vulcanize.bond.v1beta1.MsgCancelBondResponse) | CancelBond defines a method for cancelling a bond. | | + + + + + ## Scalar Value Types | .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby | diff --git a/go.mod b/go.mod index 147ccddb..afe28a5b 100644 --- a/go.mod +++ b/go.mod @@ -31,10 +31,10 @@ require ( github.com/tendermint/tm-db v0.6.4 github.com/tyler-smith/go-bip39 v1.1.0 go.etcd.io/bbolt v1.3.6 // indirect - golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect + golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f // indirect golang.org/x/sys v0.0.0-20210903071746-97244b99971b // indirect - google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af + google.golang.org/genproto v0.0.0-20210921142501-181ce0d877f6 google.golang.org/grpc v1.40.0 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index e90e6c00..cc7d219b 100644 --- a/go.sum +++ b/go.sum @@ -1128,8 +1128,10 @@ golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWP golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ= -golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210920023735-84f357641f63 h1:kETrAMYZq6WVGPa8IIixL0CaEcIUNi+1WX7grUoi3y8= +golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 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= @@ -1513,8 +1515,10 @@ google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af h1:aLMMXFYqw01RA6XJim5uaN+afqNNjc9P8HPAbnpnc5s= -google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4 h1:ysnBoUyeL/H6RCvNRhWHjKoDEmguI+mPU+qHgK8qv/w= +google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210921142501-181ce0d877f6 h1:2ncG/LajxmrclaZH+ppVi02rQxz4eXYJzGHdFN4Y9UA= +google.golang.org/genproto v0.0.0-20210921142501-181ce0d877f6/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.0.1/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= diff --git a/proto/vulcanize/bond/v1beta1/bond.proto b/proto/vulcanize/bond/v1beta1/bond.proto new file mode 100644 index 00000000..c5b32141 --- /dev/null +++ b/proto/vulcanize/bond/v1beta1/bond.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; +package vulcanize.bond.v1beta1; + +option go_package = "github.com/tharsis/ethermint/x/bond/types"; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +// Params defines the bond module parameters +message Params { + // max_bond_amount is maximum amount to bond + cosmos.base.v1beta1.Coin max_bond_amount = 1 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "json:\"max_bond_amount\" yaml:\"max_bond_amount\"" + ]; +} + +// Bond represents funds deposited by an account for record rent payments. +message Bond { + // id is unique identifier of the bond + string id = 1; + // owner of the bond + string owner = 2; + // balance of the bond + repeated cosmos.base.v1beta1.Coin balance = 3 [ + (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "json:\"balance\" yaml:\"balance\"" + ]; +} diff --git a/proto/vulcanize/bond/v1beta1/genesis.proto b/proto/vulcanize/bond/v1beta1/genesis.proto new file mode 100644 index 00000000..7f46f061 --- /dev/null +++ b/proto/vulcanize/bond/v1beta1/genesis.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +package vulcanize.bond.v1beta1; + +import "gogoproto/gogo.proto"; +import "vulcanize/bond/v1beta1/bond.proto"; + +option go_package = "github.com/tharsis/ethermint/x/bond/types"; + +// GenesisState defines the bond module's genesis state. +message GenesisState { + // params defines all the parameters of the module. + Params params = 1 [(gogoproto.nullable) = false]; + + // bonds defines all the bonds + repeated Bond bonds = 2 [ + (gogoproto.moretags) = "json:\"bonds\" yaml:\"bonds\"" + ]; +} diff --git a/proto/vulcanize/bond/v1beta1/query.proto b/proto/vulcanize/bond/v1beta1/query.proto new file mode 100644 index 00000000..283e7891 --- /dev/null +++ b/proto/vulcanize/bond/v1beta1/query.proto @@ -0,0 +1,109 @@ +syntax = "proto3"; +package vulcanize.bond.v1beta1; + +import "gogoproto/gogo.proto"; +import "vulcanize/bond/v1beta1/bond.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/tharsis/ethermint/x/bond/types"; + +// Query defines the gRPC querier service for bond module +service Query { + // Params queries bonds module params. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/ethermint/bond/v1/params"; + } + + // Bonds queries bonds list. + rpc Bonds(QueryGetBondsRequest) returns (QueryGetBondsResponse) { + option (google.api.http).get = "/ethermint/bond/v1/bonds"; + } + + // GetBondById + rpc GetBondById(QueryGetBondByIdRequest) returns (QueryGetBondByIdResponse){ + option (google.api.http).get = "/ethermint/bond/v1/bonds/{id}"; + } + + // Get Bonds List by Owner + rpc GetBondsByOwner(QueryGetBondsByOwnerRequest) returns (QueryGetBondsByOwnerResponse){ + option (google.api.http).get = "/ethermint/bond/v1/bonds_by_owner"; + } + + // Get Bonds module balance + rpc GetBondsModuleBalance(QueryGetBondModuleBalanceRequest) returns (QueryGetBondModuleBalanceResponse){ + option (google.api.http).get = "/ethermint/bond/v1/balance"; + } +} + +// QueryParamsRequest is request for query the bond module params +message QueryParamsRequest{ +} + +// QueryParamsResponse returns response type of bond module params +message QueryParamsResponse{ + Params params = 1 [ + (gogoproto.moretags) = "json:\"params\" yaml:\"params\"" + ]; +} + +// QueryGetBondById queries a bond by bond-id. +message QueryGetBondsRequest{ + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryGetBondsResponse is response type for get the bonds by bond-id +message QueryGetBondsResponse{ + repeated Bond bonds = 1 [ + (gogoproto.moretags) = "json:\"bonds\" yaml:\"bonds\"" + ]; + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryGetBondById +message QueryGetBondByIdRequest{ + string id = 1 [ + (gogoproto.moretags) = "json:\"id\" yaml:\"id\"" + ]; +} + +// QueryGetBondByIdResponse returns QueryGetBondById query response +message QueryGetBondByIdResponse{ + Bond bond = 1 [ + (gogoproto.moretags) = "json:\"bond\" yaml:\"bond\"" + ]; +} + +// QueryGetBondsByOwnerRequest is request type for Query/GetBondsByOwner RPC Method +message QueryGetBondsByOwnerRequest{ + string owner = 1; + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryGetBondsByOwnerResponse is response type for Query/GetBondsByOwner RPC Method +message QueryGetBondsByOwnerResponse { + repeated Bond bonds = 1 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "json:\"bonds\" yaml:\"bonds\"" + ]; + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryGetBondModuleBalanceRequest is request type for bond module balance rpc method +message QueryGetBondModuleBalanceRequest{ + +} + +// QueryGetBondModuleBalanceResponse is the response type for bond module balance rpc method +message QueryGetBondModuleBalanceResponse{ + repeated cosmos.base.v1beta1.Coin balance = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "json:\"coins\" yaml:\"coins\"" + ]; +} diff --git a/proto/vulcanize/bond/v1beta1/tx.proto b/proto/vulcanize/bond/v1beta1/tx.proto new file mode 100644 index 00000000..16cfe8e8 --- /dev/null +++ b/proto/vulcanize/bond/v1beta1/tx.proto @@ -0,0 +1,77 @@ +syntax = "proto3"; +package vulcanize.bond.v1beta1; + +option go_package = "github.com/tharsis/ethermint/x/bond/types"; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +// Msg defines the bond Msg service. +service Msg { + // CreateBond defines a method for creating a new bond. + rpc CreateBond(MsgCreateBond) returns (MsgCreateBondResponse); + + // RefillBond defines a method for refilling amount for bond. + rpc RefillBond(MsgRefillBond) returns (MsgRefillBondResponse); + + // WithdrawBond defines a method for withdrawing amount from bond. + rpc WithdrawBond(MsgWithdrawBond) returns (MsgWithdrawBondResponse); + + // CancelBond defines a method for cancelling a bond. + rpc CancelBond(MsgCancelBond) returns (MsgCancelBondResponse); +} + +// MsgCreateBond defines a SDK message for creating a new bond. +message MsgCreateBond{ + string signer = 1; + repeated cosmos.base.v1beta1.Coin coins = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "json:\"coins\" yaml:\"coins\"" + ]; +} + +// MsgCreateBondResponse defines the Msg/CreateBond response type. +message MsgCreateBondResponse{ + string id = 1; +} + +// MsgRefillBond defines a SDK message for refill the amount for bond. +message MsgRefillBond{ + string id = 1; + string signer = 2; + repeated cosmos.base.v1beta1.Coin coins = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "json:\"coins\" yaml:\"coins\"" + ]; +} + +// MsgRefillBondResponse defines the Msg/RefillBond response type. +message MsgRefillBondResponse{ +} + +// MsgWithdrawBond defines a SDK message for withdrawing amount from bond. +message MsgWithdrawBond { + string id = 1; + string signer = 2; + repeated cosmos.base.v1beta1.Coin coins = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "json:\"coins\" yaml:\"coins\"" + ]; +} + +// MsgWithdrawBondResponse defines the Msg/WithdrawBond response type. +message MsgWithdrawBondResponse{ +} + +// MsgCancelBond defines a SDK message for the cancel the bond. +message MsgCancelBond{ + string id = 1; + string signer = 2; +} + +// MsgCancelBondResponse defines the Msg/CancelBond response type. +message MsgCancelBondResponse{ +} diff --git a/scripts/start.sh b/scripts/start.sh index c5e84729..b29ae1e6 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -63,7 +63,7 @@ fi # Compile ethermint echo "compiling ethermint" -make build-ethermint +make build # PID array declaration arr=() @@ -120,15 +120,15 @@ echo "done sleeping" set +e if [[ -z $TEST || $TEST == "rpc" ]]; then - + for i in $(seq 1 "$TEST_QTD"); do HOST_RPC=http://$IP_ADDR:$RPC_PORT"$i" echo "going to test ethermint node $HOST_RPC ..." MODE=$MODE HOST=$HOST_RPC go test ./tests/... -timeout=300s -v -short - + RPC_FAIL=$? done - + fi stop_func() { diff --git a/x/bond/README.md b/x/bond/README.md new file mode 100644 index 00000000..8e549c73 --- /dev/null +++ b/x/bond/README.md @@ -0,0 +1,196 @@ +# Build chain +```bash +# it will create binary in build folder with `ethermintd` +$ make build +``` +# Setup Chain +```bash +./build/ethermintd keys add root +./build/ethermintd init test-moniker --chain-id ethermint_9000-1 +./build/ethermintd add-genesis-account $(./build/ethermintd keys show root -a) 1000000000000000000aphoton,1000000000000000000stake +./build/ethermintd gentx root 1000000000000000000stake --chain-id ethermint_9000-1 +./build/ethermintd collect-gentxs +./build/ethermintd start +``` + +# Params +``` +$ ./build/ethermintd q bond params -o json | jq . + +{ + "params": { + "max_bond_amount": { + "denom": "stake", + "amount": "100000000000" + } + } +} +``` + +# Create Bond +``` + $ ./build/ethermintd tx bond create 100aphoton --from root --chain-id $(./build/ethermintd status | jq .NodeInfo.network -r) + +{"body":{"messages":[{"@type":"/vulcanize.bond.v1beta1.MsgCreateBond","signer":"ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk","coins":[{"denom":"aphoton","amount":"100"}]}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]} + +confirm transaction before signing and broadcasting [y/N]: y +code: 0 +codespace: "" +data: "" +gas_used: "0" +gas_wanted: "0" +height: "0" +info: "" +logs: [] +raw_log: '[]' +timestamp: "" +tx: null +txhash: C6D362E11D4C9FB06D620F3CCAF363A69A074297A00E9CAECBDA5BE1CC302EB8 +``` +# Refill Bond +``` + $ ./build/ethermintd tx bond refill c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440 1000aphoton --from root --chain-id $(./build/ethermintd status | jq .NodeInfo.network -r) +{"body":{"messages":[{"@type":"/vulcanize.bond.v1beta1.MsgRefillBond","id":"c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440","signer":"ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk","coins":[{"denom":"aphoton","amount":"1000"}]}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]} + +confirm transaction before signing and broadcasting [y/N]: y +code: 0 +codespace: "" +data: "" +gas_used: "0" +gas_wanted: "0" +height: "0" +info: "" +logs: [] +raw_log: '[]' +timestamp: "" +tx: null +txhash: 025B04E2C923EFE2299CD171B40829CB1FE4D1A69DA7563C64AAC3D5C27BDFC9 + +``` +# Withdraw from bond +``` + $ ./build/ethermintd tx bond withdraw c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440 1000aphoton --from root --chain-id $(./build/ethermintd status | jq .NodeInfo.network -r) +{"body":{"messages":[{"@type":"/vulcanize.bond.v1beta1.MsgWithdrawBond","id":"c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440","signer":"ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk","coins":[{"denom":"aphoton","amount":"1000"}]}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]} + +confirm transaction before signing and broadcasting [y/N]: y +code: 0 +codespace: "" +data: "" +gas_used: "0" +gas_wanted: "0" +height: "0" +info: "" +logs: [] +raw_log: '[]' +timestamp: "" +tx: null +txhash: 7C5E2FE674577CD6BFFF9F92FCCBC61EDFE8F1A00CE29AC84D58FB8F013D2F03 +``` +# List Bond +``` + $ ./build/ethermintd q bond list -o json | jq . +{ + "bonds": [ + { + "id": "c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440", + "owner": "ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk", + "balance": [ + { + "denom": "aphoton", + "amount": "100" + } + ] + } + ], + "pagination": null +} + +``` +# Get Bond by Id +``` +$ ./build/ethermintd q bond get c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440 -o json | jq . +{ + "bond": { + "id": "c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440", + "owner": "ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk", + "balance": [ + { + "denom": "aphoton", + "amount": "100" + } + ] + } +} + +``` + +# Get Bond Module Balance +``` +$ ./build/ethermintd q bond balance -o json | jq . +{ + "balance": [ + { + "denom": "aphoton", + "amount": "100" + } + ] +} +``` + +# Get Bonds By Owner +``` +$ ./build/ethermintd q bond query-by-owner ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk -o json | jq . +{ + "bonds": [ + { + "id": "c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440", + "owner": "ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk", + "balance": [ + { + "denom": "aphoton", + "amount": "100" + } + ] + } + ], + "pagination": null +} +``` + +# Cancel the bond +``` + $ ./build/ethermintd tx bond cancel c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440 --from root --chain-id $(./build/ethermintd status | jq .NodeInfo.network -r) +{"body":{"messages":[{"@type":"/vulcanize.bond.v1beta1.MsgCancelBond","id":"c3f7a78c5042d2003880962ba31ff3b01fcf5942960e0bc3ca331f816346a440","signer":"ethm1mfdjngh5jvjs9lqtt9a7y2hlgw8v3syh3hsqzk"}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]} + +confirm transaction before signing and broadcasting [y/N]: y +code: 0 +codespace: "" +data: "" +gas_used: "0" +gas_wanted: "0" +height: "0" +info: "" +logs: [] +raw_log: '[]' +timestamp: "" +tx: null +txhash: 06440D0B35A862E3A6783E147F0E1CDD3374870DAE07E471D465E2830DAF7044 + +``` + +Note : After the bond create and withdraw bond and cancel bond , account amount needs change as per module +``` +$ ./build/ethermintd q bank balances $(./build/ethermintd keys show root -a) -o json | jq . +{ + "balances": [ + { + "denom": "aphoton", + "amount": "1000000000000000000" + } + ], + "pagination": { + "next_key": null, + "total": "0" + } +} +``` \ No newline at end of file diff --git a/x/bond/abci.go b/x/bond/abci.go new file mode 100644 index 00000000..1b89cc90 --- /dev/null +++ b/x/bond/abci.go @@ -0,0 +1,17 @@ +package bond + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + abci "github.com/tendermint/tendermint/abci/types" + "github.com/tharsis/ethermint/x/bond/keeper" +) + +// BeginBlocker will persist the current header and validator set as a historical entry +// and prune the oldest entry based on the HistoricalEntries parameter +func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { +} + +// EndBlocker Called every block, update validator set +func EndBlocker(ctx sdk.Context, k keeper.Keeper) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/bond/client/cli/query.go b/x/bond/client/cli/query.go new file mode 100644 index 00000000..86a969bf --- /dev/null +++ b/x/bond/client/cli/query.go @@ -0,0 +1,202 @@ +package cli + +import ( + "fmt" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/version" + "github.com/spf13/cobra" + "github.com/tharsis/ethermint/x/bond/types" + "strings" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd() *cobra.Command { + bondQueryCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the bond module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + bondQueryCmd.AddCommand( + GetQueryParamsCmd(), + GetQueryBondLists(), + GetBondByIdCmd(), + GetBondListByOwnerCmd(), + GetBondModuleBalanceCmd(), + ) + + return bondQueryCmd +} + +// GetQueryParamsCmd implements the params query command. +func GetQueryParamsCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Args: cobra.NoArgs, + Short: "Query the current bond parameters information.", + Long: strings.TrimSpace( + fmt.Sprintf(`Query values set as bond parameters. + +Example: +$ %s query %s params +`, + version.AppName, types.ModuleName, + ), + ), + 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.QueryParamRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +// GetQueryBondLists implements the bond lists query command. +func GetQueryBondLists() *cobra.Command { + cmd := &cobra.Command{ + Use: "list", + Short: "List bonds.", + Long: strings.TrimSpace( + fmt.Sprintf(`Get bond list . + +Example: +$ %s query %s list +`, + version.AppName, types.ModuleName, + ), + ), + Args: cobra.ExactArgs(0), + 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.Bonds(cmd.Context(), &types.QueryGetBondsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +// GetBondByIdCmd implements the bond info by id query command. +func GetBondByIdCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "get [bond Id]", + Short: "Get bond.", + Long: strings.TrimSpace( + fmt.Sprintf(`Get bond info by bond id . + +Example: +$ %s query bond get {BOND ID} +`, + version.AppName, + ), + ), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + id := args[0] + + res, err := queryClient.GetBondById(cmd.Context(), &types.QueryGetBondByIdRequest{Id: id}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +// GetBondListByOwnerCmd queries the bond list by owner. +func GetBondListByOwnerCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "query-by-owner [address]", + Short: "Query bonds by owner.", + Long: strings.TrimSpace( + fmt.Sprintf(`Get bond list by owner. + +Example: +$ %s query %s query-by-owner [address] +`, + version.AppName, types.ModuleName, + ), + ), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + owner := args[0] + res, err := queryClient.GetBondsByOwner(cmd.Context(), &types.QueryGetBondsByOwnerRequest{Owner: owner}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +// GetBondModuleBalanceCmd queries the bond module account balance. +func GetBondModuleBalanceCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "balance", + Short: "Get bond module account balance.", + Long: strings.TrimSpace( + fmt.Sprintf(`Get bond module balance. + +Example: +$ %s query %s balance +`, + version.AppName, types.ModuleName, + ), + ), + Args: cobra.ExactArgs(0), + 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.GetBondsModuleBalance(cmd.Context(), &types.QueryGetBondModuleBalanceRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} diff --git a/x/bond/client/cli/tx.go b/x/bond/client/cli/tx.go new file mode 100644 index 00000000..c39eec75 --- /dev/null +++ b/x/bond/client/cli/tx.go @@ -0,0 +1,125 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" + "github.com/tharsis/ethermint/server/flags" + "github.com/tharsis/ethermint/x/bond/types" +) + +// NewTxCmd returns a root CLI command handler for all x/bond transaction commands. +func NewTxCmd() *cobra.Command { + bondTxCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "bond transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + bondTxCmd.AddCommand( + NewCreateBondCmd(), + RefillBondCmd(), + WithdrawBondCmd(), + CancelBondCmd(), + ) + + return bondTxCmd +} + +// NewCreateBondCmd is the CLI command for creating a bond. +func NewCreateBondCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "create [amount]", + Short: "Create bond.", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + coin, err := sdk.ParseCoinNormalized(args[0]) + if err != nil { + return err + } + + msg := types.NewMsgCreateBond(sdk.NewCoins(coin), clientCtx.GetFromAddress()) + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + + flags.AddTxFlags(cmd) + return cmd +} + +// RefillBondCmd is the CLI command for creating a bond. +func RefillBondCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "refill [bond Id] [amount]", + Short: "Refill bond.", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + bondId := args[0] + coin, err := sdk.ParseCoinNormalized(args[1]) + if err != nil { + return err + } + + msg := types.NewMsgRefillBond(bondId, coin, clientCtx.GetFromAddress()) + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + flags.AddTxFlags(cmd) + return cmd +} + +// WithdrawBondCmd is the CLI command for withdrawing funds from a bond. +func WithdrawBondCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "withdraw [bond Id] [amount]", + Short: "Withdraw amount from bond.", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + bondId := args[0] + coin, err := sdk.ParseCoinNormalized(args[1]) + if err != nil { + return err + } + + msg := types.NewMsgWithdrawBond(bondId, coin, clientCtx.GetFromAddress()) + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + flags.AddTxFlags(cmd) + return cmd +} + +// CancelBondCmd is the CLI command for cancelling a bond. +func CancelBondCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "cancel [bond Id]", + Short: "cancel bond.", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + bondId := args[0] + msg := types.NewMsgCancelBond(bondId, clientCtx.GetFromAddress()) + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + flags.AddTxFlags(cmd) + return cmd +} diff --git a/x/bond/genesis.go b/x/bond/genesis.go new file mode 100644 index 00000000..5457122c --- /dev/null +++ b/x/bond/genesis.go @@ -0,0 +1,40 @@ +package bond + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + abci "github.com/tendermint/tendermint/abci/types" + "github.com/tharsis/ethermint/x/bond/keeper" + "github.com/tharsis/ethermint/x/bond/types" +) + +// InitGenesis initializes genesis state based on exported genesis +func InitGenesis( + ctx sdk.Context, + k keeper.Keeper, data types.GenesisState) []abci.ValidatorUpdate { + + k.SetParams(ctx, data.Params) + + for _, bond := range data.Bonds { + k.SaveBond(ctx, bond) + } + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis - output genesis parameters +func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) types.GenesisState { + params := keeper.GetParams(ctx) + bonds := keeper.ListBonds(ctx) + + return types.GenesisState{Params: params, Bonds: bonds} +} + +// ValidateGenesis - validating the genesis data +func ValidateGenesis(data types.GenesisState) error { + err := data.Params.Validate() + if err != nil { + return err + } + + return nil +} diff --git a/x/bond/keeper/grpc_query.go b/x/bond/keeper/grpc_query.go new file mode 100644 index 00000000..6ed101d0 --- /dev/null +++ b/x/bond/keeper/grpc_query.go @@ -0,0 +1,52 @@ +package keeper + +import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/tharsis/ethermint/x/bond/types" +) + +type Querier struct { + Keeper +} + +var _ types.QueryServer = Querier{} + +func (q Querier) Bonds(c context.Context, _ *types.QueryGetBondsRequest) (*types.QueryGetBondsResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + resp := q.Keeper.ListBonds(ctx) + return &types.QueryGetBondsResponse{Bonds: resp}, nil +} + +func (q Querier) Params(c context.Context, _ *types.QueryParamRequest) (*types.QueryParamsResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + params := q.Keeper.GetParams(ctx) + return &types.QueryParamsResponse{Params: ¶ms}, nil +} + +func (q Querier) GetBondById(c context.Context, req *types.QueryGetBondByIdRequest) (*types.QueryGetBondByIdResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + bondId := req.GetId() + if len(bondId) == 0 { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "bond id required") + } + bond := q.Keeper.GetBond(ctx, req.GetId()) + return &types.QueryGetBondByIdResponse{Bond: &bond}, nil +} + +func (q Querier) GetBondsByOwner(c context.Context, req *types.QueryGetBondsByOwnerRequest) (*types.QueryGetBondsByOwnerResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + owner := req.GetOwner() + if len(owner) == 0 { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "owner id required") + } + bonds := q.Keeper.QueryBondsByOwner(ctx, owner) + return &types.QueryGetBondsByOwnerResponse{Bonds: bonds}, nil +} + +func (q Querier) GetBondsModuleBalance(c context.Context, _ *types.QueryGetBondModuleBalanceRequest) (*types.QueryGetBondModuleBalanceResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + balance := q.Keeper.GetBondModuleBalances(ctx) + return &types.QueryGetBondModuleBalanceResponse{Balance: balance}, nil +} diff --git a/x/bond/keeper/invariants.go b/x/bond/keeper/invariants.go new file mode 100644 index 00000000..f7c8a4d8 --- /dev/null +++ b/x/bond/keeper/invariants.go @@ -0,0 +1,37 @@ +package keeper + +import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tharsis/ethermint/x/bond/types" +) + +// RegisterInvariants registers all bond invariants +func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) { + ir.RegisterRoute(types.ModuleName, "module-account", ModuleAccountInvariant(k)) +} + +// ModuleAccountInvariant checks that the 'bond' module account balance is non-negative. +func ModuleAccountInvariant(k Keeper) sdk.Invariant { + return func(ctx sdk.Context) (string, bool) { + moduleAddress := k.accountKeeper.GetModuleAddress(types.ModuleName) + balances := k.bankKeeper.GetAllBalances(ctx, moduleAddress) + for _, balance := range balances { + if balance.IsNegative() { + return sdk.FormatInvariant( + types.ModuleName, + "module-account", + fmt.Sprintf("Module account '%s' has negative balance.", types.ModuleName)), + true + } + } + return "", false + } +} + +// AllInvariants runs all invariants of the bonds module. +func AllInvariants(k Keeper) sdk.Invariant { + return func(ctx sdk.Context) (string, bool) { + return ModuleAccountInvariant(k)(ctx) + } +} diff --git a/x/bond/keeper/keeper.go b/x/bond/keeper/keeper.go new file mode 100644 index 00000000..70bc0338 --- /dev/null +++ b/x/bond/keeper/keeper.go @@ -0,0 +1,302 @@ +package keeper + +import ( + "crypto/sha256" + "encoding/hex" + "fmt" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + auth "github.com/cosmos/cosmos-sdk/x/auth/keeper" + bank "github.com/cosmos/cosmos-sdk/x/bank/keeper" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/tharsis/ethermint/x/bond/types" +) + +// prefixIDToBondIndex is the prefix for ID -> Bond index in the KVStore. +// Note: This is the primary index in the system. +// Note: Golang doesn't support const arrays. +var prefixIDToBondIndex = []byte{0x00} + +// prefixOwnerToBondsIndex is the prefix for the Owner -> [Bond] index in the KVStore. +var prefixOwnerToBondsIndex = []byte{0x01} + +// Keeper maintains the link to storage and exposes getter/setter methods for the various parts of the state machine +type Keeper struct { + accountKeeper auth.AccountKeeper + bankKeeper bank.Keeper + + storeKey sdk.StoreKey + + cdc codec.BinaryCodec + + paramSubspace paramtypes.Subspace +} + +// NewKeeper creates new instances of the bond Keeper +func NewKeeper(cdc codec.BinaryCodec, accountKeeper auth.AccountKeeper, bankKeeper bank.Keeper, storeKey sdk.StoreKey, ps paramtypes.Subspace) Keeper { + // set KeyTable if it has not already been set + if !ps.HasKeyTable() { + ps = ps.WithKeyTable(types.ParamKeyTable()) + } + + return Keeper{ + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + storeKey: storeKey, + cdc: cdc, + paramSubspace: ps, + } +} + +// Generates Bond ID -> Bond index key. +func getBondIndexKey(id string) []byte { + return append(prefixIDToBondIndex, []byte(id)...) +} + +// Generates Owner -> Bonds index key. +func getOwnerToBondsIndexKey(owner string, bondID string) []byte { + return append(append(prefixOwnerToBondsIndex, []byte(owner)...), []byte(bondID)...) +} + +// BondID simplifies generation of bond IDs. +type BondID struct { + Address sdk.Address + AccNum uint64 + Sequence uint64 +} + +// Generate creates the bond ID. +func (bondID BondID) Generate() string { + hasher := sha256.New() + str := fmt.Sprintf("%s:%d:%d", bondID.Address.String(), bondID.AccNum, bondID.Sequence) + hasher.Write([]byte(str)) + return hex.EncodeToString(hasher.Sum(nil)) +} + +// CreateBond creates a new bond. +func (k Keeper) CreateBond(ctx sdk.Context, ownerAddress sdk.AccAddress, coins sdk.Coins) (*types.Bond, error) { + // Check if account has funds. + for _, coin := range coins { + balance := k.bankKeeper.HasBalance(ctx, ownerAddress, coin) + if !balance { + return nil, sdkerrors.Wrap(sdkerrors.ErrInsufficientFunds, "failed to create bond; Insufficient funds") + } + } + + // Generate bond ID. + account := k.accountKeeper.GetAccount(ctx, ownerAddress) + bondID := BondID{ + Address: ownerAddress, + AccNum: account.GetAccountNumber(), + Sequence: account.GetSequence(), + }.Generate() + + maxBondAmount, err := k.getMaxBondAmount(ctx) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid max bond amount.") + } + + bond := types.Bond{Id: bondID, Owner: ownerAddress.String(), Balance: coins} + if bond.Balance.IsAnyGT(maxBondAmount) { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Max bond amount exceeded.") + } + + // Move funds into the bond account module. + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, ownerAddress, types.ModuleName, bond.Balance) + if err != nil { + return nil, err + } + + // Save bond in store. + k.SaveBond(ctx, &bond) + + return &bond, nil +} + +// SaveBond - saves a bond to the store. +func (k Keeper) SaveBond(ctx sdk.Context, bond *types.Bond) { + store := ctx.KVStore(k.storeKey) + + // Bond ID -> Bond index. + store.Set(getBondIndexKey(bond.Id), k.cdc.MustMarshal(bond)) + + // Owner -> [Bond] index. + store.Set(getOwnerToBondsIndexKey(bond.Owner, bond.Id), []byte{}) +} + +// HasBond - checks if a bond by the given ID exists. +func (k Keeper) HasBond(ctx sdk.Context, id string) bool { + store := ctx.KVStore(k.storeKey) + return store.Has(getBondIndexKey(id)) +} + +// GetBond - gets a record from the store. +func (k Keeper) GetBond(ctx sdk.Context, id string) types.Bond { + store := ctx.KVStore(k.storeKey) + + bz := store.Get(getBondIndexKey(id)) + var obj types.Bond + k.cdc.MustUnmarshal(bz, &obj) + + return obj +} + +// DeleteBond - deletes the bond. +func (k Keeper) DeleteBond(ctx sdk.Context, bond types.Bond) { + store := ctx.KVStore(k.storeKey) + store.Delete(getBondIndexKey(bond.Id)) + store.Delete(getOwnerToBondsIndexKey(bond.Owner, bond.Id)) +} + +// ListBonds - get all bonds. +func (k Keeper) ListBonds(ctx sdk.Context) []*types.Bond { + var bonds []*types.Bond + + store := ctx.KVStore(k.storeKey) + itr := sdk.KVStorePrefixIterator(store, prefixIDToBondIndex) + defer itr.Close() + for ; itr.Valid(); itr.Next() { + bz := store.Get(itr.Key()) + if bz != nil { + var obj types.Bond + k.cdc.MustUnmarshal(bz, &obj) + bonds = append(bonds, &obj) + } + } + return bonds +} + +// QueryBondsByOwner - query bonds by owner. +func (k Keeper) QueryBondsByOwner(ctx sdk.Context, ownerAddress string) []types.Bond { + var bonds []types.Bond + + ownerPrefix := append(prefixOwnerToBondsIndex, []byte(ownerAddress)...) + store := ctx.KVStore(k.storeKey) + itr := sdk.KVStorePrefixIterator(store, ownerPrefix) + defer itr.Close() + for ; itr.Valid(); itr.Next() { + bondID := itr.Key()[len(ownerPrefix):] + bz := store.Get(append(prefixIDToBondIndex, bondID...)) + if bz != nil { + var obj types.Bond + k.cdc.MustUnmarshal(bz, &obj) + bonds = append(bonds, obj) + } + } + + return bonds +} + +// RefillBond refills an existing bond. +func (k Keeper) RefillBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddress, coins sdk.Coins) (*types.Bond, error) { + if !k.HasBond(ctx, id) { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.") + } + + bond := k.GetBond(ctx, id) + if bond.Owner != ownerAddress.String() { + return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.") + } + + // Check if account has funds. + for _, coin := range coins { + if !k.bankKeeper.HasBalance(ctx, ownerAddress, coin) { + return nil, sdkerrors.Wrap(sdkerrors.ErrInsufficientFunds, "Insufficient funds.") + } + } + + maxBondAmount, err := k.getMaxBondAmount(ctx) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid max bond amount.") + } + + updatedBalance := bond.Balance.Add(coins...) + if updatedBalance.IsAnyGT(maxBondAmount) { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Max bond amount exceeded.") + } + + // Move funds into the bond account module. + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, ownerAddress, types.ModuleName, coins) + if err != nil { + return nil, err + } + + // Update bond balance and save. + bond.Balance = updatedBalance + k.SaveBond(ctx, &bond) + + return &bond, nil +} + +// WithdrawBond withdraws funds from a bond. +func (k Keeper) WithdrawBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddress, coins sdk.Coins) (*types.Bond, error) { + if !k.HasBond(ctx, id) { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.") + } + + bond := k.GetBond(ctx, id) + if bond.Owner != ownerAddress.String() { + return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.") + } + + updatedBalance, isNeg := bond.Balance.SafeSub(coins) + if isNeg { + return nil, sdkerrors.Wrap(sdkerrors.ErrInsufficientFunds, "Insufficient bond balance.") + } + + // Move funds from the bond into the account. + err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, ownerAddress, coins) + if err != nil { + return nil, err + } + + // Update bond balance and save. + bond.Balance = updatedBalance + k.SaveBond(ctx, &bond) + + return &bond, nil +} + +// CancelBond cancels a bond, returning funds to the owner. +func (k Keeper) CancelBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddress) (*types.Bond, error) { + if !k.HasBond(ctx, id) { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.") + } + + bond := k.GetBond(ctx, id) + if bond.Owner != ownerAddress.String() { + return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.") + } + + // todo: continue this once nameservice is implemented + // Check if bond is used in other modules. + //for _, usageKeeper := range k.usageKeepers { + // if usageKeeper.UsesBond(ctx, id) { + // return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, fmt.Sprintf("Bond in use by the '%s' module.", usageKeeper.ModuleName())) + // } + //} + + // Move funds from the bond into the account. + err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, ownerAddress, bond.Balance) + if err != nil { + return nil, err + } + + k.DeleteBond(ctx, bond) + + return &bond, nil +} + +func (k Keeper) getMaxBondAmount(ctx sdk.Context) (sdk.Coins, error) { + params := k.GetParams(ctx) + maxBondAmount := params.MaxBondAmount + return sdk.NewCoins(maxBondAmount), nil +} + +// GetBondModuleBalances gets the bond module account(s) balances. +func (k Keeper) GetBondModuleBalances(ctx sdk.Context) sdk.Coins { + moduleAddress := k.accountKeeper.GetModuleAddress(types.ModuleName) + balances := k.bankKeeper.GetAllBalances(ctx, moduleAddress) + return balances +} diff --git a/x/bond/keeper/msg_server.go b/x/bond/keeper/msg_server.go new file mode 100644 index 00000000..f34a60b8 --- /dev/null +++ b/x/bond/keeper/msg_server.go @@ -0,0 +1,130 @@ +package keeper + +import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tharsis/ethermint/x/bond/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the bond MsgServer interface for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} + +func (k msgServer) CreateBond(c context.Context, msg *types.MsgCreateBond) (*types.MsgCreateBondResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return nil, err + } + _, err = k.Keeper.CreateBond(ctx, signerAddress, msg.Coins) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeCreateBond, + sdk.NewAttribute(types.AttributeKeySigner, msg.Signer), + sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Coins.String()), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(types.AttributeKeySigner, msg.Signer), + ), + }) + + return &types.MsgCreateBondResponse{}, nil +} + +func (k msgServer) RefillBond(c context.Context, msg *types.MsgRefillBond) (*types.MsgRefillBondResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return nil, err + } + + _, err = k.Keeper.RefillBond(ctx, msg.Id, signerAddress, msg.Coins) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeRefillBond, + sdk.NewAttribute(types.AttributeKeySigner, msg.Signer), + sdk.NewAttribute(types.AttributeKeyBondId, msg.Id), + sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Coins.String()), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(types.AttributeKeySigner, msg.Signer), + ), + }) + + return &types.MsgRefillBondResponse{}, nil +} + +func (k msgServer) WithdrawBond(c context.Context, msg *types.MsgWithdrawBond) (*types.MsgWithdrawBondResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return nil, err + } + + _, err = k.Keeper.WithdrawBond(ctx, msg.Id, signerAddress, msg.Coins) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeWithdrawBond, + sdk.NewAttribute(types.AttributeKeySigner, msg.Signer), + sdk.NewAttribute(types.AttributeKeyBondId, msg.Id), + sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Coins.String()), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(types.AttributeKeySigner, msg.Signer), + ), + }) + + return &types.MsgWithdrawBondResponse{}, nil +} + +func (k msgServer) CancelBond(c context.Context, msg *types.MsgCancelBond) (*types.MsgCancelBondResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return nil, err + } + _, err = k.Keeper.CancelBond(ctx, msg.Id, signerAddress) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeCancelBond, + sdk.NewAttribute(types.AttributeKeySigner, msg.Signer), + sdk.NewAttribute(types.AttributeKeyBondId, msg.Id), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(types.AttributeKeySigner, msg.Signer), + ), + }) + + return &types.MsgCancelBondResponse{}, nil +} diff --git a/x/bond/keeper/params.go b/x/bond/keeper/params.go new file mode 100644 index 00000000..3942a2ac --- /dev/null +++ b/x/bond/keeper/params.go @@ -0,0 +1,23 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tharsis/ethermint/x/bond/types" +) + +// GetMaxBondAmount max bond amount +func (k Keeper) GetMaxBondAmount(ctx sdk.Context) (res sdk.Coin) { + k.paramSubspace.Get(ctx, types.ParamStoreKeyMaxBondAmount, &res) + return +} + +// GetParams - Get all parameter as as types.Params. +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + getMaxBondAmount := k.GetMaxBondAmount(ctx) + return types.Params{MaxBondAmount: getMaxBondAmount} +} + +// SetParams - set the params. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramSubspace.SetParamSet(ctx, ¶ms) +} diff --git a/x/bond/module.go b/x/bond/module.go new file mode 100644 index 00000000..eb9f0103 --- /dev/null +++ b/x/bond/module.go @@ -0,0 +1,135 @@ +package bond + +import ( + "context" + "encoding/json" + "fmt" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + abci "github.com/tendermint/tendermint/abci/types" + "github.com/tharsis/ethermint/x/bond/client/cli" + "github.com/tharsis/ethermint/x/bond/keeper" + "github.com/tharsis/ethermint/x/bond/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// AppModuleBasic defines the basic application module used by the staking module. +type AppModuleBasic struct { + cdc codec.Codec +} + +func (b AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(amino) +} + +func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + +func (b AppModuleBasic) DefaultGenesis(jsonCodec codec.JSONCodec) json.RawMessage { + return jsonCodec.MustMarshalJSON(types.DefaultGenesisState()) +} + +func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, message json.RawMessage) error { + var data types.GenesisState + if err := cdc.UnmarshalJSON(message, &data); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return ValidateGenesis(data) +} + +func (b AppModuleBasic) RegisterRESTRoutes(context client.Context, router *mux.Router) { +} + +func (b AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, serveMux *runtime.ServeMux) { + err := types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(clientCtx)) + if err != nil { + panic(err) + } +} + +func (b AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.NewTxCmd() +} + +func (b AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// Name returns the staking module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +type AppModule struct { + AppModuleBasic + keeper keeper.Keeper +} + +// NewAppModule creates a new AppModule Object +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{cdc: cdc}, + keeper: keeper, + } +} + +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, message json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + + cdc.MustUnmarshalJSON(message, &genesisState) + + return InitGenesis(ctx, am.keeper, genesisState) +} + +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(&gs) +} + +func (am AppModule) RegisterInvariants(registry sdk.InvariantRegistry) { + keeper.RegisterInvariants(registry, am.keeper) +} + +func (am AppModule) Route() sdk.Route { + return sdk.Route{} +} + +func (am AppModule) QuerierRoute() string { + return types.QuerierRoute +} + +func (am AppModule) LegacyQuerierHandler(amino *codec.LegacyAmino) sdk.Querier { + return nil +} + +func (am AppModule) RegisterServices(cfg module.Configurator) { + querier := keeper.Querier{Keeper: am.keeper} + types.RegisterQueryServer(cfg.QueryServer(), querier) + + msgServer := keeper.NewMsgServerImpl(am.keeper) + types.RegisterMsgServer(cfg.MsgServer(), msgServer) +} + +func (am AppModule) ConsensusVersion() uint64 { + return 1 +} + +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { + BeginBlocker(ctx, am.keeper) +} + +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return EndBlocker(ctx, am.keeper) +} diff --git a/x/bond/types/bond.pb.go b/x/bond/types/bond.pb.go new file mode 100644 index 00000000..28a22501 --- /dev/null +++ b/x/bond/types/bond.pb.go @@ -0,0 +1,620 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: vulcanize/bond/v1beta1/bond.proto + +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/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/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 + +// Params defines the bond module parameters +type Params struct { + // max_bond_amount is maximum amount to bond + MaxBondAmount types.Coin `protobuf:"bytes,1,opt,name=max_bond_amount,json=maxBondAmount,proto3" json:"max_bond_amount" json:"max_bond_amount" yaml:"max_bond_amount"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_ff3ef02fadb61511, []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) GetMaxBondAmount() types.Coin { + if m != nil { + return m.MaxBondAmount + } + return types.Coin{} +} + +// Bond represents funds deposited by an account for record rent payments. +type Bond struct { + // id is unique identifier of the bond + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // owner of the bond + Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` + // balance of the bond + Balance github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=balance,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"balance" json:"balance" yaml:"balance"` +} + +func (m *Bond) Reset() { *m = Bond{} } +func (m *Bond) String() string { return proto.CompactTextString(m) } +func (*Bond) ProtoMessage() {} +func (*Bond) Descriptor() ([]byte, []int) { + return fileDescriptor_ff3ef02fadb61511, []int{1} +} +func (m *Bond) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Bond) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Bond.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 *Bond) XXX_Merge(src proto.Message) { + xxx_messageInfo_Bond.Merge(m, src) +} +func (m *Bond) XXX_Size() int { + return m.Size() +} +func (m *Bond) XXX_DiscardUnknown() { + xxx_messageInfo_Bond.DiscardUnknown(m) +} + +var xxx_messageInfo_Bond proto.InternalMessageInfo + +func (m *Bond) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *Bond) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *Bond) GetBalance() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Balance + } + return nil +} + +func init() { + proto.RegisterType((*Params)(nil), "vulcanize.bond.v1beta1.Params") + proto.RegisterType((*Bond)(nil), "vulcanize.bond.v1beta1.Bond") +} + +func init() { proto.RegisterFile("vulcanize/bond/v1beta1/bond.proto", fileDescriptor_ff3ef02fadb61511) } + +var fileDescriptor_ff3ef02fadb61511 = []byte{ + // 344 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xc1, 0x4e, 0x32, 0x31, + 0x14, 0x85, 0xa7, 0xf0, 0xff, 0x18, 0xc7, 0xa8, 0xc9, 0x84, 0x18, 0x24, 0xb1, 0x20, 0x2b, 0x5c, + 0x30, 0x0d, 0x1a, 0x37, 0xee, 0x84, 0x17, 0x50, 0x96, 0x6e, 0x48, 0x67, 0xa6, 0x81, 0x2a, 0xed, + 0x25, 0xd3, 0x82, 0x83, 0x4b, 0x17, 0xae, 0x7d, 0x0e, 0xf7, 0xbe, 0x03, 0x4b, 0x96, 0xae, 0xd0, + 0xc0, 0x1b, 0xf8, 0x04, 0x66, 0xda, 0x19, 0x62, 0x34, 0x71, 0xd5, 0x9e, 0xdb, 0x73, 0xbf, 0x7b, + 0xd2, 0xeb, 0x1e, 0x4f, 0x27, 0xa3, 0x90, 0x4a, 0xfe, 0xc0, 0x48, 0x00, 0x32, 0x22, 0xd3, 0x76, + 0xc0, 0x34, 0x6d, 0x1b, 0xe1, 0x8f, 0x63, 0xd0, 0xe0, 0x1d, 0x6c, 0x2c, 0xbe, 0xa9, 0x66, 0x96, + 0x6a, 0x79, 0x00, 0x03, 0x30, 0x16, 0x92, 0xde, 0xac, 0xbb, 0x8a, 0x43, 0x50, 0x02, 0x14, 0x09, + 0xa8, 0x62, 0x1b, 0x5a, 0x08, 0x5c, 0xda, 0xf7, 0xc6, 0x23, 0x72, 0x4b, 0x57, 0x34, 0xa6, 0x42, + 0x79, 0x89, 0xbb, 0x2f, 0x68, 0xd2, 0x4f, 0xa1, 0x7d, 0x2a, 0x60, 0x22, 0x75, 0x05, 0xd5, 0x51, + 0x73, 0xe7, 0xf4, 0xd0, 0xb7, 0x10, 0x3f, 0x85, 0xe4, 0xf3, 0xfc, 0x2e, 0x70, 0xd9, 0x39, 0x9f, + 0x2f, 0x6b, 0xce, 0xe7, 0xb2, 0xd6, 0xba, 0x55, 0x20, 0x2f, 0x1a, 0x3f, 0xfa, 0x1b, 0xf5, 0x19, + 0x15, 0xa3, 0xdf, 0xe5, 0xde, 0xae, 0xa0, 0x49, 0x07, 0x64, 0x74, 0x69, 0xf5, 0x2b, 0x72, 0xff, + 0xa5, 0xd2, 0xdb, 0x73, 0x0b, 0x3c, 0x32, 0x53, 0xb7, 0x7b, 0x05, 0x1e, 0x79, 0x65, 0xf7, 0x3f, + 0xdc, 0x4b, 0x16, 0x57, 0x0a, 0xa6, 0x64, 0x85, 0xf7, 0x84, 0xdc, 0xad, 0x80, 0x8e, 0xa8, 0x0c, + 0x59, 0xa5, 0x58, 0x2f, 0xfe, 0x9d, 0xf0, 0x3a, 0x4b, 0x78, 0x64, 0x13, 0x66, 0x7d, 0x79, 0xb2, + 0x5c, 0xbe, 0xbc, 0xd7, 0x9a, 0x03, 0xae, 0x87, 0x93, 0xc0, 0x0f, 0x41, 0x90, 0xec, 0xd3, 0xec, + 0xd1, 0x52, 0xd1, 0x1d, 0xd1, 0xb3, 0x31, 0x53, 0x86, 0xa8, 0x7a, 0xf9, 0xf0, 0x4e, 0x77, 0xbe, + 0xc2, 0x68, 0xb1, 0xc2, 0xe8, 0x63, 0x85, 0xd1, 0xf3, 0x1a, 0x3b, 0x8b, 0x35, 0x76, 0xde, 0xd6, + 0xd8, 0xb9, 0x39, 0xf9, 0x06, 0xd3, 0x43, 0x1a, 0x2b, 0xae, 0x08, 0xd3, 0x43, 0x16, 0x0b, 0x2e, + 0x35, 0x49, 0xec, 0x72, 0x0d, 0x33, 0x28, 0x99, 0x45, 0x9c, 0x7d, 0x05, 0x00, 0x00, 0xff, 0xff, + 0x45, 0xf7, 0x5e, 0x13, 0xfb, 0x01, 0x00, 0x00, +} + +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 + { + size, err := m.MaxBondAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBond(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Bond) 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 *Bond) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Bond) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Balance) > 0 { + for iNdEx := len(m.Balance) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Balance[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBond(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintBond(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintBond(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintBond(dAtA []byte, offset int, v uint64) int { + offset -= sovBond(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 + l = m.MaxBondAmount.Size() + n += 1 + l + sovBond(uint64(l)) + return n +} + +func (m *Bond) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovBond(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovBond(uint64(l)) + } + if len(m.Balance) > 0 { + for _, e := range m.Balance { + l = e.Size() + n += 1 + l + sovBond(uint64(l)) + } + } + return n +} + +func sovBond(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozBond(x uint64) (n int) { + return sovBond(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 ErrIntOverflowBond + } + 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 != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxBondAmount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBond + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBond + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBond + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MaxBondAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipBond(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBond + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Bond) 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 ErrIntOverflowBond + } + 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: Bond: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Bond: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBond + } + 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 ErrInvalidLengthBond + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBond + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBond + } + 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 ErrInvalidLengthBond + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBond + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBond + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBond + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBond + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Balance = append(m.Balance, types.Coin{}) + if err := m.Balance[len(m.Balance)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipBond(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBond + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipBond(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, ErrIntOverflowBond + } + 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, ErrIntOverflowBond + } + 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, ErrIntOverflowBond + } + 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, ErrInvalidLengthBond + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupBond + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthBond + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthBond = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowBond = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupBond = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/bond/types/codec.go b/x/bond/types/codec.go new file mode 100644 index 00000000..90017b79 --- /dev/null +++ b/x/bond/types/codec.go @@ -0,0 +1,39 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "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" +) + +// RegisterLegacyAminoCodec registers the necessary x/bond interfaces and concrete types +// on the provided LegacyAmino codec. These types are used for Amino JSON serialization. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgCreateBond{}, "bond/MsgCreateBond", nil) + cdc.RegisterConcrete(&MsgRefillBond{}, "bond/MsgRefillBond", nil) + cdc.RegisterConcrete(&MsgWithdrawBond{}, "bond/MsgWithdrawBond", nil) + cdc.RegisterConcrete(&MsgCancelBond{}, "bond/MsgCancelBond", nil) +} + +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgCreateBond{}, + &MsgRefillBond{}, + &MsgCancelBond{}, + &MsgWithdrawBond{}, + ) + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + amino.Seal() +} diff --git a/x/bond/types/events.go b/x/bond/types/events.go new file mode 100644 index 00000000..11a7fd42 --- /dev/null +++ b/x/bond/types/events.go @@ -0,0 +1,15 @@ +package types + +// bond module event types + +const ( + EventTypeCreateBond = "crate_bond" + EventTypeRefillBond = "refill_bond" + EventTypeCancelBond = "cancel_bond" + EventTypeWithdrawBond = "withdraw_bond" + + AttributeKeySigner = "signer" + AttributeKeyAmount = "amount" + AttributeKeyBondId = "bond_id" + AttributeValueCategory = ModuleName +) diff --git a/x/bond/types/genesis.go b/x/bond/types/genesis.go new file mode 100644 index 00000000..04a185f5 --- /dev/null +++ b/x/bond/types/genesis.go @@ -0,0 +1,9 @@ +package types + +// DefaultGenesisState sets default evm genesis state with empty accounts and default params and +// chain config values. +func DefaultGenesisState() *GenesisState { + return &GenesisState{ + Params: DefaultParams(), + } +} diff --git a/x/bond/types/genesis.pb.go b/x/bond/types/genesis.pb.go new file mode 100644 index 00000000..eea1c623 --- /dev/null +++ b/x/bond/types/genesis.pb.go @@ -0,0 +1,391 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: vulcanize/bond/v1beta1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/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 + +// GenesisState defines the bond module's genesis state. +type GenesisState struct { + // params defines all the parameters of the module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + // bonds defines all the bonds + Bonds []*Bond `protobuf:"bytes,2,rep,name=bonds,proto3" json:"bonds,omitempty" json:"bonds" yaml:"bonds"` +} + +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_f9582eb9edb1dcdf, []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) GetBonds() []*Bond { + if m != nil { + return m.Bonds + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "vulcanize.bond.v1beta1.GenesisState") +} + +func init() { + proto.RegisterFile("vulcanize/bond/v1beta1/genesis.proto", fileDescriptor_f9582eb9edb1dcdf) +} + +var fileDescriptor_f9582eb9edb1dcdf = []byte{ + // 259 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x29, 0x2b, 0xcd, 0x49, + 0x4e, 0xcc, 0xcb, 0xac, 0x4a, 0xd5, 0x4f, 0xca, 0xcf, 0x4b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, + 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, + 0x17, 0x12, 0x83, 0xab, 0xd2, 0x03, 0xa9, 0xd2, 0x83, 0xaa, 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, + 0x07, 0x2b, 0xd1, 0x07, 0xb1, 0x20, 0xaa, 0xa5, 0x14, 0x71, 0x98, 0x09, 0xd6, 0x0a, 0x56, 0xa2, + 0x34, 0x9f, 0x91, 0x8b, 0xc7, 0x1d, 0x62, 0x45, 0x70, 0x49, 0x62, 0x49, 0xaa, 0x90, 0x0d, 0x17, + 0x5b, 0x41, 0x62, 0x51, 0x62, 0x6e, 0xb1, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0x9c, 0x1e, + 0x76, 0x2b, 0xf5, 0x02, 0xc0, 0xaa, 0x9c, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0x82, 0xea, 0x11, + 0x0a, 0xe4, 0x62, 0x05, 0x29, 0x2a, 0x96, 0x60, 0x52, 0x60, 0xd6, 0xe0, 0x36, 0x92, 0xc1, 0xa5, + 0xd9, 0x29, 0x3f, 0x2f, 0xc5, 0x49, 0xf6, 0xd3, 0x3d, 0x79, 0xc9, 0xac, 0xe2, 0xfc, 0x3c, 0x2b, + 0x25, 0xb0, 0x26, 0x25, 0x85, 0xca, 0xc4, 0xdc, 0x1c, 0x18, 0x27, 0x08, 0x62, 0x92, 0x93, 0xf3, + 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, + 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x69, 0xa6, 0x67, 0x96, 0x64, 0x94, + 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x97, 0x64, 0x24, 0x16, 0x15, 0x67, 0x16, 0xeb, 0xa7, 0x96, + 0x64, 0xa4, 0x16, 0xe5, 0x66, 0xe6, 0x95, 0xe8, 0x57, 0x40, 0xfc, 0x5c, 0x52, 0x59, 0x90, 0x5a, + 0x9c, 0xc4, 0x06, 0xf6, 0xad, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xe9, 0x23, 0x03, 0x66, + 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.Bonds) > 0 { + for iNdEx := len(m.Bonds) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Bonds[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + 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)) + if len(m.Bonds) > 0 { + for _, e := range m.Bonds { + l = e.Size() + n += 1 + l + sovGenesis(uint64(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 Bonds", 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.Bonds = append(m.Bonds, &Bond{}) + if err := m.Bonds[len(m.Bonds)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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/bond/types/keys.go b/x/bond/types/keys.go new file mode 100644 index 00000000..6c5ac625 --- /dev/null +++ b/x/bond/types/keys.go @@ -0,0 +1,15 @@ +package types + +const ( + // ModuleName is the name of the staking module + ModuleName = "bond" + + // StoreKey is the string store representation + StoreKey = ModuleName + + // QuerierRoute is the querier route for the staking module + QuerierRoute = ModuleName + + // RouterKey is the msg router key for the staking module + RouterKey = ModuleName +) diff --git a/x/bond/types/msg.go b/x/bond/types/msg.go new file mode 100644 index 00000000..84d5ec73 --- /dev/null +++ b/x/bond/types/msg.go @@ -0,0 +1,143 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var ( + _ sdk.Msg = &MsgCreateBond{} + _ sdk.Msg = &MsgRefillBond{} + _ sdk.Msg = &MsgWithdrawBond{} + _ sdk.Msg = &MsgCancelBond{} +) + +// NewMsgCreateBond is the constructor function for MsgCreateBond. +func NewMsgCreateBond(coins sdk.Coins, signer sdk.AccAddress) MsgCreateBond { + return MsgCreateBond{ + Coins: coins, + Signer: signer.String(), + } +} + +// Route Implements Msg. +func (msg MsgCreateBond) Route() string { return RouterKey } + +// Type Implements Msg. +func (msg MsgCreateBond) Type() string { return "create" } + +func (msg MsgCreateBond) ValidateBasic() error { + if len(msg.Signer) == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer) + } + if len(msg.Coins) == 0 || !msg.Coins.IsValid() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "Invalid amount.") + } + return nil +} + +func (msg MsgCreateBond) GetSigners() []sdk.AccAddress { + accAddr, _ := sdk.AccAddressFromBech32(msg.Signer) + return []sdk.AccAddress{accAddr} +} + +// GetSignBytes gets the sign bytes for the msg MsgCreateBond +func (msg MsgCreateBond) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} + +// NewMsgRefillBond is the constructor function for MsgRefillBond. +func NewMsgRefillBond(id string, amount sdk.Coin, signer sdk.AccAddress) MsgRefillBond { + return MsgRefillBond{ + Id: id, + Coins: sdk.NewCoins(amount), + Signer: signer.String(), + } +} + +func (msg MsgRefillBond) ValidateBasic() error { + if len(msg.Id) == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, msg.Id) + } + if len(msg.Signer) == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer) + } + if len(msg.Coins) == 0 || !msg.Coins.IsValid() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "Invalid amount.") + } + return nil +} + +func (msg MsgRefillBond) GetSigners() []sdk.AccAddress { + accAddr, _ := sdk.AccAddressFromBech32(msg.Signer) + return []sdk.AccAddress{accAddr} +} + +// GetSignBytes gets the sign bytes for the msg MsgCreateBond +func (msg MsgRefillBond) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} + +// NewMsgWithdrawBond is the constructor function for NewMsgWithdrawBond. +func NewMsgWithdrawBond(id string, amount sdk.Coin, signer sdk.AccAddress) MsgWithdrawBond { + return MsgWithdrawBond{ + Id: id, + Coins: sdk.NewCoins(amount), + Signer: signer.String(), + } +} + +func (msg MsgWithdrawBond) ValidateBasic() error { + if len(msg.Id) == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, msg.Id) + } + if len(msg.Signer) == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer) + } + if len(msg.Coins) == 0 || !msg.Coins.IsValid() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "Invalid amount.") + } + return nil +} + +func (msg MsgWithdrawBond) GetSigners() []sdk.AccAddress { + accAddr, _ := sdk.AccAddressFromBech32(msg.Signer) + return []sdk.AccAddress{accAddr} +} + +// GetSignBytes gets the sign bytes for the msg MsgCreateBond +func (msg MsgWithdrawBond) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} + +// NewMsgCancelBond is the constructor function for CalcelBond. +func NewMsgCancelBond(id string, signer sdk.AccAddress) MsgCancelBond { + return MsgCancelBond{ + Id: id, + Signer: signer.String(), + } +} + +func (msg MsgCancelBond) ValidateBasic() error { + if len(msg.Id) == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, msg.Id) + } + if len(msg.Signer) == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer) + } + return nil +} + +func (msg MsgCancelBond) GetSigners() []sdk.AccAddress { + accAddr, _ := sdk.AccAddressFromBech32(msg.Signer) + return []sdk.AccAddress{accAddr} +} + +// GetSignBytes gets the sign bytes for the msg MsgCreateBond +func (msg MsgCancelBond) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} diff --git a/x/bond/types/params.go b/x/bond/types/params.go new file mode 100644 index 00000000..587f8c6f --- /dev/null +++ b/x/bond/types/params.go @@ -0,0 +1,64 @@ +package types + +import ( + "errors" + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +var _ paramtypes.ParamSet = &Params{} + +// Default parameter values. +var ( + DefaultMaxBondAmountTokens = sdk.NewInt(100000000000) +) + +// Parameter keys +var ( + ParamStoreKeyMaxBondAmount = []byte("MaxBondAmount") +) + +// ParamKeyTable ParamTable for staking module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +func NewParams(maxBondAmount sdk.Coin) Params { + return Params{MaxBondAmount: maxBondAmount} +} + +// DefaultParams returns default evm parameters +// ExtraEIPs is empty to prevent overriding the latest hard fork instruction set +func DefaultParams() Params { + return NewParams(sdk.NewCoin(sdk.DefaultBondDenom, DefaultMaxBondAmountTokens)) +} + +// ParamSetPairs returns the parameter set pairs. +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(ParamStoreKeyMaxBondAmount, &p.MaxBondAmount, validateMaxBondAmount), + } +} + +func validateMaxBondAmount(i interface{}) error { + v, ok := i.(sdk.Coin) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.Amount.IsNegative() { + return errors.New("max bond amount must be positive") + } + + return nil +} + +// Validate checks that the parameters have valid values. +func (p Params) Validate() error { + if err := validateMaxBondAmount(p.MaxBondAmount); err != nil { + return err + } + + return nil +} diff --git a/x/bond/types/query.pb.go b/x/bond/types/query.pb.go new file mode 100644 index 00000000..80c7e0ec --- /dev/null +++ b/x/bond/types/query.pb.go @@ -0,0 +1,2280 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: vulcanize/bond/v1beta1/query.proto + +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" + query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "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 + +// QueryParamRequest is request for query the bond module params +type QueryParamRequest struct { +} + +func (m *QueryParamRequest) Reset() { *m = QueryParamRequest{} } +func (m *QueryParamRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamRequest) ProtoMessage() {} +func (*QueryParamRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2f225717b20da431, []int{0} +} +func (m *QueryParamRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamRequest.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 *QueryParamRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamRequest.Merge(m, src) +} +func (m *QueryParamRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamRequest proto.InternalMessageInfo + +// QueryParamsResponse returns response type of bond module params +type QueryParamsResponse struct { + Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty" json:"params" yaml:"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_2f225717b20da431, []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 nil +} + +// QueryGetBonds +type QueryGetBondsRequest struct { + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryGetBondsRequest) Reset() { *m = QueryGetBondsRequest{} } +func (m *QueryGetBondsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetBondsRequest) ProtoMessage() {} +func (*QueryGetBondsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2f225717b20da431, []int{2} +} +func (m *QueryGetBondsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetBondsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetBondsRequest.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 *QueryGetBondsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetBondsRequest.Merge(m, src) +} +func (m *QueryGetBondsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetBondsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetBondsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetBondsRequest proto.InternalMessageInfo + +func (m *QueryGetBondsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryGetBondsResponse +type QueryGetBondsResponse struct { + Bonds []*Bond `protobuf:"bytes,1,rep,name=bonds,proto3" json:"bonds,omitempty" json:"bonds" yaml:"bonds"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryGetBondsResponse) Reset() { *m = QueryGetBondsResponse{} } +func (m *QueryGetBondsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetBondsResponse) ProtoMessage() {} +func (*QueryGetBondsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2f225717b20da431, []int{3} +} +func (m *QueryGetBondsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetBondsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetBondsResponse.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 *QueryGetBondsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetBondsResponse.Merge(m, src) +} +func (m *QueryGetBondsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetBondsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetBondsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetBondsResponse proto.InternalMessageInfo + +func (m *QueryGetBondsResponse) GetBonds() []*Bond { + if m != nil { + return m.Bonds + } + return nil +} + +func (m *QueryGetBondsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryGetBondById +type QueryGetBondByIdRequest struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" json:"id" yaml:"id"` +} + +func (m *QueryGetBondByIdRequest) Reset() { *m = QueryGetBondByIdRequest{} } +func (m *QueryGetBondByIdRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetBondByIdRequest) ProtoMessage() {} +func (*QueryGetBondByIdRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2f225717b20da431, []int{4} +} +func (m *QueryGetBondByIdRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetBondByIdRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetBondByIdRequest.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 *QueryGetBondByIdRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetBondByIdRequest.Merge(m, src) +} +func (m *QueryGetBondByIdRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetBondByIdRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetBondByIdRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetBondByIdRequest proto.InternalMessageInfo + +func (m *QueryGetBondByIdRequest) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +// QueryGetBondByIdResponse returns QueryGetBondById query response +type QueryGetBondByIdResponse struct { + Bond *Bond `protobuf:"bytes,1,opt,name=bond,proto3" json:"bond,omitempty" json:"bond" yaml:"bond"` +} + +func (m *QueryGetBondByIdResponse) Reset() { *m = QueryGetBondByIdResponse{} } +func (m *QueryGetBondByIdResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetBondByIdResponse) ProtoMessage() {} +func (*QueryGetBondByIdResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2f225717b20da431, []int{5} +} +func (m *QueryGetBondByIdResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetBondByIdResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetBondByIdResponse.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 *QueryGetBondByIdResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetBondByIdResponse.Merge(m, src) +} +func (m *QueryGetBondByIdResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetBondByIdResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetBondByIdResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetBondByIdResponse proto.InternalMessageInfo + +func (m *QueryGetBondByIdResponse) GetBond() *Bond { + if m != nil { + return m.Bond + } + return nil +} + +// QueryGetBondsByOwnerRequest is request tyep for Query/GetBondsByOwner RPC Method +type QueryGetBondsByOwnerRequest struct { + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryGetBondsByOwnerRequest) Reset() { *m = QueryGetBondsByOwnerRequest{} } +func (m *QueryGetBondsByOwnerRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetBondsByOwnerRequest) ProtoMessage() {} +func (*QueryGetBondsByOwnerRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2f225717b20da431, []int{6} +} +func (m *QueryGetBondsByOwnerRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetBondsByOwnerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetBondsByOwnerRequest.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 *QueryGetBondsByOwnerRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetBondsByOwnerRequest.Merge(m, src) +} +func (m *QueryGetBondsByOwnerRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetBondsByOwnerRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetBondsByOwnerRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetBondsByOwnerRequest proto.InternalMessageInfo + +func (m *QueryGetBondsByOwnerRequest) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *QueryGetBondsByOwnerRequest) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryGetBondsByOwnerResponse is response type for Query/GetBondsByOwner RPC Method +type QueryGetBondsByOwnerResponse struct { + Bonds []Bond `protobuf:"bytes,1,rep,name=bonds,proto3" json:"bonds" json:"bonds" yaml:"bonds"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryGetBondsByOwnerResponse) Reset() { *m = QueryGetBondsByOwnerResponse{} } +func (m *QueryGetBondsByOwnerResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetBondsByOwnerResponse) ProtoMessage() {} +func (*QueryGetBondsByOwnerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2f225717b20da431, []int{7} +} +func (m *QueryGetBondsByOwnerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetBondsByOwnerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetBondsByOwnerResponse.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 *QueryGetBondsByOwnerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetBondsByOwnerResponse.Merge(m, src) +} +func (m *QueryGetBondsByOwnerResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetBondsByOwnerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetBondsByOwnerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetBondsByOwnerResponse proto.InternalMessageInfo + +func (m *QueryGetBondsByOwnerResponse) GetBonds() []Bond { + if m != nil { + return m.Bonds + } + return nil +} + +func (m *QueryGetBondsByOwnerResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryGetBondModuleBalanceRequest is request type for bond module balance rpc method +type QueryGetBondModuleBalanceRequest struct { +} + +func (m *QueryGetBondModuleBalanceRequest) Reset() { *m = QueryGetBondModuleBalanceRequest{} } +func (m *QueryGetBondModuleBalanceRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetBondModuleBalanceRequest) ProtoMessage() {} +func (*QueryGetBondModuleBalanceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2f225717b20da431, []int{8} +} +func (m *QueryGetBondModuleBalanceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetBondModuleBalanceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetBondModuleBalanceRequest.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 *QueryGetBondModuleBalanceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetBondModuleBalanceRequest.Merge(m, src) +} +func (m *QueryGetBondModuleBalanceRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetBondModuleBalanceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetBondModuleBalanceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetBondModuleBalanceRequest proto.InternalMessageInfo + +// QueryGetBondModuleBalanceResponse is response type for bond module balance rpc method +type QueryGetBondModuleBalanceResponse struct { + Balance github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=balance,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"balance" json:"coins" yaml:"coins"` +} + +func (m *QueryGetBondModuleBalanceResponse) Reset() { *m = QueryGetBondModuleBalanceResponse{} } +func (m *QueryGetBondModuleBalanceResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetBondModuleBalanceResponse) ProtoMessage() {} +func (*QueryGetBondModuleBalanceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2f225717b20da431, []int{9} +} +func (m *QueryGetBondModuleBalanceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetBondModuleBalanceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetBondModuleBalanceResponse.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 *QueryGetBondModuleBalanceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetBondModuleBalanceResponse.Merge(m, src) +} +func (m *QueryGetBondModuleBalanceResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetBondModuleBalanceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetBondModuleBalanceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetBondModuleBalanceResponse proto.InternalMessageInfo + +func (m *QueryGetBondModuleBalanceResponse) GetBalance() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Balance + } + return nil +} + +func init() { + proto.RegisterType((*QueryParamRequest)(nil), "vulcanize.bond.v1beta1.QueryParamRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "vulcanize.bond.v1beta1.QueryParamsResponse") + proto.RegisterType((*QueryGetBondsRequest)(nil), "vulcanize.bond.v1beta1.QueryGetBondsRequest") + proto.RegisterType((*QueryGetBondsResponse)(nil), "vulcanize.bond.v1beta1.QueryGetBondsResponse") + proto.RegisterType((*QueryGetBondByIdRequest)(nil), "vulcanize.bond.v1beta1.QueryGetBondByIdRequest") + proto.RegisterType((*QueryGetBondByIdResponse)(nil), "vulcanize.bond.v1beta1.QueryGetBondByIdResponse") + proto.RegisterType((*QueryGetBondsByOwnerRequest)(nil), "vulcanize.bond.v1beta1.QueryGetBondsByOwnerRequest") + proto.RegisterType((*QueryGetBondsByOwnerResponse)(nil), "vulcanize.bond.v1beta1.QueryGetBondsByOwnerResponse") + proto.RegisterType((*QueryGetBondModuleBalanceRequest)(nil), "vulcanize.bond.v1beta1.QueryGetBondModuleBalanceRequest") + proto.RegisterType((*QueryGetBondModuleBalanceResponse)(nil), "vulcanize.bond.v1beta1.QueryGetBondModuleBalanceResponse") +} + +func init() { + proto.RegisterFile("vulcanize/bond/v1beta1/query.proto", fileDescriptor_2f225717b20da431) +} + +var fileDescriptor_2f225717b20da431 = []byte{ + // 766 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x95, 0xcf, 0x6e, 0xd3, 0x4a, + 0x14, 0xc6, 0xe3, 0xdc, 0x9b, 0x5c, 0xdd, 0xe9, 0xe2, 0xea, 0x4e, 0x5b, 0x9a, 0x3a, 0xa9, 0x9d, + 0x0c, 0x82, 0xb6, 0x40, 0x6d, 0xda, 0xb2, 0x00, 0x96, 0xae, 0x44, 0xc5, 0xa2, 0x82, 0x5a, 0x42, + 0x48, 0x2c, 0xa8, 0x9c, 0x78, 0x94, 0x0e, 0x24, 0x33, 0x69, 0xc6, 0x29, 0x84, 0x3f, 0x9b, 0x22, + 0xb1, 0x43, 0x42, 0x62, 0xc1, 0x23, 0x80, 0x58, 0x21, 0xb1, 0x67, 0xdd, 0x65, 0x25, 0x36, 0xac, + 0x02, 0x6a, 0x79, 0x82, 0x3c, 0x01, 0xf2, 0xcc, 0x38, 0xb1, 0xdb, 0xa4, 0x4d, 0x11, 0x62, 0xd5, + 0x8e, 0xfd, 0x9d, 0x73, 0x7e, 0xdf, 0xf1, 0x9c, 0x13, 0x80, 0xb6, 0x5b, 0xb5, 0x8a, 0x47, 0xc9, + 0x13, 0x6c, 0x97, 0x19, 0xf5, 0xed, 0xed, 0xc5, 0x32, 0x0e, 0xbc, 0x45, 0x7b, 0xab, 0x85, 0x9b, + 0x6d, 0xab, 0xd1, 0x64, 0x01, 0x83, 0x67, 0x7a, 0x1a, 0x2b, 0xd4, 0x58, 0x4a, 0xa3, 0x4f, 0x54, + 0x59, 0x95, 0x09, 0x89, 0x1d, 0xfe, 0x27, 0xd5, 0x7a, 0x69, 0x48, 0x46, 0x11, 0x2a, 0x25, 0x85, + 0x2a, 0x63, 0xd5, 0x1a, 0xb6, 0xbd, 0x06, 0xb1, 0x3d, 0x4a, 0x59, 0xe0, 0x05, 0x84, 0x51, 0xae, + 0xde, 0x5e, 0xa8, 0x30, 0x5e, 0x67, 0xdc, 0x2e, 0x7b, 0x1c, 0x4b, 0x8e, 0x5e, 0x8e, 0x86, 0x57, + 0x25, 0x54, 0x88, 0x95, 0xd6, 0x88, 0x6b, 0x23, 0x55, 0x85, 0x11, 0xf5, 0x1e, 0x8d, 0x83, 0xff, + 0xd7, 0xc3, 0x0c, 0xb7, 0xbd, 0xa6, 0x57, 0x77, 0xf1, 0x56, 0x0b, 0xf3, 0x00, 0x51, 0x30, 0xde, + 0x7f, 0xc8, 0x5d, 0xcc, 0x1b, 0x8c, 0x72, 0x0c, 0xef, 0x82, 0x6c, 0x43, 0x3c, 0xc9, 0x69, 0x45, + 0x6d, 0x6e, 0x6c, 0xc9, 0xb0, 0x06, 0xfb, 0xb6, 0x64, 0x9c, 0x63, 0x76, 0x3b, 0x66, 0xfe, 0x01, + 0x67, 0xf4, 0x3a, 0x92, 0x71, 0xa8, 0xd8, 0xf6, 0xea, 0xb5, 0xde, 0xc9, 0x55, 0xe9, 0xd0, 0x7d, + 0x30, 0x21, 0xea, 0xad, 0xe2, 0xc0, 0x61, 0xd4, 0xe7, 0x8a, 0x03, 0xde, 0x00, 0xa0, 0x6f, 0x48, + 0x15, 0x3d, 0x6f, 0x49, 0x47, 0x56, 0xe8, 0xc8, 0x92, 0x5f, 0xa1, 0x5f, 0xb7, 0x8a, 0x55, 0xac, + 0x1b, 0x8b, 0x44, 0x9f, 0x34, 0x30, 0x79, 0xa8, 0x80, 0xb2, 0xb4, 0x0e, 0x32, 0x21, 0x79, 0xe8, + 0xe8, 0xaf, 0xb9, 0xb1, 0xa5, 0xc2, 0x30, 0x47, 0x61, 0x94, 0x33, 0xd3, 0xed, 0x98, 0xd3, 0xd2, + 0x8f, 0x08, 0x8a, 0xec, 0xc8, 0x83, 0x2b, 0x33, 0xc1, 0xd5, 0x04, 0x74, 0x5a, 0x40, 0xcf, 0x9e, + 0x08, 0x2d, 0x79, 0x12, 0xd4, 0x0e, 0x98, 0x8a, 0x43, 0x3b, 0xed, 0x9b, 0x7e, 0xd4, 0x98, 0x59, + 0x90, 0x26, 0xbe, 0x68, 0xc8, 0xbf, 0xce, 0x54, 0xb7, 0x63, 0x8e, 0x4b, 0x2a, 0xe2, 0x47, 0x48, + 0xc4, 0x47, 0x6e, 0x9a, 0xf8, 0x88, 0x80, 0xdc, 0xd1, 0x1c, 0xca, 0xfb, 0x1a, 0xf8, 0x3b, 0x24, + 0x56, 0x7d, 0x3d, 0xde, 0x7a, 0xbe, 0xdb, 0x31, 0xa7, 0xfa, 0xd6, 0xe3, 0xce, 0x91, 0x2b, 0xd2, + 0xa0, 0x67, 0x20, 0x9f, 0xe8, 0xb1, 0xd3, 0xbe, 0xf5, 0x88, 0xe2, 0x66, 0x84, 0x3c, 0x01, 0x32, + 0x2c, 0x3c, 0x4b, 0x6a, 0x57, 0x1e, 0x7e, 0x5f, 0xb3, 0x3e, 0x6b, 0xa0, 0x30, 0xb8, 0xbc, 0x72, + 0x7b, 0xe7, 0x34, 0x5f, 0xba, 0xb4, 0xdb, 0x31, 0x53, 0x7f, 0xf6, 0x6b, 0x23, 0x50, 0x8c, 0xf3, + 0xaf, 0x31, 0xbf, 0x55, 0xc3, 0x8e, 0x57, 0xf3, 0x68, 0x25, 0xba, 0xd3, 0xe8, 0xbd, 0x06, 0x4a, + 0xc7, 0x88, 0x94, 0xd3, 0x1d, 0x0d, 0xfc, 0x53, 0x96, 0xcf, 0x72, 0x69, 0x61, 0x76, 0x3a, 0x01, + 0x14, 0xa1, 0xac, 0x30, 0x42, 0x9d, 0xb5, 0xa4, 0xd3, 0x70, 0x33, 0xf4, 0x9c, 0xca, 0xc3, 0x87, + 0x6f, 0xe6, 0x5c, 0x95, 0x04, 0x9b, 0xad, 0xb2, 0x55, 0x61, 0x75, 0x5b, 0xed, 0x13, 0xf9, 0x67, + 0x81, 0xfb, 0x0f, 0xed, 0xa0, 0xdd, 0xc0, 0x5c, 0x64, 0xe3, 0x6e, 0x54, 0x78, 0xe9, 0x55, 0x16, + 0x64, 0x04, 0x2a, 0x7c, 0xa1, 0x81, 0xac, 0x5c, 0x08, 0x70, 0x7e, 0x58, 0xd3, 0x8f, 0xac, 0x20, + 0xfd, 0xe2, 0xc9, 0xd2, 0xde, 0x14, 0xa3, 0xd2, 0xce, 0x97, 0x1f, 0x6f, 0xd2, 0x79, 0x38, 0x6d, + 0xe3, 0x60, 0x13, 0x37, 0xeb, 0x84, 0x06, 0xd1, 0x6a, 0xb5, 0xe5, 0x8a, 0x81, 0x2f, 0x35, 0x90, + 0x11, 0xf7, 0x02, 0x5e, 0x3a, 0x36, 0xf3, 0xa1, 0x15, 0xa4, 0x2f, 0x8c, 0xa8, 0x56, 0x24, 0x45, + 0x41, 0xa2, 0xc3, 0xdc, 0x00, 0x12, 0x79, 0x61, 0xde, 0x6a, 0x60, 0x2c, 0x36, 0x8d, 0xd0, 0x1e, + 0xa5, 0x40, 0x6c, 0xf6, 0xf5, 0xcb, 0xa3, 0x07, 0x28, 0xa8, 0x73, 0x02, 0xca, 0x84, 0x33, 0xc3, + 0xa0, 0xec, 0xa7, 0xc4, 0x7f, 0x0e, 0xdf, 0x69, 0xe0, 0xbf, 0x43, 0xd3, 0x03, 0x97, 0x47, 0xb2, + 0x9f, 0x1c, 0x75, 0xfd, 0xca, 0xe9, 0x82, 0x14, 0xe5, 0xbc, 0xa0, 0x3c, 0x0b, 0x4b, 0xc3, 0x28, + 0x37, 0xca, 0xed, 0x0d, 0xb9, 0x35, 0x3e, 0x6a, 0x60, 0x32, 0x4a, 0x93, 0x98, 0x01, 0x78, 0x75, + 0x94, 0xd2, 0x83, 0x66, 0x4b, 0xbf, 0xf6, 0x0b, 0x91, 0x8a, 0x1c, 0x09, 0xf2, 0x02, 0xd4, 0x07, + 0x91, 0x4b, 0xad, 0xb3, 0xb2, 0xbb, 0x6f, 0x68, 0x7b, 0xfb, 0x86, 0xf6, 0x7d, 0xdf, 0xd0, 0x5e, + 0x1f, 0x18, 0xa9, 0xbd, 0x03, 0x23, 0xf5, 0xf5, 0xc0, 0x48, 0xdd, 0x9b, 0x8f, 0x0d, 0x57, 0xb0, + 0xe9, 0x35, 0x39, 0xe1, 0xb1, 0x3c, 0x8f, 0x65, 0x26, 0x31, 0x63, 0xe5, 0xac, 0xf8, 0xcd, 0x5e, + 0xfe, 0x19, 0x00, 0x00, 0xff, 0xff, 0x75, 0x49, 0xed, 0xbe, 0x94, 0x08, 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 { + // Bonds queries bonds list. + Params(ctx context.Context, in *QueryParamRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Bonds queries bonds list. + Bonds(ctx context.Context, in *QueryGetBondsRequest, opts ...grpc.CallOption) (*QueryGetBondsResponse, error) + // GetBondById + GetBondById(ctx context.Context, in *QueryGetBondByIdRequest, opts ...grpc.CallOption) (*QueryGetBondByIdResponse, error) + // Get Bonds List by Owner + GetBondsByOwner(ctx context.Context, in *QueryGetBondsByOwnerRequest, opts ...grpc.CallOption) (*QueryGetBondsByOwnerResponse, error) + // Get Bonds module balance + GetBondsModuleBalance(ctx context.Context, in *QueryGetBondModuleBalanceRequest, opts ...grpc.CallOption) (*QueryGetBondModuleBalanceResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/vulcanize.bond.v1beta1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Bonds(ctx context.Context, in *QueryGetBondsRequest, opts ...grpc.CallOption) (*QueryGetBondsResponse, error) { + out := new(QueryGetBondsResponse) + err := c.cc.Invoke(ctx, "/vulcanize.bond.v1beta1.Query/Bonds", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GetBondById(ctx context.Context, in *QueryGetBondByIdRequest, opts ...grpc.CallOption) (*QueryGetBondByIdResponse, error) { + out := new(QueryGetBondByIdResponse) + err := c.cc.Invoke(ctx, "/vulcanize.bond.v1beta1.Query/GetBondById", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GetBondsByOwner(ctx context.Context, in *QueryGetBondsByOwnerRequest, opts ...grpc.CallOption) (*QueryGetBondsByOwnerResponse, error) { + out := new(QueryGetBondsByOwnerResponse) + err := c.cc.Invoke(ctx, "/vulcanize.bond.v1beta1.Query/GetBondsByOwner", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GetBondsModuleBalance(ctx context.Context, in *QueryGetBondModuleBalanceRequest, opts ...grpc.CallOption) (*QueryGetBondModuleBalanceResponse, error) { + out := new(QueryGetBondModuleBalanceResponse) + err := c.cc.Invoke(ctx, "/vulcanize.bond.v1beta1.Query/GetBondsModuleBalance", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Bonds queries bonds list. + Params(context.Context, *QueryParamRequest) (*QueryParamsResponse, error) + // Bonds queries bonds list. + Bonds(context.Context, *QueryGetBondsRequest) (*QueryGetBondsResponse, error) + // GetBondById + GetBondById(context.Context, *QueryGetBondByIdRequest) (*QueryGetBondByIdResponse, error) + // Get Bonds List by Owner + GetBondsByOwner(context.Context, *QueryGetBondsByOwnerRequest) (*QueryGetBondsByOwnerResponse, error) + // Get Bonds module balance + GetBondsModuleBalance(context.Context, *QueryGetBondModuleBalanceRequest) (*QueryGetBondModuleBalanceResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) Bonds(ctx context.Context, req *QueryGetBondsRequest) (*QueryGetBondsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Bonds not implemented") +} +func (*UnimplementedQueryServer) GetBondById(ctx context.Context, req *QueryGetBondByIdRequest) (*QueryGetBondByIdResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetBondById not implemented") +} +func (*UnimplementedQueryServer) GetBondsByOwner(ctx context.Context, req *QueryGetBondsByOwnerRequest) (*QueryGetBondsByOwnerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetBondsByOwner not implemented") +} +func (*UnimplementedQueryServer) GetBondsModuleBalance(ctx context.Context, req *QueryGetBondModuleBalanceRequest) (*QueryGetBondModuleBalanceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetBondsModuleBalance 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(QueryParamRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/vulcanize.bond.v1beta1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Bonds_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetBondsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Bonds(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/vulcanize.bond.v1beta1.Query/Bonds", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Bonds(ctx, req.(*QueryGetBondsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GetBondById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetBondByIdRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetBondById(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/vulcanize.bond.v1beta1.Query/GetBondById", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetBondById(ctx, req.(*QueryGetBondByIdRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GetBondsByOwner_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetBondsByOwnerRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetBondsByOwner(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/vulcanize.bond.v1beta1.Query/GetBondsByOwner", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetBondsByOwner(ctx, req.(*QueryGetBondsByOwnerRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GetBondsModuleBalance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetBondModuleBalanceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetBondsModuleBalance(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/vulcanize.bond.v1beta1.Query/GetBondsModuleBalance", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetBondsModuleBalance(ctx, req.(*QueryGetBondModuleBalanceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "vulcanize.bond.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "Bonds", + Handler: _Query_Bonds_Handler, + }, + { + MethodName: "GetBondById", + Handler: _Query_GetBondById_Handler, + }, + { + MethodName: "GetBondsByOwner", + Handler: _Query_GetBondsByOwner_Handler, + }, + { + MethodName: "GetBondsModuleBalance", + Handler: _Query_GetBondsModuleBalance_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "vulcanize/bond/v1beta1/query.proto", +} + +func (m *QueryParamRequest) 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 *QueryParamRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamRequest) 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 + if m.Params != nil { + { + 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 (m *QueryGetBondsRequest) 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 *QueryGetBondsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetBondsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.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 (m *QueryGetBondsResponse) 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 *QueryGetBondsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetBondsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Bonds) > 0 { + for iNdEx := len(m.Bonds) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Bonds[iNdEx].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 (m *QueryGetBondByIdRequest) 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 *QueryGetBondByIdRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetBondByIdRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGetBondByIdResponse) 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 *QueryGetBondByIdResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetBondByIdResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Bond != nil { + { + size, err := m.Bond.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 (m *QueryGetBondsByOwnerRequest) 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 *QueryGetBondsByOwnerRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetBondsByOwnerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGetBondsByOwnerResponse) 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 *QueryGetBondsByOwnerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetBondsByOwnerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Bonds) > 0 { + for iNdEx := len(m.Bonds) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Bonds[iNdEx].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 (m *QueryGetBondModuleBalanceRequest) 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 *QueryGetBondModuleBalanceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetBondModuleBalanceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryGetBondModuleBalanceResponse) 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 *QueryGetBondModuleBalanceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetBondModuleBalanceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Balance) > 0 { + for iNdEx := len(m.Balance) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Balance[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + 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 *QueryParamRequest) 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 + if m.Params != nil { + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetBondsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetBondsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Bonds) > 0 { + for _, e := range m.Bonds { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetBondByIdRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetBondByIdResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Bond != nil { + l = m.Bond.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetBondsByOwnerRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetBondsByOwnerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Bonds) > 0 { + for _, e := range m.Bonds { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetBondModuleBalanceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryGetBondModuleBalanceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Balance) > 0 { + for _, e := range m.Balance { + l = e.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 *QueryParamRequest) 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: QueryParamRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamRequest: 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 m.Params == nil { + m.Params = &Params{} + } + 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 (m *QueryGetBondsRequest) 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: QueryGetBondsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetBondsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 (m *QueryGetBondsResponse) 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: QueryGetBondsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetBondsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bonds", 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 + } + m.Bonds = append(m.Bonds, &Bond{}) + if err := m.Bonds[len(m.Bonds)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 (m *QueryGetBondByIdRequest) 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: QueryGetBondByIdRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetBondByIdRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + 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 (m *QueryGetBondByIdResponse) 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: QueryGetBondByIdResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetBondByIdResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bond", 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 m.Bond == nil { + m.Bond = &Bond{} + } + if err := m.Bond.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 (m *QueryGetBondsByOwnerRequest) 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: QueryGetBondsByOwnerRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetBondsByOwnerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 (m *QueryGetBondsByOwnerResponse) 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: QueryGetBondsByOwnerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetBondsByOwnerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bonds", 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 + } + m.Bonds = append(m.Bonds, Bond{}) + if err := m.Bonds[len(m.Bonds)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 (m *QueryGetBondModuleBalanceRequest) 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: QueryGetBondModuleBalanceRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetBondModuleBalanceRequest: 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 *QueryGetBondModuleBalanceResponse) 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: QueryGetBondModuleBalanceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetBondModuleBalanceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Balance", 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 + } + m.Balance = append(m.Balance, types.Coin{}) + if err := m.Balance[len(m.Balance)-1].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/bond/types/query.pb.gw.go b/x/bond/types/query.pb.gw.go new file mode 100644 index 00000000..4bdcf081 --- /dev/null +++ b/x/bond/types/query.pb.gw.go @@ -0,0 +1,468 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: vulcanize/bond/v1beta1/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/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 + +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 QueryParamRequest + 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 QueryParamRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_Bonds_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_Bonds_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetBondsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Bonds_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Bonds(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Bonds_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetBondsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Bonds_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Bonds(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_GetBondById_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetBondByIdRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.GetBondById(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetBondById_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetBondByIdRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.GetBondById(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_GetBondsByOwner_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_GetBondsByOwner_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetBondsByOwnerRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetBondsByOwner_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetBondsByOwner(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetBondsByOwner_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetBondsByOwnerRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetBondsByOwner_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetBondsByOwner(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_GetBondsModuleBalance_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetBondModuleBalanceRequest + var metadata runtime.ServerMetadata + + msg, err := client.GetBondsModuleBalance(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetBondsModuleBalance_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetBondModuleBalanceRequest + var metadata runtime.ServerMetadata + + msg, err := server.GetBondsModuleBalance(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 (such as grpc.SendHeader, etc) 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() + 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) + 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()...) + + }) + + mux.Handle("GET", pattern_Query_Bonds_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Bonds_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Bonds_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetBondById_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetBondById_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetBondById_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetBondsByOwner_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetBondsByOwner_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetBondsByOwner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetBondsModuleBalance_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetBondsModuleBalance_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetBondsModuleBalance_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()...) + + }) + + mux.Handle("GET", pattern_Query_Bonds_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_Bonds_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_Bonds_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetBondById_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_GetBondById_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_GetBondById_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetBondsByOwner_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_GetBondsByOwner_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_GetBondsByOwner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetBondsModuleBalance_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_GetBondsModuleBalance_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_GetBondsModuleBalance_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{"ethermint", "bond", "v1", "params"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_Bonds_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ethermint", "bond", "v1", "bonds"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_GetBondById_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"ethermint", "bond", "v1", "bonds", "id"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_GetBondsByOwner_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ethermint", "bond", "v1", "bonds_by_owner"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_GetBondsModuleBalance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ethermint", "bond", "v1", "balance"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_Bonds_0 = runtime.ForwardResponseMessage + + forward_Query_GetBondById_0 = runtime.ForwardResponseMessage + + forward_Query_GetBondsByOwner_0 = runtime.ForwardResponseMessage + + forward_Query_GetBondsModuleBalance_0 = runtime.ForwardResponseMessage +) diff --git a/x/bond/types/tx.pb.go b/x/bond/types/tx.pb.go new file mode 100644 index 00000000..2344f1bd --- /dev/null +++ b/x/bond/types/tx.pb.go @@ -0,0 +1,1922 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: vulcanize/bond/v1beta1/tx.proto + +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/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + 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 + +// MsgCreateBond defines a SDK message for creating a new bond. +type MsgCreateBond struct { + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` + Coins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=coins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coins" json:"coins" yaml:"coins"` +} + +func (m *MsgCreateBond) Reset() { *m = MsgCreateBond{} } +func (m *MsgCreateBond) String() string { return proto.CompactTextString(m) } +func (*MsgCreateBond) ProtoMessage() {} +func (*MsgCreateBond) Descriptor() ([]byte, []int) { + return fileDescriptor_4a1095dfb30dc368, []int{0} +} +func (m *MsgCreateBond) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateBond) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateBond.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 *MsgCreateBond) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateBond.Merge(m, src) +} +func (m *MsgCreateBond) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateBond) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateBond.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateBond proto.InternalMessageInfo + +func (m *MsgCreateBond) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +func (m *MsgCreateBond) GetCoins() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Coins + } + return nil +} + +// MsgCreateBondResponse defines the Msg/CreateBond response type. +type MsgCreateBondResponse struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" json:"id" yaml:"id"` +} + +func (m *MsgCreateBondResponse) Reset() { *m = MsgCreateBondResponse{} } +func (m *MsgCreateBondResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateBondResponse) ProtoMessage() {} +func (*MsgCreateBondResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4a1095dfb30dc368, []int{1} +} +func (m *MsgCreateBondResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateBondResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateBondResponse.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 *MsgCreateBondResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateBondResponse.Merge(m, src) +} +func (m *MsgCreateBondResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateBondResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateBondResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateBondResponse proto.InternalMessageInfo + +func (m *MsgCreateBondResponse) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +// MsgRefillBond defines a SDK message for refill the amount for bond. +type MsgRefillBond struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` + Coins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=coins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coins" json:"coins" yaml:"coins"` +} + +func (m *MsgRefillBond) Reset() { *m = MsgRefillBond{} } +func (m *MsgRefillBond) String() string { return proto.CompactTextString(m) } +func (*MsgRefillBond) ProtoMessage() {} +func (*MsgRefillBond) Descriptor() ([]byte, []int) { + return fileDescriptor_4a1095dfb30dc368, []int{2} +} +func (m *MsgRefillBond) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRefillBond) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRefillBond.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 *MsgRefillBond) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRefillBond.Merge(m, src) +} +func (m *MsgRefillBond) XXX_Size() int { + return m.Size() +} +func (m *MsgRefillBond) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRefillBond.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRefillBond proto.InternalMessageInfo + +func (m *MsgRefillBond) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *MsgRefillBond) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +func (m *MsgRefillBond) GetCoins() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Coins + } + return nil +} + +// MsgRefillBondResponse defines the Msg/RefillBond response type. +type MsgRefillBondResponse struct { +} + +func (m *MsgRefillBondResponse) Reset() { *m = MsgRefillBondResponse{} } +func (m *MsgRefillBondResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRefillBondResponse) ProtoMessage() {} +func (*MsgRefillBondResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4a1095dfb30dc368, []int{3} +} +func (m *MsgRefillBondResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRefillBondResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRefillBondResponse.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 *MsgRefillBondResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRefillBondResponse.Merge(m, src) +} +func (m *MsgRefillBondResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRefillBondResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRefillBondResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRefillBondResponse proto.InternalMessageInfo + +// MsgWithdrawBond defines a SDK message for withdrawing amount from bond. +type MsgWithdrawBond struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` + Coins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=coins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coins" json:"coins" yaml:"coins"` +} + +func (m *MsgWithdrawBond) Reset() { *m = MsgWithdrawBond{} } +func (m *MsgWithdrawBond) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawBond) ProtoMessage() {} +func (*MsgWithdrawBond) Descriptor() ([]byte, []int) { + return fileDescriptor_4a1095dfb30dc368, []int{4} +} +func (m *MsgWithdrawBond) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawBond) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawBond.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 *MsgWithdrawBond) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawBond.Merge(m, src) +} +func (m *MsgWithdrawBond) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawBond) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawBond.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawBond proto.InternalMessageInfo + +func (m *MsgWithdrawBond) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *MsgWithdrawBond) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +func (m *MsgWithdrawBond) GetCoins() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Coins + } + return nil +} + +// MsgWithdrawBondResponse defines the MsgWithdrawBond response type. +type MsgWithdrawBondResponse struct { +} + +func (m *MsgWithdrawBondResponse) Reset() { *m = MsgWithdrawBondResponse{} } +func (m *MsgWithdrawBondResponse) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawBondResponse) ProtoMessage() {} +func (*MsgWithdrawBondResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4a1095dfb30dc368, []int{5} +} +func (m *MsgWithdrawBondResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawBondResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawBondResponse.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 *MsgWithdrawBondResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawBondResponse.Merge(m, src) +} +func (m *MsgWithdrawBondResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawBondResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawBondResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawBondResponse proto.InternalMessageInfo + +// MsgCancelBond defines a SDK message for the cancel the bond. +type MsgCancelBond struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgCancelBond) Reset() { *m = MsgCancelBond{} } +func (m *MsgCancelBond) String() string { return proto.CompactTextString(m) } +func (*MsgCancelBond) ProtoMessage() {} +func (*MsgCancelBond) Descriptor() ([]byte, []int) { + return fileDescriptor_4a1095dfb30dc368, []int{6} +} +func (m *MsgCancelBond) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCancelBond) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCancelBond.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 *MsgCancelBond) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCancelBond.Merge(m, src) +} +func (m *MsgCancelBond) XXX_Size() int { + return m.Size() +} +func (m *MsgCancelBond) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCancelBond.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCancelBond proto.InternalMessageInfo + +func (m *MsgCancelBond) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *MsgCancelBond) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +// MsgCancelBondResponse defines the MsgCancelBond response type. +type MsgCancelBondResponse struct { +} + +func (m *MsgCancelBondResponse) Reset() { *m = MsgCancelBondResponse{} } +func (m *MsgCancelBondResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCancelBondResponse) ProtoMessage() {} +func (*MsgCancelBondResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4a1095dfb30dc368, []int{7} +} +func (m *MsgCancelBondResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCancelBondResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCancelBondResponse.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 *MsgCancelBondResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCancelBondResponse.Merge(m, src) +} +func (m *MsgCancelBondResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCancelBondResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCancelBondResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCancelBondResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgCreateBond)(nil), "vulcanize.bond.v1beta1.MsgCreateBond") + proto.RegisterType((*MsgCreateBondResponse)(nil), "vulcanize.bond.v1beta1.MsgCreateBondResponse") + proto.RegisterType((*MsgRefillBond)(nil), "vulcanize.bond.v1beta1.MsgRefillBond") + proto.RegisterType((*MsgRefillBondResponse)(nil), "vulcanize.bond.v1beta1.MsgRefillBondResponse") + proto.RegisterType((*MsgWithdrawBond)(nil), "vulcanize.bond.v1beta1.MsgWithdrawBond") + proto.RegisterType((*MsgWithdrawBondResponse)(nil), "vulcanize.bond.v1beta1.MsgWithdrawBondResponse") + proto.RegisterType((*MsgCancelBond)(nil), "vulcanize.bond.v1beta1.MsgCancelBond") + proto.RegisterType((*MsgCancelBondResponse)(nil), "vulcanize.bond.v1beta1.MsgCancelBondResponse") +} + +func init() { proto.RegisterFile("vulcanize/bond/v1beta1/tx.proto", fileDescriptor_4a1095dfb30dc368) } + +var fileDescriptor_4a1095dfb30dc368 = []byte{ + // 478 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x94, 0x4d, 0x6e, 0xd3, 0x40, + 0x14, 0xc7, 0xe3, 0x44, 0x54, 0x62, 0xf8, 0x92, 0x0c, 0x34, 0x4d, 0x16, 0x76, 0x64, 0x09, 0x35, + 0x2c, 0x3a, 0xa3, 0x96, 0x05, 0x12, 0x2b, 0x94, 0xac, 0xb3, 0xf1, 0x06, 0x89, 0xdd, 0xd8, 0x33, + 0xd8, 0x03, 0xf6, 0x4c, 0xe4, 0x37, 0x2d, 0x2d, 0x0b, 0xce, 0xc0, 0x9e, 0x03, 0x20, 0x71, 0x01, + 0xc4, 0x0d, 0xba, 0xec, 0x92, 0x55, 0x40, 0xc9, 0x0d, 0x7a, 0x02, 0x64, 0x8f, 0xbf, 0x42, 0x2b, + 0xab, 0xac, 0x10, 0x2b, 0x7b, 0xe4, 0xdf, 0xfb, 0xf8, 0xbf, 0xf7, 0xf7, 0x20, 0xf7, 0xe4, 0x38, + 0x09, 0xa9, 0x14, 0x1f, 0x38, 0x09, 0x94, 0x64, 0xe4, 0xe4, 0x30, 0xe0, 0x9a, 0x1e, 0x12, 0x7d, + 0x8a, 0x97, 0x99, 0xd2, 0xca, 0xde, 0xad, 0x01, 0x9c, 0x03, 0xb8, 0x04, 0xc6, 0x8f, 0x22, 0x15, + 0xa9, 0x02, 0x21, 0xf9, 0x9b, 0xa1, 0xc7, 0x4e, 0xa8, 0x20, 0x55, 0x40, 0x02, 0x0a, 0xbc, 0xce, + 0x15, 0x2a, 0x21, 0xcd, 0x77, 0xef, 0x8b, 0x85, 0xee, 0x2d, 0x20, 0x9a, 0x67, 0x9c, 0x6a, 0x3e, + 0x53, 0x92, 0xd9, 0xbb, 0x68, 0x07, 0x44, 0x24, 0x79, 0xb6, 0x67, 0x4d, 0xac, 0xe9, 0x6d, 0xbf, + 0x3c, 0xd9, 0x1f, 0xd1, 0xad, 0x3c, 0x0e, 0xf6, 0xfa, 0x93, 0xc1, 0xf4, 0xce, 0xd1, 0x08, 0x9b, + 0xcc, 0x38, 0xcf, 0x5c, 0x35, 0x81, 0xe7, 0x4a, 0xc8, 0xd9, 0xe2, 0x7c, 0xe5, 0xf6, 0x2e, 0x57, + 0xee, 0xe8, 0x2d, 0x28, 0xf9, 0xc2, 0x2b, 0xa2, 0xbc, 0xc9, 0x19, 0x4d, 0x93, 0xea, 0xf0, 0xf5, + 0xa7, 0x3b, 0x8d, 0x84, 0x8e, 0x8f, 0x03, 0x1c, 0xaa, 0x94, 0x94, 0x3d, 0x9a, 0xc7, 0x01, 0xb0, + 0x77, 0x44, 0x9f, 0x2d, 0x39, 0x14, 0xd9, 0xc0, 0x37, 0x65, 0xbd, 0x97, 0xe8, 0xf1, 0x56, 0xa3, + 0x3e, 0x87, 0xa5, 0x92, 0xc0, 0xed, 0x7d, 0xd4, 0x17, 0xcc, 0x34, 0x3b, 0x1b, 0x5e, 0xae, 0xdc, + 0x87, 0xa6, 0xac, 0x60, 0x55, 0x4d, 0xc1, 0x3c, 0xbf, 0x2f, 0x98, 0xf7, 0xcd, 0x68, 0xf5, 0xf9, + 0x1b, 0x91, 0x24, 0x85, 0xd6, 0xfb, 0x4d, 0x68, 0x4e, 0xb4, 0xb4, 0xf7, 0xaf, 0xd7, 0x3e, 0xf8, + 0x37, 0xda, 0x87, 0x85, 0xf6, 0xa6, 0xf1, 0x4a, 0xbb, 0xf7, 0xdd, 0x42, 0x0f, 0x16, 0x10, 0xbd, + 0x12, 0x3a, 0x66, 0x19, 0x7d, 0xff, 0x5f, 0x89, 0x1a, 0xa1, 0xe1, 0x1f, 0xad, 0xd7, 0xb2, 0x9e, + 0x1b, 0x53, 0x52, 0x19, 0xf2, 0xbf, 0x5a, 0x54, 0x39, 0xa8, 0x26, 0xb0, 0xca, 0x78, 0xf4, 0x79, + 0x80, 0x06, 0x0b, 0x88, 0xec, 0x00, 0xa1, 0x96, 0xd7, 0x9f, 0xe0, 0xeb, 0x7f, 0x26, 0xbc, 0xe5, + 0xb4, 0xf1, 0xc1, 0x8d, 0xb0, 0xda, 0x90, 0x01, 0x42, 0x2d, 0x8f, 0x75, 0xd5, 0x68, 0xb0, 0xce, + 0x1a, 0x57, 0x17, 0x6f, 0xc7, 0xe8, 0xee, 0xd6, 0xd2, 0xf7, 0x3b, 0xc2, 0xdb, 0xe0, 0x98, 0xdc, + 0x10, 0x6c, 0xab, 0x69, 0x2d, 0xa2, 0x73, 0x62, 0x35, 0xd6, 0x3d, 0xb1, 0x2b, 0xdb, 0x99, 0xcd, + 0xcf, 0xd7, 0x8e, 0x75, 0xb1, 0x76, 0xac, 0x5f, 0x6b, 0xc7, 0xfa, 0xb4, 0x71, 0x7a, 0x17, 0x1b, + 0xa7, 0xf7, 0x63, 0xe3, 0xf4, 0x5e, 0x3f, 0x6d, 0xb9, 0x4a, 0xc7, 0x34, 0x03, 0x01, 0x84, 0xeb, + 0x98, 0x67, 0xa9, 0x90, 0x9a, 0x9c, 0x9a, 0x3b, 0xb2, 0x30, 0x57, 0xb0, 0x53, 0xdc, 0x68, 0xcf, + 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, 0xa4, 0xac, 0xaf, 0xbb, 0x42, 0x05, 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 + +// 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 { + // CreateBond defines a method for creating a new bond. + CreateBond(ctx context.Context, in *MsgCreateBond, opts ...grpc.CallOption) (*MsgCreateBondResponse, error) + // RefillBond defines a method for refilling amount for bond. + RefillBond(ctx context.Context, in *MsgRefillBond, opts ...grpc.CallOption) (*MsgRefillBondResponse, error) + // WithdrawBond defines a method for withdrawing amount from bond. + WithdrawBond(ctx context.Context, in *MsgWithdrawBond, opts ...grpc.CallOption) (*MsgWithdrawBondResponse, error) + // CancelBond defines a method for cancelling a bond. + CancelBond(ctx context.Context, in *MsgCancelBond, opts ...grpc.CallOption) (*MsgCancelBondResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) CreateBond(ctx context.Context, in *MsgCreateBond, opts ...grpc.CallOption) (*MsgCreateBondResponse, error) { + out := new(MsgCreateBondResponse) + err := c.cc.Invoke(ctx, "/vulcanize.bond.v1beta1.Msg/CreateBond", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) RefillBond(ctx context.Context, in *MsgRefillBond, opts ...grpc.CallOption) (*MsgRefillBondResponse, error) { + out := new(MsgRefillBondResponse) + err := c.cc.Invoke(ctx, "/vulcanize.bond.v1beta1.Msg/RefillBond", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) WithdrawBond(ctx context.Context, in *MsgWithdrawBond, opts ...grpc.CallOption) (*MsgWithdrawBondResponse, error) { + out := new(MsgWithdrawBondResponse) + err := c.cc.Invoke(ctx, "/vulcanize.bond.v1beta1.Msg/WithdrawBond", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) CancelBond(ctx context.Context, in *MsgCancelBond, opts ...grpc.CallOption) (*MsgCancelBondResponse, error) { + out := new(MsgCancelBondResponse) + err := c.cc.Invoke(ctx, "/vulcanize.bond.v1beta1.Msg/CancelBond", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // CreateBond defines a method for creating a new bond. + CreateBond(context.Context, *MsgCreateBond) (*MsgCreateBondResponse, error) + // RefillBond defines a method for refilling amount for bond. + RefillBond(context.Context, *MsgRefillBond) (*MsgRefillBondResponse, error) + // WithdrawBond defines a method for withdrawing amount from bond. + WithdrawBond(context.Context, *MsgWithdrawBond) (*MsgWithdrawBondResponse, error) + // CancelBond defines a method for cancelling a bond. + CancelBond(context.Context, *MsgCancelBond) (*MsgCancelBondResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) CreateBond(ctx context.Context, req *MsgCreateBond) (*MsgCreateBondResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateBond not implemented") +} +func (*UnimplementedMsgServer) RefillBond(ctx context.Context, req *MsgRefillBond) (*MsgRefillBondResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RefillBond not implemented") +} +func (*UnimplementedMsgServer) WithdrawBond(ctx context.Context, req *MsgWithdrawBond) (*MsgWithdrawBondResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WithdrawBond not implemented") +} +func (*UnimplementedMsgServer) CancelBond(ctx context.Context, req *MsgCancelBond) (*MsgCancelBondResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CancelBond not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_CreateBond_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateBond) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateBond(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/vulcanize.bond.v1beta1.Msg/CreateBond", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateBond(ctx, req.(*MsgCreateBond)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_RefillBond_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRefillBond) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RefillBond(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/vulcanize.bond.v1beta1.Msg/RefillBond", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RefillBond(ctx, req.(*MsgRefillBond)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_WithdrawBond_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgWithdrawBond) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).WithdrawBond(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/vulcanize.bond.v1beta1.Msg/WithdrawBond", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).WithdrawBond(ctx, req.(*MsgWithdrawBond)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_CancelBond_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCancelBond) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CancelBond(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/vulcanize.bond.v1beta1.Msg/CancelBond", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CancelBond(ctx, req.(*MsgCancelBond)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "vulcanize.bond.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateBond", + Handler: _Msg_CreateBond_Handler, + }, + { + MethodName: "RefillBond", + Handler: _Msg_RefillBond_Handler, + }, + { + MethodName: "WithdrawBond", + Handler: _Msg_WithdrawBond_Handler, + }, + { + MethodName: "CancelBond", + Handler: _Msg_CancelBond_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "vulcanize/bond/v1beta1/tx.proto", +} + +func (m *MsgCreateBond) 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 *MsgCreateBond) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateBond) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Coins) > 0 { + for iNdEx := len(m.Coins) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Coins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateBondResponse) 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 *MsgCreateBondResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateBondResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintTx(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRefillBond) 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 *MsgRefillBond) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRefillBond) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Coins) > 0 { + for iNdEx := len(m.Coins) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Coins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintTx(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRefillBondResponse) 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 *MsgRefillBondResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRefillBondResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgWithdrawBond) 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 *MsgWithdrawBond) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawBond) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Coins) > 0 { + for iNdEx := len(m.Coins) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Coins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintTx(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgWithdrawBondResponse) 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 *MsgWithdrawBondResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawBondResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgCancelBond) 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 *MsgCancelBond) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCancelBond) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintTx(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCancelBondResponse) 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 *MsgCancelBondResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCancelBondResponse) 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 *MsgCreateBond) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Coins) > 0 { + for _, e := range m.Coins { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgCreateBondResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRefillBond) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Coins) > 0 { + for _, e := range m.Coins { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgRefillBondResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgWithdrawBond) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Coins) > 0 { + for _, e := range m.Coins { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgWithdrawBondResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgCancelBond) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCancelBondResponse) 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 *MsgCreateBond) 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: MsgCreateBond: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateBond: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", 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.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Coins", 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 + } + m.Coins = append(m.Coins, types.Coin{}) + if err := m.Coins[len(m.Coins)-1].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 *MsgCreateBondResponse) 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: MsgCreateBondResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateBondResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", 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.Id = string(dAtA[iNdEx:postIndex]) + 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 *MsgRefillBond) 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: MsgRefillBond: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRefillBond: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", 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.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", 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.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Coins", 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 + } + m.Coins = append(m.Coins, types.Coin{}) + if err := m.Coins[len(m.Coins)-1].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 *MsgRefillBondResponse) 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: MsgRefillBondResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRefillBondResponse: 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 (m *MsgWithdrawBond) 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: MsgWithdrawBond: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawBond: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", 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.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", 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.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Coins", 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 + } + m.Coins = append(m.Coins, types.Coin{}) + if err := m.Coins[len(m.Coins)-1].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 *MsgWithdrawBondResponse) 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: MsgWithdrawBondResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawBondResponse: 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 (m *MsgCancelBond) 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: MsgCancelBond: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCancelBond: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", 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.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", 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.Signer = string(dAtA[iNdEx:postIndex]) + 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 *MsgCancelBondResponse) 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: MsgCancelBondResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCancelBondResponse: 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/evm/types/query.pb.gw.go b/x/evm/types/query.pb.gw.go index 9369b46d..f7882251 100644 --- a/x/evm/types/query.pb.gw.go +++ b/x/evm/types/query.pb.gw.go @@ -20,7 +20,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -31,7 +30,6 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage -var _ = metadata.Join func request_Query_Account_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryAccountRequest @@ -508,14 +506,12 @@ func local_request_Query_TraceTx_0(ctx context.Context, marshaler runtime.Marsha // 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. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_Account_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 { @@ -523,7 +519,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Account_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) @@ -537,8 +532,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_CosmosAccount_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 { @@ -546,7 +539,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_CosmosAccount_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) @@ -560,8 +552,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_ValidatorAccount_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 { @@ -569,7 +559,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_ValidatorAccount_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) @@ -583,8 +572,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Balance_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 { @@ -592,7 +579,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Balance_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) @@ -606,8 +592,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Storage_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 { @@ -615,7 +599,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Storage_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) @@ -629,8 +612,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Code_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 { @@ -638,7 +619,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Code_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) @@ -652,8 +632,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv 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 { @@ -661,7 +639,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv 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) @@ -675,8 +652,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_EthCall_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 { @@ -684,7 +659,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_EthCall_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) @@ -698,8 +672,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_EstimateGas_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 { @@ -707,7 +679,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_EstimateGas_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) @@ -721,8 +692,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_TraceTx_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 { @@ -730,7 +699,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_TraceTx_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) diff --git a/x/feemarket/types/query.pb.gw.go b/x/feemarket/types/query.pb.gw.go index 57a0c8d4..3795864c 100644 --- a/x/feemarket/types/query.pb.gw.go +++ b/x/feemarket/types/query.pb.gw.go @@ -20,7 +20,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -31,7 +30,6 @@ 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 @@ -90,14 +88,12 @@ func local_request_Query_BlockGas_0(ctx context.Context, marshaler runtime.Marsh // 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. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) 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 { @@ -105,7 +101,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv 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) @@ -119,8 +114,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_BaseFee_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 { @@ -128,7 +121,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_BaseFee_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) @@ -142,8 +134,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_BlockGas_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 { @@ -151,7 +141,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_BlockGas_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)