diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 0a8d35957e6e..5d1c7075156c 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -4,6 +4,40 @@ ## Table of Contents +- [cosmos/base/v1beta1/coin.proto](#cosmos/base/v1beta1/coin.proto) + - [Coin](#cosmos.base.v1beta1.Coin) + - [DecCoin](#cosmos.base.v1beta1.DecCoin) + - [DecProto](#cosmos.base.v1beta1.DecProto) + - [IntProto](#cosmos.base.v1beta1.IntProto) + +- [cosmos/airdrop/v1beta1/airdrop.proto](#cosmos/airdrop/v1beta1/airdrop.proto) + - [ActiveFund](#cosmos.airdrop.v1beta1.ActiveFund) + - [Fund](#cosmos.airdrop.v1beta1.Fund) + - [Params](#cosmos.airdrop.v1beta1.Params) + +- [cosmos/airdrop/v1beta1/genesis.proto](#cosmos/airdrop/v1beta1/genesis.proto) + - [GenesisState](#cosmos.airdrop.v1beta1.GenesisState) + +- [cosmos/base/query/v1beta1/pagination.proto](#cosmos/base/query/v1beta1/pagination.proto) + - [PageRequest](#cosmos.base.query.v1beta1.PageRequest) + - [PageResponse](#cosmos.base.query.v1beta1.PageResponse) + +- [cosmos/airdrop/v1beta1/query.proto](#cosmos/airdrop/v1beta1/query.proto) + - [QueryAllFundsRequest](#cosmos.airdrop.v1beta1.QueryAllFundsRequest) + - [QueryAllFundsResponse](#cosmos.airdrop.v1beta1.QueryAllFundsResponse) + - [QueryFundRequest](#cosmos.airdrop.v1beta1.QueryFundRequest) + - [QueryFundResponse](#cosmos.airdrop.v1beta1.QueryFundResponse) + - [QueryParamsRequest](#cosmos.airdrop.v1beta1.QueryParamsRequest) + - [QueryParamsResponse](#cosmos.airdrop.v1beta1.QueryParamsResponse) + + - [Query](#cosmos.airdrop.v1beta1.Query) + +- [cosmos/airdrop/v1beta1/tx.proto](#cosmos/airdrop/v1beta1/tx.proto) + - [MsgAirDrop](#cosmos.airdrop.v1beta1.MsgAirDrop) + - [MsgAirDropResponse](#cosmos.airdrop.v1beta1.MsgAirDropResponse) + + - [Msg](#cosmos.airdrop.v1beta1.Msg) + - [cosmos/auth/v1beta1/auth.proto](#cosmos/auth/v1beta1/auth.proto) - [BaseAccount](#cosmos.auth.v1beta1.BaseAccount) - [ModuleAccount](#cosmos.auth.v1beta1.ModuleAccount) @@ -20,12 +54,6 @@ - [Query](#cosmos.auth.v1beta1.Query) -- [cosmos/base/v1beta1/coin.proto](#cosmos/base/v1beta1/coin.proto) - - [Coin](#cosmos.base.v1beta1.Coin) - - [DecCoin](#cosmos.base.v1beta1.DecCoin) - - [DecProto](#cosmos.base.v1beta1.DecProto) - - [IntProto](#cosmos.base.v1beta1.IntProto) - - [cosmos/bank/v1beta1/bank.proto](#cosmos/bank/v1beta1/bank.proto) - [DenomUnit](#cosmos.bank.v1beta1.DenomUnit) - [Input](#cosmos.bank.v1beta1.Input) @@ -39,10 +67,6 @@ - [Balance](#cosmos.bank.v1beta1.Balance) - [GenesisState](#cosmos.bank.v1beta1.GenesisState) -- [cosmos/base/query/v1beta1/pagination.proto](#cosmos/base/query/v1beta1/pagination.proto) - - [PageRequest](#cosmos.base.query.v1beta1.PageRequest) - - [PageResponse](#cosmos.base.query.v1beta1.PageResponse) - - [cosmos/bank/v1beta1/query.proto](#cosmos/bank/v1beta1/query.proto) - [QueryAllBalancesRequest](#cosmos.bank.v1beta1.QueryAllBalancesRequest) - [QueryAllBalancesResponse](#cosmos.bank.v1beta1.QueryAllBalancesResponse) @@ -691,63 +715,138 @@ - +

Top

-## cosmos/auth/v1beta1/auth.proto +## cosmos/base/v1beta1/coin.proto - + -### BaseAccount -BaseAccount defines a base account type. It contains all the necessary fields -for basic account functionality. Any custom account type should extend this -type for additional functionality (e.g. vesting). +### Coin +Coin defines a token with a denomination and an amount. + +NOTE: The amount field is an Int which implements the custom method +signatures required by gogoproto. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | | -| `pub_key` | [google.protobuf.Any](#google.protobuf.Any) | | | -| `account_number` | [uint64](#uint64) | | | -| `sequence` | [uint64](#uint64) | | | +| `denom` | [string](#string) | | | +| `amount` | [string](#string) | | | - + -### ModuleAccount -ModuleAccount defines an account for modules that holds coins on a pool. +### DecCoin +DecCoin defines a token with a denomination and a decimal amount. + +NOTE: The amount field is an Dec which implements the custom method +signatures required by gogoproto. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `base_account` | [BaseAccount](#cosmos.auth.v1beta1.BaseAccount) | | | -| `name` | [string](#string) | | | -| `permissions` | [string](#string) | repeated | | +| `denom` | [string](#string) | | | +| `amount` | [string](#string) | | | - + + +### DecProto +DecProto defines a Protobuf wrapper around a Dec object. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `dec` | [string](#string) | | | + + + + + + + + +### IntProto +IntProto defines a Protobuf wrapper around an Int object. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `int` | [string](#string) | | | + + + + + + + + + + + + + + + + +

Top

+ +## cosmos/airdrop/v1beta1/airdrop.proto + + + + + +### ActiveFund +ActiveFund describes an active fund on the network + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | | +| `fund` | [Fund](#cosmos.airdrop.v1beta1.Fund) | | | + + + + + + + + +### Fund +Fund defines a structure for a fund that is being distributed to network stakers + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | The amount of fund that is remaining | +| `drip_amount` | [string](#string) | | The amount of funds that should be removed from the fund every block | + + + + + + + ### Params -Params defines the parameters for the auth module. +Params define the module parameters | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `max_memo_characters` | [uint64](#uint64) | | | -| `tx_sig_limit` | [uint64](#uint64) | | | -| `tx_size_cost_per_byte` | [uint64](#uint64) | | | -| `sig_verify_cost_ed25519` | [uint64](#uint64) | | | -| `sig_verify_cost_secp256k1` | [uint64](#uint64) | | | +| `allow_list` | [string](#string) | repeated | The set of addresses which are allowed to create are drop funds | @@ -763,23 +862,23 @@ Params defines the parameters for the auth module. - +

Top

-## cosmos/auth/v1beta1/genesis.proto +## cosmos/airdrop/v1beta1/genesis.proto - + ### GenesisState -GenesisState defines the auth module's genesis state. +GenesisState defines the bank module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#cosmos.auth.v1beta1.Params) | | params defines all the paramaters of the module. | -| `accounts` | [google.protobuf.Any](#google.protobuf.Any) | repeated | accounts are the accounts present at genesis. | +| `params` | [Params](#cosmos.airdrop.v1beta1.Params) | | params defines all the parameters of the module. | +| `funds` | [ActiveFund](#cosmos.airdrop.v1beta1.ActiveFund) | repeated | balances is an array containing the balances of all the accounts. | @@ -795,62 +894,155 @@ GenesisState defines the auth module's genesis state. - +

Top

-## cosmos/auth/v1beta1/query.proto +## cosmos/base/query/v1beta1/pagination.proto - + -### QueryAccountRequest -QueryAccountRequest is the request type for the Query/Account RPC method. +### PageRequest +PageRequest is to be embedded in gRPC request messages for efficient +pagination. Ex: + + message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | address defines the address to query for. | +| `key` | [bytes](#bytes) | | key is a value returned in PageResponse.next_key to begin querying the next page most efficiently. Only one of offset or key should be set. | +| `offset` | [uint64](#uint64) | | offset is a numeric offset that can be used when key is unavailable. It is less efficient than using key. Only one of offset or key should be set. | +| `limit` | [uint64](#uint64) | | limit is the total number of results to be returned in the result page. If left empty it will default to a value to be set by each app. | +| `count_total` | [bool](#bool) | | count_total is set to true to indicate that the result set should include a count of the total number of items available for pagination in UIs. count_total is only respected when offset is used. It is ignored when key is set. | - + -### QueryAccountResponse -QueryAccountResponse is the response type for the Query/Account RPC method. +### PageResponse +PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `account` | [google.protobuf.Any](#google.protobuf.Any) | | account defines the account of the corresponding address. | +| `next_key` | [bytes](#bytes) | | next_key is the key to be passed to PageRequest.key to query the next page most efficiently | +| `total` | [uint64](#uint64) | | total is total number of results available if PageRequest.count_total was set, its value is undefined otherwise | + - + + + + + + + + + +

Top

+ +## cosmos/airdrop/v1beta1/query.proto + + + + + +### QueryAllFundsRequest +QueryAllFundsRequest defines the request for querying all the funds + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | | + + + + + + + + +### QueryAllFundsResponse +QueryAllFundsResponse defines the response for querying all the funds + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `funds` | [ActiveFund](#cosmos.airdrop.v1beta1.ActiveFund) | repeated | | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | | + + + + + + + + +### QueryFundRequest +QueryFundRequest defines the request for querying a specific fund + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [string](#string) | | | + + + + + + + + +### QueryFundResponse +QueryFundResponse defines the response for querying a specific fund + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `fund` | [Fund](#cosmos.airdrop.v1beta1.Fund) | | | + + + + + + + ### QueryParamsRequest -QueryParamsRequest is the request type for the Query/Params RPC method. +QueryParamsRequest defines the request type for querying x/airdrop parameters. - + ### QueryParamsResponse -QueryParamsResponse is the response type for the Query/Params RPC method. +QueryParamsResponse defines the response type for querying x/airdrop parameters. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#cosmos.auth.v1beta1.Params) | | params defines the parameters of the module. | +| `params` | [Params](#cosmos.airdrop.v1beta1.Params) | | | @@ -863,89 +1055,233 @@ QueryParamsResponse is the response type for the Query/Params RPC method. - + ### Query Query defines the gRPC querier service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Account` | [QueryAccountRequest](#cosmos.auth.v1beta1.QueryAccountRequest) | [QueryAccountResponse](#cosmos.auth.v1beta1.QueryAccountResponse) | Account returns account details based on address. | GET|/cosmos/auth/v1beta1/accounts/{address}| -| `Params` | [QueryParamsRequest](#cosmos.auth.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#cosmos.auth.v1beta1.QueryParamsResponse) | Params queries all parameters. | GET|/cosmos/auth/v1beta1/params| +| `AllFunds` | [QueryAllFundsRequest](#cosmos.airdrop.v1beta1.QueryAllFundsRequest) | [QueryAllFundsResponse](#cosmos.airdrop.v1beta1.QueryAllFundsResponse) | AllFunds queries all active airdrop funds | GET|/cosmos/airdrop/v1beta1/funds| +| `Fund` | [QueryFundRequest](#cosmos.airdrop.v1beta1.QueryFundRequest) | [QueryFundResponse](#cosmos.airdrop.v1beta1.QueryFundResponse) | Fund queries a specific airdrop fund | GET|/cosmos/airdrop/v1beta1/funds/{address}| +| `Params` | [QueryParamsRequest](#cosmos.airdrop.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#cosmos.airdrop.v1beta1.QueryParamsResponse) | Params queries the current modules parameters | GET|/cosmos/airdrop/v1beta1/params| - +

Top

-## cosmos/base/v1beta1/coin.proto +## cosmos/airdrop/v1beta1/tx.proto - + -### Coin -Coin defines a token with a denomination and an amount. +### MsgAirDrop +MsgAirDrop represents a message to create an airdrop fund for distribution + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `from_address` | [string](#string) | | | +| `fund` | [Fund](#cosmos.airdrop.v1beta1.Fund) | | | + + + + + + + + +### MsgAirDropResponse +MsgAirDropResponse represents a message for the response -NOTE: The amount field is an Int which implements the custom method -signatures required by gogoproto. + + + + + + + + + + + + + +### Msg +Msg defines the airdrop Msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `AirDrop` | [MsgAirDrop](#cosmos.airdrop.v1beta1.MsgAirDrop) | [MsgAirDropResponse](#cosmos.airdrop.v1beta1.MsgAirDropResponse) | AirDrop defines a method for sending coins to the airdrop module for distribution | | + + + + + + +

Top

+ +## cosmos/auth/v1beta1/auth.proto + + + + + +### BaseAccount +BaseAccount defines a base account type. It contains all the necessary fields +for basic account functionality. Any custom account type should extend this +type for additional functionality (e.g. vesting). | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `denom` | [string](#string) | | | -| `amount` | [string](#string) | | | +| `address` | [string](#string) | | | +| `pub_key` | [google.protobuf.Any](#google.protobuf.Any) | | | +| `account_number` | [uint64](#uint64) | | | +| `sequence` | [uint64](#uint64) | | | - + -### DecCoin -DecCoin defines a token with a denomination and a decimal amount. +### ModuleAccount +ModuleAccount defines an account for modules that holds coins on a pool. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `base_account` | [BaseAccount](#cosmos.auth.v1beta1.BaseAccount) | | | +| `name` | [string](#string) | | | +| `permissions` | [string](#string) | repeated | | -NOTE: The amount field is an Dec which implements the custom method -signatures required by gogoproto. + + + + + + + +### Params +Params defines the parameters for the auth module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `denom` | [string](#string) | | | -| `amount` | [string](#string) | | | +| `max_memo_characters` | [uint64](#uint64) | | | +| `tx_sig_limit` | [uint64](#uint64) | | | +| `tx_size_cost_per_byte` | [uint64](#uint64) | | | +| `sig_verify_cost_ed25519` | [uint64](#uint64) | | | +| `sig_verify_cost_secp256k1` | [uint64](#uint64) | | | + - + -### DecProto -DecProto defines a Protobuf wrapper around a Dec object. + + + + + + + +

Top

+ +## cosmos/auth/v1beta1/genesis.proto + + + + + +### GenesisState +GenesisState defines the auth module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `dec` | [string](#string) | | | +| `params` | [Params](#cosmos.auth.v1beta1.Params) | | params defines all the paramaters of the module. | +| `accounts` | [google.protobuf.Any](#google.protobuf.Any) | repeated | accounts are the accounts present at genesis. | + - + -### IntProto -IntProto defines a Protobuf wrapper around an Int object. + + + + + + + +

Top

+ +## cosmos/auth/v1beta1/query.proto + + + + + +### QueryAccountRequest +QueryAccountRequest is the request type for the Query/Account RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `int` | [string](#string) | | | +| `address` | [string](#string) | | address defines the address to query for. | + + + + + + + + +### QueryAccountResponse +QueryAccountResponse is the response type for the Query/Account RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `account` | [google.protobuf.Any](#google.protobuf.Any) | | account defines the account of the corresponding address. | + + + + + + + + +### QueryParamsRequest +QueryParamsRequest is the request type for the Query/Params RPC method. + + + + + + + + +### QueryParamsResponse +QueryParamsResponse is the response type for the Query/Params RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#cosmos.auth.v1beta1.Params) | | params defines the parameters of the module. | @@ -957,6 +1293,17 @@ IntProto defines a Protobuf wrapper around an Int object. + + + +### Query +Query defines the gRPC querier service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Account` | [QueryAccountRequest](#cosmos.auth.v1beta1.QueryAccountRequest) | [QueryAccountResponse](#cosmos.auth.v1beta1.QueryAccountResponse) | Account returns account details based on address. | GET|/cosmos/auth/v1beta1/accounts/{address}| +| `Params` | [QueryParamsRequest](#cosmos.auth.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#cosmos.auth.v1beta1.QueryParamsResponse) | Params queries all parameters. | GET|/cosmos/auth/v1beta1/params| + @@ -1136,68 +1483,6 @@ GenesisState defines the bank module's genesis state. - - - - - - - - - - - -

Top

- -## cosmos/base/query/v1beta1/pagination.proto - - - - - -### PageRequest -PageRequest is to be embedded in gRPC request messages for efficient -pagination. Ex: - - message SomeRequest { - Foo some_parameter = 1; - PageRequest pagination = 2; - } - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `key` | [bytes](#bytes) | | key is a value returned in PageResponse.next_key to begin querying the next page most efficiently. Only one of offset or key should be set. | -| `offset` | [uint64](#uint64) | | offset is a numeric offset that can be used when key is unavailable. It is less efficient than using key. Only one of offset or key should be set. | -| `limit` | [uint64](#uint64) | | limit is the total number of results to be returned in the result page. If left empty it will default to a value to be set by each app. | -| `count_total` | [bool](#bool) | | count_total is set to true to indicate that the result set should include a count of the total number of items available for pagination in UIs. count_total is only respected when offset is used. It is ignored when key is set. | - - - - - - - - -### PageResponse -PageResponse is to be embedded in gRPC response messages where the -corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `next_key` | [bytes](#bytes) | | next_key is the key to be passed to PageRequest.key to query the next page most efficiently | -| `total` | [uint64](#uint64) | | total is total number of results available if PageRequest.count_total was set, its value is undefined otherwise | - - - - - diff --git a/proto/cosmos/airdrop/v1beta1/airdrop.proto b/proto/cosmos/airdrop/v1beta1/airdrop.proto new file mode 100644 index 000000000000..dd66cbe06275 --- /dev/null +++ b/proto/cosmos/airdrop/v1beta1/airdrop.proto @@ -0,0 +1,35 @@ +syntax = "proto3"; +package cosmos.airdrop.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/airdrop/types"; + +// Fund defines a structure for a fund that is being distributed to network stakers +message Fund { + option (gogoproto.equal) = true; + + // The amount of fund that is remaining + cosmos.base.v1beta1.Coin amount = 1 [(gogoproto.moretags) = "yaml:\"amount\""]; + + // The amount of funds that should be removed from the fund every block + string drip_amount = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"drip_amount\"" + ]; +} + +// ActiveFund describes an active fund on the network +message ActiveFund { + string sender = 1 [(gogoproto.moretags) = "yaml:\"sender\""]; + Fund fund = 2 [(gogoproto.moretags) = "yaml:\"blocks_remaining\""]; +} + +// Params define the module parameters +message Params { + // The set of addresses which are allowed to create are drop funds + repeated string allow_list = 1 [(gogoproto.moretags) = "yaml:\"allow_list\""]; +} diff --git a/proto/cosmos/airdrop/v1beta1/genesis.proto b/proto/cosmos/airdrop/v1beta1/genesis.proto new file mode 100644 index 000000000000..ff5f60572f45 --- /dev/null +++ b/proto/cosmos/airdrop/v1beta1/genesis.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package cosmos.airdrop.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/airdrop/v1beta1/airdrop.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/airdrop/types"; + +// GenesisState defines the bank module's genesis state. +message GenesisState { + // params defines all the parameters of the module. + Params params = 1 [(gogoproto.nullable) = false]; + + // balances is an array containing the balances of all the accounts. + repeated ActiveFund funds = 2 [(gogoproto.nullable) = false]; +} diff --git a/proto/cosmos/airdrop/v1beta1/query.proto b/proto/cosmos/airdrop/v1beta1/query.proto new file mode 100644 index 000000000000..098dc6a5d409 --- /dev/null +++ b/proto/cosmos/airdrop/v1beta1/query.proto @@ -0,0 +1,57 @@ +syntax = "proto3"; +package cosmos.airdrop.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "cosmos/airdrop/v1beta1/airdrop.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/airdrop/types"; + +// Query defines the gRPC querier service. +service Query { + + // AllFunds queries all active airdrop funds + rpc AllFunds(QueryAllFundsRequest) returns (QueryAllFundsResponse) { + option (google.api.http).get = "/cosmos/airdrop/v1beta1/funds"; + } + + // Fund queries a specific airdrop fund + rpc Fund(QueryFundRequest) returns (QueryFundResponse) { + option (google.api.http).get = "/cosmos/airdrop/v1beta1/funds/{address}"; + } + + // Params queries the current modules parameters + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/airdrop/v1beta1/params"; + } +} + +// QueryAllFundsRequest defines the request for querying all the funds +message QueryAllFundsRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryAllFundsResponse defines the response for querying all the funds +message QueryAllFundsResponse { + repeated cosmos.airdrop.v1beta1.ActiveFund funds = 1; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryFundRequest defines the request for querying a specific fund +message QueryFundRequest { + string address = 1 [(gogoproto.nullable) = true]; +} + +// QueryFundResponse defines the response for querying a specific fund +message QueryFundResponse { + cosmos.airdrop.v1beta1.Fund fund = 1; +} + +// QueryParamsRequest defines the request type for querying x/airdrop parameters. +message QueryParamsRequest {} + +// QueryParamsResponse defines the response type for querying x/airdrop parameters. +message QueryParamsResponse { + Params params = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/cosmos/airdrop/v1beta1/tx.proto b/proto/cosmos/airdrop/v1beta1/tx.proto new file mode 100644 index 000000000000..e01a0210d1c9 --- /dev/null +++ b/proto/cosmos/airdrop/v1beta1/tx.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package cosmos.airdrop.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/airdrop/v1beta1/airdrop.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/airdrop/types"; + +// Msg defines the airdrop Msg service. +service Msg { + + // AirDrop defines a method for sending coins to the airdrop module for distribution + rpc AirDrop(MsgAirDrop) returns (MsgAirDropResponse); +} + +// MsgAirDrop represents a message to create an airdrop fund for distribution +message MsgAirDrop { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""]; + Fund fund = 2 [(gogoproto.moretags) = "yaml:\"fund\""]; +} + +// MsgAirDropResponse represents a message for the response +message MsgAirDropResponse {} diff --git a/simapp/app.go b/simapp/app.go index 5eebfebb0f48..3107299dea5d 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -1,6 +1,7 @@ package simapp import ( + airdroptypes "github.com/cosmos/cosmos-sdk/x/airdrop/types" "io" "net/http" "os" @@ -30,6 +31,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/version" + airdropkeeper "github.com/cosmos/cosmos-sdk/x/airdrop/keeper" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/ante" authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest" @@ -125,6 +127,7 @@ var ( maccPerms = map[string][]string{ authtypes.FeeCollectorName: nil, distrtypes.ModuleName: nil, + airdroptypes.ModuleName: nil, minttypes.ModuleName: {authtypes.Minter}, stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, @@ -169,6 +172,7 @@ type SimApp struct { IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly EvidenceKeeper evidencekeeper.Keeper TransferKeeper ibctransferkeeper.Keeper + AirdropKeeper *airdropkeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -213,6 +217,7 @@ func NewSimApp( minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, + airdroptypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -296,6 +301,11 @@ func NewSimApp( app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, ) + app.AirdropKeeper = airdropkeeper.NewKeeper( + appCodec, keys[airdroptypes.StoreKey], app.GetSubspace(airdroptypes.ModuleName), app.BankKeeper, + authtypes.FeeCollectorName, + ) + transferModule := transfer.NewAppModule(app.TransferKeeper) // NOTE: the IBC mock keeper and application module is used only for testing core IBC. Do @@ -602,6 +612,7 @@ func initParamsKeeper(appCodec codec.BinaryMarshaler, legacyAmino *codec.LegacyA paramsKeeper.Subspace(crisistypes.ModuleName) paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibchost.ModuleName) + paramsKeeper.Subspace(airdroptypes.ModuleName) return paramsKeeper } diff --git a/x/airdrop/abci.go b/x/airdrop/abci.go new file mode 100644 index 000000000000..b9d44560f0cc --- /dev/null +++ b/x/airdrop/abci.go @@ -0,0 +1,18 @@ +package airdrop + +import ( + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/airdrop/keeper" + "github.com/cosmos/cosmos-sdk/x/airdrop/types" + "time" +) + +func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) + + _, err := k.DripAllFunds(ctx) + if err != nil { + ctx.Logger().Error("Unable to perform airdrop drip", "err", err.Error()) + } +} diff --git a/x/airdrop/client/cli/query.go b/x/airdrop/client/cli/query.go new file mode 100644 index 000000000000..ea0eec4fb03a --- /dev/null +++ b/x/airdrop/client/cli/query.go @@ -0,0 +1,70 @@ +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/cosmos/cosmos-sdk/x/airdrop/types" + "github.com/spf13/cobra" + "strings" +) + +func GetQueryCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the bank module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + GetFunds(), + ) + + return cmd +} + +func GetFunds() *cobra.Command { + cmd := &cobra.Command{ + Use: "funds", + Short: "Query the currently active airdrop funds", + Long: strings.TrimSpace( + fmt.Sprintf(`Query the currently active airdrop funds. + +Example: + $ %s query %s funds +`, + 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) + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + params := types.NewQueryAllFundsRequest(pageReq) + + res, err := queryClient.AllFunds(cmd.Context(), params) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "all funds") + + return cmd +} diff --git a/x/airdrop/client/cli/tx.go b/x/airdrop/client/cli/tx.go new file mode 100644 index 000000000000..1dec79715394 --- /dev/null +++ b/x/airdrop/client/cli/tx.go @@ -0,0 +1,79 @@ +package cli + +import ( + "fmt" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/version" + "github.com/cosmos/cosmos-sdk/x/airdrop/types" + "github.com/spf13/cobra" + "strings" +) + +func GetTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Airdrop transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + txCmd.AddCommand(NewCreateTxCmd()) + + return txCmd +} + +func NewCreateTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "create [from_key_or_address] [amount] [drip_amount]", + Short: `Creates a new airdrop fund. Note, the '--from' flag is +ignored as it is implied from [from_key_or_address].`, + Long: strings.TrimSpace( + fmt.Sprintf(`Creates a new airdrop fund. + +When creating an airdrop fund, the sender transfers a specified amount of funds to the block chain along with +the drip amount. Every block up to a maximum of drip_amount of funds are added to the rewards of the current block. +The maximum duration of the airdrop is therefore calculated as amount / drip_amount blocks. + +Example: + $ %s tx %s create [address] [amount] [drip_amount] + $ %s tx %s create fetch1se8mjg4mtvy8zaf4599m84xz4atn59dlqmwhnl 200000000000000000000afet 2000000000000000000 +`, + version.AppName, types.ModuleName, version.AppName, types.ModuleName, + ), + ), + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + cmd.Flags().Set(flags.FlagFrom, args[0]) + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + coin, err := sdk.ParseCoinNormalized(args[1]) + if err != nil { + return err + } + + dripAmount, okay := sdk.NewIntFromString(args[2]) + if !okay || !dripAmount.IsPositive() { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%s is not a valid drip rate", args[2]) + } + + msg := types.NewMsgAirDrop(clientCtx.GetFromAddress(), coin, dripAmount) + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/airdrop/handler.go b/x/airdrop/handler.go new file mode 100644 index 000000000000..7066c9aa3b32 --- /dev/null +++ b/x/airdrop/handler.go @@ -0,0 +1,25 @@ +package airdrop + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/airdrop/keeper" + "github.com/cosmos/cosmos-sdk/x/airdrop/types" +) + +func NewHandler(k keeper.Keeper) sdk.Handler { + msgServer := keeper.NewMsgServerImpl(k) + + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + ctx = ctx.WithEventManager(sdk.NewEventManager()) + + switch msg := msg.(type) { + case *types.MsgAirDrop: + res, err := msgServer.AirDrop(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + + default: + return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized airdrop message type: %T", msg) + } + } +} diff --git a/x/airdrop/keeper/genesis.go b/x/airdrop/keeper/genesis.go new file mode 100644 index 000000000000..b3fac84da493 --- /dev/null +++ b/x/airdrop/keeper/genesis.go @@ -0,0 +1,26 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/airdrop/types" +) + +func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { + k.SetParams(ctx, genState.Params) + err := k.SetActiveFunds(ctx, genState.Funds) + if err != nil { + panic(err) + } +} + +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + activeFunds, err := k.GetActiveFunds(ctx) + if err != nil { + panic(err) + } + + return types.NewGenesisState( + k.GetParams(ctx), + activeFunds, + ) +} diff --git a/x/airdrop/keeper/grpc_query.go b/x/airdrop/keeper/grpc_query.go new file mode 100644 index 000000000000..aea5437db8ee --- /dev/null +++ b/x/airdrop/keeper/grpc_query.go @@ -0,0 +1,81 @@ +package keeper + +import ( + "context" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/cosmos/cosmos-sdk/x/airdrop/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +var _ types.QueryServer = Keeper{} + +func (k Keeper) AllFunds(ctx context.Context, req *types.QueryAllFundsRequest) (*types.QueryAllFundsResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + store := sdkCtx.KVStore(k.storeKey) + activeFundStore := prefix.NewStore(store, types.ActiveFundKeyPrefix) + + var activeFunds []*types.ActiveFund + pageRes, err := query.Paginate(activeFundStore, req.Pagination, func(key, value []byte) error { + account := sdk.AccAddress(key) + + var fund types.Fund + err := k.cdc.UnmarshalBinaryBare(value, &fund) + if err != nil { + return err + } + + activeFunds = append(activeFunds, &types.ActiveFund{ + Sender: account.String(), + Fund: &fund, + }) + return nil + }) + + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "paginate: %v", err) + } + + return &types.QueryAllFundsResponse{Funds: activeFunds, Pagination: pageRes}, nil +} + +func (k Keeper) Fund(ctx context.Context, req *types.QueryFundRequest) (*types.QueryFundResponse, error) { + if req.Address == "" { + return nil, status.Error(codes.InvalidArgument, "address cannot be empty") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + address, err := sdk.AccAddressFromBech32(req.Address) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid address: %s", err.Error()) + } + + fund, err := k.GetFund(sdkCtx, address) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "unable to lookup funds: %s", err.Error()) + } + + if fund == nil { + return nil, status.Errorf(codes.NotFound, "unable to find fund") + } + + resp := &types.QueryFundResponse{ + Fund: fund, + } + + return resp, nil +} + +func (k Keeper) Params(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + params := k.GetParams(sdkCtx) + + return &types.QueryParamsResponse{Params: params}, nil +} diff --git a/x/airdrop/keeper/grpc_query_test.go b/x/airdrop/keeper/grpc_query_test.go new file mode 100644 index 000000000000..9aa3e6dbcec0 --- /dev/null +++ b/x/airdrop/keeper/grpc_query_test.go @@ -0,0 +1,287 @@ +package keeper_test + +import ( + gocontext "context" + "fmt" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/simapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/cosmos/cosmos-sdk/x/airdrop/types" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "testing" +) + +var ( + queryAddr1 = sdk.AccAddress([]byte("addr1_______________")) + queryAddr2 = sdk.AccAddress([]byte("addr2_______________")) +) + +type KeeperGrpcQueryTestSuite struct { + suite.Suite + + app *simapp.SimApp + ctx sdk.Context + queryClient types.QueryClient +} + +func (s *KeeperGrpcQueryTestSuite) SetupTest() { + s.app = simapp.Setup(false) + s.ctx = s.app.BaseApp.NewContext(false, tmproto.Header{}) + s.app.AirdropKeeper.SetParams(s.ctx, types.NewParams(queryAddr1.String(), queryAddr2.String())) + + queryHelper := baseapp.NewQueryServerTestHelper(s.ctx, s.app.InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, s.app.AirdropKeeper) + s.queryClient = types.NewQueryClient(queryHelper) +} + +func (s *KeeperGrpcQueryTestSuite) TestQueryFund() { + var ( + req *types.QueryFundRequest + expResponse types.QueryFundResponse + ) + + testCases := []struct { + msg string + malleate func() + expPass bool + }{ + { + "without an address being specified", + func() { + req = &types.QueryFundRequest{} + expResponse = types.QueryFundResponse{} + }, + false, + }, + { + "with an address being specified", + func() { + amount := sdk.NewInt64Coin(sdk.DefaultBondDenom, 2000) + fund := types.Fund{ + Amount: &amount, + DripAmount: sdk.NewInt(40), + } + err := s.app.BankKeeper.SetBalance(s.ctx, queryAddr1, amount) + if err != nil { + panic(err) + } + err = s.app.AirdropKeeper.AddFund(s.ctx, queryAddr1, fund) + if err != nil { + panic(err) + } + + req = &types.QueryFundRequest{ + Address: queryAddr1.String(), + } + expResponse = types.QueryFundResponse{Fund: &fund} + }, + true, + }, + { + "with an address being specified but fund not present", + func() { + req = &types.QueryFundRequest{ + Address: queryAddr1.String(), + } + expResponse = types.QueryFundResponse{} + }, + false, + }, + } + + for _, tc := range testCases { + s.Run(fmt.Sprintf("Case %s", tc.msg), func() { + s.SetupTest() // reset + + tc.malleate() + + res, err := s.queryClient.Fund(gocontext.Background(), req) + + if tc.expPass { + s.Require().NoError(err) + s.Require().NotNil(res) + s.Require().Equal(&expResponse, res) + } else { + s.Require().Error(err) + } + }) + } +} + +func (s *KeeperGrpcQueryTestSuite) TestQueryAllFund() { + amount := sdk.NewInt64Coin(sdk.DefaultBondDenom, 2000) + fund := types.Fund{ + Amount: &amount, + DripAmount: sdk.NewInt(40), + } + + var ( + req *types.QueryAllFundsRequest + expResponse types.QueryAllFundsResponse + ) + + testCases := []struct { + msg string + malleate func() + expPass bool + }{ + { + "when no funds are present", + func() { + req = &types.QueryAllFundsRequest{} + expResponse = types.QueryAllFundsResponse{ + Pagination: &query.PageResponse{ + NextKey: nil, + Total: 0, + }, + } + }, + true, + }, + { + "when funds are present", + func() { + err := s.app.BankKeeper.SetBalance(s.ctx, queryAddr1, *fund.Amount) + if err != nil { + panic(err) + } + err = s.app.BankKeeper.SetBalance(s.ctx, queryAddr2, *fund.Amount) + if err != nil { + panic(err) + } + err = s.app.AirdropKeeper.AddFund(s.ctx, queryAddr1, fund) + if err != nil { + panic(err) + } + err = s.app.AirdropKeeper.AddFund(s.ctx, queryAddr2, fund) + if err != nil { + panic(err) + } + + req = &types.QueryAllFundsRequest{} + expResponse = types.QueryAllFundsResponse{ + Funds: []*types.ActiveFund{ + { + Sender: queryAddr1.String(), + Fund: &fund, + }, + { + Sender: queryAddr2.String(), + Fund: &fund, + }, + }, + Pagination: &query.PageResponse{ + NextKey: nil, + Total: 2, + }, + } + }, + true, + }, + { + "when funds are present with page 1", + func() { + err := s.app.BankKeeper.SetBalance(s.ctx, queryAddr1, *fund.Amount) + if err != nil { + panic(err) + } + err = s.app.BankKeeper.SetBalance(s.ctx, queryAddr2, *fund.Amount) + if err != nil { + panic(err) + } + err = s.app.AirdropKeeper.AddFund(s.ctx, queryAddr1, fund) + if err != nil { + panic(err) + } + err = s.app.AirdropKeeper.AddFund(s.ctx, queryAddr2, fund) + if err != nil { + panic(err) + } + + req = &types.QueryAllFundsRequest{ + Pagination: &query.PageRequest{ + Key: nil, + Offset: 0, + Limit: 1, + CountTotal: false, + }, + } + expResponse = types.QueryAllFundsResponse{ + Funds: []*types.ActiveFund{ + { + Sender: queryAddr1.String(), + Fund: &fund, + }, + }, + Pagination: &query.PageResponse{ + NextKey: queryAddr2, + }, + } + }, + true, + }, + { + "when funds are present with page 2", + func() { + err := s.app.BankKeeper.SetBalance(s.ctx, queryAddr1, *fund.Amount) + if err != nil { + panic(err) + } + err = s.app.BankKeeper.SetBalance(s.ctx, queryAddr2, *fund.Amount) + if err != nil { + panic(err) + } + err = s.app.AirdropKeeper.AddFund(s.ctx, queryAddr1, fund) + if err != nil { + panic(err) + } + err = s.app.AirdropKeeper.AddFund(s.ctx, queryAddr2, fund) + if err != nil { + panic(err) + } + + req = &types.QueryAllFundsRequest{ + Pagination: &query.PageRequest{ + Key: nil, + Offset: 1, + Limit: 1, + CountTotal: false, + }, + } + expResponse = types.QueryAllFundsResponse{ + Funds: []*types.ActiveFund{ + { + Sender: queryAddr2.String(), + Fund: &fund, + }, + }, + Pagination: &query.PageResponse{}, + } + }, + true, + }, + } + + for _, tc := range testCases { + s.Run(fmt.Sprintf("Case %s", tc.msg), func() { + s.SetupTest() // reset + + tc.malleate() + + res, err := s.queryClient.AllFunds(gocontext.Background(), req) + + if tc.expPass { + s.Require().NoError(err) + s.Require().Equal(&expResponse, res) + } else { + s.Require().Error(err) + } + }) + } +} + +func TestKeeperGrpcQueryTestSuite(t *testing.T) { + suite.Run(t, new(KeeperGrpcQueryTestSuite)) +} diff --git a/x/airdrop/keeper/keeper.go b/x/airdrop/keeper/keeper.go new file mode 100644 index 000000000000..557df45ff884 --- /dev/null +++ b/x/airdrop/keeper/keeper.go @@ -0,0 +1,224 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/airdrop/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/tendermint/tendermint/libs/log" +) + +type Keeper struct { + bankKeeper types.BankKeeper + cdc codec.BinaryMarshaler + storeKey sdk.StoreKey + feeCollectorName string + paramSpace paramtypes.Subspace +} + +type FundPair struct { + Fund types.Fund + Account sdk.AccAddress +} + +func NewKeeper(cdc codec.BinaryMarshaler, storeKey sdk.StoreKey, paramSpace paramtypes.Subspace, bankKeeper types.BankKeeper, feeCollectorName string) *Keeper { + + // set KeyTable if it has not already been set + if !paramSpace.HasKeyTable() { + paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) + } + + return &Keeper{ + bankKeeper: bankKeeper, + cdc: cdc, + storeKey: storeKey, + feeCollectorName: feeCollectorName, + paramSpace: paramSpace, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", "x/"+types.ModuleName) +} + +func (k Keeper) AddFund(ctx sdk.Context, sender sdk.AccAddress, fund types.Fund) error { + params := k.GetParams(ctx) + if !params.IsAllowedSender(sender) { + return sdkerrors.Wrapf( + sdkerrors.ErrConflict, + "Non-whitelist sender %s", sender.String(), + ) + } + + // validate that the fund we are adding is correct + err := fund.ValidateBasic() + if err != nil { + return err + } + + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, sdk.NewCoins(*fund.Amount)) + if err != nil { + return err + } + + return k.setFund(ctx, sender, fund, false) +} + +func (k Keeper) UpdateFund(ctx sdk.Context, sender sdk.AccAddress, fund types.Fund) error { + return k.setFund(ctx, sender, fund, true) +} + +func (k Keeper) setFund(ctx sdk.Context, sender sdk.AccAddress, fund types.Fund, shouldExist bool) error { + key := types.GetActiveFundKey(sender) + + // check that we do not already have fund from this account + store := ctx.KVStore(k.storeKey) + + // check to see if the fund should exist or not + if shouldExist { + if !store.Has(key) { + return sdkerrors.Wrapf(sdkerrors.ErrConflict, "Fund from sender does not exists") + } + + // if a fund is updated with a zero or negative remaining amount then simple delete the entry + if fund.Amount.IsNegative() || fund.Amount.IsZero() { + store.Delete(key) // remove the entry + } else { + store.Set(key, k.cdc.MustMarshalBinaryBare(&fund)) // update the entry + } + + } else { + if store.Has(key) { + return sdkerrors.Wrapf(sdkerrors.ErrConflict, "Fund from sender already exists") + } + + if fund.Amount.IsNegative() || fund.Amount.IsZero() { + return sdkerrors.Wrapf(sdkerrors.ErrConflict, "Fund has a zero or negative amount") + } + + // update the fund + store.Set(key, k.cdc.MustMarshalBinaryBare(&fund)) + } + + return nil +} + +func (k Keeper) GetFund(ctx sdk.Context, sender sdk.AccAddress) (*types.Fund, error) { + key := types.GetActiveFundKey(sender) + + store := ctx.KVStore(k.storeKey) + bz := store.Get(key) + if bz == nil { + return nil, nil + } + + fund := &types.Fund{} + err := k.cdc.UnmarshalBinaryBare(bz, fund) + if err != nil { + return nil, err + } + return fund, nil +} + +func (k Keeper) GetAllFunds(ctx sdk.Context) ([]FundPair, error) { + store := ctx.KVStore(k.storeKey) + iter := sdk.KVStorePrefixIterator(store, types.ActiveFundKeyPrefix) + defer iter.Close() + + funds := []FundPair{} + for ; iter.Valid(); iter.Next() { + pair := FundPair{ + Account: types.GetAddressFromActiveFundKey(iter.Key()), + } + + err := k.cdc.UnmarshalBinaryBare(iter.Value(), &pair.Fund) + if err != nil { + return nil, err + } + + funds = append(funds, pair) + } + + return funds, nil +} + +func (k Keeper) DripAllFunds(ctx sdk.Context) (sdk.Coins, error) { + drips := sdk.NewCoins() + funds, err := k.GetAllFunds(ctx) + if err != nil { + return nil, err + } + + for _, fund := range funds { + newFund, drip := fund.Fund.Drip() // calculate the drip for this block + + // update the fund - we either delete or update + err := k.UpdateFund(ctx, fund.Account, newFund) + if err != nil { + k.Logger(ctx).Error("Unable to drip fund", "err", err.Error()) + continue // ignore this drip + } + + // update the drips + drips = drips.Add(drip) + } + + // send the funds to the fee collector module + err = k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, k.feeCollectorName, drips) + if err != nil { + return nil, err + } + + return drips, nil +} + +func (k Keeper) GetActiveFunds(ctx sdk.Context) ([]types.ActiveFund, error) { + allFunds, err := k.GetAllFunds(ctx) + if err != nil { + return nil, err + } + + activeFunds := make([]types.ActiveFund, len(allFunds)) + for i, fund := range allFunds { + activeFunds[i] = types.ActiveFund{ + Sender: fund.Account.String(), + Fund: &fund.Fund, + } + } + + return activeFunds, nil +} + +// SetActiveFunds forcibly sets the active funds that should be used +func (k Keeper) SetActiveFunds(ctx sdk.Context, funds []types.ActiveFund) error { + coins := sdk.NewCoins() + + for _, fund := range funds { + account, err := sdk.AccAddressFromBech32(fund.Sender) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrConflict, "Invalid address: %s", fund.Sender) + } + + if fund.Fund == nil { + return sdkerrors.Wrapf(sdkerrors.ErrConflict, "Invalid fund") + } + + // update the coins + coins = coins.Add(*fund.Fund.Amount) + + err = k.setFund(ctx, account, *fund.Fund, false) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrConflict, "Failed to set active fund: %s", err.Error()) + } + } + + // finally set the balance for this module + err := k.bankKeeper.SetBalances(ctx, authtypes.NewModuleAddress(types.ModuleName), coins) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrConflict, "Failed to set active coins: %s", err.Error()) + } + + return nil +} diff --git a/x/airdrop/keeper/keeper_test.go b/x/airdrop/keeper/keeper_test.go new file mode 100644 index 000000000000..94aa2b7d799e --- /dev/null +++ b/x/airdrop/keeper/keeper_test.go @@ -0,0 +1,169 @@ +package keeper_test + +import ( + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/x/airdrop/types" + "testing" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +var ( + moduleAddress = authtypes.NewModuleAddress(types.ModuleName) + feeCollectorAddress = authtypes.NewModuleAddress(authtypes.FeeCollectorName) + addr1 = sdk.AccAddress([]byte("addr1_______________")) + addr2 = sdk.AccAddress([]byte("addr2_______________")) +) + +type KeeperTestSuite struct { + suite.Suite + + app *simapp.SimApp + ctx sdk.Context +} + +func (s *KeeperTestSuite) SetupTest() { + app := simapp.Setup(false) + s.app = app + s.ctx = app.BaseApp.NewContext(false, tmproto.Header{ + Time: time.Now(), + Height: 10, + }) + + s.app.AirdropKeeper.SetParams(s.ctx, types.NewParams(addr1.String(), addr2.String())) +} + +func (s *KeeperTestSuite) TestAddNewFund() { + amount := sdk.NewInt64Coin(sdk.DefaultBondDenom, 4000) + s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr1, amount)) // ensure the account is funded + + addrBalance := s.app.BankKeeper.GetBalance(s.ctx, addr1, sdk.DefaultBondDenom) + moduleBalance := s.app.BankKeeper.GetBalance(s.ctx, moduleAddress, sdk.DefaultBondDenom) + + // sanity check + s.Require().Equal(addrBalance, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(4000))) + s.Require().Equal(moduleBalance, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(0))) + + fund := types.Fund{ + Amount: &amount, + DripAmount: sdk.NewInt(40), + } + s.Require().NoError(s.app.AirdropKeeper.AddFund(s.ctx, addr1, fund)) + + addrBalance = s.app.BankKeeper.GetBalance(s.ctx, addr1, sdk.DefaultBondDenom) + moduleBalance = s.app.BankKeeper.GetBalance(s.ctx, moduleAddress, sdk.DefaultBondDenom) + + s.Require().Equal(addrBalance, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(0))) + s.Require().Equal(moduleBalance, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(4000))) +} + +func (s *KeeperTestSuite) TestCreateRetrieveFund() { + amount := sdk.NewInt64Coin(sdk.DefaultBondDenom, 4000) + s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr1, amount)) // ensure the account is funded + + fund := types.Fund{ + Amount: &amount, + DripAmount: sdk.NewInt(40), + } + s.Require().NoError(s.app.AirdropKeeper.AddFund(s.ctx, addr1, fund)) + + recoveredFund, err := s.app.AirdropKeeper.GetFund(s.ctx, addr1) + s.Require().NoError(err) + s.Require().Equal(*recoveredFund, fund) +} + +func (s *KeeperTestSuite) TestUnableToCreateDuplicateFunds() { + amount := sdk.NewInt64Coin(sdk.DefaultBondDenom, 4000) + addrAmount := sdk.NewInt64Coin(sdk.DefaultBondDenom, 8000) + s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr1, addrAmount)) // ensure the account is funded for the two funds + + fund := types.Fund{ + Amount: &amount, + DripAmount: sdk.NewInt(40), + } + s.Require().NoError(s.app.AirdropKeeper.AddFund(s.ctx, addr1, fund)) + s.Require().Error(s.app.AirdropKeeper.AddFund(s.ctx, addr1, fund)) // this should fail +} + +func (s *KeeperTestSuite) TestUnableToCreateFundWithNecessaryFunds() { + amount := sdk.NewInt64Coin(sdk.DefaultBondDenom, 4000) + addrAmount := sdk.NewInt64Coin(sdk.DefaultBondDenom, 2000) // not enough + s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr1, addrAmount)) // ensure the account is funded for the two funds + + fund := types.Fund{ + Amount: &amount, + DripAmount: sdk.NewInt(40), + } + s.Require().Error(s.app.AirdropKeeper.AddFund(s.ctx, addr1, fund)) // this should fail - user doesn't have enough funds +} + +func (s *KeeperTestSuite) TestQueryOfAllFunds() { + amount := sdk.NewInt64Coin(sdk.DefaultBondDenom, 4000) + fund := types.Fund{ + Amount: &amount, + DripAmount: sdk.NewInt(40), + } + s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr1, amount)) + s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr2, amount)) + + s.Require().NoError(s.app.AirdropKeeper.AddFund(s.ctx, addr1, fund)) + s.Require().NoError(s.app.AirdropKeeper.AddFund(s.ctx, addr2, fund)) + + funds, err := s.app.AirdropKeeper.GetAllFunds(s.ctx) + s.Require().NoError(err) + s.Require().Equal(len(funds), 2) + + s.Require().Equal(funds[0].Fund, fund) + s.Require().Equal(funds[0].Account, addr1) + + s.Require().Equal(funds[1].Fund, fund) + s.Require().Equal(funds[1].Account, addr2) + + moduleBalance := s.app.BankKeeper.GetBalance(s.ctx, moduleAddress, sdk.DefaultBondDenom) + s.Require().Equal(moduleBalance, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(8000))) +} + +func (s *KeeperTestSuite) TestFeeDrip() { + amount := sdk.NewInt64Coin(sdk.DefaultBondDenom, 4000) + fund1 := types.Fund{ + Amount: &amount, + DripAmount: sdk.NewInt(40), + } + fund2 := types.Fund{ + Amount: &amount, + DripAmount: sdk.NewInt(4000), // will only last one block + } + + s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr1, amount)) + s.Require().NoError(s.app.BankKeeper.SetBalance(s.ctx, addr2, amount)) + + s.Require().NoError(s.app.AirdropKeeper.AddFund(s.ctx, addr1, fund1)) + s.Require().NoError(s.app.AirdropKeeper.AddFund(s.ctx, addr2, fund2)) + + // check the balances + moduleBalance := s.app.BankKeeper.GetBalance(s.ctx, moduleAddress, sdk.DefaultBondDenom) + feeCollectorBalance := s.app.BankKeeper.GetBalance(s.ctx, feeCollectorAddress, sdk.DefaultBondDenom) + + s.Require().Equal(moduleBalance, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(8000))) + s.Require().Equal(feeCollectorBalance, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(0))) + + // test case - drip the funds + + _, err := s.app.AirdropKeeper.DripAllFunds(s.ctx) + s.Require().NoError(err) + + // check that the fees have been transferred + moduleBalance = s.app.BankKeeper.GetBalance(s.ctx, moduleAddress, sdk.DefaultBondDenom) + feeCollectorBalance = s.app.BankKeeper.GetBalance(s.ctx, feeCollectorAddress, sdk.DefaultBondDenom) + + s.Require().Equal(moduleBalance, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(3960))) // 40 fund1 4000 fund2 + s.Require().Equal(feeCollectorBalance, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(4040))) +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} diff --git a/x/airdrop/keeper/msg_server.go b/x/airdrop/keeper/msg_server.go new file mode 100644 index 000000000000..3660e1a45394 --- /dev/null +++ b/x/airdrop/keeper/msg_server.go @@ -0,0 +1,43 @@ +package keeper + +import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/airdrop/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the bank MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} + +func (m msgServer) AirDrop(goCtx context.Context, msg *types.MsgAirDrop) (*types.MsgAirDropResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // validate the from address + sender, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + return nil, err + } + + // validate the fund + err = msg.Fund.ValidateBasic() + if err != nil { + return nil, err + } + + // add the fund to our keeper + err = m.AddFund(ctx, sender, *msg.Fund) + if err != nil { + return nil, err + } + + return &types.MsgAirDropResponse{}, nil +} diff --git a/x/airdrop/keeper/params.go b/x/airdrop/keeper/params.go new file mode 100644 index 000000000000..c748d41074de --- /dev/null +++ b/x/airdrop/keeper/params.go @@ -0,0 +1,22 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/airdrop/types" +) + +func (k Keeper) GetWhiteListClients(ctx sdk.Context) []string { + var res []string + k.paramSpace.Get(ctx, types.KeyWhiteList, &res) + return res +} + +// GetParams returns the total set of ibc-transfer parameters. +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + return types.NewParams(k.GetWhiteListClients(ctx)...) +} + +// SetParams sets the total set of ibc-transfer parameters. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramSpace.SetParamSet(ctx, ¶ms) +} diff --git a/x/airdrop/module.go b/x/airdrop/module.go new file mode 100644 index 000000000000..5b5ec2e87bcc --- /dev/null +++ b/x/airdrop/module.go @@ -0,0 +1,139 @@ +package airdrop + +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/cosmos/cosmos-sdk/x/airdrop/client/cli" + "github.com/cosmos/cosmos-sdk/x/airdrop/keeper" + "github.com/cosmos/cosmos-sdk/x/airdrop/types" + host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + abci "github.com/tendermint/tendermint/abci/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +//____________________________________________________________________________ + +// AppModuleBasic defines the basic application module used by the airdrop module. +type AppModuleBasic struct{} + +// Name returns the airdrop module's name. +func (a AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec does nothings. Airdrop does not support amino +func (a AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) {} + +// RegisterInterfaces registers module concrete types into protobuf Any. +func (a AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + +// DefaultGenesis returns default genesis state as raw bytes for the airdrop module +func (a AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) +} + +// ValidateGenesis performs genesis state validation for the airdrop module. +func (a AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, _ client.TxEncodingConfig, bz json.RawMessage) error { + var gs types.GenesisState + if err := cdc.UnmarshalJSON(bz, &gs); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", host.ModuleName, err) + } + + return gs.Validate() +} + +// RegisterRESTRoutes does nothing. Airdrop does not support legacy REST routes. +func (a AppModuleBasic) RegisterRESTRoutes(context client.Context, router *mux.Router) {} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the ibc module. +func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) +} + +// GetTxCmd returns the root tx command for the airdrop module. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the root query command for the airdrop module. +func (a AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// AppModule implements an application module for the airdrop module. +type AppModule struct { + AppModuleBasic + + keeper *keeper.Keeper +} + +// NewAppModule creates a new AppModule object +func NewAppModule(k *keeper.Keeper) AppModule { + return AppModule{ + keeper: k, + } +} + +// Name returns the airdrop module's name. +func (a AppModule) Name() string { + return types.ModuleName +} + +// InitGenesis performs genesis initialization for the airdrop module +func (a AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, data json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + cdc.MustUnmarshalJSON(data, &genesisState) + a.keeper.InitGenesis(ctx, &genesisState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the airdrop module +func (a AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONMarshaler) json.RawMessage { + gs := a.keeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(gs) +} + +// RegisterInvariants registers the airdrop module invariants. +func (a AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// Route returns the message routing key for the airdrop module. +func (a AppModule) Route() sdk.Route { + return sdk.NewRoute(types.RouterKey, NewHandler(*a.keeper)) +} + +// QuerierRoute returns the airdrop module's querier route name. +func (a AppModule) QuerierRoute() string { return types.RouterKey } + +// LegacyQuerierHandler not supported for the airdrop module +func (a AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { return nil } + +// RegisterServices registers module services. +func (a AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(*a.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), *a.keeper) +} + +// BeginBlock handles the begin block events +func (a AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { + BeginBlocker(ctx, *a.keeper) +} + +// EndBlock returns the end blocker for the airdrop module. +func (a AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/airdrop/types/airdrop.go b/x/airdrop/types/airdrop.go new file mode 100644 index 000000000000..ae083c1267e5 --- /dev/null +++ b/x/airdrop/types/airdrop.go @@ -0,0 +1,32 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +func (fund Fund) ValidateBasic() error { + validDripRate := !fund.DripAmount.IsNil() && fund.DripAmount.IsPositive() + if !validDripRate { + return sdkerrors.Wrapf(sdkerrors.ErrConflict, "Invalid drip rate") + } + validAmount := !fund.Amount.Amount.IsNil() && !fund.DripAmount.IsNegative() + if !validAmount { + return sdkerrors.Wrapf(sdkerrors.ErrConflict, "Invalid amount") + } + + return nil +} + +// Drip the funds that should be dripped for this block +func (fund Fund) Drip() (Fund, sdk.Coin) { + amount := fund.Amount.Amount + if amount.GTE(fund.DripAmount) { + amount = fund.DripAmount + } + + drip := sdk.NewCoin(fund.Amount.Denom, amount) + remainingAmount := fund.Amount.Sub(drip) + + return Fund{Amount: &remainingAmount, DripAmount: fund.DripAmount}, drip +} diff --git a/x/airdrop/types/airdrop.pb.go b/x/airdrop/types/airdrop.pb.go new file mode 100644 index 000000000000..d92faf136e8c --- /dev/null +++ b/x/airdrop/types/airdrop.pb.go @@ -0,0 +1,829 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/airdrop/v1beta1/airdrop.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" + _ "github.com/regen-network/cosmos-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 + +// Fund defines a structure for a fund that is being distributed to network stakers +type Fund struct { + // The amount of fund that is remaining + Amount *types.Coin `protobuf:"bytes,1,opt,name=amount,proto3" json:"amount,omitempty" yaml:"amount"` + // The amount of funds that should be removed from the fund every block + DripAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=drip_amount,json=dripAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"drip_amount" yaml:"drip_amount"` +} + +func (m *Fund) Reset() { *m = Fund{} } +func (m *Fund) String() string { return proto.CompactTextString(m) } +func (*Fund) ProtoMessage() {} +func (*Fund) Descriptor() ([]byte, []int) { + return fileDescriptor_a5dba1341e10f0e5, []int{0} +} +func (m *Fund) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Fund) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Fund.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 *Fund) XXX_Merge(src proto.Message) { + xxx_messageInfo_Fund.Merge(m, src) +} +func (m *Fund) XXX_Size() int { + return m.Size() +} +func (m *Fund) XXX_DiscardUnknown() { + xxx_messageInfo_Fund.DiscardUnknown(m) +} + +var xxx_messageInfo_Fund proto.InternalMessageInfo + +func (m *Fund) GetAmount() *types.Coin { + if m != nil { + return m.Amount + } + return nil +} + +// ActiveFund describes an active fund on the network +type ActiveFund struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + Fund *Fund `protobuf:"bytes,2,opt,name=fund,proto3" json:"fund,omitempty" yaml:"blocks_remaining"` +} + +func (m *ActiveFund) Reset() { *m = ActiveFund{} } +func (m *ActiveFund) String() string { return proto.CompactTextString(m) } +func (*ActiveFund) ProtoMessage() {} +func (*ActiveFund) Descriptor() ([]byte, []int) { + return fileDescriptor_a5dba1341e10f0e5, []int{1} +} +func (m *ActiveFund) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ActiveFund) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ActiveFund.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 *ActiveFund) XXX_Merge(src proto.Message) { + xxx_messageInfo_ActiveFund.Merge(m, src) +} +func (m *ActiveFund) XXX_Size() int { + return m.Size() +} +func (m *ActiveFund) XXX_DiscardUnknown() { + xxx_messageInfo_ActiveFund.DiscardUnknown(m) +} + +var xxx_messageInfo_ActiveFund proto.InternalMessageInfo + +func (m *ActiveFund) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *ActiveFund) GetFund() *Fund { + if m != nil { + return m.Fund + } + return nil +} + +// Params define the module parameters +type Params struct { + // The set of addresses which are allowed to create are drop funds + AllowList []string `protobuf:"bytes,1,rep,name=allow_list,json=allowList,proto3" json:"allow_list,omitempty" yaml:"allow_list"` +} + +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_a5dba1341e10f0e5, []int{2} +} +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) GetAllowList() []string { + if m != nil { + return m.AllowList + } + return nil +} + +func init() { + proto.RegisterType((*Fund)(nil), "cosmos.airdrop.v1beta1.Fund") + proto.RegisterType((*ActiveFund)(nil), "cosmos.airdrop.v1beta1.ActiveFund") + proto.RegisterType((*Params)(nil), "cosmos.airdrop.v1beta1.Params") +} + +func init() { + proto.RegisterFile("cosmos/airdrop/v1beta1/airdrop.proto", fileDescriptor_a5dba1341e10f0e5) +} + +var fileDescriptor_a5dba1341e10f0e5 = []byte{ + // 405 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x52, 0xcf, 0x8a, 0xd4, 0x30, + 0x1c, 0x6e, 0x74, 0x28, 0x34, 0x83, 0x87, 0x2d, 0xfe, 0xdb, 0x55, 0xda, 0x25, 0x88, 0x8c, 0xa0, + 0x29, 0xbb, 0x7a, 0xda, 0x83, 0xb0, 0x75, 0x59, 0x10, 0x14, 0xa4, 0x47, 0x2f, 0x25, 0x6d, 0x63, + 0x0d, 0xd3, 0x26, 0xa5, 0x49, 0x47, 0xe7, 0x05, 0x3c, 0xfb, 0x08, 0xbe, 0x86, 0x6f, 0x30, 0xc7, + 0x39, 0x8a, 0x87, 0x22, 0x33, 0x17, 0xcf, 0x7d, 0x02, 0x69, 0x92, 0x19, 0xe6, 0x20, 0x7b, 0x6a, + 0xbf, 0x7c, 0x7f, 0x7e, 0xbf, 0x7c, 0x2d, 0x7c, 0x92, 0x0b, 0x59, 0x0b, 0x19, 0x11, 0xd6, 0x16, + 0xad, 0x68, 0xa2, 0xc5, 0x59, 0x46, 0x15, 0x39, 0xdb, 0x61, 0xdc, 0xb4, 0x42, 0x09, 0xff, 0xbe, + 0x51, 0xe1, 0xdd, 0xa9, 0x55, 0x9d, 0xdc, 0x2d, 0x45, 0x29, 0xb4, 0x24, 0x1a, 0xdf, 0x8c, 0xfa, + 0xe4, 0xd8, 0xa8, 0x53, 0x43, 0x58, 0xab, 0xa1, 0x02, 0x3b, 0x2e, 0x23, 0x92, 0xee, 0x67, 0xe5, + 0x82, 0x71, 0xc3, 0xa3, 0x9f, 0x00, 0x4e, 0xae, 0x3b, 0x5e, 0xf8, 0x57, 0xd0, 0x25, 0xb5, 0xe8, + 0xb8, 0x7a, 0x08, 0x4e, 0xc1, 0x6c, 0x7a, 0x7e, 0x8c, 0x6d, 0xce, 0xe8, 0xdc, 0xcd, 0xc7, 0x6f, + 0x04, 0xe3, 0xf1, 0xd1, 0xd0, 0x87, 0x77, 0x96, 0xa4, 0xae, 0x2e, 0x90, 0xb1, 0xa0, 0xc4, 0x7a, + 0x7d, 0x0a, 0xa7, 0x45, 0xcb, 0x9a, 0xd4, 0x46, 0xdd, 0x3a, 0x05, 0x33, 0x2f, 0xbe, 0x5a, 0xf5, + 0xa1, 0xf3, 0xbb, 0x0f, 0x9f, 0x96, 0x4c, 0x7d, 0xee, 0x32, 0x9c, 0x8b, 0xda, 0x2e, 0x69, 0x1f, + 0x2f, 0x64, 0x31, 0x8f, 0xd4, 0xb2, 0xa1, 0x12, 0xbf, 0xe5, 0x6a, 0xe8, 0x43, 0xdf, 0xa4, 0x1f, + 0x44, 0xa1, 0x04, 0x8e, 0xe8, 0x52, 0x83, 0x8b, 0xc9, 0xdf, 0x1f, 0x21, 0x40, 0xdf, 0x00, 0x84, + 0x97, 0xb9, 0x62, 0x0b, 0xaa, 0x6f, 0xf0, 0x0c, 0xba, 0x92, 0xf2, 0x82, 0xb6, 0xfa, 0x06, 0xde, + 0xe1, 0x9a, 0xe6, 0x1c, 0x25, 0x56, 0xe0, 0xbf, 0x87, 0x93, 0x4f, 0x1d, 0x2f, 0xf4, 0x7e, 0xd3, + 0xf3, 0xc7, 0xf8, 0xff, 0x6d, 0xe3, 0x31, 0x36, 0x7e, 0x34, 0xf4, 0xe1, 0x03, 0x13, 0x93, 0x55, + 0x22, 0x9f, 0xcb, 0xb4, 0xa5, 0x35, 0x61, 0x9c, 0xf1, 0x12, 0x25, 0x3a, 0x06, 0xbd, 0x86, 0xee, + 0x07, 0xd2, 0x92, 0x5a, 0xfa, 0xaf, 0x20, 0x24, 0x55, 0x25, 0xbe, 0xa4, 0x15, 0x93, 0x63, 0x93, + 0xb7, 0x67, 0x5e, 0x7c, 0x6f, 0xe8, 0xc3, 0x23, 0x5b, 0xd7, 0x9e, 0x43, 0x89, 0xa7, 0xc1, 0x3b, + 0x26, 0x55, 0x7c, 0xbd, 0xda, 0x04, 0x60, 0xbd, 0x09, 0xc0, 0x9f, 0x4d, 0x00, 0xbe, 0x6f, 0x03, + 0x67, 0xbd, 0x0d, 0x9c, 0x5f, 0xdb, 0xc0, 0xf9, 0xf8, 0xfc, 0xc6, 0xca, 0xbe, 0xee, 0xff, 0x22, + 0x5d, 0x5e, 0xe6, 0xea, 0x6f, 0xfa, 0xf2, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x29, 0x35, 0xac, + 0x67, 0x64, 0x02, 0x00, 0x00, +} + +func (this *Fund) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Fund) + if !ok { + that2, ok := that.(Fund) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Amount.Equal(that1.Amount) { + return false + } + if !this.DripAmount.Equal(that1.DripAmount) { + return false + } + return true +} +func (m *Fund) 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 *Fund) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Fund) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.DripAmount.Size() + i -= size + if _, err := m.DripAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAirdrop(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.Amount != nil { + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAirdrop(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ActiveFund) 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 *ActiveFund) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ActiveFund) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Fund != nil { + { + size, err := m.Fund.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAirdrop(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintAirdrop(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AllowList) > 0 { + for iNdEx := len(m.AllowList) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AllowList[iNdEx]) + copy(dAtA[i:], m.AllowList[iNdEx]) + i = encodeVarintAirdrop(dAtA, i, uint64(len(m.AllowList[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintAirdrop(dAtA []byte, offset int, v uint64) int { + offset -= sovAirdrop(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Fund) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Amount != nil { + l = m.Amount.Size() + n += 1 + l + sovAirdrop(uint64(l)) + } + l = m.DripAmount.Size() + n += 1 + l + sovAirdrop(uint64(l)) + return n +} + +func (m *ActiveFund) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovAirdrop(uint64(l)) + } + if m.Fund != nil { + l = m.Fund.Size() + n += 1 + l + sovAirdrop(uint64(l)) + } + return n +} + +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.AllowList) > 0 { + for _, s := range m.AllowList { + l = len(s) + n += 1 + l + sovAirdrop(uint64(l)) + } + } + return n +} + +func sovAirdrop(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozAirdrop(x uint64) (n int) { + return sovAirdrop(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Fund) 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 ErrIntOverflowAirdrop + } + 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: Fund: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Fund: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAirdrop + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAirdrop + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAirdrop + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Amount == nil { + m.Amount = &types.Coin{} + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DripAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAirdrop + } + 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 ErrInvalidLengthAirdrop + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAirdrop + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.DripAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAirdrop(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAirdrop + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ActiveFund) 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 ErrIntOverflowAirdrop + } + 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: ActiveFund: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ActiveFund: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAirdrop + } + 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 ErrInvalidLengthAirdrop + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAirdrop + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fund", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAirdrop + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAirdrop + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAirdrop + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Fund == nil { + m.Fund = &Fund{} + } + if err := m.Fund.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAirdrop(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAirdrop + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +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 ErrIntOverflowAirdrop + } + 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 AllowList", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAirdrop + } + 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 ErrInvalidLengthAirdrop + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAirdrop + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AllowList = append(m.AllowList, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAirdrop(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAirdrop + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAirdrop(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, ErrIntOverflowAirdrop + } + 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, ErrIntOverflowAirdrop + } + 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, ErrIntOverflowAirdrop + } + 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, ErrInvalidLengthAirdrop + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupAirdrop + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthAirdrop + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthAirdrop = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAirdrop = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAirdrop = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/airdrop/types/codec.go b/x/airdrop/types/codec.go new file mode 100644 index 000000000000..0bf39a7ab380 --- /dev/null +++ b/x/airdrop/types/codec.go @@ -0,0 +1,15 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgAirDrop{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} diff --git a/x/airdrop/types/expected_keepers.go b/x/airdrop/types/expected_keepers.go new file mode 100644 index 000000000000..d98268cffb17 --- /dev/null +++ b/x/airdrop/types/expected_keepers.go @@ -0,0 +1,9 @@ +package types + +import sdk "github.com/cosmos/cosmos-sdk/types" + +type BankKeeper interface { + SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + SetBalances(ctx sdk.Context, addr sdk.AccAddress, balances sdk.Coins) error +} diff --git a/x/airdrop/types/genesis.go b/x/airdrop/types/genesis.go new file mode 100644 index 000000000000..8ffe5c45964a --- /dev/null +++ b/x/airdrop/types/genesis.go @@ -0,0 +1,28 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "strings" +) + +func DefaultGenesisState() *GenesisState { + return &GenesisState{} +} + +func NewGenesisState(params Params, funds []ActiveFund) *GenesisState { + return &GenesisState{params, funds} +} + +func (gs *GenesisState) Validate() error { + whiteListAddresses := []sdk.AccAddress{} + + for _, address := range gs.Params.AllowList { + accAddress, err := sdk.AccAddressFromBech32(strings.TrimSpace(address)) + if err != nil { + return err + } + whiteListAddresses = append(whiteListAddresses, accAddress) + } + + return nil +} diff --git a/x/airdrop/types/genesis.pb.go b/x/airdrop/types/genesis.pb.go new file mode 100644 index 000000000000..c390336d28b8 --- /dev/null +++ b/x/airdrop/types/genesis.pb.go @@ -0,0 +1,389 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/airdrop/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 bank 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"` + // balances is an array containing the balances of all the accounts. + Funds []ActiveFund `protobuf:"bytes,2,rep,name=funds,proto3" json:"funds"` +} + +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_e00c27dbe748c0be, []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) GetFunds() []ActiveFund { + if m != nil { + return m.Funds + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "cosmos.airdrop.v1beta1.GenesisState") +} + +func init() { + proto.RegisterFile("cosmos/airdrop/v1beta1/genesis.proto", fileDescriptor_e00c27dbe748c0be) +} + +var fileDescriptor_e00c27dbe748c0be = []byte{ + // 236 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0xcc, 0x2c, 0x4a, 0x29, 0xca, 0x2f, 0xd0, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, + 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, + 0x17, 0x12, 0x83, 0xa8, 0xd2, 0x83, 0xaa, 0xd2, 0x83, 0xaa, 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, + 0x07, 0x2b, 0xd1, 0x07, 0xb1, 0x20, 0xaa, 0xa5, 0x70, 0x99, 0x09, 0xd3, 0x0d, 0x56, 0xa5, 0xd4, + 0xc3, 0xc8, 0xc5, 0xe3, 0x0e, 0xb1, 0x25, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x86, 0x8b, 0xad, + 0x20, 0xb1, 0x28, 0x31, 0xb7, 0x58, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x4e, 0x0f, 0xbb, + 0xad, 0x7a, 0x01, 0x60, 0x55, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0xf5, 0x08, 0xd9, + 0x71, 0xb1, 0xa6, 0x95, 0xe6, 0xa5, 0x14, 0x4b, 0x30, 0x29, 0x30, 0x6b, 0x70, 0x1b, 0x29, 0xe1, + 0xd2, 0xec, 0x98, 0x5c, 0x92, 0x59, 0x96, 0xea, 0x56, 0x9a, 0x97, 0x02, 0x35, 0x00, 0xa2, 0xcd, + 0xc9, 0xed, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, + 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x74, 0xd2, 0x33, 0x4b, + 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xa1, 0x3e, 0x83, 0x50, 0xba, 0xc5, 0x29, 0xd9, + 0xfa, 0x15, 0x70, 0x6f, 0x96, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x7d, 0x67, 0x0c, 0x08, + 0x00, 0x00, 0xff, 0xff, 0x8a, 0x59, 0x05, 0x80, 0x59, 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.Funds) > 0 { + for iNdEx := len(m.Funds) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Funds[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.Funds) > 0 { + for _, e := range m.Funds { + 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 Funds", 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.Funds = append(m.Funds, ActiveFund{}) + if err := m.Funds[len(m.Funds)-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/airdrop/types/keys.go b/x/airdrop/types/keys.go new file mode 100644 index 000000000000..10d316b80024 --- /dev/null +++ b/x/airdrop/types/keys.go @@ -0,0 +1,25 @@ +package types + +import sdk "github.com/cosmos/cosmos-sdk/types" + +const ( + ModuleName = "airdrop" + StoreKey = ModuleName + RouterKey = ModuleName +) + +var ( + ActiveFundKeyPrefix = []byte{0x01} +) + +func GetActiveFundKey(address sdk.AccAddress) []byte { + return append(ActiveFundKeyPrefix, address.Bytes()...) +} + +func GetAddressFromActiveFundKey(key []byte) sdk.AccAddress { + addr := key[1:] + if len(addr) != sdk.AddrLen { + panic("unexpected key length") + } + return sdk.AccAddress(addr) +} diff --git a/x/airdrop/types/msgs.go b/x/airdrop/types/msgs.go new file mode 100644 index 000000000000..e96a4e7548bb --- /dev/null +++ b/x/airdrop/types/msgs.go @@ -0,0 +1,53 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const ( + TypeMsgAirDrop = "airdrop" +) + +func NewMsgAirDrop(fromAddr sdk.AccAddress, amount sdk.Coin, dripAmount sdk.Int) *MsgAirDrop { + return &MsgAirDrop{FromAddress: fromAddr.String(), Fund: &Fund{ + Amount: &amount, + DripAmount: dripAmount, + }} +} + +var _ sdk.Msg = &MsgAirDrop{} + +func (msg MsgAirDrop) Route() string { + return RouterKey +} + +func (msg MsgAirDrop) Type() string { + return TypeMsgAirDrop +} + +func (msg MsgAirDrop) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + + err = msg.Fund.ValidateBasic() + if err != nil { + return err + } + + return nil +} + +func (msg MsgAirDrop) GetSignBytes() []byte { + panic("Airdrop messages do not support amino") +} + +func (msg MsgAirDrop) GetSigners() []sdk.AccAddress { + from, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{from} +} diff --git a/x/airdrop/types/params.go b/x/airdrop/types/params.go new file mode 100644 index 000000000000..51eb62de3ad4 --- /dev/null +++ b/x/airdrop/types/params.go @@ -0,0 +1,60 @@ +package types + +import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "strings" +) + +var ( + // KeyWhiteList is store's key for WhiteList Params + KeyWhiteList = []byte("AllowList") +) + +func NewParams(whiteListClients ...string) Params { + return Params{ + AllowList: whiteListClients, + } +} + +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyWhiteList, &p.AllowList, validateWhiteList), + } +} + +func validateWhiteList(i interface{}) error { + clients, ok := i.([]string) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + for _, address := range clients { + _, err := sdk.AccAddressFromBech32(strings.TrimSpace(address)) + if err != nil { + return fmt.Errorf("invalid addresss: %s", address) + } + } + + return nil +} + +// IsAllowedSender checks if the given address can perform an airdrop +func (p Params) IsAllowedSender(sender sdk.AccAddress) bool { + for _, address := range p.AllowList { + accAddress, err := sdk.AccAddressFromBech32(strings.TrimSpace(address)) + if err != nil { + continue + } + + if sender.Equals(accAddress) { + return true + } + } + return false +} diff --git a/x/airdrop/types/querier.go b/x/airdrop/types/querier.go new file mode 100644 index 000000000000..c1f8e951a412 --- /dev/null +++ b/x/airdrop/types/querier.go @@ -0,0 +1,9 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/types/query" +) + +func NewQueryAllFundsRequest(req *query.PageRequest) *QueryAllFundsRequest { + return &QueryAllFundsRequest{Pagination: req} +} diff --git a/x/airdrop/types/query.pb.go b/x/airdrop/types/query.pb.go new file mode 100644 index 000000000000..782aabf26c22 --- /dev/null +++ b/x/airdrop/types/query.pb.go @@ -0,0 +1,1400 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/airdrop/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + 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 + +// QueryAllFundsRequest defines the request for querying all the funds +type QueryAllFundsRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllFundsRequest) Reset() { *m = QueryAllFundsRequest{} } +func (m *QueryAllFundsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllFundsRequest) ProtoMessage() {} +func (*QueryAllFundsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a99d0420e0920c92, []int{0} +} +func (m *QueryAllFundsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllFundsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllFundsRequest.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 *QueryAllFundsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllFundsRequest.Merge(m, src) +} +func (m *QueryAllFundsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllFundsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllFundsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllFundsRequest proto.InternalMessageInfo + +func (m *QueryAllFundsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryAllFundsResponse defines the response for querying all the funds +type QueryAllFundsResponse struct { + Funds []*ActiveFund `protobuf:"bytes,1,rep,name=funds,proto3" json:"funds,omitempty"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllFundsResponse) Reset() { *m = QueryAllFundsResponse{} } +func (m *QueryAllFundsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllFundsResponse) ProtoMessage() {} +func (*QueryAllFundsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a99d0420e0920c92, []int{1} +} +func (m *QueryAllFundsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllFundsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllFundsResponse.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 *QueryAllFundsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllFundsResponse.Merge(m, src) +} +func (m *QueryAllFundsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllFundsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllFundsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllFundsResponse proto.InternalMessageInfo + +func (m *QueryAllFundsResponse) GetFunds() []*ActiveFund { + if m != nil { + return m.Funds + } + return nil +} + +func (m *QueryAllFundsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryFundRequest defines the request for querying a specific fund +type QueryFundRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *QueryFundRequest) Reset() { *m = QueryFundRequest{} } +func (m *QueryFundRequest) String() string { return proto.CompactTextString(m) } +func (*QueryFundRequest) ProtoMessage() {} +func (*QueryFundRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a99d0420e0920c92, []int{2} +} +func (m *QueryFundRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFundRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFundRequest.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 *QueryFundRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFundRequest.Merge(m, src) +} +func (m *QueryFundRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryFundRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFundRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFundRequest proto.InternalMessageInfo + +func (m *QueryFundRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +// QueryFundResponse defines the response for querying a specific fund +type QueryFundResponse struct { + Fund *Fund `protobuf:"bytes,1,opt,name=fund,proto3" json:"fund,omitempty"` +} + +func (m *QueryFundResponse) Reset() { *m = QueryFundResponse{} } +func (m *QueryFundResponse) String() string { return proto.CompactTextString(m) } +func (*QueryFundResponse) ProtoMessage() {} +func (*QueryFundResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a99d0420e0920c92, []int{3} +} +func (m *QueryFundResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryFundResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryFundResponse.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 *QueryFundResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFundResponse.Merge(m, src) +} +func (m *QueryFundResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryFundResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFundResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryFundResponse proto.InternalMessageInfo + +func (m *QueryFundResponse) GetFund() *Fund { + if m != nil { + return m.Fund + } + return nil +} + +// QueryParamsRequest defines the request type for querying x/airdrop parameters. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a99d0420e0920c92, []int{4} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse defines the response type for querying x/airdrop parameters. +type QueryParamsResponse struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a99d0420e0920c92, []int{5} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*QueryAllFundsRequest)(nil), "cosmos.airdrop.v1beta1.QueryAllFundsRequest") + proto.RegisterType((*QueryAllFundsResponse)(nil), "cosmos.airdrop.v1beta1.QueryAllFundsResponse") + proto.RegisterType((*QueryFundRequest)(nil), "cosmos.airdrop.v1beta1.QueryFundRequest") + proto.RegisterType((*QueryFundResponse)(nil), "cosmos.airdrop.v1beta1.QueryFundResponse") + proto.RegisterType((*QueryParamsRequest)(nil), "cosmos.airdrop.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "cosmos.airdrop.v1beta1.QueryParamsResponse") +} + +func init() { + proto.RegisterFile("cosmos/airdrop/v1beta1/query.proto", fileDescriptor_a99d0420e0920c92) +} + +var fileDescriptor_a99d0420e0920c92 = []byte{ + // 508 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x3f, 0x6f, 0x13, 0x3f, + 0x18, 0xc7, 0xe3, 0x36, 0xcd, 0xef, 0xc7, 0xd3, 0x05, 0x4c, 0x40, 0xd5, 0xa9, 0xb8, 0xd1, 0x09, + 0xda, 0xb4, 0xb4, 0x36, 0x0d, 0x0b, 0x03, 0x4b, 0x2b, 0x11, 0xd6, 0x72, 0x6c, 0x0c, 0x48, 0x4e, + 0xce, 0x1c, 0x27, 0x92, 0xf3, 0xf5, 0x7c, 0xa9, 0xa8, 0x10, 0x0b, 0x1b, 0x12, 0x42, 0x48, 0x6c, + 0xbc, 0x0d, 0xde, 0x44, 0xc7, 0x4a, 0x2c, 0x4c, 0x08, 0x25, 0xbc, 0x10, 0x74, 0xf6, 0x73, 0x25, + 0x41, 0xbd, 0x90, 0x29, 0x91, 0xf3, 0xfd, 0xf3, 0x79, 0xfc, 0x38, 0xe0, 0xf7, 0xb5, 0x19, 0x6a, + 0x23, 0x64, 0x9c, 0x85, 0x99, 0x4e, 0xc5, 0xc9, 0x7e, 0x4f, 0xe5, 0x72, 0x5f, 0x1c, 0x8f, 0x54, + 0x76, 0xca, 0xd3, 0x4c, 0xe7, 0x9a, 0xde, 0x74, 0x1a, 0x8e, 0x1a, 0x8e, 0x1a, 0xaf, 0x19, 0xe9, + 0x48, 0x5b, 0x89, 0x28, 0xbe, 0x39, 0xb5, 0xb7, 0x1e, 0x69, 0x1d, 0x0d, 0x94, 0x90, 0x69, 0x2c, + 0x64, 0x92, 0xe8, 0x5c, 0xe6, 0xb1, 0x4e, 0x0c, 0xfe, 0xba, 0x83, 0x7d, 0x3d, 0x69, 0x94, 0x2b, + 0xb9, 0xa8, 0x4c, 0x65, 0x14, 0x27, 0x56, 0x8c, 0xda, 0xdb, 0x15, 0x6c, 0x25, 0x87, 0x55, 0xf9, + 0xcf, 0xa1, 0xf9, 0xa4, 0xc8, 0x39, 0x18, 0x0c, 0xba, 0xa3, 0x24, 0x34, 0x81, 0x3a, 0x1e, 0x29, + 0x93, 0xd3, 0x2e, 0xc0, 0x9f, 0xc4, 0x35, 0xd2, 0x22, 0xed, 0xd5, 0xce, 0x26, 0xc7, 0x51, 0x8a, + 0x7a, 0xee, 0x66, 0xc4, 0x54, 0x7e, 0x24, 0x23, 0x85, 0xde, 0x60, 0xca, 0xe9, 0x7f, 0x21, 0x70, + 0xe3, 0xaf, 0x02, 0x93, 0xea, 0xc4, 0x28, 0xfa, 0x00, 0x56, 0x5e, 0x14, 0x07, 0x6b, 0xa4, 0xb5, + 0xdc, 0x5e, 0xed, 0xf8, 0xfc, 0xf2, 0x7b, 0xe2, 0x07, 0xfd, 0x3c, 0x3e, 0x51, 0x85, 0x37, 0x70, + 0x06, 0xfa, 0x78, 0x86, 0x6d, 0xc9, 0xb2, 0x6d, 0xfd, 0x93, 0xcd, 0xd5, 0xce, 0xc0, 0x75, 0xe0, + 0xaa, 0x65, 0xb3, 0xe1, 0x38, 0x38, 0x83, 0xff, 0x64, 0x18, 0x66, 0xca, 0x18, 0x3b, 0xf5, 0x95, + 0xc3, 0xfa, 0xd9, 0x8f, 0x0d, 0x12, 0x94, 0x87, 0xfe, 0x23, 0xb8, 0x36, 0xe5, 0xc1, 0x59, 0xee, + 0x41, 0xbd, 0x40, 0xc3, 0x7b, 0x5a, 0xaf, 0x1a, 0xc5, 0x7a, 0xac, 0xd2, 0x6f, 0x02, 0xb5, 0x31, + 0x47, 0x32, 0x93, 0xc3, 0xf2, 0xd6, 0xfd, 0xa7, 0x70, 0x7d, 0xe6, 0x14, 0xe3, 0x1f, 0x42, 0x23, + 0xb5, 0x27, 0x58, 0xc0, 0xaa, 0x0a, 0x9c, 0xcf, 0x22, 0xd7, 0x02, 0xf4, 0x74, 0xbe, 0x2e, 0xc3, + 0x8a, 0x4d, 0xa5, 0x1f, 0x09, 0xfc, 0x5f, 0xee, 0x81, 0xee, 0x56, 0x85, 0x5c, 0xf6, 0x1e, 0xbc, + 0xbd, 0x05, 0xd5, 0x8e, 0xd8, 0xbf, 0xf3, 0xee, 0xdb, 0xaf, 0xcf, 0x4b, 0x1b, 0xf4, 0x96, 0xa8, + 0x78, 0x85, 0x6e, 0x93, 0x1f, 0x08, 0xd4, 0x0b, 0x23, 0x6d, 0xcf, 0x8d, 0x9f, 0xda, 0x8f, 0xb7, + 0xbd, 0x80, 0x12, 0x21, 0x84, 0x85, 0xd8, 0xa6, 0x5b, 0x73, 0x21, 0xc4, 0x1b, 0x5c, 0xed, 0x5b, + 0xfa, 0x9e, 0x40, 0xc3, 0x5d, 0x21, 0xdd, 0x99, 0x5b, 0x33, 0xb3, 0x35, 0xef, 0xee, 0x42, 0x5a, + 0x84, 0xda, 0xb4, 0x50, 0x2d, 0xca, 0xaa, 0xa0, 0xdc, 0xd6, 0x0e, 0xbb, 0x67, 0x63, 0x46, 0xce, + 0xc7, 0x8c, 0xfc, 0x1c, 0x33, 0xf2, 0x69, 0xc2, 0x6a, 0xe7, 0x13, 0x56, 0xfb, 0x3e, 0x61, 0xb5, + 0x67, 0xbb, 0x51, 0x9c, 0xbf, 0x1c, 0xf5, 0x78, 0x5f, 0x0f, 0xcb, 0x0c, 0xf7, 0xb1, 0x67, 0xc2, + 0x57, 0xe2, 0xf5, 0x45, 0x60, 0x7e, 0x9a, 0x2a, 0xd3, 0x6b, 0xd8, 0xff, 0xf9, 0xfd, 0xdf, 0x01, + 0x00, 0x00, 0xff, 0xff, 0xbe, 0xf8, 0x1d, 0xc0, 0xab, 0x04, 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 { + // AllFunds queries all active airdrop funds + AllFunds(ctx context.Context, in *QueryAllFundsRequest, opts ...grpc.CallOption) (*QueryAllFundsResponse, error) + // Fund queries a specific airdrop fund + Fund(ctx context.Context, in *QueryFundRequest, opts ...grpc.CallOption) (*QueryFundResponse, error) + // Params queries the current modules parameters + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) AllFunds(ctx context.Context, in *QueryAllFundsRequest, opts ...grpc.CallOption) (*QueryAllFundsResponse, error) { + out := new(QueryAllFundsResponse) + err := c.cc.Invoke(ctx, "/cosmos.airdrop.v1beta1.Query/AllFunds", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Fund(ctx context.Context, in *QueryFundRequest, opts ...grpc.CallOption) (*QueryFundResponse, error) { + out := new(QueryFundResponse) + err := c.cc.Invoke(ctx, "/cosmos.airdrop.v1beta1.Query/Fund", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/cosmos.airdrop.v1beta1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // AllFunds queries all active airdrop funds + AllFunds(context.Context, *QueryAllFundsRequest) (*QueryAllFundsResponse, error) + // Fund queries a specific airdrop fund + Fund(context.Context, *QueryFundRequest) (*QueryFundResponse, error) + // Params queries the current modules parameters + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) AllFunds(ctx context.Context, req *QueryAllFundsRequest) (*QueryAllFundsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AllFunds not implemented") +} +func (*UnimplementedQueryServer) Fund(ctx context.Context, req *QueryFundRequest) (*QueryFundResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Fund not implemented") +} +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_AllFunds_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllFundsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AllFunds(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.airdrop.v1beta1.Query/AllFunds", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AllFunds(ctx, req.(*QueryAllFundsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Fund_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFundRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Fund(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.airdrop.v1beta1.Query/Fund", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Fund(ctx, req.(*QueryFundRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.airdrop.v1beta1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cosmos.airdrop.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "AllFunds", + Handler: _Query_AllFunds_Handler, + }, + { + MethodName: "Fund", + Handler: _Query_Fund_Handler, + }, + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/airdrop/v1beta1/query.proto", +} + +func (m *QueryAllFundsRequest) 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 *QueryAllFundsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllFundsRequest) 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 *QueryAllFundsResponse) 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 *QueryAllFundsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllFundsResponse) 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.Funds) > 0 { + for iNdEx := len(m.Funds) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Funds[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 *QueryFundRequest) 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 *QueryFundRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFundRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryFundResponse) 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 *QueryFundResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFundResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Fund != nil { + { + size, err := m.Fund.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 *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryAllFundsRequest) 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 *QueryAllFundsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Funds) > 0 { + for _, e := range m.Funds { + 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 *QueryFundRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryFundResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Fund != nil { + l = m.Fund.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryAllFundsRequest) 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: QueryAllFundsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllFundsRequest: 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 *QueryAllFundsResponse) 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: QueryAllFundsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllFundsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Funds", 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.Funds = append(m.Funds, &ActiveFund{}) + if err := m.Funds[len(m.Funds)-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 *QueryFundRequest) 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: QueryFundRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFundRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", 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.Address = 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 *QueryFundResponse) 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: QueryFundResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFundResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fund", 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.Fund == nil { + m.Fund = &Fund{} + } + if err := m.Fund.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 *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/airdrop/types/query.pb.gw.go b/x/airdrop/types/query.pb.gw.go new file mode 100644 index 000000000000..cc8953c53b60 --- /dev/null +++ b/x/airdrop/types/query.pb.gw.go @@ -0,0 +1,326 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: cosmos/airdrop/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 + +var ( + filter_Query_AllFunds_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_AllFunds_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllFundsRequest + 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_AllFunds_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.AllFunds(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_AllFunds_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllFundsRequest + 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_AllFunds_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.AllFunds(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Fund_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFundRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := client.Fund(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Fund_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFundRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := server.Fund(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (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_AllFunds_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_AllFunds_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_AllFunds_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Fund_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_Fund_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_Fund_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + 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()...) + + }) + + 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_AllFunds_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_AllFunds_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_AllFunds_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Fund_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_Fund_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_Fund_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_AllFunds_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "airdrop", "v1beta1", "funds"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_Fund_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "airdrop", "v1beta1", "funds", "address"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "airdrop", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_AllFunds_0 = runtime.ForwardResponseMessage + + forward_Query_Fund_0 = runtime.ForwardResponseMessage + + forward_Query_Params_0 = runtime.ForwardResponseMessage +) diff --git a/x/airdrop/types/tx.pb.go b/x/airdrop/types/tx.pb.go new file mode 100644 index 000000000000..748f1dbc5ac7 --- /dev/null +++ b/x/airdrop/types/tx.pb.go @@ -0,0 +1,578 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/airdrop/v1beta1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "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 + +// MsgAirDrop represents a message to create an airdrop fund for distribution +type MsgAirDrop struct { + FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty" yaml:"from_address"` + Fund *Fund `protobuf:"bytes,2,opt,name=fund,proto3" json:"fund,omitempty" yaml:"fund"` +} + +func (m *MsgAirDrop) Reset() { *m = MsgAirDrop{} } +func (m *MsgAirDrop) String() string { return proto.CompactTextString(m) } +func (*MsgAirDrop) ProtoMessage() {} +func (*MsgAirDrop) Descriptor() ([]byte, []int) { + return fileDescriptor_bbea7cc5769c257f, []int{0} +} +func (m *MsgAirDrop) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAirDrop) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAirDrop.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 *MsgAirDrop) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAirDrop.Merge(m, src) +} +func (m *MsgAirDrop) XXX_Size() int { + return m.Size() +} +func (m *MsgAirDrop) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAirDrop.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAirDrop proto.InternalMessageInfo + +// MsgAirDropResponse represents a message for the response +type MsgAirDropResponse struct { +} + +func (m *MsgAirDropResponse) Reset() { *m = MsgAirDropResponse{} } +func (m *MsgAirDropResponse) String() string { return proto.CompactTextString(m) } +func (*MsgAirDropResponse) ProtoMessage() {} +func (*MsgAirDropResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_bbea7cc5769c257f, []int{1} +} +func (m *MsgAirDropResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAirDropResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAirDropResponse.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 *MsgAirDropResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAirDropResponse.Merge(m, src) +} +func (m *MsgAirDropResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgAirDropResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAirDropResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAirDropResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgAirDrop)(nil), "cosmos.airdrop.v1beta1.MsgAirDrop") + proto.RegisterType((*MsgAirDropResponse)(nil), "cosmos.airdrop.v1beta1.MsgAirDropResponse") +} + +func init() { proto.RegisterFile("cosmos/airdrop/v1beta1/tx.proto", fileDescriptor_bbea7cc5769c257f) } + +var fileDescriptor_bbea7cc5769c257f = []byte{ + // 300 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0xcc, 0x2c, 0x4a, 0x29, 0xca, 0x2f, 0xd0, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, + 0x49, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x83, 0x28, 0xd0, + 0x83, 0x2a, 0xd0, 0x83, 0x2a, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd1, 0x07, 0xb1, + 0x20, 0xaa, 0xa5, 0x54, 0x70, 0x18, 0x07, 0xd3, 0x0d, 0x56, 0xa5, 0x34, 0x95, 0x91, 0x8b, 0xcb, + 0xb7, 0x38, 0xdd, 0x31, 0xb3, 0xc8, 0xa5, 0x28, 0xbf, 0x40, 0xc8, 0x8a, 0x8b, 0x27, 0xad, 0x28, + 0x3f, 0x37, 0x3e, 0x31, 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x58, 0x82, 0x51, 0x81, 0x51, 0x83, 0xd3, + 0x49, 0xfc, 0xd3, 0x3d, 0x79, 0xe1, 0xca, 0xc4, 0xdc, 0x1c, 0x2b, 0x25, 0x64, 0x59, 0xa5, 0x20, + 0x6e, 0x10, 0xd7, 0x11, 0xc2, 0x13, 0x72, 0xe4, 0x62, 0x49, 0x2b, 0xcd, 0x4b, 0x91, 0x60, 0x52, + 0x60, 0xd4, 0xe0, 0x36, 0x92, 0xd1, 0xc3, 0xee, 0x5a, 0x3d, 0xb7, 0xd2, 0xbc, 0x14, 0x27, 0xfe, + 0x4f, 0xf7, 0xe4, 0xb9, 0xa1, 0x26, 0x96, 0xe6, 0xa5, 0x28, 0x05, 0x81, 0xb5, 0x5a, 0x71, 0x74, + 0x2c, 0x90, 0x67, 0x78, 0xb1, 0x40, 0x9e, 0x41, 0x49, 0x84, 0x4b, 0x08, 0xe1, 0xac, 0xa0, 0xd4, + 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0xa3, 0x04, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x48, 0x2e, + 0x76, 0x98, 0x83, 0x95, 0x70, 0x59, 0x83, 0xd0, 0x2d, 0xa5, 0x45, 0x58, 0x0d, 0xcc, 0x06, 0x27, + 0xb7, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, + 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0xd2, 0x49, 0xcf, 0x2c, 0xc9, + 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x06, 0x2d, 0x84, 0xd2, 0x2d, 0x4e, 0xc9, 0xd6, + 0xaf, 0x80, 0x87, 0x73, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x78, 0x8d, 0x01, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x3d, 0x89, 0x5e, 0x78, 0xd5, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// 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 { + // AirDrop defines a method for sending coins to the airdrop module for distribution + AirDrop(ctx context.Context, in *MsgAirDrop, opts ...grpc.CallOption) (*MsgAirDropResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) AirDrop(ctx context.Context, in *MsgAirDrop, opts ...grpc.CallOption) (*MsgAirDropResponse, error) { + out := new(MsgAirDropResponse) + err := c.cc.Invoke(ctx, "/cosmos.airdrop.v1beta1.Msg/AirDrop", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // AirDrop defines a method for sending coins to the airdrop module for distribution + AirDrop(context.Context, *MsgAirDrop) (*MsgAirDropResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) AirDrop(ctx context.Context, req *MsgAirDrop) (*MsgAirDropResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AirDrop not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_AirDrop_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAirDrop) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).AirDrop(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.airdrop.v1beta1.Msg/AirDrop", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).AirDrop(ctx, req.(*MsgAirDrop)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cosmos.airdrop.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "AirDrop", + Handler: _Msg_AirDrop_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/airdrop/v1beta1/tx.proto", +} + +func (m *MsgAirDrop) 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 *MsgAirDrop) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAirDrop) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Fund != nil { + { + size, err := m.Fund.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.FromAddress) > 0 { + i -= len(m.FromAddress) + copy(dAtA[i:], m.FromAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.FromAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgAirDropResponse) 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 *MsgAirDropResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAirDropResponse) 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 *MsgAirDrop) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FromAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Fund != nil { + l = m.Fund.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgAirDropResponse) 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 *MsgAirDrop) 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: MsgAirDrop: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAirDrop: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FromAddress", 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.FromAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fund", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Fund == nil { + m.Fund = &Fund{} + } + if err := m.Fund.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 *MsgAirDropResponse) 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: MsgAirDropResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAirDropResponse: 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") +)