diff --git a/app/app.go b/app/app.go
index 17933df3c..ad59ec3ca 100644
--- a/app/app.go
+++ b/app/app.go
@@ -154,14 +154,6 @@ import (
dexkeeper "github.com/neutron-org/neutron/x/dex/keeper"
dextypes "github.com/neutron-org/neutron/x/dex/types"
- "github.com/neutron-org/neutron/x/incentives"
- incentiveskeeper "github.com/neutron-org/neutron/x/incentives/keeper"
- incentivestypes "github.com/neutron-org/neutron/x/incentives/types"
-
- "github.com/neutron-org/neutron/x/epochs"
- epochskeeper "github.com/neutron-org/neutron/x/epochs/keeper"
- epochstypes "github.com/neutron-org/neutron/x/epochs/types"
-
"github.com/neutron-org/neutron/x/ibcswap"
ibcswapkeeper "github.com/neutron-org/neutron/x/ibcswap/keeper"
ibcswaptypes "github.com/neutron-org/neutron/x/ibcswap/types"
@@ -238,8 +230,6 @@ var (
globalfee.AppModule{},
dex.AppModuleBasic{},
ibcswap.AppModuleBasic{},
- epochs.AppModuleBasic{},
- incentives.AppModuleBasic{},
)
// module account permissions
@@ -257,7 +247,6 @@ var (
tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
crontypes.ModuleName: nil,
dextypes.ModuleName: {authtypes.Minter, authtypes.Burner},
- incentivestypes.ModuleName: nil,
ibcswaptypes.ModuleName: {authtypes.Burner},
}
)
@@ -324,8 +313,6 @@ type App struct {
RouterKeeper *routerkeeper.Keeper
DexKeeper dexkeeper.Keeper
SwapKeeper ibcswapkeeper.Keeper
- IncentivesKeeper *incentiveskeeper.Keeper
- EpochsKeeper *epochskeeper.Keeper
RouterModule router.AppModule
@@ -410,7 +397,7 @@ func New(
icahosttypes.StoreKey, capabilitytypes.StoreKey,
interchainqueriesmoduletypes.StoreKey, contractmanagermoduletypes.StoreKey, interchaintxstypes.StoreKey, wasmtypes.StoreKey, feetypes.StoreKey,
feeburnertypes.StoreKey, adminmoduletypes.StoreKey, ccvconsumertypes.StoreKey, tokenfactorytypes.StoreKey, routertypes.StoreKey,
- crontypes.StoreKey, ibchookstypes.StoreKey, consensusparamtypes.StoreKey, crisistypes.StoreKey, auctiontypes.StoreKey, dextypes.StoreKey, incentivestypes.StoreKey, epochstypes.StoreKey,
+ crontypes.StoreKey, ibchookstypes.StoreKey, consensusparamtypes.StoreKey, crisistypes.StoreKey, auctiontypes.StoreKey, dextypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, feetypes.MemStoreKey)
@@ -652,38 +639,6 @@ func New(
swapModule := ibcswap.NewAppModule(app.SwapKeeper)
- app.EpochsKeeper = epochskeeper.NewKeeper(keys[epochstypes.StoreKey])
-
- app.IncentivesKeeper = incentiveskeeper.NewKeeper(
- keys[incentivestypes.StoreKey],
- app.AccountKeeper,
- app.BankKeeper,
- app.EpochsKeeper,
- app.DexKeeper,
- authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(),
- )
-
- app.IncentivesKeeper.SetHooks(
- incentivestypes.NewMultiIncentiveHooks(
- // insert Incentives hooks receivers here
- ),
- )
-
- incentivesModule := incentives.NewAppModule(
- app.IncentivesKeeper,
- app.AccountKeeper,
- app.BankKeeper,
- app.EpochsKeeper,
- )
-
- app.EpochsKeeper.SetHooks(epochstypes.NewMultiEpochHooks(
- app.IncentivesKeeper.Hooks(),
- ))
-
- // NB: This must be initialized AFTER app.EpochsKeeper.SetHooks() because otherwise
- // we dereference an out-of-date EpochsKeeper.
- epochsModule := epochs.NewAppModule(*app.EpochsKeeper)
-
wasmDir := filepath.Join(homePath, "wasm")
wasmConfig, err := wasm.ReadWasmConfig(appOpts)
if err != nil {
@@ -858,8 +813,6 @@ func New(
auction.NewAppModule(appCodec, app.AuctionKeeper),
swapModule,
dexModule,
- incentivesModule,
- epochsModule,
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them
)
@@ -897,8 +850,6 @@ func New(
crontypes.ModuleName,
globalfee.ModuleName,
ibcswaptypes.ModuleName,
- incentivestypes.ModuleName,
- epochstypes.ModuleName,
dextypes.ModuleName,
)
@@ -932,8 +883,6 @@ func New(
crontypes.ModuleName,
globalfee.ModuleName,
ibcswaptypes.ModuleName,
- incentivestypes.ModuleName,
- epochstypes.ModuleName,
// NOTE: Because of the gas sensitivity of PurgeExpiredLimit order operations
// dexmodule must be the last endBlock module to run
dextypes.ModuleName,
@@ -975,8 +924,6 @@ func New(
globalfee.ModuleName,
ibcswaptypes.ModuleName,
dextypes.ModuleName,
- incentivestypes.ModuleName,
- epochstypes.ModuleName,
)
app.mm.RegisterInvariants(&app.CrisisKeeper)
diff --git a/app/proposals_allowlisting.go b/app/proposals_allowlisting.go
index 624c7e577..da85afeee 100644
--- a/app/proposals_allowlisting.go
+++ b/app/proposals_allowlisting.go
@@ -16,7 +16,6 @@ import (
dextypes "github.com/neutron-org/neutron/x/dex/types"
feeburnertypes "github.com/neutron-org/neutron/x/feeburner/types"
feerefundertypes "github.com/neutron-org/neutron/x/feerefunder/types"
- incentivestypes "github.com/neutron-org/neutron/x/incentives/types"
interchainqueriestypes "github.com/neutron-org/neutron/x/interchainqueries/types"
interchaintxstypes "github.com/neutron-org/neutron/x/interchaintxs/types"
tokenfactorytypes "github.com/neutron-org/neutron/x/tokenfactory/types"
@@ -63,7 +62,6 @@ func isSdkMessageWhitelisted(msg sdk.Msg) bool {
*feerefundertypes.MsgUpdateParams,
*crontypes.MsgUpdateParams,
*contractmanagertypes.MsgUpdateParams,
- *incentivestypes.MsgUpdateParams,
*dextypes.MsgUpdateParams:
return true
}
diff --git a/app/upgrades/nextupgrade/constants.go b/app/upgrades/nextupgrade/constants.go
index 142f65a92..cda89f115 100644
--- a/app/upgrades/nextupgrade/constants.go
+++ b/app/upgrades/nextupgrade/constants.go
@@ -5,10 +5,8 @@ import (
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
"github.com/neutron-org/neutron/app/upgrades"
- auctiontypes "github.com/skip-mev/block-sdk/x/auction/types"
dextypes "github.com/neutron-org/neutron/x/dex/types"
- epochstypes "github.com/neutron-org/neutron/x/epochs/types"
- incentivestypes "github.com/neutron-org/neutron/x/incentives/types"
+ auctiontypes "github.com/skip-mev/block-sdk/x/auction/types"
)
const (
@@ -25,8 +23,6 @@ var Upgrade = upgrades.Upgrade{
crisistypes.ModuleName,
auctiontypes.ModuleName,
dextypes.ModuleName,
- incentivestypes.ModuleName,
- epochstypes.ModuleName,
},
},
}
diff --git a/network/init-neutrond.sh b/network/init-neutrond.sh
index d2461210f..6d7ce50ff 100755
--- a/network/init-neutrond.sh
+++ b/network/init-neutrond.sh
@@ -643,7 +643,7 @@ set_genesis_param_jq ".app_state.globalfee.params.bypass_min_fee_msg_types" "$BY
set_genesis_param proposer_fee "\"0.25\"" # builder(POB)
set_genesis_param escrow_account_address "\"$DAO_CONTRACT_ADDRESS_B64\"," # builder(POB)
set_genesis_param sudo_call_gas_limit "\"1000000\"" # contractmanager
-set_genesis_param max_gas "\"40000000\"" # consensus_params
+set_genesis_param max_gas "\"1000000000\"" # consensus_params
if ! jq -e . "$GENESIS_PATH" >/dev/null 2>&1; then
echo "genesis appears to become incorrect json" >&2
diff --git a/proto/neutron/dex/tx.proto b/proto/neutron/dex/tx.proto
index b2bacb988..37fcd83ec 100644
--- a/proto/neutron/dex/tx.proto
+++ b/proto/neutron/dex/tx.proto
@@ -37,13 +37,13 @@ message MsgDeposit {
(gogoproto.moretags) = "yaml:\"amountsA\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false,
- (gogoproto.jsontag) = "amountA"
+ (gogoproto.jsontag) = "amountsA"
];
repeated string amountsB = 6 [
(gogoproto.moretags) = "yaml:\"amountsB\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false,
- (gogoproto.jsontag) = "amountB"
+ (gogoproto.jsontag) = "amountsB"
];
repeated int64 tickIndexesAToB = 7;
repeated uint64 fees = 8;
diff --git a/proto/neutron/epochs/genesis.proto b/proto/neutron/epochs/genesis.proto
deleted file mode 100644
index 4a5c1ca4e..000000000
--- a/proto/neutron/epochs/genesis.proto
+++ /dev/null
@@ -1,72 +0,0 @@
-syntax = "proto3";
-package neutron.epochs;
-
-import "gogoproto/gogo.proto";
-import "google/protobuf/duration.proto";
-import "google/protobuf/timestamp.proto";
-
-option go_package = "github.com/neutron-org/neutron/x/epochs/types";
-
-// EpochInfo is a struct that describes the data going into
-// a timer defined by the x/epochs module.
-message EpochInfo {
- // identifier is a unique reference to this particular timer.
- string identifier = 1;
- // start_time is the time at which the timer first ever ticks.
- // If start_time is in the future, the epoch will not begin until the start
- // time.
- google.protobuf.Timestamp start_time = 2 [
- (gogoproto.stdtime) = true,
- (gogoproto.nullable) = false,
- (gogoproto.moretags) = "yaml:\"start_time\""
- ];
- // duration is the time in between epoch ticks.
- // In order for intended behavior to be met, duration should
- // be greater than the chains expected block time.
- // Duration must be non-zero.
- google.protobuf.Duration duration = 3 [
- (gogoproto.nullable) = false,
- (gogoproto.stdduration) = true,
- (gogoproto.jsontag) = "duration,omitempty",
- (gogoproto.moretags) = "yaml:\"duration\""
- ];
- // current_epoch is the current epoch number, or in other words,
- // how many times has the timer 'ticked'.
- // The first tick (current_epoch=1) is defined as
- // the first block whose blocktime is greater than the EpochInfo start_time.
- int64 current_epoch = 4;
- // current_epoch_start_time describes the start time of the current timer
- // interval. The interval is (current_epoch_start_time,
- // current_epoch_start_time + duration] When the timer ticks, this is set to
- // current_epoch_start_time = last_epoch_start_time + duration only one timer
- // tick for a given identifier can occur per block.
- //
- // NOTE! The current_epoch_start_time may diverge significantly from the
- // wall-clock time the epoch began at. Wall-clock time of epoch start may be
- // >> current_epoch_start_time. Suppose current_epoch_start_time = 10,
- // duration = 5. Suppose the chain goes offline at t=14, and comes back online
- // at t=30, and produces blocks at every successive time. (t=31, 32, etc.)
- // * The t=30 block will start the epoch for (10, 15]
- // * The t=31 block will start the epoch for (15, 20]
- // * The t=32 block will start the epoch for (20, 25]
- // * The t=33 block will start the epoch for (25, 30]
- // * The t=34 block will start the epoch for (30, 35]
- // * The **t=36** block will start the epoch for (35, 40]
- google.protobuf.Timestamp current_epoch_start_time = 5 [
- (gogoproto.stdtime) = true,
- (gogoproto.nullable) = false,
- (gogoproto.moretags) = "yaml:\"current_epoch_start_time\""
- ];
- // epoch_counting_started is a boolean, that indicates whether this
- // epoch timer has began yet.
- bool epoch_counting_started = 6;
- reserved 7;
- // current_epoch_start_height is the block height at which the current epoch
- // started. (The block height at which the timer last ticked)
- int64 current_epoch_start_height = 8;
-}
-
-// GenesisState defines the epochs module's genesis state.
-message GenesisState {
- repeated EpochInfo epochs = 1 [ (gogoproto.nullable) = false ];
-}
diff --git a/proto/neutron/epochs/query.proto b/proto/neutron/epochs/query.proto
deleted file mode 100644
index b615eff97..000000000
--- a/proto/neutron/epochs/query.proto
+++ /dev/null
@@ -1,30 +0,0 @@
-syntax = "proto3";
-package neutron.epochs;
-
-import "gogoproto/gogo.proto";
-import "google/api/annotations.proto";
-import "cosmos/base/query/v1beta1/pagination.proto";
-import "neutron/epochs/genesis.proto";
-
-option go_package = "github.com/neutron-org/neutron/x/epochs/types";
-
-// Query defines the gRPC querier service.
-service Query {
- // EpochInfos provide running epochInfos
- rpc EpochInfos(QueryEpochsInfoRequest) returns (QueryEpochsInfoResponse) {
- option (google.api.http).get = "/neutron/epochs/epochs";
- }
- // CurrentEpoch provide current epoch of specified identifier
- rpc CurrentEpoch(QueryCurrentEpochRequest)
- returns (QueryCurrentEpochResponse) {
- option (google.api.http).get = "/neutron/epochs/current_epoch";
- }
-}
-
-message QueryEpochsInfoRequest {}
-message QueryEpochsInfoResponse {
- repeated EpochInfo epochs = 1 [ (gogoproto.nullable) = false ];
-}
-
-message QueryCurrentEpochRequest { string identifier = 1; }
-message QueryCurrentEpochResponse { int64 current_epoch = 1; }
\ No newline at end of file
diff --git a/proto/neutron/incentives/account_history.proto b/proto/neutron/incentives/account_history.proto
deleted file mode 100644
index 22188f152..000000000
--- a/proto/neutron/incentives/account_history.proto
+++ /dev/null
@@ -1,19 +0,0 @@
-syntax = "proto3";
-package neutron.incentives;
-
-import "gogoproto/gogo.proto";
-import "cosmos/base/v1beta1/coin.proto";
-
-option go_package = "github.com/neutron-org/neutron/x/incentives/types";
-
-// Describes the total distributions to an account over time
-message AccountHistory {
- // the address of this account
- string account = 1;
-
- // coins describes the total amount of coins that have been distributed to this user over time
- repeated cosmos.base.v1beta1.Coin coins = 2 [
- (gogoproto.nullable) = false,
- (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
- ];
-}
diff --git a/proto/neutron/incentives/gauge.proto b/proto/neutron/incentives/gauge.proto
deleted file mode 100644
index 5399bc761..000000000
--- a/proto/neutron/incentives/gauge.proto
+++ /dev/null
@@ -1,115 +0,0 @@
-syntax = "proto3";
-package neutron.incentives;
-
-import "gogoproto/gogo.proto";
-import "google/protobuf/duration.proto";
-import "google/protobuf/timestamp.proto";
-import "cosmos/base/v1beta1/coin.proto";
-import "neutron/dex/pair_id.proto";
-
-option go_package = "github.com/neutron-org/neutron/x/incentives/types";
-
-// Gauge is an object that describes an LP incentivization plan and its state.
-message Gauge {
- // id is the unique ID of a Gauge
- uint64 id = 1;
-
- // There are two kinds of gauges: perpetual and non-perpetual. Perpetual
- // gauges describe an incentivization program for which the token rewards
- // distributed on any given day must be added to the gauge prior to that day's
- // distribution using an AddToGauge message. When distribute is called on a
- // perpetual gauge, all of the remaining rewards in the gauge are distributed.
- // Because of this, all perpetual gauges must have `num_epochs_paid_over` set
- // to 1. A non-perpetual gauge by contrast distributes its rewards over a
- // schedule as determined by `num_epochs_paid_over`. If a non-perpetual gauge
- // is created with coins=[100atom] and num_epochs_paid_over=10, this means
- // that for 10 days (10 epochs) the gauge will distribute 10atom each day to
- // the staked LP positions qualifying for the gauge.
- bool is_perpetual = 2;
-
- // distribute_to describes a set of staked LP positions that should be
- // distributed to from this gauge.
- QueryCondition distribute_to = 3
- [ (gogoproto.nullable) = false ];
-
- // coins describes the total amount of coins that have been added to this
- // gauge for distribution.
- repeated cosmos.base.v1beta1.Coin coins = 4 [
- (gogoproto.nullable) = false,
- (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
- ];
-
- // start_time describes when this gauge should begin distributing rewards.
- // This allows gauge creators to schedule gauges into the future, in the event
- // that an earlier gauge is expected to expire.
- google.protobuf.Timestamp start_time = 5 [
- (gogoproto.stdtime) = true,
- (gogoproto.nullable) = false,
- (gogoproto.moretags) = "yaml:\"start_time\""
- ];
-
- // num_epochs_paid_over is the number of total epochs (days) the rewards in
- // this gauge will be distributed over.
- uint64 num_epochs_paid_over = 6;
-
- // filled_epochs describes the number of epochs distribution have been completed
- // already
- uint64 filled_epochs = 7;
-
- // distributed_coins describes coins that have been distributed already from
- // this gauge.
- repeated cosmos.base.v1beta1.Coin distributed_coins = 8 [
- (gogoproto.nullable) = false,
- (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
- ];
-
- // pricing_tick is necessary for fairly distributing rewards over a range of
- // ticks. Without pricing_tick, we might naively distribute rewards in
- // proportion to the number of deposit shares staked within the gauge's
- // qualifying tick range.
- //
- // For example, a gauge with a distribute_to tick range of [-10, 10] would
- // distribute to staked LP tokens where both tick-fee and tick+fee are within
- // [-10, 10]. Let's say for pair "tokenA<>tokenB", the current trading tick is
- // 0. If Alice were to LP (10tokenA, 0tokenB) @ tick -8, fee 2, this would
- // mean Alice would be issued 10 shares (10 + 0 * 1.0001^-8), since shares are
- // in terms of token0. Let's further assume Bob LPs (0tokenA, 10tokenB) @ tick
- // 8, fee 2, such that Bob is issued 10.008 shares (0 + 10 * 1.0001^8). Under
- // this naive approach, if Alice and Bob were to stake their shares, Bob would
- // receive more in rewards, purely on the basis of the relative locations of
- // their liquidity.
- //
- // This disparity originates in the fact that LP deposit denominations are not
- // fungible across ticks. To avoid this, we can use a single price throughout
- // the gauge's tick range for relating the relative value of token0 and
- // token1, as specified by pricing_tick.
- //
- // Let's run through the earier example using the more sophisticated approach,
- // where the gauge has pricing_tick set to 0. For the purpose of calculating
- // reward distribution weight, Alice's shares are worth 10 + 0 * 1.0001^0 = 10
- // and Bob's shares are worth 0 + 10 * 1.0001^0 = 10. With the distribution
- // weight of both shares set according to a gauge-specific tick, we do not
- // distribute more or less rewards according to the relative location of
- // liquidity within the gauge's tick range, freeing users to place liquidity
- // whereever they deem most profitable in the gauge's range and still equally
- // qualify for rewards.
- int64 pricing_tick = 9;
-}
-
-// QueryCondition describes a set of staked LP positions that a gauge is
-// configured to distribute to. LP tokens qualifying for a given QueryCondition
-// must have both tick-fee and tick+fee fall within the range [startTick, endTick],
-// such that all of the tradable liquidity for the pool is within that range.
-message QueryCondition {
-
- // pairID is the token pair which should be distributed to.
- neutron.dex.PairID pairID = 1;
-
- // start_tick is the inclusive lower bound on the location of LP tokens that
- // qualify for a gauge's distribution.
- int64 startTick = 2;
-
- // end_tick is the inclusive upper bound on the location of LP tokens that
- // qualify for a gauge's distribution.
- int64 endTick = 3;
-}
\ No newline at end of file
diff --git a/proto/neutron/incentives/genesis.proto b/proto/neutron/incentives/genesis.proto
deleted file mode 100644
index 739095ca6..000000000
--- a/proto/neutron/incentives/genesis.proto
+++ /dev/null
@@ -1,26 +0,0 @@
-syntax = "proto3";
-package neutron.incentives;
-
-import "gogoproto/gogo.proto";
-import "neutron/incentives/params.proto";
-import "neutron/incentives/gauge.proto";
-import "neutron/incentives/stake.proto";
-import "neutron/incentives/account_history.proto";
-
-option go_package = "github.com/neutron-org/neutron/x/incentives/types";
-
-// GenesisState defines the incentives module's various parameters when first
-// initialized
-message GenesisState {
- // params are all the parameters of the module
- Params params = 1 [ (gogoproto.nullable) = false ];
- // gauges are all gauges that should exist at genesis
- repeated Gauge gauges = 2;
- // last_gauge_id is what the gauge number will increment from when creating
- // the next gauge after genesis
- uint64 last_gauge_id = 3;
-
- uint64 last_stake_id = 4;
- repeated Stake stakes = 5;
- repeated AccountHistory accountHistories = 6;
-}
diff --git a/proto/neutron/incentives/params.proto b/proto/neutron/incentives/params.proto
deleted file mode 100644
index 99a7693da..000000000
--- a/proto/neutron/incentives/params.proto
+++ /dev/null
@@ -1,17 +0,0 @@
-syntax = "proto3";
-package neutron.incentives;
-
-import "gogoproto/gogo.proto";
-
-option go_package = "github.com/neutron-org/neutron/x/incentives/types";
-
-// Params holds parameters for the incentives module
-message Params {
- // distr_epoch_identifier is what epoch type distribution will be triggered by
- // (day, week, etc.)
- string distr_epoch_identifier = 1
- [ (gogoproto.moretags) = "yaml:\"distr_epoch_identifier\"" ];
-
- uint64 max_gauges = 2
- [ (gogoproto.moretags) = "yaml:\"max_gauges\"" ];
-}
diff --git a/proto/neutron/incentives/query.proto b/proto/neutron/incentives/query.proto
deleted file mode 100644
index 0ea1c02ee..000000000
--- a/proto/neutron/incentives/query.proto
+++ /dev/null
@@ -1,161 +0,0 @@
-syntax = "proto3";
-package neutron.incentives;
-
-import "gogoproto/gogo.proto";
-import "google/api/annotations.proto";
-import "cosmos/base/v1beta1/coin.proto";
-import "cosmos/base/query/v1beta1/pagination.proto";
-import "neutron/incentives/gauge.proto";
-import "neutron/incentives/stake.proto";
-import "neutron/incentives/params.proto";
-
-option go_package = "github.com/neutron-org/neutron/x/incentives/types";
-
-// Query defines the gRPC querier service
-service Query {
- // GetModuleStatus returns a rundown of coins in the module and their status
- rpc GetModuleStatus(GetModuleStatusRequest)
- returns (GetModuleStatusResponse) {
- option (google.api.http).get =
- "/neutron/incentives/v1beta1/module_status";
- }
-
- // GetGaugeByID returns a gauge by its ID
- rpc GetGaugeByID(GetGaugeByIDRequest) returns (GetGaugeByIDResponse) {
- option (google.api.http).get =
- "/neutron/incentives/v1beta1/gauges/{id}";
- }
-
- // GetGauges returns gauges according to the filter provided
- rpc GetGauges(GetGaugesRequest) returns (GetGaugesResponse) {
- option (google.api.http).get = "/neutron/incentives/v1beta1/gauges";
- }
-
- // GetStakeByID returns a stake by its ID
- rpc GetStakeByID(GetStakeByIDRequest) returns (GetStakeByIDResponse) {
- option (google.api.http).get =
- "/neutron/incentives/stakes/{stake_id}";
- }
-
- // GetStakes returns stakes by the filter provided. At least one filter must be provided.
- rpc GetStakes(GetStakesRequest) returns (GetStakesResponse) {
- option (google.api.http).get =
- "/neutron/incentives/stakes";
- }
-
- // GetFutureRewardsEstimate returns an estimate of the rewards from now until a specified
- // time in the future. The requestor either provides an address or a set of locks
- // for which they want to find the associated rewards.
- rpc GetFutureRewardEstimate(GetFutureRewardEstimateRequest) returns (GetFutureRewardEstimateResponse) {
- option (google.api.http).get =
- "/neutron/incentives/v1beta1/future_rewards_estimate/{owner}";
- }
-
- // GetAccountHistory returns the total accumulated rewards per denom for a given user.
- rpc GetAccountHistory(GetAccountHistoryRequest) returns (GetAccountHistoryResponse) {
- option (google.api.http).get =
- "/neutron/incentives/v1beta1/account_history/{account}";
- }
-
- // Returns the total amount of value currently qualifying for the gauge. This is useful for calculating
- // the prospective future rewards of staking.
- rpc GetGaugeQualifyingValue(GetGaugeQualifyingValueRequest) returns (GetGaugeQualifyingValueResponse) {
- option (google.api.http).get =
- "/neutron/incentives/v1beta1/get_gauge_qualifying_value/{id}";
- }
-}
-
-message GetModuleStatusRequest {}
-message GetModuleStatusResponse {
- // Coins that have yet to be distributed
- repeated cosmos.base.v1beta1.Coin reward_coins = 1 [
- (gogoproto.nullable) = false,
- (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
- ];
- repeated cosmos.base.v1beta1.Coin staked_coins = 2 [
- (gogoproto.nullable) = false,
- (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
- ];
- Params params = 3 [ (gogoproto.nullable) = false ];
-}
-
-message GetGaugeByIDRequest {
- // Gague ID being queried
- uint64 id = 1;
-}
-message GetGaugeByIDResponse {
- // Gauge that corresponds to provided gague ID
- Gauge gauge = 1;
-}
-
-message GetGaugeQualifyingValueRequest {
- // Gague ID being queried
- uint64 id = 1;
-}
-message GetGaugeQualifyingValueResponse {
- // The amount of value at the gauge's pricing tick currently qualifying for the gauge.
- uint64 qualifying_value = 1;
-}
-
-enum GaugeStatus {
- ACTIVE_UPCOMING = 0;
- ACTIVE = 1;
- UPCOMING = 2;
- FINISHED = 3;
-}
-
-message GetGaugesRequest {
- // Pagination defines pagination for the request
-
- GaugeStatus status = 1;
- string denom = 2;
-}
-message GetGaugesResponse {
- // Upcoming and active gauges
- repeated Gauge gauges = 1;
-}
-
-message GetStakeByIDRequest {
- uint64 stake_id = 1;
-};
-message GetStakeByIDResponse {
- Stake stake = 1;
-};
-
-message GetStakesRequest {
- string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
-};
-
-message GetStakesResponse {
- repeated Stake stakes = 1;
-};
-
-message GetFutureRewardEstimateRequest {
- // Address that is being queried for future estimated rewards
- string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
- // Stake IDs included in future reward estimation
- repeated uint64 stake_ids = 2;
- // Determines upper time limit of reward estimation
- // reward estimation goes up to current_epoch + num_epochs
- int64 num_epochs = 3;
-}
-message GetFutureRewardEstimateResponse {
- // Estimated coin rewards that will be recieved at provided address
- // from specified locks between current time and end epoch
- repeated cosmos.base.v1beta1.Coin coins = 1 [
- (gogoproto.nullable) = false,
- (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
- ];
-}
-
-message GetAccountHistoryRequest {
- // Address that is being queried for account history
- string account = 1 [ (gogoproto.moretags) = "yaml:\"account\"" ];
-}
-message GetAccountHistoryResponse {
- // Gauge rewards that have been distributed to this address to date
- repeated cosmos.base.v1beta1.Coin coins = 1 [
- (gogoproto.nullable) = false,
- (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
- ];
-}
diff --git a/proto/neutron/incentives/stake.proto b/proto/neutron/incentives/stake.proto
deleted file mode 100644
index 690c4e9fa..000000000
--- a/proto/neutron/incentives/stake.proto
+++ /dev/null
@@ -1,41 +0,0 @@
-syntax = "proto3";
-package neutron.incentives;
-
-import "gogoproto/gogo.proto";
-import "google/protobuf/timestamp.proto";
-import "cosmos/base/v1beta1/coin.proto";
-
-option go_package = "github.com/neutron-org/neutron/x/incentives/types";
-
-// Stake records what coins are staked when by who for the purpose of
-// calculating gauge reward distributions.
-message Stake {
-
- // ID is the "autoincrementing" id of the stake, assigned at creation.
- uint64 ID = 1;
-
- // owner is the account originating the stake. Only the owner can withdraw
- // coins from the stake.
- string owner = 2 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
-
- // start_time is the time at which the coins in the lock were staked.
- google.protobuf.Timestamp start_time = 3 [
- (gogoproto.stdtime) = true,
- (gogoproto.nullable) = false,
- (gogoproto.jsontag) = "start_time,omitempty",
- (gogoproto.moretags) = "yaml:\"start_time\""
- ];
-
- // coins are the tokens staked, and managed by the module account.
- repeated cosmos.base.v1beta1.Coin coins = 4 [
- (gogoproto.nullable) = false,
- (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
- ];
-
- // start_dist_epoch is the dist epoch (defaulting to the day) at which the
- // coins in the lock were staked. This is used by distribution logic to filter
- // on stakes that have existed for longer than the distribution period (you
- // can only qualify for today's rewards if you staked your LP tokens
- // yesterday). We use int64 instead of uint64 to make testing easier.
- int64 start_dist_epoch = 5;
-}
\ No newline at end of file
diff --git a/proto/neutron/incentives/tx.proto b/proto/neutron/incentives/tx.proto
deleted file mode 100644
index cb6487234..000000000
--- a/proto/neutron/incentives/tx.proto
+++ /dev/null
@@ -1,119 +0,0 @@
-syntax = "proto3";
-package neutron.incentives;
-
-import "gogoproto/gogo.proto";
-import "google/protobuf/timestamp.proto";
-import "cosmos/base/v1beta1/coin.proto";
-import "neutron/incentives/gauge.proto";
-import "neutron/incentives/stake.proto";
-import "google/protobuf/duration.proto";
-import "amino/amino.proto";
-import "neutron/incentives/params.proto";
-import "cosmos/msg/v1/msg.proto";
-import "cosmos_proto/cosmos.proto";
-
-option go_package = "github.com/neutron-org/neutron/x/incentives/types";
-
-service Msg {
- // Create an incentive program
- rpc CreateGauge(MsgCreateGauge) returns (MsgCreateGaugeResponse);
- // Add rewards to an existing incentives program
- rpc AddToGauge(MsgAddToGauge) returns (MsgAddToGaugeResponse);
- // Deposit LP tokens to the module, qualifying for rewards from gauges
- rpc Stake(MsgStake) returns (MsgStakeResponse);
- // Withdraw LP tokens from the module, forfeiting future rewards from gauges
- rpc Unstake(MsgUnstake) returns (MsgUnstakeResponse);
- // Update incentives params
- rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
-}
-
-// MsgCreateGauge creates a gague to distribute rewards to users
-message MsgCreateGauge {
- // is_perpetual shows if it's a perpetual or non-perpetual gauge
- // Non-perpetual gauges distribute their tokens equally per epoch while the
- // gauge is in the active period. Perpetual gauges distribute all their tokens
- // at a single time and only distribute their tokens again once the gauge is
- // refilled
- bool is_perpetual = 1;
-
- // owner is the address of gauge creator, should be the module authority
- string owner = 2 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
-
- // distribute_to show which lock the gauge should distribute to by time
- // duration or by timestamp
- QueryCondition distribute_to = 3
- [ (gogoproto.nullable) = false ];
- // coins are coin(s) to be distributed by the gauge
- repeated cosmos.base.v1beta1.Coin coins = 4 [
- (gogoproto.nullable) = false,
- (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
- ];
- // start_time is the distribution start time
- google.protobuf.Timestamp start_time = 5 [
- (gogoproto.stdtime) = true,
- (gogoproto.nullable) = false,
- (gogoproto.moretags) = "yaml:\"timestamp\""
- ];
- // num_epochs_paid_over is the number of epochs distribution will be completed
- // over
- uint64 num_epochs_paid_over = 6;
-
- // pricing_tick is the price that liquidity within the gauge range will be priced at
- int64 pricing_tick = 7;
-}
-message MsgCreateGaugeResponse {}
-
-// MsgAddToGauge adds coins to a previously created gauge
-message MsgAddToGauge {
- // owner is the gauge owner's address
- string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
- // gauge_id is the ID of gauge that rewards are getting added to
- uint64 gauge_id = 2;
- // rewards are the coin(s) to add to gauge
- repeated cosmos.base.v1beta1.Coin rewards = 3 [
- (gogoproto.nullable) = false,
- (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
- ];
-}
-message MsgAddToGaugeResponse {}
-
-message MsgStake {
- string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
- repeated cosmos.base.v1beta1.Coin coins = 2 [
- (gogoproto.nullable) = false,
- (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
- ];
-}
-message MsgStakeResponse { uint64 ID = 1; }
-
-message MsgUnstake {
- message UnstakeDescriptor {
- uint64 ID = 1;
- repeated cosmos.base.v1beta1.Coin coins = 2 [
- (gogoproto.nullable) = false,
- (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
- ];
- }
- string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
-
- // If unstake is left empty, this is interpreted as "unstake all"
- repeated UnstakeDescriptor unstakes = 2;
-}
-message MsgUnstakeResponse {}
-
-message MsgUpdateParams {
- option (amino.name) = "dex/MsgUpdateParams";
- option (cosmos.msg.v1.signer) = "authority";
-
- // Authority is the address of the governance account.
- string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
- // NOTE: All parameters must be supplied.
- Params params = 2
- [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
-}
-
-// MsgUpdateParamsResponse defines the response structure for executing a
-// MsgUpdateParams message.
-//
-// Since: 0.47
-message MsgUpdateParamsResponse {}
diff --git a/testutil/apptesting/test_suite.go b/testutil/apptesting/test_suite.go
index 4f885b495..6a6bf9b46 100644
--- a/testutil/apptesting/test_suite.go
+++ b/testutil/apptesting/test_suite.go
@@ -46,21 +46,6 @@ func (s *KeeperTestHelper) Setup() {
GRPCQueryRouter: s.App.GRPCQueryRouter(),
Ctx: s.Ctx,
}
-
- s.SetEpochStartTime()
-}
-
-func (s *KeeperTestHelper) SetEpochStartTime() {
- epochsKeeper := s.App.EpochsKeeper
-
- for _, epoch := range epochsKeeper.AllEpochInfos(s.Ctx) {
- epoch.StartTime = s.Ctx.BlockTime()
- epochsKeeper.DeleteEpochInfo(s.Ctx, epoch.Identifier)
- err := epochsKeeper.AddEpochInfo(s.Ctx, epoch)
- if err != nil {
- panic(err)
- }
- }
}
// setupAddr takes a balance, prefix, and address number. Then returns the respective account address byte array.
diff --git a/wasmbinding/stargate_allowlist.go b/wasmbinding/stargate_allowlist.go
index ac0a41597..30f0843b2 100644
--- a/wasmbinding/stargate_allowlist.go
+++ b/wasmbinding/stargate_allowlist.go
@@ -9,9 +9,7 @@ import (
ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
ibcconnectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
dextypes "github.com/neutron-org/neutron/x/dex/types"
- epochstypes "github.com/neutron-org/neutron/x/epochs/types"
feeburnertypes "github.com/neutron-org/neutron/x/feeburner/types"
- incentivestypes "github.com/neutron-org/neutron/x/incentives/types"
interchainqueriestypes "github.com/neutron-org/neutron/x/interchainqueries/types"
interchaintxstypes "github.com/neutron-org/neutron/x/interchaintxs/types"
tokenfactorytypes "github.com/neutron-org/neutron/x/tokenfactory/types"
@@ -65,19 +63,5 @@ func AcceptedStargateQueries() wasmkeeper.AcceptedStargateQueries {
"/neutron.dex.Query/PoolReserves": &dextypes.QueryGetPoolReservesResponse{},
"/neutron.dex.Query/EstimateMultiHopSwap": &dextypes.QueryEstimateMultiHopSwapResponse{},
"/neutron.dex.Query/EstimatePlaceLimitOrder": &dextypes.QueryEstimatePlaceLimitOrderResponse{},
-
- // incentives
- "/neutron.incentives.Query/GetModuleStatus": &incentivestypes.GetModuleStatusResponse{},
- "/neutron.incentives.Query/GetGaugeByID": &incentivestypes.GetGaugeByIDResponse{},
- "/neutron.incentives.Query/GetGauges": &incentivestypes.GetGaugesResponse{},
- "/neutron.incentives.Query/GetStakeByID": &incentivestypes.GetStakeByIDResponse{},
- "/neutron.incentives.Query/GetStakes": &incentivestypes.GetStakesResponse{},
- "/neutron.incentives.Query/GetFutureRewardEstimate": &incentivestypes.GetFutureRewardEstimateResponse{},
- "/neutron.incentives.Query/GetAccountHistory": &incentivestypes.GetAccountHistoryResponse{},
- "/neutron.incentives.Query/GetGaugeQualifyingValue": &incentivestypes.GetGaugeQualifyingValueResponse{},
-
- // epochs
- "/neutron.epochs.Query/EpochInfos": &epochstypes.QueryEpochsInfoResponse{},
- "/neutron.epochs.Query/CurrentEpoch": &epochstypes.QueryCurrentEpochResponse{},
}
}
diff --git a/x/dex/keeper/liquidity.go b/x/dex/keeper/liquidity.go
index a24ec9bfb..1b86c504b 100644
--- a/x/dex/keeper/liquidity.go
+++ b/x/dex/keeper/liquidity.go
@@ -3,6 +3,7 @@ package keeper
import (
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
+
math_utils "github.com/neutron-org/neutron/utils/math"
"github.com/neutron-org/neutron/x/dex/types"
)
diff --git a/x/dex/keeper/liquidity_test.go b/x/dex/keeper/liquidity_test.go
index 0cfdad2b7..94d42ef68 100644
--- a/x/dex/keeper/liquidity_test.go
+++ b/x/dex/keeper/liquidity_test.go
@@ -5,6 +5,7 @@ import (
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
+
"github.com/neutron-org/neutron/x/dex/types"
)
diff --git a/x/dex/keeper/multihop_swap.go b/x/dex/keeper/multihop_swap.go
index 656a76732..a9acc89e4 100644
--- a/x/dex/keeper/multihop_swap.go
+++ b/x/dex/keeper/multihop_swap.go
@@ -4,6 +4,7 @@ import (
sdkerrors "cosmossdk.io/errors"
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
+
math_utils "github.com/neutron-org/neutron/utils/math"
"github.com/neutron-org/neutron/x/dex/types"
)
diff --git a/x/dex/types/message_deposit.go b/x/dex/types/message_deposit.go
index 83d29eaab..b53a9b33c 100644
--- a/x/dex/types/message_deposit.go
+++ b/x/dex/types/message_deposit.go
@@ -73,7 +73,8 @@ func (msg *MsgDeposit) ValidateBasic() error {
numDeposits := len(msg.AmountsA)
if numDeposits != len(msg.Fees) ||
numDeposits != len(msg.TickIndexesAToB) ||
- numDeposits != len(msg.AmountsB) {
+ numDeposits != len(msg.AmountsB) ||
+ numDeposits != len(msg.Options) {
return ErrUnbalancedTxArray
}
if numDeposits == 0 {
diff --git a/x/dex/types/message_deposit_test.go b/x/dex/types/message_deposit_test.go
index e06bd3e5d..233dfb139 100644
--- a/x/dex/types/message_deposit_test.go
+++ b/x/dex/types/message_deposit_test.go
@@ -4,9 +4,10 @@ import (
"testing"
"cosmossdk.io/math"
+ "github.com/stretchr/testify/require"
+
"github.com/neutron-org/neutron/testutil/common/sample"
. "github.com/neutron-org/neutron/x/dex/types"
- "github.com/stretchr/testify/require"
)
func TestMsgDeposit_ValidateBasic(t *testing.T) {
@@ -24,6 +25,7 @@ func TestMsgDeposit_ValidateBasic(t *testing.T) {
TickIndexesAToB: []int64{0},
AmountsA: []math.Int{math.OneInt()},
AmountsB: []math.Int{math.OneInt()},
+ Options: []*DepositOptions{{false}},
},
err: ErrInvalidAddress,
},
@@ -36,6 +38,7 @@ func TestMsgDeposit_ValidateBasic(t *testing.T) {
TickIndexesAToB: []int64{0},
AmountsA: []math.Int{math.OneInt()},
AmountsB: []math.Int{math.OneInt()},
+ Options: []*DepositOptions{{false}},
},
err: ErrInvalidAddress,
},
@@ -48,6 +51,7 @@ func TestMsgDeposit_ValidateBasic(t *testing.T) {
TickIndexesAToB: []int64{},
AmountsA: []math.Int{},
AmountsB: []math.Int{},
+ Options: []*DepositOptions{{false}},
},
err: ErrUnbalancedTxArray,
},
@@ -108,6 +112,7 @@ func TestMsgDeposit_ValidateBasic(t *testing.T) {
TickIndexesAToB: []int64{0, 0, 0},
AmountsA: []math.Int{math.OneInt(), math.OneInt(), math.OneInt()},
AmountsB: []math.Int{math.OneInt(), math.OneInt(), math.OneInt()},
+ Options: []*DepositOptions{{false}, {false}, {false}},
},
err: ErrDuplicatePoolDeposit,
},
@@ -120,6 +125,7 @@ func TestMsgDeposit_ValidateBasic(t *testing.T) {
TickIndexesAToB: []int64{0},
AmountsA: []math.Int{math.ZeroInt()},
AmountsB: []math.Int{math.ZeroInt()},
+ Options: []*DepositOptions{{false}},
},
err: ErrZeroDeposit,
},
@@ -132,6 +138,7 @@ func TestMsgDeposit_ValidateBasic(t *testing.T) {
TickIndexesAToB: []int64{0},
AmountsA: []math.Int{math.OneInt()},
AmountsB: []math.Int{math.OneInt()},
+ Options: []*DepositOptions{{false}},
},
},
}
diff --git a/x/dex/types/pool_denom.go b/x/dex/types/pool_denom.go
index 1d3ddbbfc..8ec7547cb 100644
--- a/x/dex/types/pool_denom.go
+++ b/x/dex/types/pool_denom.go
@@ -21,10 +21,9 @@ func NewPoolDenom(poolID uint64) string {
}
func ValidatePoolDenom(denom string) error {
- if !PoolDenomRegexp.MatchString(denom) {
- return ErrInvalidPoolDenom
+ if _, err := ParsePoolIDFromDenom(denom); err != nil {
+ return err
}
-
return nil
}
diff --git a/x/dex/types/pool_denom_test.go b/x/dex/types/pool_denom_test.go
index 0d46a66f8..57683a701 100644
--- a/x/dex/types/pool_denom_test.go
+++ b/x/dex/types/pool_denom_test.go
@@ -3,11 +3,12 @@ package types_test
import (
"testing"
- . "github.com/neutron-org/neutron/x/dex/types"
"github.com/stretchr/testify/require"
+
+ . "github.com/neutron-org/neutron/x/dex/types"
)
-func TestParsePoolIDFromDenom(t *testing.T) {
+func TestValidatePoolDenom(t *testing.T) {
for _, tc := range []struct {
desc string
denom string
@@ -26,6 +27,11 @@ func TestParsePoolIDFromDenom(t *testing.T) {
expected: 999999999,
valid: true,
},
+ {
+ desc: "invalid denom long",
+ denom: "neutron/pool/99999999999999999999",
+ valid: false,
+ },
{
desc: "invalid format 1",
denom: "/neutron/pool/0",
@@ -43,12 +49,15 @@ func TestParsePoolIDFromDenom(t *testing.T) {
},
} {
t.Run(tc.desc, func(t *testing.T) {
+ validateError := ValidatePoolDenom(tc.denom)
id, err := ParsePoolIDFromDenom(tc.denom)
if tc.valid {
require.NoError(t, err)
+ require.NoError(t, validateError)
require.Equal(t, tc.expected, id)
} else {
require.Error(t, err)
+ require.Equal(t, err, validateError)
}
})
}
diff --git a/x/dex/types/tx.pb.go b/x/dex/types/tx.pb.go
index a90fadfc9..488966197 100644
--- a/x/dex/types/tx.pb.go
+++ b/x/dex/types/tx.pb.go
@@ -121,8 +121,8 @@ type MsgDeposit struct {
Receiver string `protobuf:"bytes,2,opt,name=receiver,proto3" json:"receiver,omitempty"`
TokenA string `protobuf:"bytes,3,opt,name=tokenA,proto3" json:"tokenA,omitempty"`
TokenB string `protobuf:"bytes,4,opt,name=tokenB,proto3" json:"tokenB,omitempty"`
- AmountsA []github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,rep,name=amountsA,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amountA" yaml:"amountsA"`
- AmountsB []github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,rep,name=amountsB,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amountB" yaml:"amountsB"`
+ AmountsA []github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,rep,name=amountsA,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amountsA" yaml:"amountsA"`
+ AmountsB []github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,rep,name=amountsB,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amountsB" yaml:"amountsB"`
TickIndexesAToB []int64 `protobuf:"varint,7,rep,packed,name=tickIndexesAToB,proto3" json:"tickIndexesAToB,omitempty"`
Fees []uint64 `protobuf:"varint,8,rep,packed,name=fees,proto3" json:"fees,omitempty"`
Options []*DepositOptions `protobuf:"bytes,9,rep,name=Options,proto3" json:"Options,omitempty"`
@@ -960,97 +960,96 @@ func init() {
func init() { proto.RegisterFile("neutron/dex/tx.proto", fileDescriptor_a489f6e187d5e074) }
var fileDescriptor_a489f6e187d5e074 = []byte{
- // 1425 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xcf, 0x8f, 0xd3, 0xc6,
- 0x17, 0x5f, 0x27, 0x21, 0xd9, 0xcc, 0xfe, 0xca, 0xce, 0x02, 0x6b, 0xc2, 0xf7, 0x9b, 0x44, 0x86,
- 0x2f, 0xe4, 0xbb, 0x12, 0x09, 0xd9, 0xaa, 0x48, 0xa5, 0xa7, 0x78, 0x77, 0x69, 0x0d, 0x09, 0x59,
- 0x99, 0x50, 0xd4, 0x56, 0x6a, 0xe4, 0x75, 0x86, 0xc4, 0xda, 0xd8, 0x63, 0x79, 0x26, 0x4b, 0xf6,
- 0xd0, 0x43, 0x7b, 0x44, 0xad, 0xc4, 0xa5, 0x27, 0xfe, 0x81, 0xf6, 0xc6, 0x01, 0xa9, 0x87, 0xfe,
- 0x03, 0x1c, 0x51, 0x7b, 0xa9, 0x7a, 0x48, 0x2b, 0x38, 0x20, 0x71, 0x5c, 0xa9, 0xf7, 0xca, 0xe3,
- 0xb1, 0x63, 0x3b, 0x2c, 0xcb, 0x42, 0xdb, 0x4b, 0x32, 0xf3, 0xde, 0x67, 0x3e, 0xef, 0xcd, 0x9b,
- 0x37, 0xef, 0x8d, 0xc1, 0x49, 0x0b, 0x0d, 0xa9, 0x83, 0xad, 0x6a, 0x17, 0x8d, 0xaa, 0x74, 0x54,
- 0xb1, 0x1d, 0x4c, 0x31, 0x9c, 0xe3, 0xd2, 0x4a, 0x17, 0x8d, 0xf2, 0x27, 0x7b, 0xb8, 0x87, 0x99,
- 0xbc, 0xea, 0x8e, 0x3c, 0x48, 0xbe, 0xa0, 0x63, 0x62, 0x62, 0x52, 0xdd, 0xd1, 0x08, 0xaa, 0xee,
- 0xd5, 0x76, 0x10, 0xd5, 0x6a, 0x55, 0x1d, 0x1b, 0x16, 0xd7, 0x17, 0x7b, 0x18, 0xf7, 0x06, 0xa8,
- 0xca, 0x66, 0x3b, 0xc3, 0xbb, 0x55, 0x6a, 0x98, 0x88, 0x50, 0xcd, 0xb4, 0x39, 0x60, 0x59, 0x33,
- 0x0d, 0x0b, 0x57, 0xd9, 0x2f, 0x17, 0x89, 0x61, 0x67, 0x6c, 0xcd, 0xd1, 0x4c, 0xc2, 0x35, 0xab,
- 0xdc, 0x9a, 0x49, 0x7a, 0xd5, 0xbd, 0x9a, 0xfb, 0xc7, 0x15, 0x67, 0x3c, 0x45, 0xc7, 0xf3, 0xcf,
- 0x9b, 0x78, 0x2a, 0xe9, 0x43, 0xb0, 0xb8, 0x89, 0x6c, 0x4c, 0x0c, 0xda, 0xb2, 0xa9, 0x81, 0x2d,
- 0x02, 0xff, 0x0f, 0x72, 0x5d, 0x83, 0x68, 0x3b, 0x03, 0xd4, 0xd1, 0x86, 0x14, 0x93, 0x7b, 0x9a,
- 0x2d, 0x0a, 0x25, 0xa1, 0x3c, 0xab, 0x2e, 0x71, 0x79, 0x9d, 0x8b, 0xa5, 0x9f, 0x92, 0x00, 0x34,
- 0x49, 0x8f, 0x13, 0x40, 0x11, 0x64, 0x74, 0x07, 0x69, 0x14, 0x3b, 0x6c, 0x41, 0x56, 0xf5, 0xa7,
- 0x30, 0x0f, 0x66, 0x1d, 0xa4, 0x23, 0x63, 0x0f, 0x39, 0x62, 0x82, 0xa9, 0x82, 0x39, 0x3c, 0x0d,
- 0xd2, 0x14, 0xef, 0x22, 0xab, 0x2e, 0x26, 0x99, 0x86, 0xcf, 0x02, 0xb9, 0x2c, 0xa6, 0x42, 0x72,
- 0x19, 0xf6, 0xc1, 0xac, 0x66, 0xe2, 0xa1, 0x45, 0x49, 0x5d, 0x3c, 0x51, 0x4a, 0x96, 0xb3, 0x72,
- 0xe3, 0xc9, 0xb8, 0x38, 0xf3, 0xdb, 0xb8, 0x78, 0xa1, 0x67, 0xd0, 0xfe, 0x70, 0xa7, 0xa2, 0x63,
- 0x93, 0x6f, 0x92, 0xff, 0x5d, 0x22, 0xdd, 0xdd, 0x2a, 0xdd, 0xb7, 0x11, 0xa9, 0x28, 0x16, 0x7d,
- 0x39, 0x2e, 0x66, 0x3c, 0x86, 0xfa, 0xc1, 0xb8, 0xb8, 0xb4, 0xaf, 0x99, 0x83, 0xab, 0x92, 0x4f,
- 0x29, 0xa9, 0x01, 0x7b, 0xc8, 0x92, 0x2c, 0xa6, 0xdf, 0xcd, 0x92, 0x3c, 0x65, 0x49, 0x9e, 0x58,
- 0x92, 0x61, 0x19, 0x2c, 0x51, 0x43, 0xdf, 0x55, 0xac, 0x2e, 0x1a, 0x21, 0x52, 0x6f, 0x63, 0x59,
- 0xcc, 0x94, 0x92, 0xe5, 0xa4, 0x1a, 0x17, 0x43, 0x08, 0x52, 0x77, 0x11, 0x22, 0xe2, 0x6c, 0x29,
- 0x59, 0x4e, 0xa9, 0x6c, 0x0c, 0xdf, 0x07, 0x19, 0x7e, 0x78, 0x62, 0xb6, 0x94, 0x2c, 0xcf, 0xad,
- 0x9f, 0xad, 0x84, 0x52, 0xb3, 0x12, 0x3d, 0x5f, 0xd5, 0xc7, 0x4a, 0x8f, 0x13, 0x00, 0x4e, 0x4e,
- 0x4f, 0x45, 0xc4, 0xc6, 0x16, 0x41, 0xf0, 0x5b, 0x01, 0x2c, 0xab, 0x88, 0x20, 0x67, 0x0f, 0x5d,
- 0xe6, 0x3a, 0xd4, 0x15, 0x05, 0xb6, 0xff, 0xce, 0xb1, 0xf7, 0xbf, 0xec, 0xc4, 0xa9, 0x0e, 0xc6,
- 0x45, 0xd1, 0x8b, 0xc4, 0x94, 0x4a, 0x52, 0xa7, 0x2d, 0x87, 0xfd, 0xa9, 0x4d, 0xfc, 0x49, 0xbc,
- 0xa3, 0x3f, 0xb5, 0xc3, 0xfd, 0xa9, 0xbd, 0xc2, 0x9f, 0x90, 0xec, 0xc7, 0x04, 0x58, 0x68, 0x92,
- 0xde, 0x1d, 0x83, 0xf6, 0xbb, 0x8e, 0x76, 0x4f, 0x1b, 0xfc, 0x4b, 0x79, 0xff, 0x95, 0x00, 0x16,
- 0x49, 0x5f, 0x73, 0x10, 0x69, 0x63, 0x15, 0x99, 0x78, 0x0f, 0xf1, 0xf4, 0xff, 0xf4, 0xd8, 0x41,
- 0x88, 0xf1, 0x1c, 0x8c, 0x8b, 0xa7, 0xbc, 0x08, 0x44, 0xe5, 0x92, 0x1a, 0x03, 0xbe, 0x2a, 0x4f,
- 0xd3, 0xaf, 0xcf, 0xd3, 0xcc, 0x24, 0x4f, 0xa5, 0x55, 0x70, 0x2a, 0x12, 0x38, 0x3f, 0xe5, 0xa4,
- 0x87, 0x29, 0x96, 0x89, 0xdb, 0x03, 0x4d, 0x47, 0x0d, 0xc3, 0x34, 0x68, 0xcb, 0xe9, 0x22, 0xe7,
- 0x2d, 0xe3, 0x2a, 0x82, 0x0c, 0x8b, 0x98, 0x62, 0xf1, 0xc0, 0xfa, 0x53, 0x77, 0x15, 0x1b, 0xb6,
- 0x86, 0x94, 0xc7, 0x36, 0x98, 0xc3, 0x35, 0x90, 0x0b, 0xb6, 0xa0, 0x58, 0x6d, 0xec, 0x62, 0x4e,
- 0x94, 0x84, 0x72, 0x52, 0x9d, 0x92, 0x43, 0xc3, 0xaf, 0x0b, 0x8a, 0x25, 0x66, 0x5c, 0x1e, 0xb9,
- 0x79, 0xec, 0x23, 0x08, 0x18, 0xe2, 0x85, 0x41, 0xb1, 0x82, 0xc2, 0xa0, 0x58, 0xf0, 0x03, 0x90,
- 0xc5, 0x6e, 0x2c, 0xda, 0xfb, 0x36, 0x12, 0x67, 0x4b, 0x42, 0x79, 0x31, 0x76, 0xb9, 0x27, 0xe1,
- 0x72, 0x21, 0xea, 0x04, 0x0d, 0x1b, 0x60, 0x11, 0x8d, 0x6c, 0xc3, 0xd1, 0xdc, 0xdb, 0xde, 0x36,
- 0x4c, 0x24, 0x66, 0x4b, 0x42, 0x79, 0x6e, 0x3d, 0x5f, 0xf1, 0x9a, 0x4e, 0xc5, 0x6f, 0x3a, 0x95,
- 0xb6, 0xdf, 0x74, 0xe4, 0xd9, 0x27, 0xe3, 0xa2, 0xf0, 0xe0, 0xf7, 0xa2, 0xa0, 0xc6, 0xd6, 0xc2,
- 0x7d, 0x30, 0x6f, 0x6a, 0xa3, 0x3a, 0xf3, 0xcb, 0x8d, 0x0d, 0x60, 0xfb, 0xbe, 0xed, 0xe2, 0x8f,
- 0xb5, 0xef, 0x08, 0xcb, 0xc1, 0xb8, 0xb8, 0xe2, 0xed, 0x3d, 0x2c, 0x95, 0xd4, 0x08, 0x48, 0xfa,
- 0x25, 0x01, 0xf2, 0xd3, 0xd9, 0x11, 0xd4, 0xab, 0x02, 0x00, 0xd4, 0xd1, 0x2c, 0xbd, 0x8f, 0x6e,
- 0xa0, 0x7d, 0x9e, 0x28, 0x21, 0x09, 0xfc, 0x12, 0xa4, 0xdd, 0x8e, 0xab, 0x58, 0x2c, 0x53, 0xe6,
- 0xd6, 0xcf, 0x54, 0x78, 0x03, 0x74, 0x9b, 0x72, 0x85, 0x37, 0xe5, 0xca, 0x06, 0x36, 0x2c, 0xf9,
- 0x3a, 0x3f, 0xc6, 0x8b, 0x6f, 0xb0, 0x1d, 0x77, 0xc1, 0xcb, 0x71, 0x91, 0x73, 0x1f, 0x8c, 0x8b,
- 0x0b, 0xde, 0x4e, 0xbc, 0xb9, 0xa4, 0x72, 0x05, 0xfc, 0x4e, 0x00, 0xf3, 0x54, 0xdb, 0x45, 0x8e,
- 0xbb, 0xc0, 0x8d, 0x5c, 0xf2, 0x28, 0x2f, 0x3e, 0x39, 0xbe, 0x17, 0x11, 0x0b, 0x93, 0xa8, 0x86,
- 0xa5, 0x92, 0x1a, 0x01, 0x49, 0x77, 0xc0, 0xd9, 0xd0, 0x65, 0xbc, 0x66, 0x0c, 0x06, 0xa8, 0xfb,
- 0x46, 0x77, 0x2f, 0x1a, 0xef, 0x44, 0x3c, 0xde, 0xd2, 0xff, 0xc0, 0xb9, 0xd7, 0x10, 0x07, 0x77,
- 0xbe, 0x05, 0x56, 0x9a, 0xa4, 0xb7, 0xa1, 0x59, 0x3a, 0x1a, 0xfc, 0x2d, 0x76, 0xff, 0xcb, 0x36,
- 0x14, 0x27, 0x0c, 0xec, 0x9d, 0x03, 0x0b, 0xcd, 0xe1, 0x80, 0x1a, 0x1f, 0x63, 0x5b, 0xc5, 0x43,
- 0x8a, 0xdc, 0x0a, 0xd5, 0xc7, 0x36, 0xf1, 0x3a, 0x9b, 0xca, 0xc6, 0xd2, 0xc3, 0x24, 0x58, 0x6a,
- 0x92, 0x9e, 0x0f, 0xbc, 0x75, 0x4f, 0xb3, 0xdf, 0xb2, 0x0a, 0xad, 0x83, 0xb4, 0xe3, 0x9a, 0x21,
- 0x62, 0x92, 0xb5, 0xe4, 0x7c, 0xe4, 0xd6, 0x46, 0x3c, 0x51, 0x39, 0x32, 0x52, 0x57, 0x52, 0xff,
- 0x6c, 0x5d, 0xf9, 0x46, 0x70, 0xab, 0x83, 0x41, 0x59, 0xa0, 0xb6, 0x1d, 0x43, 0x47, 0xac, 0xda,
- 0x65, 0xe5, 0x2e, 0xb7, 0x58, 0x0b, 0x59, 0xe4, 0x9e, 0x5f, 0xc2, 0x4e, 0xcf, 0x1f, 0x57, 0x87,
- 0xd4, 0x18, 0x90, 0xaa, 0xa9, 0xd1, 0x7e, 0x65, 0xdb, 0x41, 0xfa, 0x26, 0xd2, 0xdd, 0xbe, 0x12,
- 0xa5, 0x9c, 0xf4, 0x95, 0xa8, 0x5c, 0x52, 0x63, 0x40, 0x78, 0x1e, 0x2c, 0xd8, 0x86, 0xbe, 0x2b,
- 0x23, 0x42, 0x59, 0x48, 0xc4, 0x34, 0x7b, 0x70, 0x46, 0x85, 0xd2, 0x7d, 0x01, 0xac, 0xc6, 0x4e,
- 0x27, 0xa8, 0x02, 0x18, 0x64, 0x74, 0x7e, 0xc1, 0x84, 0xa3, 0x2e, 0xd8, 0xd5, 0xe3, 0x5f, 0x30,
- 0x9f, 0x5c, 0xf5, 0x07, 0xd2, 0x0f, 0x02, 0x4b, 0x95, 0xdb, 0x76, 0x57, 0xa3, 0x68, 0x9b, 0x3d,
- 0xc3, 0xe1, 0x15, 0x90, 0xd5, 0x86, 0xb4, 0x8f, 0x1d, 0x83, 0xf2, 0x4a, 0x24, 0x8b, 0x3f, 0x3f,
- 0xbe, 0x74, 0x92, 0x7b, 0x52, 0xef, 0x76, 0x1d, 0x44, 0xc8, 0x2d, 0xea, 0x18, 0x56, 0x4f, 0x9d,
- 0x40, 0xe1, 0x15, 0x90, 0xf6, 0x1e, 0xf2, 0xbc, 0x44, 0xad, 0x44, 0x92, 0xc5, 0x23, 0x97, 0xb3,
- 0xae, 0xd7, 0xdf, 0xbf, 0x78, 0xb4, 0x26, 0xa8, 0x1c, 0x7d, 0xf5, 0xc2, 0xd7, 0x2f, 0x1e, 0xad,
- 0x4d, 0x78, 0xee, 0xbf, 0x78, 0xb4, 0xb6, 0xe2, 0x7e, 0x15, 0xc4, 0xfc, 0x92, 0xce, 0xb0, 0xb8,
- 0x85, 0x45, 0x7e, 0xdc, 0xd6, 0x46, 0x60, 0x31, 0xda, 0x42, 0xe0, 0x69, 0x00, 0x3f, 0x6a, 0xb5,
- 0x36, 0x3b, 0x6d, 0xa5, 0xd1, 0xd9, 0xa8, 0xdf, 0xdc, 0xd8, 0x6a, 0x34, 0xb6, 0x36, 0x73, 0x33,
- 0x30, 0x07, 0xe6, 0xaf, 0x29, 0x8d, 0x46, 0xa7, 0xa5, 0x76, 0x6e, 0x28, 0x8d, 0x46, 0x4e, 0x80,
- 0xab, 0x60, 0x45, 0x69, 0x36, 0xb7, 0x36, 0x95, 0x7a, 0x7b, 0xcb, 0x15, 0x7b, 0xe8, 0x5c, 0xc2,
- 0x85, 0x5e, 0xbf, 0x7d, 0xab, 0xdd, 0x51, 0x6e, 0x76, 0xda, 0x4a, 0x73, 0x2b, 0x97, 0x84, 0xcb,
- 0x60, 0x21, 0x20, 0x65, 0xa2, 0xd4, 0xfa, 0x9f, 0x29, 0x90, 0x6c, 0x92, 0x1e, 0xdc, 0x00, 0x19,
- 0xff, 0x03, 0x62, 0x35, 0x7a, 0x49, 0x82, 0xb7, 0x69, 0xbe, 0x78, 0x88, 0x22, 0x38, 0xfe, 0x06,
- 0x00, 0xa1, 0x07, 0x59, 0x3e, 0x0e, 0x9f, 0xe8, 0xf2, 0xd2, 0xe1, 0xba, 0x80, 0xed, 0x73, 0xb0,
- 0x14, 0x7f, 0x8b, 0x4c, 0x79, 0x10, 0x03, 0xe4, 0x2f, 0x1e, 0x01, 0x08, 0xc8, 0xf7, 0x80, 0x78,
- 0x68, 0xd5, 0x2d, 0x1f, 0xe6, 0x5c, 0x1c, 0x99, 0xbf, 0xfc, 0xa6, 0xc8, 0xc0, 0xee, 0x17, 0x20,
- 0x37, 0x55, 0x6d, 0x4b, 0x71, 0x96, 0x38, 0x22, 0x5f, 0x3e, 0x0a, 0x11, 0xf0, 0xab, 0x60, 0x3e,
- 0x52, 0x37, 0xff, 0x13, 0x5f, 0x19, 0xd6, 0xe6, 0xcf, 0xbf, 0x4e, 0x1b, 0xe6, 0x8c, 0x5c, 0xb0,
- 0x29, 0xce, 0xb0, 0x76, 0x9a, 0xf3, 0x55, 0x19, 0x2f, 0x6f, 0x3e, 0x79, 0x56, 0x10, 0x9e, 0x3e,
- 0x2b, 0x08, 0x7f, 0x3c, 0x2b, 0x08, 0x0f, 0x9e, 0x17, 0x66, 0x9e, 0x3e, 0x2f, 0xcc, 0xfc, 0xfa,
- 0xbc, 0x30, 0xf3, 0xd9, 0xda, 0x11, 0x35, 0x6f, 0xe4, 0x7d, 0xff, 0xbb, 0x75, 0x61, 0x27, 0xcd,
- 0x5e, 0x4f, 0xef, 0xfd, 0x15, 0x00, 0x00, 0xff, 0xff, 0xba, 0xdd, 0x59, 0x72, 0x1b, 0x10, 0x00,
- 0x00,
+ // 1420 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xcf, 0x6f, 0x13, 0xc7,
+ 0x17, 0xcf, 0xda, 0xc6, 0x8e, 0x27, 0xbf, 0x9c, 0x09, 0x90, 0xc5, 0x7c, 0xbf, 0xb6, 0xb5, 0xf0,
+ 0x05, 0x7f, 0x23, 0x61, 0xe3, 0x54, 0x45, 0x2a, 0x3d, 0x79, 0x93, 0xd0, 0x2e, 0xd8, 0x38, 0x5a,
+ 0x4c, 0x51, 0x5b, 0xa9, 0xd6, 0x66, 0x3d, 0xd8, 0xab, 0x78, 0x77, 0x56, 0x3b, 0xe3, 0xe0, 0x1c,
+ 0x7a, 0x68, 0x8f, 0xa8, 0x95, 0xb8, 0xf4, 0xc4, 0x3f, 0xd0, 0xde, 0x38, 0x20, 0xf5, 0xd4, 0x3b,
+ 0x47, 0xd4, 0x5e, 0xaa, 0x1e, 0xdc, 0x0a, 0x0e, 0x48, 0x1c, 0x23, 0xf5, 0x5e, 0xed, 0xec, 0xec,
+ 0x7a, 0x77, 0x4d, 0x08, 0x81, 0xb6, 0x17, 0xb2, 0xf3, 0xde, 0x67, 0xde, 0x7b, 0xf3, 0x99, 0xf7,
+ 0x63, 0x0c, 0x38, 0x69, 0xa1, 0x21, 0x75, 0xb0, 0x55, 0xed, 0xa2, 0x51, 0x95, 0x8e, 0x2a, 0xb6,
+ 0x83, 0x29, 0x86, 0x73, 0x5c, 0x5a, 0xe9, 0xa2, 0x51, 0xfe, 0x64, 0x0f, 0xf7, 0x30, 0x93, 0x57,
+ 0xdd, 0x2f, 0x0f, 0x92, 0x2f, 0xe8, 0x98, 0x98, 0x98, 0x54, 0x77, 0x34, 0x82, 0xaa, 0x7b, 0xb5,
+ 0x1d, 0x44, 0xb5, 0x5a, 0x55, 0xc7, 0x86, 0xc5, 0xf5, 0xc5, 0x1e, 0xc6, 0xbd, 0x01, 0xaa, 0xb2,
+ 0xd5, 0xce, 0xf0, 0x6e, 0x95, 0x1a, 0x26, 0x22, 0x54, 0x33, 0x6d, 0x0e, 0x58, 0xd6, 0x4c, 0xc3,
+ 0xc2, 0x55, 0xf6, 0x2f, 0x17, 0x89, 0xe1, 0x60, 0x6c, 0xcd, 0xd1, 0x4c, 0xc2, 0x35, 0xab, 0xdc,
+ 0x9b, 0x49, 0x7a, 0xd5, 0xbd, 0x9a, 0xfb, 0x87, 0x2b, 0xce, 0x78, 0x8a, 0x8e, 0x17, 0x9f, 0xb7,
+ 0xf0, 0x54, 0xd2, 0x87, 0x60, 0x71, 0x13, 0xd9, 0x98, 0x18, 0xb4, 0x65, 0x53, 0x03, 0x5b, 0x04,
+ 0xfe, 0x1f, 0xe4, 0xba, 0x06, 0xd1, 0x76, 0x06, 0xa8, 0xa3, 0x0d, 0x29, 0x26, 0xf7, 0x34, 0x5b,
+ 0x14, 0x4a, 0x42, 0x79, 0x56, 0x5d, 0xe2, 0xf2, 0x3a, 0x17, 0x4b, 0x3f, 0x25, 0x01, 0x68, 0x92,
+ 0x1e, 0x37, 0x00, 0x45, 0x90, 0xd1, 0x1d, 0xa4, 0x51, 0xec, 0xb0, 0x0d, 0x59, 0xd5, 0x5f, 0xc2,
+ 0x3c, 0x98, 0x75, 0x90, 0x8e, 0x8c, 0x3d, 0xe4, 0x88, 0x09, 0xa6, 0x0a, 0xd6, 0xf0, 0x34, 0x48,
+ 0x53, 0xbc, 0x8b, 0xac, 0xba, 0x98, 0x64, 0x1a, 0xbe, 0x0a, 0xe4, 0xb2, 0x98, 0x0a, 0xc9, 0x65,
+ 0x68, 0x80, 0x59, 0xcd, 0xc4, 0x43, 0x8b, 0x92, 0xba, 0x78, 0xa2, 0x94, 0x2c, 0x67, 0xe5, 0xe6,
+ 0x93, 0x71, 0x71, 0xe6, 0xb7, 0x71, 0xf1, 0x42, 0xcf, 0xa0, 0xfd, 0xe1, 0x4e, 0x45, 0xc7, 0x26,
+ 0x3f, 0x24, 0xff, 0x73, 0x89, 0x74, 0x77, 0xab, 0x74, 0xdf, 0x46, 0xa4, 0xa2, 0x58, 0xf4, 0xe5,
+ 0xb8, 0x18, 0x58, 0x38, 0x18, 0x17, 0x97, 0xf6, 0x35, 0x73, 0x70, 0x55, 0xf2, 0x25, 0x92, 0x1a,
+ 0x28, 0x43, 0xae, 0x64, 0x31, 0xfd, 0x8e, 0xae, 0xe4, 0x29, 0x57, 0xf2, 0xc4, 0x95, 0x0c, 0xcb,
+ 0x60, 0x89, 0x1a, 0xfa, 0xae, 0x62, 0x75, 0xd1, 0x08, 0x91, 0x7a, 0x1b, 0xcb, 0x62, 0xa6, 0x94,
+ 0x2c, 0x27, 0xd5, 0xb8, 0x18, 0x42, 0x90, 0xba, 0x8b, 0x10, 0x11, 0x67, 0x4b, 0xc9, 0x72, 0x4a,
+ 0x65, 0xdf, 0xf0, 0x7d, 0x90, 0xe1, 0xd7, 0x27, 0x66, 0x4b, 0xc9, 0xf2, 0xdc, 0xfa, 0xd9, 0x4a,
+ 0x28, 0x39, 0x2b, 0xd1, 0x1b, 0x56, 0x7d, 0xac, 0xf4, 0x38, 0x01, 0xe0, 0xe4, 0xfe, 0x54, 0x44,
+ 0x6c, 0x6c, 0x11, 0x04, 0xbf, 0x15, 0xc0, 0xb2, 0x8a, 0x08, 0x72, 0xf6, 0xd0, 0x65, 0xae, 0x43,
+ 0x5d, 0x51, 0x60, 0x04, 0x74, 0x8e, 0x4d, 0xc0, 0xb2, 0x13, 0x37, 0x75, 0x30, 0x2e, 0x8a, 0x1e,
+ 0x13, 0x53, 0x2a, 0x49, 0x9d, 0xf6, 0x1c, 0x8e, 0xa7, 0x36, 0x89, 0x27, 0xf1, 0x8e, 0xf1, 0xd4,
+ 0x0e, 0x8f, 0xa7, 0xf6, 0x8a, 0x78, 0x42, 0xb2, 0x1f, 0x13, 0x60, 0xa1, 0x49, 0x7a, 0x77, 0x0c,
+ 0xda, 0xef, 0x3a, 0xda, 0x3d, 0x6d, 0xf0, 0x2f, 0x65, 0xfe, 0x57, 0x02, 0x58, 0x24, 0x7d, 0xcd,
+ 0x41, 0xa4, 0x8d, 0x55, 0x64, 0xe2, 0x3d, 0xc4, 0x0b, 0xe0, 0xd3, 0x63, 0x93, 0x10, 0xb3, 0x73,
+ 0x30, 0x2e, 0x9e, 0xf2, 0x18, 0x88, 0xca, 0x25, 0x35, 0x06, 0x7c, 0x55, 0x9e, 0xa6, 0x5f, 0x9f,
+ 0xa7, 0x99, 0x49, 0x9e, 0x4a, 0xab, 0xe0, 0x54, 0x84, 0x38, 0x3f, 0xe5, 0xa4, 0x87, 0x29, 0x96,
+ 0x89, 0xdb, 0x03, 0x4d, 0x47, 0x0d, 0xc3, 0x34, 0x68, 0xcb, 0xe9, 0x22, 0xe7, 0x2d, 0x79, 0x15,
+ 0x41, 0x86, 0x31, 0xa6, 0x58, 0x9c, 0x58, 0x7f, 0xe9, 0xee, 0x62, 0x9f, 0xad, 0x21, 0xe5, 0xdc,
+ 0x06, 0x6b, 0xb8, 0x06, 0x72, 0xc1, 0x11, 0x14, 0xab, 0x8d, 0x5d, 0xcc, 0x89, 0x92, 0x50, 0x4e,
+ 0xaa, 0x53, 0xf2, 0x49, 0x63, 0x50, 0x2c, 0x31, 0xe3, 0xda, 0x79, 0xfb, 0xc6, 0xa0, 0x58, 0xf1,
+ 0xc6, 0xa0, 0x58, 0x41, 0x63, 0x50, 0x2c, 0xf8, 0x01, 0xc8, 0x62, 0x97, 0x8b, 0xf6, 0xbe, 0x8d,
+ 0xc4, 0xd9, 0x92, 0x50, 0x5e, 0x8c, 0x15, 0xf7, 0x84, 0x2e, 0x17, 0xa2, 0x4e, 0xd0, 0xb0, 0x01,
+ 0x16, 0xd1, 0xc8, 0x36, 0x1c, 0xcd, 0xad, 0xf6, 0xb6, 0x61, 0x22, 0x31, 0x5b, 0x12, 0xca, 0x73,
+ 0xeb, 0xf9, 0x8a, 0x37, 0x76, 0x2a, 0xfe, 0xd8, 0xa9, 0xb4, 0xfd, 0xb1, 0x23, 0xcf, 0x3e, 0x19,
+ 0x17, 0x85, 0x07, 0xbf, 0x17, 0x05, 0x35, 0xb6, 0x17, 0xee, 0x83, 0x79, 0x53, 0x1b, 0xd5, 0x59,
+ 0x5c, 0x2e, 0x37, 0x80, 0x9d, 0xfb, 0xb6, 0x8b, 0x3f, 0xd6, 0xb9, 0x23, 0x56, 0x0e, 0xc6, 0xc5,
+ 0x15, 0xef, 0xec, 0x61, 0xa9, 0xa4, 0x46, 0x40, 0xd2, 0x2f, 0x09, 0x90, 0x9f, 0xce, 0x8e, 0xa0,
+ 0x5f, 0x15, 0x00, 0xa0, 0x8e, 0x66, 0xe9, 0x7d, 0x74, 0x03, 0xed, 0xf3, 0x44, 0x09, 0x49, 0xe0,
+ 0x97, 0x20, 0xed, 0xce, 0x5c, 0xc5, 0x62, 0x99, 0x32, 0xb7, 0x7e, 0xa6, 0xc2, 0x47, 0xa0, 0x3b,
+ 0x96, 0x2b, 0x7c, 0x2c, 0x57, 0x36, 0xb0, 0x61, 0xc9, 0xd7, 0xf9, 0x35, 0x5e, 0x7c, 0x83, 0xe3,
+ 0xb8, 0x1b, 0x5e, 0x8e, 0x8b, 0xdc, 0xf6, 0xc1, 0xb8, 0xb8, 0xe0, 0x9d, 0xc4, 0x5b, 0x4b, 0x2a,
+ 0x57, 0xc0, 0xef, 0x04, 0x30, 0x4f, 0xb5, 0x5d, 0xe4, 0xb8, 0x1b, 0x5c, 0xe6, 0x92, 0x47, 0x45,
+ 0xf1, 0xc9, 0xf1, 0xa3, 0x88, 0x78, 0x98, 0xb0, 0x1a, 0x96, 0x4a, 0x6a, 0x04, 0x24, 0xdd, 0x01,
+ 0x67, 0x43, 0xc5, 0x78, 0xcd, 0x18, 0x0c, 0x50, 0xf7, 0x8d, 0x6a, 0x2f, 0xca, 0x77, 0x22, 0xce,
+ 0xb7, 0xf4, 0x3f, 0x70, 0xee, 0x35, 0x86, 0x83, 0x9a, 0x6f, 0x81, 0x95, 0x26, 0xe9, 0x6d, 0x68,
+ 0x96, 0x8e, 0x06, 0x7f, 0x8b, 0xdf, 0xff, 0xb2, 0x03, 0xc5, 0x0d, 0x06, 0xfe, 0xce, 0x81, 0x85,
+ 0xe6, 0x70, 0x40, 0x8d, 0x8f, 0xb1, 0xad, 0xe2, 0x21, 0x45, 0x6e, 0x87, 0xea, 0x63, 0x9b, 0x78,
+ 0x93, 0x4d, 0x65, 0xdf, 0xd2, 0xc3, 0x24, 0x58, 0x6a, 0x92, 0x9e, 0x0f, 0xbc, 0x75, 0x4f, 0xb3,
+ 0xdf, 0xb2, 0x0b, 0xad, 0x83, 0xb4, 0xe3, 0xba, 0x21, 0x62, 0x92, 0x8d, 0xe4, 0x7c, 0xa4, 0x6a,
+ 0x23, 0x91, 0xa8, 0x1c, 0x19, 0xe9, 0x2b, 0xa9, 0x7f, 0xb6, 0xaf, 0x7c, 0x23, 0xb8, 0xdd, 0xc1,
+ 0xa0, 0x8c, 0xa8, 0x6d, 0xc7, 0xd0, 0x11, 0xeb, 0x76, 0x59, 0xb9, 0xcb, 0x3d, 0xd6, 0x42, 0x1e,
+ 0x79, 0xe4, 0x97, 0xb0, 0xd3, 0xf3, 0xbf, 0xab, 0x43, 0x6a, 0x0c, 0x48, 0xd5, 0xd4, 0x68, 0xbf,
+ 0xb2, 0xed, 0x20, 0x7d, 0x13, 0xe9, 0xee, 0x5c, 0x89, 0x9a, 0x9c, 0xcc, 0x95, 0xa8, 0x5c, 0x52,
+ 0x63, 0x40, 0x78, 0x1e, 0x2c, 0xd8, 0x86, 0xbe, 0x2b, 0x23, 0x42, 0x19, 0x25, 0x62, 0x9a, 0x3d,
+ 0x39, 0xa3, 0x42, 0xe9, 0xbe, 0x00, 0x56, 0x63, 0xb7, 0x13, 0x74, 0x01, 0x0c, 0x32, 0x3a, 0x2f,
+ 0x30, 0xe1, 0xa8, 0x02, 0xbb, 0x7a, 0xfc, 0x02, 0xf3, 0x8d, 0xab, 0xfe, 0x87, 0xf4, 0x83, 0xc0,
+ 0x52, 0xe5, 0xb6, 0xdd, 0xd5, 0x28, 0xda, 0x66, 0x0f, 0x71, 0x78, 0x05, 0x64, 0xb5, 0x21, 0xed,
+ 0x63, 0xc7, 0xa0, 0xbc, 0x13, 0xc9, 0xe2, 0xcf, 0x8f, 0x2f, 0x9d, 0xe4, 0x91, 0xd4, 0xbb, 0x5d,
+ 0x07, 0x11, 0x72, 0x8b, 0x3a, 0x86, 0xd5, 0x53, 0x27, 0x50, 0x78, 0x05, 0xa4, 0xbd, 0xa7, 0x3c,
+ 0x6f, 0x51, 0x2b, 0x91, 0x64, 0xf1, 0x8c, 0xcb, 0x59, 0x37, 0xea, 0xef, 0x5f, 0x3c, 0x5a, 0x13,
+ 0x54, 0x8e, 0xbe, 0x7a, 0xe1, 0xeb, 0x17, 0x8f, 0xd6, 0x26, 0x76, 0xee, 0xbf, 0x78, 0xb4, 0xb6,
+ 0xe2, 0xfe, 0x2e, 0x88, 0xc5, 0x25, 0x9d, 0x61, 0xbc, 0x85, 0x45, 0x3e, 0x6f, 0x6b, 0x23, 0xb0,
+ 0x18, 0x1d, 0x21, 0xf0, 0x34, 0x80, 0x1f, 0xb5, 0x5a, 0x9b, 0x9d, 0xb6, 0xd2, 0xe8, 0x6c, 0xd4,
+ 0x6f, 0x6e, 0x6c, 0x35, 0x1a, 0x5b, 0x9b, 0xb9, 0x19, 0x98, 0x03, 0xf3, 0xd7, 0x94, 0x46, 0xa3,
+ 0xd3, 0x52, 0x3b, 0x37, 0x94, 0x46, 0x23, 0x27, 0xc0, 0x55, 0xb0, 0xa2, 0x34, 0x9b, 0x5b, 0x9b,
+ 0x4a, 0xbd, 0xbd, 0xe5, 0x8a, 0x3d, 0x74, 0x2e, 0xe1, 0x42, 0xaf, 0xdf, 0xbe, 0xd5, 0xee, 0x28,
+ 0x37, 0x3b, 0x6d, 0xa5, 0xb9, 0x95, 0x4b, 0xc2, 0x65, 0xb0, 0x10, 0x18, 0x65, 0xa2, 0xd4, 0xfa,
+ 0x9f, 0x29, 0x90, 0x6c, 0x92, 0x1e, 0xdc, 0x00, 0x19, 0xff, 0x27, 0xc4, 0x6a, 0xb4, 0x48, 0x82,
+ 0xb7, 0x69, 0xbe, 0x78, 0x88, 0x22, 0xb8, 0xfe, 0x06, 0x00, 0xa1, 0x07, 0x59, 0x3e, 0x0e, 0x9f,
+ 0xe8, 0xf2, 0xd2, 0xe1, 0xba, 0xc0, 0xda, 0xe7, 0x60, 0x29, 0xfe, 0x16, 0x99, 0x8a, 0x20, 0x06,
+ 0xc8, 0x5f, 0x3c, 0x02, 0x10, 0x18, 0xdf, 0x03, 0xe2, 0xa1, 0x5d, 0xb7, 0x7c, 0x58, 0x70, 0x71,
+ 0x64, 0xfe, 0xf2, 0x9b, 0x22, 0x03, 0xbf, 0x5f, 0x80, 0xdc, 0x54, 0xb7, 0x2d, 0xc5, 0xad, 0xc4,
+ 0x11, 0xf9, 0xf2, 0x51, 0x88, 0xc0, 0xbe, 0x0a, 0xe6, 0x23, 0x7d, 0xf3, 0x3f, 0xf1, 0x9d, 0x61,
+ 0x6d, 0xfe, 0xfc, 0xeb, 0xb4, 0x61, 0x9b, 0x91, 0x02, 0x9b, 0xb2, 0x19, 0xd6, 0x4e, 0xdb, 0x7c,
+ 0x55, 0xc6, 0xcb, 0x9b, 0x4f, 0x9e, 0x15, 0x84, 0xa7, 0xcf, 0x0a, 0xc2, 0x1f, 0xcf, 0x0a, 0xc2,
+ 0x83, 0xe7, 0x85, 0x99, 0xa7, 0xcf, 0x0b, 0x33, 0xbf, 0x3e, 0x2f, 0xcc, 0x7c, 0xb6, 0x76, 0x44,
+ 0xcf, 0x1b, 0x79, 0xff, 0x03, 0xe0, 0xf6, 0x85, 0x9d, 0x34, 0x7b, 0x3d, 0xbd, 0xf7, 0x57, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0xa9, 0x01, 0xb0, 0x91, 0x1d, 0x10, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
diff --git a/x/epochs/README.md b/x/epochs/README.md
deleted file mode 100644
index 0b95457c9..000000000
--- a/x/epochs/README.md
+++ /dev/null
@@ -1,187 +0,0 @@
-# Epochs
-
-## Abstract
-
-Often in the SDK, we would like to run certain code every-so often. The
-purpose of `epochs` module is to allow other modules to set that they
-would like to be signaled once every period. So another module can
-specify it wants to execute code once a week, starting at UTC-time = x.
-`epochs` creates a generalized epoch interface to other modules so that
-they can easily be signalled upon such events.
-
-## Contents
-
-1. **[Concept](#concepts)**
-2. **[State](#state)**
-3. **[Events](#events)**
-4. **[Keeper](#keepers)**
-5. **[Hooks](#hooks)**
-6. **[Queries](#queries)**
-
-## Concepts
-
-The epochs module defines on-chain timers, that execute at fixed time intervals.
-Other SDK modules can then register logic to be executed at the timer ticks.
-We refer to the period in between two timer ticks as an "epoch".
-
-Every timer has a unique identifier.
-Every epoch will have a start time, and an end time, where `end time = start time + timer interval`.
-On Neutron mainnet, we only utilize one identifier, with a time interval of `one day`.
-
-The timer will tick at the first block whose blocktime is greater than the timer end time,
-and set the start as the prior timer end time. (Notably, its not set to the block time!)
-This means that if the chain has been down for awhile, you will get one timer tick per block,
-until the timer has caught up.
-
-## State
-
-The Epochs module keeps a single [`EpochInfo`](https://github.com/osmosis-labs/osmosis/blob/b4befe4f3eb97ebb477323234b910c4afafab9b7/proto/osmosis/epochs/genesis.proto#L12) per identifier.
-This contains the current state of the timer with the corresponding identifier.
-Its fields are modified at every timer tick.
-EpochInfos are initialized as part of genesis initialization or upgrade logic,
-and are only modified on begin blockers.
-
-## Events
-
-The `epochs` module emits the following events:
-
-### BeginBlocker
-
-| Type | Attribute Key | Attribute Value |
-| ----------- | ------------- | --------------- |
-| epoch_start | epoch_number | {epoch_number} |
-| epoch_start | start_time | {start_time} |
-
-### EndBlocker
-
-| Type | Attribute Key | Attribute Value |
-| --------- | ------------- | --------------- |
-| epoch_end | epoch_number | {epoch_number} |
-
-## Keepers
-
-### Keeper functions
-
-Epochs keeper module provides utility functions to manage epochs.
-
-```go
-// Keeper is the interface for lockup module keeper
-type Keeper interface {
- // GetEpochInfo returns epoch info by identifier
- GetEpochInfo(ctx sdk.Context, identifier string) types.EpochInfo
- // SetEpochInfo set epoch info
- SetEpochInfo(ctx sdk.Context, epoch types.EpochInfo)
- // DeleteEpochInfo delete epoch info
- DeleteEpochInfo(ctx sdk.Context, identifier string)
- // IterateEpochInfo iterate through epochs
- IterateEpochInfo(ctx sdk.Context, fn func(index int64, epochInfo types.EpochInfo) (stop bool))
- // Get all epoch infos
- AllEpochInfos(ctx sdk.Context) []types.EpochInfo
-}
-```
-
-## Hooks
-
-```go
- // the first block whose timestamp is after the duration is counted as the end of the epoch
- AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64)
- // new epoch is next block of epoch end block
- BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64)
-```
-
-### How modules receive hooks
-
-On hook receiver function of other modules, they need to filter
-`epochIdentifier` and only do executions for only specific
-epochIdentifier. Filtering epochIdentifier could be in `Params` of other
-modules so that they can be modified by governance.
-
-This is the standard dev UX of this:
-
-```golang
-func (k MyModuleKeeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) {
- params := k.GetParams(ctx)
- if epochIdentifier == params.DistrEpochIdentifier {
- // my logic
- }
-}
-```
-
-### Panic isolation
-
-If a given epoch hook panics, its state update is reverted, but we keep
-proceeding through the remaining hooks. This allows more advanced epoch
-logic to be used, without concern over state machine halting, or halting
-subsequent modules.
-
-This does mean that if there is behavior you expect from a prior epoch
-hook, and that epoch hook reverted, your hook may also have an issue. So
-do keep in mind "what if a prior hook didn't get executed" in the safety
-checks you consider for a new epoch hook.
-
-## Queries
-
-Epochs module is providing below queries to check the module's state.
-
-```protobuf
-service Query {
- // EpochInfos provide running epochInfos
- rpc EpochInfos(QueryEpochsInfoRequest) returns (QueryEpochsInfoResponse) {}
- // CurrentEpoch provide current epoch of specified identifier
- rpc CurrentEpoch(QueryCurrentEpochRequest) returns (QueryCurrentEpochResponse) {}
-}
-```
-
-### Epoch Infos
-
-Query the currently running epochInfos
-
-```sh
-neutrond query epochs epoch-infos
-```
-
-::: details Example
-
-An example output:
-
-```sh
-epochs:
-- current_epoch: "183"
- current_epoch_start_height: "2438409"
- current_epoch_start_time: "2021-12-18T17:16:09.898160996Z"
- duration: 86400s
- epoch_counting_started: true
- identifier: day
- start_time: "2021-06-18T17:00:00Z"
-- current_epoch: "26"
- current_epoch_start_height: "2424854"
- current_epoch_start_time: "2021-12-17T17:02:07.229632445Z"
- duration: 604800s
- epoch_counting_started: true
- identifier: week
- start_time: "2021-06-18T17:00:00Z"
-```
-
-:::
-
-### Current Epoch
-
-Query the current epoch by the specified identifier
-
-```sh
-neutrond query epochs current-epoch [identifier]
-```
-
-::: details Example
-
-Query the current `day` epoch:
-
-```sh
-neutrond query epochs current-epoch day
-```
-
-Which in this example outputs:
-
-```sh
-current_epoch: "183"
-```
diff --git a/x/epochs/client/cli/cli_test.go b/x/epochs/client/cli/cli_test.go
deleted file mode 100644
index b8406fa5d..000000000
--- a/x/epochs/client/cli/cli_test.go
+++ /dev/null
@@ -1,33 +0,0 @@
-package cli_test
-
-import (
- "testing"
-
- "github.com/neutron-org/neutron/utils/dcli"
- "github.com/neutron-org/neutron/x/epochs/client/cli"
- "github.com/neutron-org/neutron/x/epochs/types"
-)
-
-func TestGetCmdCurrentEpoch(t *testing.T) {
- desc, _ := cli.GetCmdCurrentEpoch()
- tcs := map[string]dcli.QueryCliTestCase[*types.QueryCurrentEpochRequest]{
- "basic test": {
- Cmd: "day",
- ExpectedQuery: &types.QueryCurrentEpochRequest{
- Identifier: "day",
- },
- },
- }
- dcli.RunQueryTestCases(t, desc, tcs)
-}
-
-func TestGetCmdEpochsInfo(t *testing.T) {
- desc, _ := cli.GetCmdEpochInfos()
- tcs := map[string]dcli.QueryCliTestCase[*types.QueryEpochsInfoRequest]{
- "basic test": {
- Cmd: "",
- ExpectedQuery: &types.QueryEpochsInfoRequest{},
- },
- }
- dcli.RunQueryTestCases(t, desc, tcs)
-}
diff --git a/x/epochs/client/cli/query.go b/x/epochs/client/cli/query.go
deleted file mode 100644
index e9bcf2238..000000000
--- a/x/epochs/client/cli/query.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package cli
-
-import (
- "github.com/spf13/cobra"
-
- "github.com/neutron-org/neutron/utils/dcli"
- "github.com/neutron-org/neutron/x/epochs/types"
-)
-
-// GetQueryCmd returns the cli query commands for this module.
-func GetQueryCmd() *cobra.Command {
- cmd := dcli.QueryIndexCmd(types.ModuleName)
- dcli.AddQueryCmd(cmd, types.NewQueryClient, GetCmdEpochInfos)
- dcli.AddQueryCmd(cmd, types.NewQueryClient, GetCmdCurrentEpoch)
-
- return cmd
-}
-
-func GetCmdEpochInfos() (*dcli.QueryDescriptor, *types.QueryEpochsInfoRequest) {
- return &dcli.QueryDescriptor{
- Use: "epoch-infos",
- Short: "Query running epoch infos.",
- Long: `{{.Short}}{{.ExampleHeader}}
-{{.CommandPrefix}}`,
- QueryFnName: "EpochInfos",
- }, &types.QueryEpochsInfoRequest{}
-}
-
-func GetCmdCurrentEpoch() (*dcli.QueryDescriptor, *types.QueryCurrentEpochRequest) {
- return &dcli.QueryDescriptor{
- Use: "current-epoch",
- Short: "Query current epoch by specified identifier.",
- Long: `{{.Short}}{{.ExampleHeader}}
-{{.CommandPrefix}} day`,
- }, &types.QueryCurrentEpochRequest{}
-}
diff --git a/x/epochs/keeper/abci.go b/x/epochs/keeper/abci.go
deleted file mode 100644
index ccf3fcf87..000000000
--- a/x/epochs/keeper/abci.go
+++ /dev/null
@@ -1,81 +0,0 @@
-package keeper
-
-import (
- "fmt"
- "time"
-
- "github.com/neutron-org/neutron/x/epochs/types"
-
- "github.com/cosmos/cosmos-sdk/telemetry"
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-// BeginBlocker of epochs module.
-func (k Keeper) BeginBlocker(ctx sdk.Context) {
- defer telemetry.ModuleMeasureSince(
- types.ModuleName,
- time.Now(),
- telemetry.MetricKeyBeginBlocker,
- )
- k.IterateEpochInfo(ctx, func(index int64, epochInfo types.EpochInfo) (stop bool) {
- logger := k.Logger(ctx)
-
- // If blocktime < initial epoch start time, return
- if ctx.BlockTime().Before(epochInfo.StartTime) {
- return
- }
- // if epoch counting hasn't started, signal we need to start.
- shouldInitialEpochStart := !epochInfo.EpochCountingStarted
-
- epochEndTime := epochInfo.CurrentEpochStartTime.Add(epochInfo.Duration)
- shouldEpochStart := (ctx.BlockTime().After(epochEndTime)) || shouldInitialEpochStart
-
- if !shouldEpochStart {
- return false
- }
- epochInfo.CurrentEpochStartHeight = ctx.BlockHeight()
-
- if shouldInitialEpochStart {
- epochInfo.EpochCountingStarted = true
- epochInfo.CurrentEpoch = 1
- epochInfo.CurrentEpochStartTime = epochInfo.StartTime
- logger.Info(
- "Starting epoch",
- "Identifier",
- epochInfo.Identifier,
- "CurEpoch",
- epochInfo.CurrentEpoch,
- )
- } else {
- ctx.EventManager().EmitEvent(
- sdk.NewEvent(
- types.EventTypeEpochEnd,
- sdk.NewAttribute(types.AttributeEpochNumber, fmt.Sprintf("%d", epochInfo.CurrentEpoch)),
- ),
- )
- k.AfterEpochEnd(ctx, epochInfo.Identifier)
- epochInfo.CurrentEpoch++
- epochInfo.CurrentEpochStartTime = epochInfo.CurrentEpochStartTime.Add(epochInfo.Duration)
- logger.Info("Starting epoch", "Identifier", epochInfo.Identifier, "CurEpoch", epochInfo.CurrentEpoch)
- }
-
- // emit new epoch start event, set epoch info, and run BeforeEpochStart hook
- ctx.EventManager().EmitEvent(
- sdk.NewEvent(
- types.EventTypeEpochStart,
- sdk.NewAttribute(
- types.AttributeEpochNumber,
- fmt.Sprintf("%d", epochInfo.CurrentEpoch),
- ),
- sdk.NewAttribute(
- types.AttributeEpochStartTime,
- fmt.Sprintf("%d", epochInfo.CurrentEpochStartTime.Unix()),
- ),
- ),
- )
- k.setEpochInfo(ctx, epochInfo)
- k.BeforeEpochStart(ctx, epochInfo.Identifier)
-
- return false
- })
-}
diff --git a/x/epochs/keeper/abci_test.go b/x/epochs/keeper/abci_test.go
deleted file mode 100644
index 223827ac6..000000000
--- a/x/epochs/keeper/abci_test.go
+++ /dev/null
@@ -1,302 +0,0 @@
-package keeper_test
-
-import (
- "testing"
- "time"
-
- tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
- "github.com/stretchr/testify/require"
-
- "github.com/neutron-org/neutron/testutil"
- "github.com/neutron-org/neutron/x/epochs/types"
-
- "golang.org/x/exp/maps"
-
- "github.com/neutron-org/neutron/utils"
-)
-
-// This test is responsible for testing how epochs increment based off
-// of their initial conditions, and subsequent block height / times.
-
-func (suite *EpochsTestSuite) TestEpochInfoBeginBlockChanges() {
- block1Time := time.Unix(1656907200, 0).UTC()
- const defaultIdentifier = "hourly"
- const defaultDuration = time.Hour
- // eps is short for epsilon - in this case a negligible amount of time.
- const eps = time.Nanosecond
-
- tests := map[string]struct {
- // if identifier, duration is not set, we make it defaultIdentifier and defaultDuration.
- // EpochCountingStarted, if unspecified, is inferred by CurrentEpoch == 0
- // StartTime is inferred to be block1Time if left blank.
- initialEpochInfo types.EpochInfo
- blockHeightTimePairs map[int]time.Time
- expEpochInfo types.EpochInfo
- }{
- "First block running at exactly start time sets epoch tick": {
- initialEpochInfo: types.EpochInfo{
- StartTime: block1Time,
- CurrentEpoch: 0,
- CurrentEpochStartTime: time.Time{},
- },
- expEpochInfo: types.EpochInfo{
- StartTime: block1Time,
- CurrentEpoch: 1,
- CurrentEpochStartTime: block1Time,
- CurrentEpochStartHeight: 1,
- },
- },
- "First block run sets start time, subsequent blocks within timer interval do not cause timer tick": {
- initialEpochInfo: types.EpochInfo{
- StartTime: block1Time,
- CurrentEpoch: 0,
- CurrentEpochStartTime: time.Time{},
- },
- blockHeightTimePairs: map[int]time.Time{
- 2: block1Time.Add(time.Second),
- 3: block1Time.Add(time.Minute),
- 4: block1Time.Add(30 * time.Minute),
- },
- expEpochInfo: types.EpochInfo{
- StartTime: block1Time,
- CurrentEpoch: 1,
- CurrentEpochStartTime: block1Time,
- CurrentEpochStartHeight: 1,
- },
- },
- "Second block at exactly timer interval later does not tick": {
- initialEpochInfo: types.EpochInfo{
- StartTime: block1Time,
- CurrentEpoch: 0,
- CurrentEpochStartTime: time.Time{},
- },
- blockHeightTimePairs: map[int]time.Time{2: block1Time.Add(defaultDuration)},
- expEpochInfo: types.EpochInfo{
- StartTime: block1Time,
- CurrentEpoch: 1,
- CurrentEpochStartTime: block1Time,
- CurrentEpochStartHeight: 1,
- },
- },
- "Second block at timer interval + epsilon later does tick": {
- initialEpochInfo: types.EpochInfo{
- StartTime: block1Time,
- CurrentEpoch: 0,
- CurrentEpochStartTime: time.Time{},
- },
- blockHeightTimePairs: map[int]time.Time{2: block1Time.Add(defaultDuration).Add(eps)},
- expEpochInfo: types.EpochInfo{
- StartTime: block1Time,
- CurrentEpoch: 2,
- CurrentEpochStartTime: block1Time.Add(time.Hour),
- CurrentEpochStartHeight: 2,
- },
- },
- "Downtime recovery (many intervals), first block causes 1 tick and sets current start time 1 interval ahead": {
- initialEpochInfo: types.EpochInfo{
- StartTime: block1Time,
- CurrentEpoch: 0,
- CurrentEpochStartTime: time.Time{},
- },
- blockHeightTimePairs: map[int]time.Time{2: block1Time.Add(24 * time.Hour)},
- expEpochInfo: types.EpochInfo{
- StartTime: block1Time,
- CurrentEpoch: 2,
- CurrentEpochStartTime: block1Time.Add(time.Hour),
- CurrentEpochStartHeight: 2,
- },
- },
- "Downtime recovery (many intervals), second block is at tick 2, w/ start time 2 intervals ahead": {
- initialEpochInfo: types.EpochInfo{
- StartTime: block1Time,
- CurrentEpoch: 0,
- CurrentEpochStartTime: time.Time{},
- },
- blockHeightTimePairs: map[int]time.Time{
- 2: block1Time.Add(24 * time.Hour),
- 3: block1Time.Add(24 * time.Hour).Add(eps),
- },
- expEpochInfo: types.EpochInfo{
- StartTime: block1Time,
- CurrentEpoch: 3,
- CurrentEpochStartTime: block1Time.Add(2 * time.Hour),
- CurrentEpochStartHeight: 3,
- },
- },
- "Many blocks between first and second tick": {
- initialEpochInfo: types.EpochInfo{
- StartTime: block1Time,
- CurrentEpoch: 1,
- CurrentEpochStartTime: block1Time,
- },
- blockHeightTimePairs: map[int]time.Time{
- 2: block1Time.Add(time.Second),
- 3: block1Time.Add(2 * time.Second),
- 4: block1Time.Add(time.Hour).Add(eps),
- },
- expEpochInfo: types.EpochInfo{
- StartTime: block1Time,
- CurrentEpoch: 2,
- CurrentEpochStartTime: block1Time.Add(time.Hour),
- CurrentEpochStartHeight: 4,
- },
- },
- "Distinct identifier and duration still works": {
- initialEpochInfo: types.EpochInfo{
- Identifier: "hello",
- Duration: time.Minute,
- StartTime: block1Time,
- CurrentEpoch: 0,
- CurrentEpochStartTime: time.Time{},
- },
- blockHeightTimePairs: map[int]time.Time{
- 2: block1Time.Add(time.Second),
- 3: block1Time.Add(time.Minute).Add(eps),
- },
- expEpochInfo: types.EpochInfo{
- Identifier: "hello",
- Duration: time.Minute,
- StartTime: block1Time,
- CurrentEpoch: 2,
- CurrentEpochStartTime: block1Time.Add(time.Minute),
- CurrentEpochStartHeight: 3,
- },
- },
- "StartTime in future won't get ticked on first block": {
- initialEpochInfo: types.EpochInfo{
- StartTime: block1Time.Add(time.Second),
- CurrentEpoch: 0,
- CurrentEpochStartTime: time.Time{},
- },
- // currentEpochStartHeight is 1 because thats when the timer was created on-chain
- expEpochInfo: types.EpochInfo{
- StartTime: block1Time.Add(time.Second),
- CurrentEpoch: 0,
- CurrentEpochStartTime: time.Time{},
- CurrentEpochStartHeight: 1,
- },
- },
- "StartTime in past will get ticked on first block": {
- initialEpochInfo: types.EpochInfo{
- StartTime: block1Time.Add(-time.Second),
- CurrentEpoch: 0,
- CurrentEpochStartTime: time.Time{},
- },
- expEpochInfo: types.EpochInfo{
- StartTime: block1Time.Add(-time.Second),
- CurrentEpoch: 1,
- CurrentEpochStartTime: block1Time.Add(-time.Second),
- CurrentEpochStartHeight: 1,
- },
- },
- }
- for name, test := range tests {
- suite.Run(name, func() {
- suite.SetupTest()
- suite.Ctx = suite.Ctx.WithBlockHeight(1).WithBlockTime(block1Time)
- initialEpoch := initializeBlankEpochInfoFields(
- test.initialEpochInfo,
- defaultIdentifier,
- defaultDuration,
- )
- err := suite.App.EpochsKeeper.AddEpochInfo(suite.Ctx, initialEpoch)
- suite.Require().NoError(err)
- suite.App.EpochsKeeper.BeginBlocker(suite.Ctx)
-
- // get sorted heights
- heights := maps.Keys(test.blockHeightTimePairs)
- utils.SortSlice(heights)
- for _, h := range heights {
- // for each height in order, run begin block
- suite.Ctx = suite.Ctx.WithBlockHeight(int64(h)).
- WithBlockTime(test.blockHeightTimePairs[h])
- suite.App.EpochsKeeper.BeginBlocker(suite.Ctx)
- }
- expEpoch := initializeBlankEpochInfoFields(
- test.expEpochInfo,
- initialEpoch.Identifier,
- initialEpoch.Duration,
- )
- actEpoch := suite.App.EpochsKeeper.GetEpochInfo(suite.Ctx, initialEpoch.Identifier)
- suite.Require().Equal(expEpoch, actEpoch)
- })
- }
-}
-
-// initializeBlankEpochInfoFields set identifier, duration and epochCountingStarted if blank in epoch
-func initializeBlankEpochInfoFields(
- epoch types.EpochInfo,
- identifier string,
- duration time.Duration,
-) types.EpochInfo {
- if epoch.Identifier == "" {
- epoch.Identifier = identifier
- }
- if epoch.Duration == time.Duration(0) {
- epoch.Duration = duration
- }
- epoch.EpochCountingStarted = (epoch.CurrentEpoch != 0)
-
- return epoch
-}
-
-func TestEpochStartingOneMonthAfterInitGenesis(t *testing.T) {
- app := testutil.Setup(t)
- ctx := app.BaseApp.NewContext(false, tmproto.Header{})
-
- // On init genesis, default epochs information is set
- // To check init genesis again, should make it fresh status
- epochInfos := app.EpochsKeeper.AllEpochInfos(ctx)
- for _, epochInfo := range epochInfos {
- app.EpochsKeeper.DeleteEpochInfo(ctx, epochInfo.Identifier)
- }
-
- now := time.Now()
- week := time.Hour * 24 * 7
- month := time.Hour * 24 * 30
- initialBlockHeight := int64(1)
- ctx = ctx.WithBlockHeight(initialBlockHeight).WithBlockTime(now)
-
- app.EpochsKeeper.InitGenesis(ctx, types.GenesisState{
- Epochs: []types.EpochInfo{
- {
- Identifier: "monthly",
- StartTime: now.Add(month),
- Duration: time.Hour * 24 * 30,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: ctx.BlockHeight(),
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: false,
- },
- },
- })
-
- // epoch not started yet
- epochInfo := app.EpochsKeeper.GetEpochInfo(ctx, "monthly")
- require.Equal(t, epochInfo.CurrentEpoch, int64(0))
- require.Equal(t, epochInfo.CurrentEpochStartHeight, initialBlockHeight)
- require.Equal(t, epochInfo.CurrentEpochStartTime, time.Time{})
- require.Equal(t, epochInfo.EpochCountingStarted, false)
-
- // after 1 week
- ctx = ctx.WithBlockHeight(2).WithBlockTime(now.Add(week))
- app.EpochsKeeper.BeginBlocker(ctx)
-
- // epoch not started yet
- epochInfo = app.EpochsKeeper.GetEpochInfo(ctx, "monthly")
- require.Equal(t, epochInfo.CurrentEpoch, int64(0))
- require.Equal(t, epochInfo.CurrentEpochStartHeight, initialBlockHeight)
- require.Equal(t, epochInfo.CurrentEpochStartTime, time.Time{})
- require.Equal(t, epochInfo.EpochCountingStarted, false)
-
- // after 1 month
- ctx = ctx.WithBlockHeight(3).WithBlockTime(now.Add(month))
- app.EpochsKeeper.BeginBlocker(ctx)
-
- // epoch started
- epochInfo = app.EpochsKeeper.GetEpochInfo(ctx, "monthly")
- require.Equal(t, epochInfo.CurrentEpoch, int64(1))
- require.Equal(t, epochInfo.CurrentEpochStartHeight, ctx.BlockHeight())
- require.Equal(t, epochInfo.CurrentEpochStartTime.UTC().String(), now.Add(month).UTC().String())
- require.Equal(t, epochInfo.EpochCountingStarted, true)
-}
diff --git a/x/epochs/keeper/epoch.go b/x/epochs/keeper/epoch.go
deleted file mode 100644
index 6bd2a3f43..000000000
--- a/x/epochs/keeper/epoch.go
+++ /dev/null
@@ -1,114 +0,0 @@
-package keeper
-
-import (
- "fmt"
- "time"
-
- "github.com/cosmos/gogoproto/proto"
-
- "github.com/neutron-org/neutron/x/epochs/types"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-// GetEpochInfo returns epoch info by identifier.
-func (k Keeper) GetEpochInfo(ctx sdk.Context, identifier string) types.EpochInfo {
- epoch := types.EpochInfo{}
- store := ctx.KVStore(k.storeKey)
- b := store.Get(append(types.KeyPrefixEpoch, []byte(identifier)...))
- if b == nil {
- return epoch
- }
- err := proto.Unmarshal(b, &epoch)
- if err != nil {
- panic(err)
- }
-
- return epoch
-}
-
-// AddEpochInfo adds a new epoch info. Will return an error if the epoch fails validation,
-// or re-uses an existing identifier.
-// This method also sets the start time if left unset, and sets the epoch start height.
-func (k Keeper) AddEpochInfo(ctx sdk.Context, epoch types.EpochInfo) error {
- if err := epoch.Validate(); err != nil {
- return err
- }
- // Check if identifier already exists
- if (k.GetEpochInfo(ctx, epoch.Identifier) != types.EpochInfo{}) {
- return fmt.Errorf("epoch with identifier %s already exists", epoch.Identifier)
- }
-
- // Initialize empty and default epoch values
- if epoch.StartTime.Equal(time.Time{}) {
- epoch.StartTime = ctx.BlockTime()
- }
- epoch.CurrentEpochStartHeight = ctx.BlockHeight()
- k.setEpochInfo(ctx, epoch)
-
- return nil
-}
-
-// setEpochInfo set epoch info.
-func (k Keeper) setEpochInfo(ctx sdk.Context, epoch types.EpochInfo) {
- store := ctx.KVStore(k.storeKey)
- value, err := proto.Marshal(&epoch)
- if err != nil {
- panic(err)
- }
- store.Set(append(types.KeyPrefixEpoch, []byte(epoch.Identifier)...), value)
-}
-
-// DeleteEpochInfo delete epoch info.
-func (k Keeper) DeleteEpochInfo(ctx sdk.Context, identifier string) {
- store := ctx.KVStore(k.storeKey)
- store.Delete(append(types.KeyPrefixEpoch, []byte(identifier)...))
-}
-
-// IterateEpochInfo iterate through epochs.
-func (k Keeper) IterateEpochInfo(ctx sdk.Context, fn func(index int64, epochInfo types.EpochInfo) (stop bool)) {
- store := ctx.KVStore(k.storeKey)
-
- iterator := sdk.KVStorePrefixIterator(store, types.KeyPrefixEpoch)
- defer iterator.Close()
-
- i := int64(0)
-
- for ; iterator.Valid(); iterator.Next() {
- epoch := types.EpochInfo{}
- err := proto.Unmarshal(iterator.Value(), &epoch)
- if err != nil {
- panic(err)
- }
- stop := fn(i, epoch)
-
- if stop {
- break
- }
- i++
- }
-}
-
-// AllEpochInfos iterate through epochs to return all epochs info.
-func (k Keeper) AllEpochInfos(ctx sdk.Context) []types.EpochInfo {
- epochs := []types.EpochInfo{}
- k.IterateEpochInfo(ctx, func(index int64, epochInfo types.EpochInfo) (stop bool) {
- epochs = append(epochs, epochInfo)
- return false
- })
-
- return epochs
-}
-
-// NumBlocksSinceEpochStart returns the number of blocks since the epoch started.
-// if the epoch started on block N, then calling this during block N (after BeforeEpochStart)
-// would return 0.
-// Calling it any point in block N+1 (assuming the epoch doesn't increment) would return 1.
-func (k Keeper) NumBlocksSinceEpochStart(ctx sdk.Context, identifier string) (int64, error) {
- epoch := k.GetEpochInfo(ctx, identifier)
- if (epoch == types.EpochInfo{}) {
- return 0, fmt.Errorf("epoch with identifier %s not found", identifier)
- }
-
- return ctx.BlockHeight() - epoch.CurrentEpochStartHeight, nil
-}
diff --git a/x/epochs/keeper/epoch_test.go b/x/epochs/keeper/epoch_test.go
deleted file mode 100644
index 94ab6c0d3..000000000
--- a/x/epochs/keeper/epoch_test.go
+++ /dev/null
@@ -1,99 +0,0 @@
-package keeper_test
-
-import (
- "time"
-
- "github.com/neutron-org/neutron/x/epochs/types"
-)
-
-func (suite *EpochsTestSuite) TestAddEpochInfo() {
- defaultIdentifier := "default_add_epoch_info_id"
- defaultDuration := time.Hour
- startBlockHeight := int64(100)
- startBlockTime := time.Unix(1656907200, 0).UTC()
- tests := map[string]struct {
- addedEpochInfo types.EpochInfo
- expErr bool
- expEpochInfo types.EpochInfo
- }{
- "simple_add": {
- addedEpochInfo: types.EpochInfo{
- Identifier: defaultIdentifier,
- StartTime: time.Time{},
- Duration: defaultDuration,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: 0,
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: false,
- },
- expErr: false,
- expEpochInfo: types.EpochInfo{
- Identifier: defaultIdentifier,
- StartTime: startBlockTime,
- Duration: defaultDuration,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: startBlockHeight,
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: false,
- },
- },
- "zero_duration": {
- addedEpochInfo: types.EpochInfo{
- Identifier: defaultIdentifier,
- StartTime: time.Time{},
- Duration: time.Duration(0),
- CurrentEpoch: 0,
- CurrentEpochStartHeight: 0,
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: false,
- },
- expErr: true,
- },
- }
- for name, test := range tests {
- suite.Run(name, func() {
- suite.SetupTest()
- suite.Ctx = suite.Ctx.WithBlockHeight(startBlockHeight).WithBlockTime(startBlockTime)
- err := suite.App.EpochsKeeper.AddEpochInfo(suite.Ctx, test.addedEpochInfo)
- if !test.expErr {
- suite.Require().NoError(err)
- actualEpochInfo := suite.App.EpochsKeeper.GetEpochInfo(suite.Ctx, test.addedEpochInfo.Identifier)
- suite.Require().Equal(test.expEpochInfo, actualEpochInfo)
- } else {
- suite.Require().Error(err)
- }
- })
- }
-}
-
-func (suite *EpochsTestSuite) TestDuplicateAddEpochInfo() {
- identifier := "duplicate_add_epoch_info"
- epochInfo := types.NewGenesisEpochInfo(identifier, time.Hour*24*30)
- err := suite.App.EpochsKeeper.AddEpochInfo(suite.Ctx, epochInfo)
- suite.Require().NoError(err)
- err = suite.App.EpochsKeeper.AddEpochInfo(suite.Ctx, epochInfo)
- suite.Require().Error(err)
-}
-
-func (suite *EpochsTestSuite) TestEpochLifeCycle() {
- suite.SetupTest()
-
- epochInfo := types.NewGenesisEpochInfo("monthly", time.Hour*24*30)
- err := suite.App.EpochsKeeper.AddEpochInfo(suite.Ctx, epochInfo)
- suite.Require().NoError(err)
-
- epochInfoSaved := suite.App.EpochsKeeper.GetEpochInfo(suite.Ctx, "monthly")
-
- // setup expected epoch info
- expectedEpochInfo := epochInfo
- expectedEpochInfo.StartTime = suite.Ctx.BlockTime()
- expectedEpochInfo.CurrentEpochStartHeight = suite.Ctx.BlockHeight()
- suite.Require().Equal(expectedEpochInfo, epochInfoSaved)
-
- allEpochs := suite.App.EpochsKeeper.AllEpochInfos(suite.Ctx)
- suite.Require().Len(allEpochs, 4)
- suite.Require().Equal(allEpochs[0].Identifier, "day") // alphabetical order
- suite.Require().Equal(allEpochs[1].Identifier, "hour")
- suite.Require().Equal(allEpochs[2].Identifier, "monthly")
- suite.Require().Equal(allEpochs[3].Identifier, "week")
-}
diff --git a/x/epochs/keeper/genesis.go b/x/epochs/keeper/genesis.go
deleted file mode 100644
index 00fd79188..000000000
--- a/x/epochs/keeper/genesis.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package keeper
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/neutron-org/neutron/x/epochs/types"
-)
-
-// InitGenesis sets epoch info from genesis
-func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) {
- for _, epoch := range genState.Epochs {
- err := k.AddEpochInfo(ctx, epoch)
- if err != nil {
- panic(err)
- }
- }
-}
-
-// ExportGenesis returns the capability module's exported genesis.
-func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
- genesis := types.DefaultGenesis()
- genesis.Epochs = k.AllEpochInfos(ctx)
- return genesis
-}
diff --git a/x/epochs/keeper/genesis_test.go b/x/epochs/keeper/genesis_test.go
deleted file mode 100644
index 2d685b0fd..000000000
--- a/x/epochs/keeper/genesis_test.go
+++ /dev/null
@@ -1,96 +0,0 @@
-package keeper_test
-
-import (
- "testing"
- "time"
-
- tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
- "github.com/stretchr/testify/require"
-
- "github.com/neutron-org/neutron/testutil"
- "github.com/neutron-org/neutron/x/epochs/types"
-)
-
-func TestEpochsExportGenesis(t *testing.T) {
- app := testutil.Setup(t)
- ctx := app.BaseApp.NewContext(false, tmproto.Header{})
-
- chainStartTime := ctx.BlockTime()
-
- genesis := app.EpochsKeeper.ExportGenesis(ctx)
- require.Len(t, genesis.Epochs, 3)
-
- expectedEpochs := types.DefaultGenesis().Epochs
- for i := 0; i < len(expectedEpochs); i++ {
- expectedEpochs[i].CurrentEpochStartHeight = 2
- expectedEpochs[i].CurrentEpochStartTime = chainStartTime
- expectedEpochs[i].EpochCountingStarted = true
- expectedEpochs[i].CurrentEpoch = 1
- }
- require.Equal(t, expectedEpochs, genesis.Epochs)
-}
-
-func TestEpochsInitGenesis(t *testing.T) {
- app := testutil.Setup(t)
- ctx := app.BaseApp.NewContext(false, tmproto.Header{})
-
- // On init genesis, default epochs information is set
- // To check init genesis again, should make it fresh status
- epochInfos := app.EpochsKeeper.AllEpochInfos(ctx)
- for _, epochInfo := range epochInfos {
- app.EpochsKeeper.DeleteEpochInfo(ctx, epochInfo.Identifier)
- }
-
- now := time.Now()
- ctx = ctx.WithBlockHeight(1)
- ctx = ctx.WithBlockTime(now)
-
- // test genesisState validation
- genesisState := types.GenesisState{
- Epochs: []types.EpochInfo{
- {
- Identifier: "monthly",
- StartTime: time.Time{},
- Duration: time.Hour * 24,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: ctx.BlockHeight(),
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: true,
- },
- {
- Identifier: "monthly",
- StartTime: time.Time{},
- Duration: time.Hour * 24,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: ctx.BlockHeight(),
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: true,
- },
- },
- }
- require.EqualError(t, genesisState.Validate(), "epoch identifier should be unique")
-
- genesisState = types.GenesisState{
- Epochs: []types.EpochInfo{
- {
- Identifier: "monthly",
- StartTime: time.Time{},
- Duration: time.Hour * 24,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: ctx.BlockHeight(),
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: true,
- },
- },
- }
-
- app.EpochsKeeper.InitGenesis(ctx, genesisState)
- epochInfo := app.EpochsKeeper.GetEpochInfo(ctx, "monthly")
- require.Equal(t, epochInfo.Identifier, "monthly")
- require.Equal(t, epochInfo.StartTime.UTC().String(), now.UTC().String())
- require.Equal(t, epochInfo.Duration, time.Hour*24)
- require.Equal(t, epochInfo.CurrentEpoch, int64(0))
- require.Equal(t, epochInfo.CurrentEpochStartHeight, ctx.BlockHeight())
- require.Equal(t, epochInfo.CurrentEpochStartTime.UTC().String(), time.Time{}.String())
- require.Equal(t, epochInfo.EpochCountingStarted, true)
-}
diff --git a/x/epochs/keeper/grpc_query.go b/x/epochs/keeper/grpc_query.go
deleted file mode 100644
index 283bf32ae..000000000
--- a/x/epochs/keeper/grpc_query.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package keeper
-
-import (
- "context"
- "errors"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/status"
-
- "github.com/neutron-org/neutron/x/epochs/types"
-)
-
-var _ types.QueryServer = Querier{}
-
-// Querier defines a wrapper around the x/epochs keeper providing gRPC method
-// handlers.
-type Querier struct {
- Keeper
-}
-
-// NewQuerier initializes new querier.
-func NewQuerier(k Keeper) Querier {
- return Querier{Keeper: k}
-}
-
-// EpochInfos provide running epochInfos.
-func (q Querier) EpochInfos(
- c context.Context,
- _ *types.QueryEpochsInfoRequest,
-) (*types.QueryEpochsInfoResponse, error) {
- ctx := sdk.UnwrapSDKContext(c)
-
- return &types.QueryEpochsInfoResponse{
- Epochs: q.Keeper.AllEpochInfos(ctx),
- }, nil
-}
-
-// CurrentEpoch provides current epoch of specified identifier.
-func (q Querier) CurrentEpoch(c context.Context,
- req *types.QueryCurrentEpochRequest,
-) (*types.QueryCurrentEpochResponse, error) {
- if req == nil {
- return nil, status.Error(codes.InvalidArgument, "empty request")
- }
- if req.Identifier == "" {
- return nil, status.Error(codes.InvalidArgument, "identifier is empty")
- }
-
- ctx := sdk.UnwrapSDKContext(c)
-
- info := q.Keeper.GetEpochInfo(ctx, req.Identifier)
- if info.Identifier != req.Identifier {
- return nil, errors.New("not available identifier")
- }
-
- return &types.QueryCurrentEpochResponse{
- CurrentEpoch: info.CurrentEpoch,
- }, nil
-}
diff --git a/x/epochs/keeper/grpc_query_test.go b/x/epochs/keeper/grpc_query_test.go
deleted file mode 100644
index a2b5c8c95..000000000
--- a/x/epochs/keeper/grpc_query_test.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package keeper_test
-
-import (
- gocontext "context"
-
- "github.com/neutron-org/neutron/x/epochs/types"
-)
-
-func (suite *EpochsTestSuite) TestQueryEpochInfos() {
- suite.SetupTest()
- queryClient := suite.queryClient
-
- // Check that querying epoch infos on default genesis returns the default genesis epoch infos
- epochInfosResponse, err := queryClient.EpochInfos(
- gocontext.Background(),
- &types.QueryEpochsInfoRequest{},
- )
- suite.Require().NoError(err)
- suite.Require().Len(epochInfosResponse.Epochs, 3)
-
- expectedEpochs := types.DefaultGenesis().Epochs
- for id := range expectedEpochs {
- expectedEpochs[id].StartTime = suite.Ctx.BlockTime()
- expectedEpochs[id].CurrentEpochStartHeight = suite.Ctx.BlockHeight()
- expectedEpochs[id].CurrentEpoch = 1
- expectedEpochs[id].EpochCountingStarted = true
- }
-
- suite.Require().Equal(expectedEpochs, epochInfosResponse.Epochs)
-}
diff --git a/x/epochs/keeper/hooks.go b/x/epochs/keeper/hooks.go
deleted file mode 100644
index 5828d2ef6..000000000
--- a/x/epochs/keeper/hooks.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package keeper
-
-import (
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-// AfterEpochEnd gets called at the end of the epoch,
-// end of epoch is the timestamp of first block produced after epoch duration.
-func (k Keeper) AfterEpochEnd(ctx sdk.Context, identifier string) {
- // Error is not handled as AfterEpochEnd Hooks use utils.ApplyFuncIfNoError()
- if k.hooks != nil {
- _ = k.hooks.AfterEpochEnd(ctx, identifier)
- }
-}
-
-// BeforeEpochStart new epoch is next block of epoch end block
-func (k Keeper) BeforeEpochStart(ctx sdk.Context, identifier string) {
- // Error is not handled as BeforeEpochStart Hooks use utils.ApplyFuncIfNoError()
- if k.hooks != nil {
- _ = k.hooks.BeforeEpochStart(ctx, identifier)
- }
-}
diff --git a/x/epochs/keeper/keeper.go b/x/epochs/keeper/keeper.go
deleted file mode 100644
index 583d4f598..000000000
--- a/x/epochs/keeper/keeper.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package keeper
-
-import (
- "fmt"
-
- "github.com/cometbft/cometbft/libs/log"
-
- "github.com/neutron-org/neutron/x/epochs/types"
-
- storetypes "github.com/cosmos/cosmos-sdk/store/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-type (
- Keeper struct {
- storeKey storetypes.StoreKey
- hooks types.EpochHooks
- }
-)
-
-// NewKeeper returns a new keeper by codec and storeKey inputs.
-func NewKeeper(storeKey storetypes.StoreKey) *Keeper {
- return &Keeper{
- storeKey: storeKey,
- }
-}
-
-// Set the gamm hooks.
-func (k *Keeper) SetHooks(eh types.EpochHooks) *Keeper {
- if k.hooks != nil {
- panic("cannot set epochs hooks twice")
- }
-
- k.hooks = eh
-
- return k
-}
-
-func (k Keeper) Logger(ctx sdk.Context) log.Logger {
- return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName))
-}
diff --git a/x/epochs/keeper/keeper_test.go b/x/epochs/keeper/keeper_test.go
deleted file mode 100644
index 4871e2de1..000000000
--- a/x/epochs/keeper/keeper_test.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package keeper_test
-
-import (
- "testing"
-
- "github.com/stretchr/testify/suite"
-
- "github.com/neutron-org/neutron/testutil/apptesting"
- "github.com/neutron-org/neutron/x/epochs/types"
-)
-
-type EpochsTestSuite struct {
- apptesting.KeeperTestHelper
- queryClient types.QueryClient
-}
-
-func (suite *EpochsTestSuite) SetupTest() {
- suite.Setup()
- suite.queryClient = types.NewQueryClient(suite.QueryHelper)
-}
-
-func TestEpochsTestSuite(t *testing.T) {
- suite.Run(t, new(EpochsTestSuite))
-}
diff --git a/x/epochs/module.go b/x/epochs/module.go
deleted file mode 100644
index 9bf259b38..000000000
--- a/x/epochs/module.go
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
-Often in the SDK, we would like to run certain code every-so often. The
-purpose of `epochs` module is to allow other modules to set that they
-would like to be signaled once every period. So another module can
-specify it wants to execute code once a week, starting at UTC-time = x.
-`epochs` creates a generalized epoch interface to other modules so that
-they can easily be signalled upon such events.
- - Contains functionality for querying epoch.
- - Events for BeginBlock and EndBlock.
- - Initialization for epoch-related infos.
-*/
-
-package epochs
-
-import (
- "context"
- "encoding/json"
- "fmt"
-
- abci "github.com/cometbft/cometbft/abci/types"
- "github.com/gorilla/mux"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/spf13/cobra"
-
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/codec"
- cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/module"
-
- "github.com/neutron-org/neutron/x/epochs/client/cli"
- "github.com/neutron-org/neutron/x/epochs/keeper"
- "github.com/neutron-org/neutron/x/epochs/types"
-)
-
-var (
- _ module.AppModule = AppModule{}
- _ module.AppModuleBasic = AppModuleBasic{}
-)
-
-// ----------------------------------------------------------------------------
-// AppModuleBasic
-// ----------------------------------------------------------------------------
-
-// AppModuleBasic implements the AppModuleBasic interface for the capability module.
-type AppModuleBasic struct{}
-
-func NewAppModuleBasic() AppModuleBasic {
- return AppModuleBasic{}
-}
-
-// Name returns the capability module's name.
-func (AppModuleBasic) Name() string {
- return types.ModuleName
-}
-
-// RegisterLegacyAminoCodec registers the module's Amino codec that properly handles protobuf types with Any's.
-func (AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {}
-
-// RegisterInterfaces registers the module's interface types.
-func (a AppModuleBasic) RegisterInterfaces(_ cdctypes.InterfaceRegistry) {}
-
-// DefaultGenesis returns the capability module's default genesis state.
-func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
- return cdc.MustMarshalJSON(types.DefaultGenesis())
-}
-
-// ValidateGenesis performs genesis state validation for the capability module.
-func (AppModuleBasic) ValidateGenesis(
- cdc codec.JSONCodec,
- _ client.TxEncodingConfig,
- bz json.RawMessage,
-) error {
- var genState types.GenesisState
- if err := cdc.UnmarshalJSON(bz, &genState); err != nil {
- return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
- }
-
- return genState.Validate()
-}
-
-// RegisterRESTRoutes registers the capability module's REST service handlers.
-func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {}
-
-// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
-func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
- types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck
-}
-
-// GetTxCmd returns the capability module's root tx command.
-func (a AppModuleBasic) GetTxCmd() *cobra.Command {
- return nil
-}
-
-// GetQueryCmd returns the capability module's root query command.
-func (AppModuleBasic) GetQueryCmd() *cobra.Command {
- return cli.GetQueryCmd()
-}
-
-// ----------------------------------------------------------------------------
-// AppModule
-// ----------------------------------------------------------------------------
-
-// AppModule implements the AppModule interface for the capability module.
-type AppModule struct {
- AppModuleBasic
-
- keeper keeper.Keeper
-}
-
-func NewAppModule(keeper keeper.Keeper) AppModule {
- return AppModule{
- AppModuleBasic: NewAppModuleBasic(),
- keeper: keeper,
- }
-}
-
-// Name returns the capability module's name.
-func (am AppModule) Name() string {
- return am.AppModuleBasic.Name()
-}
-
-// QuerierRoute returns the capability module's query routing key.
-func (AppModule) QuerierRoute() string { return types.QuerierRoute }
-
-// RegisterServices registers a GRPC query service to respond to the
-// module-specific GRPC queries.
-func (am AppModule) RegisterServices(cfg module.Configurator) {
- types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerier(am.keeper))
-}
-
-// RegisterInvariants registers the capability module's invariants.
-func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
-
-// InitGenesis performs the capability module's genesis initialization It returns
-// no validator updates.
-func (am AppModule) InitGenesis(
- ctx sdk.Context,
- cdc codec.JSONCodec,
- gs json.RawMessage,
-) []abci.ValidatorUpdate {
- var genState types.GenesisState
- // Initialize global index to index in genesis state
- cdc.MustUnmarshalJSON(gs, &genState)
-
- am.keeper.InitGenesis(ctx, genState)
-
- return []abci.ValidatorUpdate{}
-}
-
-// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes.
-func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
- genState := am.keeper.ExportGenesis(ctx)
- return cdc.MustMarshalJSON(genState)
-}
-
-// BeginBlock executes all ABCI BeginBlock logic respective to the capability module.
-func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {
- am.keeper.BeginBlocker(ctx)
-}
-
-// EndBlock executes all ABCI EndBlock logic respective to the capability module. It
-// returns no validator updates.
-func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
- return []abci.ValidatorUpdate{}
-}
-
-// ConsensusVersion implements AppModule/ConsensusVersion.
-func (AppModule) ConsensusVersion() uint64 { return 1 }
diff --git a/x/epochs/types/doc.go b/x/epochs/types/doc.go
deleted file mode 100644
index c1b138dfb..000000000
--- a/x/epochs/types/doc.go
+++ /dev/null
@@ -1,4 +0,0 @@
-/*
-Package types translates gRPC into RESTful JSON APIs.
-*/
-package types
diff --git a/x/epochs/types/events.go b/x/epochs/types/events.go
deleted file mode 100644
index da0ac836e..000000000
--- a/x/epochs/types/events.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package types
-
-const (
- EventTypeEpochEnd = "epoch_end"
- EventTypeEpochStart = "epoch_start"
-
- AttributeEpochNumber = "epoch_number"
- AttributeEpochStartTime = "start_time"
-)
diff --git a/x/epochs/types/genesis.go b/x/epochs/types/genesis.go
deleted file mode 100644
index 3aadcce3b..000000000
--- a/x/epochs/types/genesis.go
+++ /dev/null
@@ -1,68 +0,0 @@
-package types
-
-import (
- "errors"
- "time"
-)
-
-func NewGenesisState(epochs []EpochInfo) *GenesisState {
- return &GenesisState{Epochs: epochs}
-}
-
-// DefaultGenesis returns the default Capability genesis state.
-func DefaultGenesis() *GenesisState {
- epochs := []EpochInfo{
- NewGenesisEpochInfo("day", time.Hour*24), // alphabetical order
- NewGenesisEpochInfo("hour", time.Hour),
- NewGenesisEpochInfo("week", time.Hour*24*7),
- }
-
- return NewGenesisState(epochs)
-}
-
-// Validate performs basic genesis state validation returning an error upon any
-// failure.
-func (gs GenesisState) Validate() error {
- epochIdentifiers := map[string]bool{}
- for _, epoch := range gs.Epochs {
- if err := epoch.Validate(); err != nil {
- return err
- }
- if epochIdentifiers[epoch.Identifier] {
- return errors.New("epoch identifier should be unique")
- }
- epochIdentifiers[epoch.Identifier] = true
- }
-
- return nil
-}
-
-// Validate also validates epoch info.
-func (epoch EpochInfo) Validate() error {
- if epoch.Identifier == "" {
- return errors.New("epoch identifier should NOT be empty")
- }
- if epoch.Duration == 0 {
- return errors.New("epoch duration should NOT be 0")
- }
- if epoch.CurrentEpoch < 0 {
- return errors.New("epoch CurrentEpoch must be non-negative")
- }
- if epoch.CurrentEpochStartHeight < 0 {
- return errors.New("epoch CurrentEpoch must be non-negative")
- }
-
- return nil
-}
-
-func NewGenesisEpochInfo(identifier string, duration time.Duration) EpochInfo {
- return EpochInfo{
- Identifier: identifier,
- StartTime: time.Time{},
- Duration: duration,
- CurrentEpoch: 0,
- CurrentEpochStartHeight: 0,
- CurrentEpochStartTime: time.Time{},
- EpochCountingStarted: false,
- }
-}
diff --git a/x/epochs/types/genesis.pb.go b/x/epochs/types/genesis.pb.go
deleted file mode 100644
index d89510958..000000000
--- a/x/epochs/types/genesis.pb.go
+++ /dev/null
@@ -1,820 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: neutron/epochs/genesis.proto
-
-package types
-
-import (
- fmt "fmt"
- _ "github.com/cosmos/gogoproto/gogoproto"
- proto "github.com/cosmos/gogoproto/proto"
- github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types"
- _ "google.golang.org/protobuf/types/known/durationpb"
- _ "google.golang.org/protobuf/types/known/timestamppb"
- io "io"
- math "math"
- math_bits "math/bits"
- time "time"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-var _ = time.Kitchen
-
-// 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
-
-// EpochInfo is a struct that describes the data going into
-// a timer defined by the x/epochs module.
-type EpochInfo struct {
- // identifier is a unique reference to this particular timer.
- Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"`
- // start_time is the time at which the timer first ever ticks.
- // If start_time is in the future, the epoch will not begin until the start
- // time.
- StartTime time.Time `protobuf:"bytes,2,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"`
- // duration is the time in between epoch ticks.
- // In order for intended behavior to be met, duration should
- // be greater than the chains expected block time.
- // Duration must be non-zero.
- Duration time.Duration `protobuf:"bytes,3,opt,name=duration,proto3,stdduration" json:"duration,omitempty" yaml:"duration"`
- // current_epoch is the current epoch number, or in other words,
- // how many times has the timer 'ticked'.
- // The first tick (current_epoch=1) is defined as
- // the first block whose blocktime is greater than the EpochInfo start_time.
- CurrentEpoch int64 `protobuf:"varint,4,opt,name=current_epoch,json=currentEpoch,proto3" json:"current_epoch,omitempty"`
- // current_epoch_start_time describes the start time of the current timer
- // interval. The interval is (current_epoch_start_time,
- // current_epoch_start_time + duration] When the timer ticks, this is set to
- // current_epoch_start_time = last_epoch_start_time + duration only one timer
- // tick for a given identifier can occur per block.
- //
- // NOTE! The current_epoch_start_time may diverge significantly from the
- // wall-clock time the epoch began at. Wall-clock time of epoch start may be
- // >> current_epoch_start_time. Suppose current_epoch_start_time = 10,
- // duration = 5. Suppose the chain goes offline at t=14, and comes back online
- // at t=30, and produces blocks at every successive time. (t=31, 32, etc.)
- // * The t=30 block will start the epoch for (10, 15]
- // * The t=31 block will start the epoch for (15, 20]
- // * The t=32 block will start the epoch for (20, 25]
- // * The t=33 block will start the epoch for (25, 30]
- // * The t=34 block will start the epoch for (30, 35]
- // * The **t=36** block will start the epoch for (35, 40]
- CurrentEpochStartTime time.Time `protobuf:"bytes,5,opt,name=current_epoch_start_time,json=currentEpochStartTime,proto3,stdtime" json:"current_epoch_start_time" yaml:"current_epoch_start_time"`
- // epoch_counting_started is a boolean, that indicates whether this
- // epoch timer has began yet.
- EpochCountingStarted bool `protobuf:"varint,6,opt,name=epoch_counting_started,json=epochCountingStarted,proto3" json:"epoch_counting_started,omitempty"`
- // current_epoch_start_height is the block height at which the current epoch
- // started. (The block height at which the timer last ticked)
- CurrentEpochStartHeight int64 `protobuf:"varint,8,opt,name=current_epoch_start_height,json=currentEpochStartHeight,proto3" json:"current_epoch_start_height,omitempty"`
-}
-
-func (m *EpochInfo) Reset() { *m = EpochInfo{} }
-func (m *EpochInfo) String() string { return proto.CompactTextString(m) }
-func (*EpochInfo) ProtoMessage() {}
-func (*EpochInfo) Descriptor() ([]byte, []int) {
- return fileDescriptor_924a4bf36f8131d7, []int{0}
-}
-func (m *EpochInfo) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *EpochInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_EpochInfo.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 *EpochInfo) XXX_Merge(src proto.Message) {
- xxx_messageInfo_EpochInfo.Merge(m, src)
-}
-func (m *EpochInfo) XXX_Size() int {
- return m.Size()
-}
-func (m *EpochInfo) XXX_DiscardUnknown() {
- xxx_messageInfo_EpochInfo.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_EpochInfo proto.InternalMessageInfo
-
-func (m *EpochInfo) GetIdentifier() string {
- if m != nil {
- return m.Identifier
- }
- return ""
-}
-
-func (m *EpochInfo) GetStartTime() time.Time {
- if m != nil {
- return m.StartTime
- }
- return time.Time{}
-}
-
-func (m *EpochInfo) GetDuration() time.Duration {
- if m != nil {
- return m.Duration
- }
- return 0
-}
-
-func (m *EpochInfo) GetCurrentEpoch() int64 {
- if m != nil {
- return m.CurrentEpoch
- }
- return 0
-}
-
-func (m *EpochInfo) GetCurrentEpochStartTime() time.Time {
- if m != nil {
- return m.CurrentEpochStartTime
- }
- return time.Time{}
-}
-
-func (m *EpochInfo) GetEpochCountingStarted() bool {
- if m != nil {
- return m.EpochCountingStarted
- }
- return false
-}
-
-func (m *EpochInfo) GetCurrentEpochStartHeight() int64 {
- if m != nil {
- return m.CurrentEpochStartHeight
- }
- return 0
-}
-
-// GenesisState defines the epochs module's genesis state.
-type GenesisState struct {
- Epochs []EpochInfo `protobuf:"bytes,1,rep,name=epochs,proto3" json:"epochs"`
-}
-
-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_924a4bf36f8131d7, []int{1}
-}
-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) GetEpochs() []EpochInfo {
- if m != nil {
- return m.Epochs
- }
- return nil
-}
-
-func init() {
- proto.RegisterType((*EpochInfo)(nil), "neutron.epochs.EpochInfo")
- proto.RegisterType((*GenesisState)(nil), "neutron.epochs.GenesisState")
-}
-
-func init() { proto.RegisterFile("neutron/epochs/genesis.proto", fileDescriptor_924a4bf36f8131d7) }
-
-var fileDescriptor_924a4bf36f8131d7 = []byte{
- // 463 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x4d, 0x8f, 0xd3, 0x30,
- 0x10, 0xad, 0x69, 0x29, 0xa9, 0x59, 0xbe, 0xac, 0x05, 0x42, 0x05, 0x49, 0x14, 0x2e, 0x95, 0x60,
- 0x13, 0xf1, 0x21, 0x21, 0xc1, 0xad, 0x80, 0x0a, 0x1c, 0x53, 0x0e, 0x88, 0x4b, 0x95, 0xb6, 0xae,
- 0x63, 0x69, 0x63, 0x47, 0xc9, 0x44, 0xa2, 0x37, 0x7e, 0x42, 0x8f, 0xfc, 0xa4, 0x3d, 0xee, 0x91,
- 0x53, 0x40, 0xed, 0x8d, 0xe3, 0xfe, 0x02, 0x14, 0xdb, 0x29, 0x5d, 0x0a, 0xda, 0x9b, 0x33, 0xef,
- 0xcd, 0x7b, 0x9e, 0x97, 0x31, 0xbe, 0x2f, 0x68, 0x09, 0xb9, 0x14, 0x21, 0xcd, 0xe4, 0x2c, 0x29,
- 0x42, 0x46, 0x05, 0x2d, 0x78, 0x11, 0x64, 0xb9, 0x04, 0x49, 0xae, 0x1b, 0x34, 0xd0, 0x68, 0xff,
- 0x90, 0x49, 0x26, 0x15, 0x14, 0xd6, 0x27, 0xcd, 0xea, 0x3b, 0x4c, 0x4a, 0x76, 0x4c, 0x43, 0xf5,
- 0x35, 0x2d, 0x17, 0xe1, 0xbc, 0xcc, 0x63, 0xe0, 0x52, 0x18, 0xdc, 0xfd, 0x1b, 0x07, 0x9e, 0xd2,
- 0x02, 0xe2, 0x34, 0xd3, 0x04, 0x7f, 0xd5, 0xc1, 0xbd, 0xb7, 0xb5, 0xc3, 0x7b, 0xb1, 0x90, 0xc4,
- 0xc1, 0x98, 0xcf, 0xa9, 0x00, 0xbe, 0xe0, 0x34, 0xb7, 0x91, 0x87, 0x06, 0xbd, 0x68, 0xa7, 0x42,
- 0x3e, 0x61, 0x5c, 0x40, 0x9c, 0xc3, 0xa4, 0x96, 0xb1, 0x2f, 0x79, 0x68, 0x70, 0xf5, 0x69, 0x3f,
- 0xd0, 0x1e, 0x41, 0xe3, 0x11, 0x7c, 0x6c, 0x3c, 0x86, 0x0f, 0x4e, 0x2a, 0xb7, 0x75, 0x56, 0xb9,
- 0xb7, 0x96, 0x71, 0x7a, 0xfc, 0xd2, 0xff, 0xd3, 0xeb, 0xaf, 0x7e, 0xb8, 0x28, 0xea, 0xa9, 0x42,
- 0x4d, 0x27, 0x09, 0xb6, 0x9a, 0xab, 0xdb, 0x6d, 0xa5, 0x7b, 0x6f, 0x4f, 0xf7, 0x8d, 0x21, 0x0c,
- 0x9f, 0xd4, 0xb2, 0xbf, 0x2a, 0x97, 0x34, 0x2d, 0x8f, 0x65, 0xca, 0x81, 0xa6, 0x19, 0x2c, 0xcf,
- 0x2a, 0xf7, 0x86, 0x36, 0x6b, 0x30, 0xff, 0x5b, 0x6d, 0xb5, 0x55, 0x27, 0x0f, 0xf1, 0xb5, 0x59,
- 0x99, 0xe7, 0x54, 0xc0, 0x44, 0x45, 0x6b, 0x77, 0x3c, 0x34, 0x68, 0x47, 0x07, 0xa6, 0xa8, 0xc2,
- 0x20, 0x5f, 0x11, 0xb6, 0xcf, 0xb1, 0x26, 0x3b, 0x73, 0x5f, 0xbe, 0x70, 0xee, 0x47, 0x66, 0x6e,
- 0x57, 0x5f, 0xe5, 0x7f, 0x4a, 0x3a, 0x85, 0xdb, 0xbb, 0xce, 0xe3, 0x6d, 0x22, 0xcf, 0xf1, 0x1d,
- 0xcd, 0x9f, 0xc9, 0x52, 0x00, 0x17, 0x4c, 0x37, 0xd2, 0xb9, 0xdd, 0xf5, 0xd0, 0xc0, 0x8a, 0x0e,
- 0x15, 0xfa, 0xda, 0x80, 0x63, 0x8d, 0x91, 0x57, 0xb8, 0xff, 0x2f, 0xb7, 0x84, 0x72, 0x96, 0x80,
- 0x6d, 0xa9, 0x51, 0xef, 0xee, 0x19, 0xbe, 0x53, 0xf0, 0x87, 0x8e, 0x75, 0xe5, 0xa6, 0xe5, 0x8f,
- 0xf0, 0xc1, 0x48, 0xaf, 0xe2, 0x18, 0x62, 0xa0, 0xe4, 0x05, 0xee, 0xea, 0x1d, 0xb4, 0x91, 0xd7,
- 0x56, 0x3f, 0xe6, 0xfc, 0x6a, 0x06, 0xdb, 0xfd, 0x19, 0x76, 0xea, 0xb9, 0x23, 0x43, 0x1f, 0x8e,
- 0x4e, 0xd6, 0x0e, 0x3a, 0x5d, 0x3b, 0xe8, 0xe7, 0xda, 0x41, 0xab, 0x8d, 0xd3, 0x3a, 0xdd, 0x38,
- 0xad, 0xef, 0x1b, 0xa7, 0xf5, 0xf9, 0x88, 0x71, 0x48, 0xca, 0x69, 0x30, 0x93, 0x69, 0x68, 0xc4,
- 0x8e, 0x64, 0xce, 0x9a, 0x73, 0xf8, 0xa5, 0x79, 0x13, 0xb0, 0xcc, 0x68, 0x31, 0xed, 0xaa, 0x88,
- 0x9f, 0xfd, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x27, 0xb8, 0xfb, 0x5b, 0x32, 0x03, 0x00, 0x00,
-}
-
-func (m *EpochInfo) 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 *EpochInfo) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *EpochInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.CurrentEpochStartHeight != 0 {
- i = encodeVarintGenesis(dAtA, i, uint64(m.CurrentEpochStartHeight))
- i--
- dAtA[i] = 0x40
- }
- if m.EpochCountingStarted {
- i--
- if m.EpochCountingStarted {
- dAtA[i] = 1
- } else {
- dAtA[i] = 0
- }
- i--
- dAtA[i] = 0x30
- }
- n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.CurrentEpochStartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CurrentEpochStartTime):])
- if err1 != nil {
- return 0, err1
- }
- i -= n1
- i = encodeVarintGenesis(dAtA, i, uint64(n1))
- i--
- dAtA[i] = 0x2a
- if m.CurrentEpoch != 0 {
- i = encodeVarintGenesis(dAtA, i, uint64(m.CurrentEpoch))
- i--
- dAtA[i] = 0x20
- }
- n2, err2 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.Duration, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.Duration):])
- if err2 != nil {
- return 0, err2
- }
- i -= n2
- i = encodeVarintGenesis(dAtA, i, uint64(n2))
- i--
- dAtA[i] = 0x1a
- n3, err3 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime):])
- if err3 != nil {
- return 0, err3
- }
- i -= n3
- i = encodeVarintGenesis(dAtA, i, uint64(n3))
- i--
- dAtA[i] = 0x12
- if len(m.Identifier) > 0 {
- i -= len(m.Identifier)
- copy(dAtA[i:], m.Identifier)
- i = encodeVarintGenesis(dAtA, i, uint64(len(m.Identifier)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-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.Epochs) > 0 {
- for iNdEx := len(m.Epochs) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Epochs[iNdEx].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 *EpochInfo) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Identifier)
- if l > 0 {
- n += 1 + l + sovGenesis(uint64(l))
- }
- l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime)
- n += 1 + l + sovGenesis(uint64(l))
- l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.Duration)
- n += 1 + l + sovGenesis(uint64(l))
- if m.CurrentEpoch != 0 {
- n += 1 + sovGenesis(uint64(m.CurrentEpoch))
- }
- l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CurrentEpochStartTime)
- n += 1 + l + sovGenesis(uint64(l))
- if m.EpochCountingStarted {
- n += 2
- }
- if m.CurrentEpochStartHeight != 0 {
- n += 1 + sovGenesis(uint64(m.CurrentEpochStartHeight))
- }
- return n
-}
-
-func (m *GenesisState) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if len(m.Epochs) > 0 {
- for _, e := range m.Epochs {
- 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 *EpochInfo) 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: EpochInfo: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: EpochInfo: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Identifier", wireType)
- }
- var stringLen uint64
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- stringLen |= uint64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- intStringLen := int(stringLen)
- if intStringLen < 0 {
- return ErrInvalidLengthGenesis
- }
- postIndex := iNdEx + intStringLen
- if postIndex < 0 {
- return ErrInvalidLengthGenesis
- }
- if postIndex > l {
- return io.ErrUnexpectedEOF
- }
- m.Identifier = string(dAtA[iNdEx:postIndex])
- iNdEx = postIndex
- case 2:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field StartTime", 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 := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 3:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Duration", 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 := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.Duration, dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 4:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpoch", wireType)
- }
- m.CurrentEpoch = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.CurrentEpoch |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- case 5:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpochStartTime", 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 := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.CurrentEpochStartTime, dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- case 6:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field EpochCountingStarted", wireType)
- }
- var v int
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- v |= int(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- m.EpochCountingStarted = bool(v != 0)
- case 8:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpochStartHeight", wireType)
- }
- m.CurrentEpochStartHeight = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowGenesis
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.CurrentEpochStartHeight |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- 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 (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 Epochs", 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.Epochs = append(m.Epochs, EpochInfo{})
- if err := m.Epochs[len(m.Epochs)-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/epochs/types/hooks.go b/x/epochs/types/hooks.go
deleted file mode 100644
index d3cab5e61..000000000
--- a/x/epochs/types/hooks.go
+++ /dev/null
@@ -1,64 +0,0 @@
-package types
-
-import (
- fmt "fmt"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
-
- "github.com/neutron-org/neutron/utils"
-)
-
-type EpochHooks interface {
- // the first block whose timestamp is after the duration is counted as the end of the epoch
- AfterEpochEnd(ctx sdk.Context, epochIdentifier string) error
- // new epoch is next block of epoch end block
- BeforeEpochStart(ctx sdk.Context, epochIdentifier string) error
-}
-
-var _ EpochHooks = MultiEpochHooks{}
-
-// combine multiple gamm hooks, all hook functions are run in array sequence.
-type MultiEpochHooks []EpochHooks
-
-func NewMultiEpochHooks(hooks ...EpochHooks) MultiEpochHooks {
- return hooks
-}
-
-// AfterEpochEnd is called when epoch is going to be ended, epochNumber is the number of epoch that is ending.
-func (h MultiEpochHooks) AfterEpochEnd(
- ctx sdk.Context,
- epochIdentifier string,
-) error {
- for i := range h {
- panicCatchingEpochHook(ctx, h[i].AfterEpochEnd, epochIdentifier)
- }
-
- return nil
-}
-
-// BeforeEpochStart is called when epoch is going to be started, epochNumber is the number of epoch that is starting.
-func (h MultiEpochHooks) BeforeEpochStart(
- ctx sdk.Context,
- epochIdentifier string,
-) error {
- for i := range h {
- panicCatchingEpochHook(ctx, h[i].BeforeEpochStart, epochIdentifier)
- }
-
- return nil
-}
-
-func panicCatchingEpochHook(
- ctx sdk.Context,
- hookFn func(ctx sdk.Context, epochIdentifier string) error,
- epochIdentifier string,
-) {
- wrappedHookFn := func(ctx sdk.Context) error {
- return hookFn(ctx, epochIdentifier)
- }
- // TODO: Thread info for which hook this is, may be dependent on larger hook system refactoring
- err := utils.ApplyFuncIfNoError(ctx, wrappedHookFn)
- if err != nil {
- ctx.Logger().Error(fmt.Sprintf("error in epoch hook %v", err))
- }
-}
diff --git a/x/epochs/types/hooks_test.go b/x/epochs/types/hooks_test.go
deleted file mode 100644
index 84475d652..000000000
--- a/x/epochs/types/hooks_test.go
+++ /dev/null
@@ -1,163 +0,0 @@
-package types_test
-
-import (
- "testing"
-
- "cosmossdk.io/errors"
- "github.com/cosmos/cosmos-sdk/testutil"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/stretchr/testify/suite"
-
- "github.com/neutron-org/neutron/x/epochs/types"
-)
-
-type KeeperTestSuite struct {
- suite.Suite
- Ctx sdk.Context
-}
-
-func TestKeeperTestSuite(t *testing.T) {
- suite.Run(t, new(KeeperTestSuite))
-}
-
-func (s *KeeperTestSuite) SetupTest() {
- s.Ctx = testutil.DefaultContext(
- sdk.NewKVStoreKey(types.StoreKey),
- sdk.NewTransientStoreKey("transient_test"),
- )
-}
-
-func dummyAfterEpochEndEvent(epochIdentifier string) sdk.Event {
- return sdk.NewEvent(
- "afterEpochEnd",
- sdk.NewAttribute("epochIdentifier", epochIdentifier),
- )
-}
-
-func dummyBeforeEpochStartEvent(epochIdentifier string) sdk.Event {
- return sdk.NewEvent(
- "beforeEpochStart",
- sdk.NewAttribute("epochIdentifier", epochIdentifier),
- )
-}
-
-var errDummy = errors.New("9", 9, "dummyError")
-
-// dummyEpochHook is a struct satisfying the epoch hook interface,
-// that maintains a counter for how many times its been successfully called,
-// and a boolean for whether it should panic during its execution.
-type dummyEpochHook struct {
- successCounter int
- shouldPanic bool
- shouldError bool
-}
-
-func (hook *dummyEpochHook) AfterEpochEnd(
- ctx sdk.Context,
- epochIdentifier string,
-) error {
- if hook.shouldPanic {
- panic("dummyEpochHook is panicking")
- }
- if hook.shouldError {
- return errDummy
- }
- hook.successCounter++
- ctx.EventManager().EmitEvent(dummyAfterEpochEndEvent(epochIdentifier))
-
- return nil
-}
-
-func (hook *dummyEpochHook) BeforeEpochStart(
- ctx sdk.Context,
- epochIdentifier string,
-) error {
- if hook.shouldPanic {
- panic("dummyEpochHook is panicking")
- }
- if hook.shouldError {
- return errDummy
- }
- hook.successCounter++
- ctx.EventManager().EmitEvent(dummyBeforeEpochStartEvent(epochIdentifier))
-
- return nil
-}
-
-func (hook *dummyEpochHook) Clone() *dummyEpochHook {
- newHook := dummyEpochHook{
- shouldPanic: hook.shouldPanic,
- successCounter: hook.successCounter,
- shouldError: hook.shouldError,
- }
- return &newHook
-}
-
-var _ types.EpochHooks = &dummyEpochHook{}
-
-func (s *KeeperTestSuite) TestHooksPanicRecovery() {
- // panicHook := dummyEpochHook{shouldPanic: true}
- noPanicHook := dummyEpochHook{shouldPanic: false}
- // errorHook := dummyEpochHook{shouldError: true}
- // noErrorHook := dummyEpochHook{shouldError: false} // same as nopanic
- // simpleHooks := []dummyEpochHook{panicHook, noPanicHook, errorHook, noErrorHook}
-
- tests := []struct {
- hooks []dummyEpochHook
- expectedCounterValues []int
- lenEvents int
- }{
- {[]dummyEpochHook{noPanicHook}, []int{1}, 1},
- // {[]dummyEpochHook{panicHook}, []int{0}, 0},
- // {[]dummyEpochHook{errorHook}, []int{0}, 0},
- // {simpleHooks, []int{0, 1, 0, 1}, 2},
- }
-
- for tcIndex, tc := range tests {
- for epochActionSelector := 0; epochActionSelector < 2; epochActionSelector++ {
- s.SetupTest()
- hookRefs := []types.EpochHooks{}
-
- for _, hook := range tc.hooks {
- hookRefs = append(hookRefs, hook.Clone())
- }
-
- hooks := types.NewMultiEpochHooks(hookRefs...)
-
- events := func(epochID string, dummyEvent func(id string) sdk.Event) sdk.Events {
- evts := make(sdk.Events, tc.lenEvents)
- for i := 0; i < tc.lenEvents; i++ {
- evts[i] = dummyEvent(epochID)
- }
-
- return evts
- }
-
- s.NotPanics(func() {
- if epochActionSelector == 0 {
- err := hooks.BeforeEpochStart(s.Ctx, "id")
- s.Require().NoError(err)
- s.Require().Equal(
- events(
- "id",
- dummyBeforeEpochStartEvent,
- ),
- s.Ctx.EventManager().Events(),
- "test case index %d, before epoch event check", tcIndex,
- )
- } else if epochActionSelector == 1 {
- err := hooks.AfterEpochEnd(s.Ctx, "id")
- s.Require().NoError(err)
- s.Require().Equal(events("id", dummyAfterEpochEndEvent), s.Ctx.EventManager().Events(),
- "test case index %d, after epoch event check", tcIndex)
- }
- })
-
- for i := 0; i < len(hooks); i++ {
- epochHook := hookRefs[i].(*dummyEpochHook)
- s.Require().
- Equal(tc.expectedCounterValues[i], epochHook.successCounter, "test case index %d", tcIndex)
- }
- }
- }
-}
diff --git a/x/epochs/types/identifier.go b/x/epochs/types/identifier.go
deleted file mode 100644
index 1cd154fa0..000000000
--- a/x/epochs/types/identifier.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package types
-
-import (
- "fmt"
-)
-
-func ValidateEpochIdentifierInterface(i interface{}) error {
- v, ok := i.(string)
- if !ok {
- return fmt.Errorf("invalid parameter type: %T", i)
- }
- err := ValidateEpochIdentifierString(v)
-
- return err
-}
-
-func ValidateEpochIdentifierString(s string) error {
- if s == "" {
- return fmt.Errorf("empty distribution epoch identifier: %+v", s)
- }
-
- return nil
-}
diff --git a/x/epochs/types/keys.go b/x/epochs/types/keys.go
deleted file mode 100644
index 4c6186fe5..000000000
--- a/x/epochs/types/keys.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package types
-
-const (
- // ModuleName defines the module name.
- ModuleName = "epochs"
-
- // StoreKey defines the primary module store key.
- StoreKey = ModuleName
-
- // RouterKey is the message route for slashing.
- RouterKey = ModuleName
-
- // QuerierRoute defines the module's query routing key.
- QuerierRoute = ModuleName
-)
-
-// KeyPrefixEpoch defines prefix key for storing epochs.
-var KeyPrefixEpoch = []byte{0x01}
diff --git a/x/epochs/types/query.pb.go b/x/epochs/types/query.pb.go
deleted file mode 100644
index 26f6b8c3c..000000000
--- a/x/epochs/types/query.pb.go
+++ /dev/null
@@ -1,911 +0,0 @@
-// Code generated by protoc-gen-gogo. DO NOT EDIT.
-// source: neutron/epochs/query.proto
-
-package types
-
-import (
- context "context"
- fmt "fmt"
- _ "github.com/cosmos/cosmos-sdk/types/query"
- _ "github.com/cosmos/gogoproto/gogoproto"
- grpc1 "github.com/cosmos/gogoproto/grpc"
- proto "github.com/cosmos/gogoproto/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
-
-type QueryEpochsInfoRequest struct {
-}
-
-func (m *QueryEpochsInfoRequest) Reset() { *m = QueryEpochsInfoRequest{} }
-func (m *QueryEpochsInfoRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryEpochsInfoRequest) ProtoMessage() {}
-func (*QueryEpochsInfoRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_11ec49a7f39aeaae, []int{0}
-}
-func (m *QueryEpochsInfoRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryEpochsInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryEpochsInfoRequest.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 *QueryEpochsInfoRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryEpochsInfoRequest.Merge(m, src)
-}
-func (m *QueryEpochsInfoRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryEpochsInfoRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryEpochsInfoRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryEpochsInfoRequest proto.InternalMessageInfo
-
-type QueryEpochsInfoResponse struct {
- Epochs []EpochInfo `protobuf:"bytes,1,rep,name=epochs,proto3" json:"epochs"`
-}
-
-func (m *QueryEpochsInfoResponse) Reset() { *m = QueryEpochsInfoResponse{} }
-func (m *QueryEpochsInfoResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryEpochsInfoResponse) ProtoMessage() {}
-func (*QueryEpochsInfoResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_11ec49a7f39aeaae, []int{1}
-}
-func (m *QueryEpochsInfoResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryEpochsInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryEpochsInfoResponse.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 *QueryEpochsInfoResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryEpochsInfoResponse.Merge(m, src)
-}
-func (m *QueryEpochsInfoResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryEpochsInfoResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryEpochsInfoResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryEpochsInfoResponse proto.InternalMessageInfo
-
-func (m *QueryEpochsInfoResponse) GetEpochs() []EpochInfo {
- if m != nil {
- return m.Epochs
- }
- return nil
-}
-
-type QueryCurrentEpochRequest struct {
- Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"`
-}
-
-func (m *QueryCurrentEpochRequest) Reset() { *m = QueryCurrentEpochRequest{} }
-func (m *QueryCurrentEpochRequest) String() string { return proto.CompactTextString(m) }
-func (*QueryCurrentEpochRequest) ProtoMessage() {}
-func (*QueryCurrentEpochRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_11ec49a7f39aeaae, []int{2}
-}
-func (m *QueryCurrentEpochRequest) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryCurrentEpochRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryCurrentEpochRequest.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 *QueryCurrentEpochRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryCurrentEpochRequest.Merge(m, src)
-}
-func (m *QueryCurrentEpochRequest) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryCurrentEpochRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryCurrentEpochRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryCurrentEpochRequest proto.InternalMessageInfo
-
-func (m *QueryCurrentEpochRequest) GetIdentifier() string {
- if m != nil {
- return m.Identifier
- }
- return ""
-}
-
-type QueryCurrentEpochResponse struct {
- CurrentEpoch int64 `protobuf:"varint,1,opt,name=current_epoch,json=currentEpoch,proto3" json:"current_epoch,omitempty"`
-}
-
-func (m *QueryCurrentEpochResponse) Reset() { *m = QueryCurrentEpochResponse{} }
-func (m *QueryCurrentEpochResponse) String() string { return proto.CompactTextString(m) }
-func (*QueryCurrentEpochResponse) ProtoMessage() {}
-func (*QueryCurrentEpochResponse) Descriptor() ([]byte, []int) {
- return fileDescriptor_11ec49a7f39aeaae, []int{3}
-}
-func (m *QueryCurrentEpochResponse) XXX_Unmarshal(b []byte) error {
- return m.Unmarshal(b)
-}
-func (m *QueryCurrentEpochResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- if deterministic {
- return xxx_messageInfo_QueryCurrentEpochResponse.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 *QueryCurrentEpochResponse) XXX_Merge(src proto.Message) {
- xxx_messageInfo_QueryCurrentEpochResponse.Merge(m, src)
-}
-func (m *QueryCurrentEpochResponse) XXX_Size() int {
- return m.Size()
-}
-func (m *QueryCurrentEpochResponse) XXX_DiscardUnknown() {
- xxx_messageInfo_QueryCurrentEpochResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_QueryCurrentEpochResponse proto.InternalMessageInfo
-
-func (m *QueryCurrentEpochResponse) GetCurrentEpoch() int64 {
- if m != nil {
- return m.CurrentEpoch
- }
- return 0
-}
-
-func init() {
- proto.RegisterType((*QueryEpochsInfoRequest)(nil), "neutron.epochs.QueryEpochsInfoRequest")
- proto.RegisterType((*QueryEpochsInfoResponse)(nil), "neutron.epochs.QueryEpochsInfoResponse")
- proto.RegisterType((*QueryCurrentEpochRequest)(nil), "neutron.epochs.QueryCurrentEpochRequest")
- proto.RegisterType((*QueryCurrentEpochResponse)(nil), "neutron.epochs.QueryCurrentEpochResponse")
-}
-
-func init() { proto.RegisterFile("neutron/epochs/query.proto", fileDescriptor_11ec49a7f39aeaae) }
-
-var fileDescriptor_11ec49a7f39aeaae = []byte{
- // 400 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xc1, 0x8b, 0xd3, 0x40,
- 0x18, 0xc5, 0x93, 0x56, 0x0b, 0x8e, 0xd5, 0xc3, 0x20, 0x35, 0x0d, 0x3a, 0x2d, 0x11, 0xb5, 0x0a,
- 0xcd, 0xd0, 0x7a, 0x10, 0x3c, 0x49, 0x45, 0xc4, 0xa3, 0x39, 0x7a, 0x91, 0x24, 0x4e, 0xa7, 0x03,
- 0x76, 0xbe, 0x34, 0x33, 0x11, 0x7b, 0xf0, 0xb2, 0xc7, 0x3d, 0x2d, 0xf4, 0x9f, 0xea, 0xb1, 0xb0,
- 0x97, 0x3d, 0x2d, 0x4b, 0xbb, 0x7f, 0xc8, 0xd2, 0x49, 0x5a, 0xda, 0x6c, 0x60, 0xf7, 0x94, 0x30,
- 0xef, 0xbd, 0xdf, 0xbc, 0xef, 0x63, 0x90, 0x2b, 0x59, 0xa6, 0x53, 0x90, 0x94, 0x25, 0x10, 0x4f,
- 0x14, 0x9d, 0x65, 0x2c, 0x9d, 0xfb, 0x49, 0x0a, 0x1a, 0xf0, 0xd3, 0x42, 0xf3, 0x73, 0xcd, 0x7d,
- 0xc6, 0x81, 0x83, 0x91, 0xe8, 0xf6, 0x2f, 0x77, 0xb9, 0x2f, 0x38, 0x00, 0xff, 0xc3, 0x68, 0x98,
- 0x08, 0x1a, 0x4a, 0x09, 0x3a, 0xd4, 0x02, 0xa4, 0x2a, 0xd4, 0xf7, 0x31, 0xa8, 0x29, 0x28, 0x1a,
- 0x85, 0x8a, 0xe5, 0x70, 0xfa, 0x77, 0x10, 0x31, 0x1d, 0x0e, 0x68, 0x12, 0x72, 0x21, 0x8d, 0x79,
- 0x47, 0x2a, 0x75, 0xe1, 0x4c, 0x32, 0x25, 0x0a, 0x92, 0xe7, 0xa0, 0xd6, 0x8f, 0x6d, 0xfe, 0xab,
- 0x11, 0xbf, 0xcb, 0x31, 0x04, 0x6c, 0x96, 0x31, 0xa5, 0xbd, 0x00, 0x3d, 0xbf, 0xa5, 0xa8, 0x04,
- 0xa4, 0x62, 0xf8, 0x23, 0x6a, 0xe4, 0x30, 0xc7, 0xee, 0xd6, 0x7b, 0x8f, 0x87, 0x6d, 0xff, 0x78,
- 0x26, 0xdf, 0x64, 0xb6, 0x91, 0xd1, 0x83, 0xe5, 0x65, 0xc7, 0x0a, 0x0a, 0xbb, 0xf7, 0x09, 0x39,
- 0x86, 0xf9, 0x25, 0x4b, 0x53, 0x26, 0xb5, 0xb1, 0x15, 0xf7, 0x61, 0x82, 0x90, 0xf8, 0xcd, 0xa4,
- 0x16, 0x63, 0xc1, 0x52, 0xc7, 0xee, 0xda, 0xbd, 0x47, 0xc1, 0xc1, 0x89, 0xf7, 0x19, 0xb5, 0x2b,
- 0xb2, 0x45, 0xa3, 0x57, 0xe8, 0x49, 0x9c, 0x9f, 0xff, 0x32, 0x57, 0x99, 0x7c, 0x3d, 0x68, 0xc6,
- 0x07, 0xe6, 0xe1, 0xa2, 0x86, 0x1e, 0x1a, 0x04, 0xfe, 0x8f, 0xd0, 0xbe, 0xa2, 0xc2, 0x6f, 0xca,
- 0xf5, 0xab, 0x37, 0xe2, 0xbe, 0xbd, 0xd3, 0x97, 0xb7, 0xf1, 0xc8, 0xc9, 0xf9, 0xf5, 0xa2, 0xe6,
- 0xe0, 0x16, 0x2d, 0xed, 0x3e, 0xff, 0xe0, 0x53, 0x1b, 0x35, 0x0f, 0xc7, 0xc0, 0xbd, 0x4a, 0x72,
- 0xc5, 0x96, 0xdc, 0x77, 0xf7, 0x70, 0x16, 0x2d, 0x5e, 0x9b, 0x16, 0x1d, 0xfc, 0xb2, 0xdc, 0xe2,
- 0x68, 0x53, 0xa3, 0x6f, 0xcb, 0x35, 0xb1, 0x57, 0x6b, 0x62, 0x5f, 0xad, 0x89, 0x7d, 0xb6, 0x21,
- 0xd6, 0x6a, 0x43, 0xac, 0x8b, 0x0d, 0xb1, 0x7e, 0xf6, 0xb9, 0xd0, 0x93, 0x2c, 0xf2, 0x63, 0x98,
- 0xee, 0x10, 0x7d, 0x48, 0xf9, 0x1e, 0xf7, 0x6f, 0x07, 0xd4, 0xf3, 0x84, 0xa9, 0xa8, 0x61, 0x5e,
- 0xd4, 0x87, 0x9b, 0x00, 0x00, 0x00, 0xff, 0xff, 0xda, 0x17, 0x4e, 0xb5, 0xfd, 0x02, 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 {
- // EpochInfos provide running epochInfos
- EpochInfos(ctx context.Context, in *QueryEpochsInfoRequest, opts ...grpc.CallOption) (*QueryEpochsInfoResponse, error)
- // CurrentEpoch provide current epoch of specified identifier
- CurrentEpoch(ctx context.Context, in *QueryCurrentEpochRequest, opts ...grpc.CallOption) (*QueryCurrentEpochResponse, error)
-}
-
-type queryClient struct {
- cc grpc1.ClientConn
-}
-
-func NewQueryClient(cc grpc1.ClientConn) QueryClient {
- return &queryClient{cc}
-}
-
-func (c *queryClient) EpochInfos(ctx context.Context, in *QueryEpochsInfoRequest, opts ...grpc.CallOption) (*QueryEpochsInfoResponse, error) {
- out := new(QueryEpochsInfoResponse)
- err := c.cc.Invoke(ctx, "/neutron.epochs.Query/EpochInfos", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *queryClient) CurrentEpoch(ctx context.Context, in *QueryCurrentEpochRequest, opts ...grpc.CallOption) (*QueryCurrentEpochResponse, error) {
- out := new(QueryCurrentEpochResponse)
- err := c.cc.Invoke(ctx, "/neutron.epochs.Query/CurrentEpoch", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// QueryServer is the server API for Query service.
-type QueryServer interface {
- // EpochInfos provide running epochInfos
- EpochInfos(context.Context, *QueryEpochsInfoRequest) (*QueryEpochsInfoResponse, error)
- // CurrentEpoch provide current epoch of specified identifier
- CurrentEpoch(context.Context, *QueryCurrentEpochRequest) (*QueryCurrentEpochResponse, error)
-}
-
-// UnimplementedQueryServer can be embedded to have forward compatible implementations.
-type UnimplementedQueryServer struct {
-}
-
-func (*UnimplementedQueryServer) EpochInfos(ctx context.Context, req *QueryEpochsInfoRequest) (*QueryEpochsInfoResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method EpochInfos not implemented")
-}
-func (*UnimplementedQueryServer) CurrentEpoch(ctx context.Context, req *QueryCurrentEpochRequest) (*QueryCurrentEpochResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method CurrentEpoch not implemented")
-}
-
-func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
- s.RegisterService(&_Query_serviceDesc, srv)
-}
-
-func _Query_EpochInfos_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryEpochsInfoRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).EpochInfos(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/neutron.epochs.Query/EpochInfos",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).EpochInfos(ctx, req.(*QueryEpochsInfoRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Query_CurrentEpoch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(QueryCurrentEpochRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(QueryServer).CurrentEpoch(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/neutron.epochs.Query/CurrentEpoch",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(QueryServer).CurrentEpoch(ctx, req.(*QueryCurrentEpochRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _Query_serviceDesc = grpc.ServiceDesc{
- ServiceName: "neutron.epochs.Query",
- HandlerType: (*QueryServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "EpochInfos",
- Handler: _Query_EpochInfos_Handler,
- },
- {
- MethodName: "CurrentEpoch",
- Handler: _Query_CurrentEpoch_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "neutron/epochs/query.proto",
-}
-
-func (m *QueryEpochsInfoRequest) 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 *QueryEpochsInfoRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryEpochsInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- return len(dAtA) - i, nil
-}
-
-func (m *QueryEpochsInfoResponse) 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 *QueryEpochsInfoResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryEpochsInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Epochs) > 0 {
- for iNdEx := len(m.Epochs) - 1; iNdEx >= 0; iNdEx-- {
- {
- size, err := m.Epochs[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 *QueryCurrentEpochRequest) 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 *QueryCurrentEpochRequest) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryCurrentEpochRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if len(m.Identifier) > 0 {
- i -= len(m.Identifier)
- copy(dAtA[i:], m.Identifier)
- i = encodeVarintQuery(dAtA, i, uint64(len(m.Identifier)))
- i--
- dAtA[i] = 0xa
- }
- return len(dAtA) - i, nil
-}
-
-func (m *QueryCurrentEpochResponse) 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 *QueryCurrentEpochResponse) MarshalTo(dAtA []byte) (int, error) {
- size := m.Size()
- return m.MarshalToSizedBuffer(dAtA[:size])
-}
-
-func (m *QueryCurrentEpochResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
- i := len(dAtA)
- _ = i
- var l int
- _ = l
- if m.CurrentEpoch != 0 {
- i = encodeVarintQuery(dAtA, i, uint64(m.CurrentEpoch))
- i--
- dAtA[i] = 0x8
- }
- 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 *QueryEpochsInfoRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- return n
-}
-
-func (m *QueryEpochsInfoResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if len(m.Epochs) > 0 {
- for _, e := range m.Epochs {
- l = e.Size()
- n += 1 + l + sovQuery(uint64(l))
- }
- }
- return n
-}
-
-func (m *QueryCurrentEpochRequest) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- l = len(m.Identifier)
- if l > 0 {
- n += 1 + l + sovQuery(uint64(l))
- }
- return n
-}
-
-func (m *QueryCurrentEpochResponse) Size() (n int) {
- if m == nil {
- return 0
- }
- var l int
- _ = l
- if m.CurrentEpoch != 0 {
- n += 1 + sovQuery(uint64(m.CurrentEpoch))
- }
- 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 *QueryEpochsInfoRequest) 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: QueryEpochsInfoRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryEpochsInfoRequest: 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 *QueryEpochsInfoResponse) 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: QueryEpochsInfoResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryEpochsInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Epochs", 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.Epochs = append(m.Epochs, EpochInfo{})
- if err := m.Epochs[len(m.Epochs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
- return err
- }
- iNdEx = postIndex
- default:
- iNdEx = preIndex
- skippy, err := skipQuery(dAtA[iNdEx:])
- if err != nil {
- return err
- }
- if (skippy < 0) || (iNdEx+skippy) < 0 {
- return ErrInvalidLengthQuery
- }
- if (iNdEx + skippy) > l {
- return io.ErrUnexpectedEOF
- }
- iNdEx += skippy
- }
- }
-
- if iNdEx > l {
- return io.ErrUnexpectedEOF
- }
- return nil
-}
-func (m *QueryCurrentEpochRequest) 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: QueryCurrentEpochRequest: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryCurrentEpochRequest: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 2 {
- return fmt.Errorf("proto: wrong wireType = %d for field Identifier", 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.Identifier = 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 *QueryCurrentEpochResponse) 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: QueryCurrentEpochResponse: wiretype end group for non-group")
- }
- if fieldNum <= 0 {
- return fmt.Errorf("proto: QueryCurrentEpochResponse: illegal tag %d (wire type %d)", fieldNum, wire)
- }
- switch fieldNum {
- case 1:
- if wireType != 0 {
- return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpoch", wireType)
- }
- m.CurrentEpoch = 0
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return ErrIntOverflowQuery
- }
- if iNdEx >= l {
- return io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- m.CurrentEpoch |= int64(b&0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- 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/epochs/types/query.pb.gw.go b/x/epochs/types/query.pb.gw.go
deleted file mode 100644
index 3b0d42301..000000000
--- a/x/epochs/types/query.pb.gw.go
+++ /dev/null
@@ -1,236 +0,0 @@
-// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
-// source: neutron/epochs/query.proto
-
-/*
-Package types is a reverse proxy.
-
-It translates gRPC into RESTful JSON APIs.
-*/
-package types
-
-import (
- "context"
- "io"
- "net/http"
-
- "github.com/golang/protobuf/descriptor"
- "github.com/golang/protobuf/proto"
- "github.com/grpc-ecosystem/grpc-gateway/runtime"
- "github.com/grpc-ecosystem/grpc-gateway/utilities"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/grpclog"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/status"
-)
-
-// Suppress "imported and not used" errors
-var _ codes.Code
-var _ io.Reader
-var _ status.Status
-var _ = runtime.String
-var _ = utilities.NewDoubleArray
-var _ = descriptor.ForMessage
-var _ = metadata.Join
-
-func request_Query_EpochInfos_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryEpochsInfoRequest
- var metadata runtime.ServerMetadata
-
- msg, err := client.EpochInfos(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_EpochInfos_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryEpochsInfoRequest
- var metadata runtime.ServerMetadata
-
- msg, err := server.EpochInfos(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-var (
- filter_Query_CurrentEpoch_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-)
-
-func request_Query_CurrentEpoch_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryCurrentEpochRequest
- 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_CurrentEpoch_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := client.CurrentEpoch(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-
-}
-
-func local_request_Query_CurrentEpoch_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var protoReq QueryCurrentEpochRequest
- 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_CurrentEpoch_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
-
- msg, err := server.CurrentEpoch(ctx, &protoReq)
- return msg, metadata, err
-
-}
-
-// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
-// UnaryRPC :call QueryServer directly.
-// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
-// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
-func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
-
- mux.Handle("GET", pattern_Query_EpochInfos_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_EpochInfos_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_EpochInfos_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_CurrentEpoch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_Query_CurrentEpoch_0(rctx, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- ctx = runtime.NewServerMetadataContext(ctx, md)
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
-
- forward_Query_CurrentEpoch_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_EpochInfos_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_EpochInfos_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_EpochInfos_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- mux.Handle("GET", pattern_Query_CurrentEpoch_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_CurrentEpoch_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_CurrentEpoch_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
-
- })
-
- return nil
-}
-
-var (
- pattern_Query_EpochInfos_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 1}, []string{"neutron", "epochs"}, "", runtime.AssumeColonVerbOpt(false)))
-
- pattern_Query_CurrentEpoch_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"neutron", "epochs", "current_epoch"}, "", runtime.AssumeColonVerbOpt(false)))
-)
-
-var (
- forward_Query_EpochInfos_0 = runtime.ForwardResponseMessage
-
- forward_Query_CurrentEpoch_0 = runtime.ForwardResponseMessage
-)
diff --git a/x/gmp/types.go b/x/gmp/types.go
index ed497174e..63c371ff6 100644
--- a/x/gmp/types.go
+++ b/x/gmp/types.go
@@ -1,7 +1,5 @@
package gmp
-const AxelarGMPAcc = "axelar1dv4u5k73pzqrxlzujxg3qp8kvc3pje7jtdvu72npnt5zhq05ejcsn5qme5"
-
// Message is attached in ICS20 packet memo field
type Message struct {
SourceChain string `json:"source_chain"`
diff --git a/x/incentives/README GAUGES.md b/x/incentives/README GAUGES.md
deleted file mode 100644
index c7bbd8f52..000000000
--- a/x/incentives/README GAUGES.md
+++ /dev/null
@@ -1,651 +0,0 @@
-# Incentives
-
-## Abstract
-
-Incentives module provides general interface to give yield to stakers.
-
-The yield to be given to stakers are stored in `gauge` and it is distributed on epoch basis to the stakers who meet specific conditions.
-
-Anyone can create gauge and add rewards to the gauge, there is no way to take it out other than distribution.
-
-There are two kinds of `gauges`, perpetual and non-perpetual ones.
-
-- Non perpetual ones get removed from active queue after the the distribution period finish but perpetual ones persist.
-- For non perpetual ones, they distribute the tokens equally per epoch during the `gauge` is in the active period.
-- For perpetual ones, it distribute all the tokens at a single time and somewhere else put the tokens regularly to distribute the tokens, it's mainly used to distribute minted OSMO tokens to LP token stakers.
-
-## Contents
-
-1. **[Concept](#concepts)**
-2. **[State](#state)**
-3. **[Messages](#messages)**
-4. **[Events](#events)**
-5. **[Hooks](#hooks)**
-6. **[Params](#parameters)**
-7. **[Transactions](#transactions)**
-8. **[Queries](#queries)**
-
-## Concepts
-
-The purpose of `incentives` module is to provide incentives to the users
-who stake specific token for specific period of time.
-
-Staked tokens can be of any denomination, including LP tokens (gamm/pool/x), IBC tokens (tokens sent through IBC such as ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2), and native tokens (such as ATOM or LUNA).
-
-The incentive amount is entered by the gauge creator. Rewards for a given pool of staked up tokens are pooled into a gauge until the disbursement time. At the disbursement time, they are distributed pro-rata (proportionally) to members of the pool.
-
-Anyone can create a gauge and add rewards to the gauge. There is no way to withdraw gauge rewards other than distribution. Governance proposals can be raised to match the external incentive tokens with equivalent Osmo incentives (see for example: [proposal 47](https://www.mintscan.io/osmosis/proposals/47)).
-
-There are two kinds of gauges: **`perpetual`** and **`non-perpetual`**:
-
-- **`Non-perpetual`** gauges distribute their tokens equally per epoch while the gauge is in the active period. These gauges get removed from the active queue after the distribution period finishes
-
-- **`Perpetual gauges`** distribute all their tokens at a single time and only distribute their tokens again once the gauge is refilled (this is mainly used to distribute minted OSMO tokens to LP token stakers). Perpetual gauges persist and will re-disburse tokens when refilled (there is no "active" period)
-
-## State
-
-### Incentives management
-
-All the incentives that are going to be provided are staked into
-`IncentivePool` until released to the appropriate recipients after a
-specific period of time.
-
-### Gauge
-
-Rewards to be distributed are organized by `Gauge`. The `Gauge`
-describes how users can get reward, stores the amount of coins in the
-gauge, the cadence at which rewards are to be distributed, and the
-number of epochs to distribute the reward over.
-
-```protobuf
-enum StakeQueryType {
- option (gogoproto.goproto_enum_prefix) = false;
-
- ByDuration = 0; // stakes which has more than specific duration
- ByTime = 1; // stakes which are started before specific time
-}
-
-message QueryCondition {
- StakeQueryType stake_query_type = 1; // type of stake, ByStakeDuration | ByStakeTime
- string denom = 2; // stake denom
- google.protobuf.Duration duration = 3; // condition for stake duration, only valid if positive
- google.protobuf.Timestamp timestamp = 4; // condition for stake start time, not valid if unset value
-}
-
-message Gauge {
- uint64 id = 1; // unique ID of a Gauge
- QueryCondition distribute_to = 2; // distribute condition of a stake which meet one of these conditions
- repeated cosmos.base.v1beta1.Coin coins = 3; // can distribute multiple coins
- google.protobuf.Timestamp start_time = 4; // condition for stake start time, not valid if unset value
- uint64 num_epochs_paid_over = 5; // number of epochs distribution will be done
-}
-```
-
-### Gauge queues
-
-#### Upcoming queue
-
-To start release `Gauges` at a specific time, we schedule distribution
-start time with time key queue.
-
-#### Active queue
-
-Active queue has all the `Gauges` that are distributing and after
-distribution period finish, it's removed from the queue.
-
-#### Active by Denom queue
-
-To speed up the distribution process, module introduces the active
-`Gauges` by denom.
-
-#### Finished queue
-
-Finished queue saves the `Gauges` that has finished distribution to keep
-in track.
-
-#### Module state
-
-The state of the module is expressed by `params`, `stakeable_durations`
-and `gauges`.
-
-```protobuf
-// GenesisState defines the incentives module's genesis state.
-message GenesisState {
- // params defines all the parameters of the module
- Params params = 1 [ (gogoproto.nullable) = false ];
- repeated Gauge gauges = 2 [ (gogoproto.nullable) = false ];
- repeated google.protobuf.Duration stakeable_durations = 3 [
- (gogoproto.nullable) = false,
- (gogoproto.stdduration) = true,
- (gogoproto.moretags) = "yaml:\"stakeable_durations\""
- ];
-}
-```
-
-## Messages
-
-### Create Gauge
-
-`MsgCreateGauge` can be submitted by any account to create a `Gauge`.
-
-```go
-type MsgCreateGauge struct {
- Owner sdk.AccAddress
- DistributeTo QueryCondition
- Rewards sdk.Coins
- StartTime time.Time // start time to start distribution
- NumEpochsPaidOver uint64 // number of epochs distribution will be done
-}
-```
-
-**State modifications:**
-
-- Validate `Owner` has enough tokens for rewards
-- Generate new `Gauge` record
-- Save the record inside the keeper's time basis unstake queue
-- Transfer the tokens from the `Owner` to incentives `ModuleAccount`.
-
-### Adding balance to Gauge
-
-`MsgAddToGauge` can be submitted by any account to add more incentives
-to a `Gauge`.
-
-```go
-type MsgAddToGauge struct {
- GaugeID uint64
- Rewards sdk.Coins
-}
-```
-
-**State modifications:**
-
-- Validate `Owner` has enough tokens for rewards
-- Check if `Gauge` with specified `msg.GaugeID` is available
-- Modify the `Gauge` record by adding `msg.Rewards`
-- Transfer the tokens from the `Owner` to incentives `ModuleAccount`.
-
-## Events
-
-The incentives module emits the following events:
-
-### Handlers
-
-#### MsgCreateGauge
-
-| Type | Attribute Key | Attribute Value |
-| ------------ | -------------------- | ------------------- |
-| create_gauge | gauge_id | {gaugeID} |
-| create_gauge | distribute_to | {owner} |
-| create_gauge | rewards | {rewards} |
-| create_gauge | start_time | {startTime} |
-| create_gauge | num_epochs_paid_over | {numEpochsPaidOver} |
-| message | action | create_gauge |
-| message | sender | {owner} |
-| transfer | recipient | {moduleAccount} |
-| transfer | sender | {owner} |
-| transfer | amount | {amount} |
-
-#### MsgAddToGauge
-
-| Type | Attribute Key | Attribute Value |
-| ------------ | ------------- | --------------- |
-| add_to_gauge | gauge_id | {gaugeID} |
-| create_gauge | rewards | {rewards} |
-| message | action | create_gauge |
-| message | sender | {owner} |
-| transfer | recipient | {moduleAccount} |
-| transfer | sender | {owner} |
-| transfer | amount | {amount} |
-
-### EndBlockers
-
-#### Incentives distribution
-
-| Type | Attribute Key | Attribute Value |
-| ------------ | ------------- | --------------- |
-| transfer\[\] | recipient | {receiver} |
-| transfer\[\] | sender | {moduleAccount} |
-| transfer\[\] | amount | {distrAmount} |
-
-## Hooks
-
-In this section we describe the "hooks" that `incentives` module provide
-for other modules.
-
-If there's no usecase for this, we could ignore this.
-
-```go
- AfterCreateGauge(ctx sdk.Context, gaugeId uint64)
- AfterAddToGauge(ctx sdk.Context, gaugeId uint64)
- AfterStartDistribution(ctx sdk.Context, gaugeId uint64)
- AfterFinishDistribution(ctx sdk.Context, gaugeId uint64)
- AfterDistribute(ctx sdk.Context, gaugeId uint64)
-```
-
-## Parameters
-
-The incentives module contains the following parameters:
-
-| Key | Type | Example |
-| -------------------- | ------ | -------- |
-| DistrEpochIdentifier | string | "weekly" |
-
-Note: DistrEpochIdentifier is a epoch identifier, and module distribute
-rewards at the end of epochs. As `epochs` module is handling multiple
-epochs, the identifier is required to check if distribution should be
-done at `AfterEpochEnd` hook
-
-
-
-
-## Transactions
-
-### create-gauge
-
-Create a gauge to distribute rewards to users
-
-```sh
-osmosisd tx incentives create-gauge [stake_denom] [reward] [flags]
-```
-
-::: details Example 1
-
-I want to make incentives for LP tokens of pool 3, namely gamm/pool/3 that have been staked up for at least 1 day.
-I want to reward 100 AKT to this pool over 2 days (2 epochs). (50 rewarded on each day)
-I want the rewards to start dispersing on 21 December 2021 (1640081402 UNIX time)
-
-```bash
-osmosisd tx incentives create-gauge gamm/pool/3 10000ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4 \
---duration 24h --start-time 1640081402 --epochs 2 --from WALLET_NAME --chain-id osmosis-1
-```
-
-:::
-
-::: details Example 2
-
-I want to make incentives for ATOM (ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2) that have been staked up for at least 1 week (164h).
-I want to reward 1000 JUNO (ibc/46B44899322F3CD854D2D46DEEF881958467CDD4B3B10086DA49296BBED94BED) to ATOM holders perpetually (perpetually meaning I must add more tokens to this gauge myself every epoch). I want the reward to start dispersing immediately.
-
-```bash
-osmosisd tx incentives create-gauge ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2 \
-1000000000ibc/46B44899322F3CD854D2D46DEEF881958467CDD4B3B10086DA49296BBED94BED --perpetual --duration 168h \
---from WALLET_NAME --chain-id osmosis-1
-```
-
-:::
-
-### add-to-gauge
-
-Add coins to a gauge previously created to distribute more rewards to users
-
-```sh
-osmosisd tx incentives add-to-gauge [gauge_id] [rewards] [flags]
-```
-
-::: details Example
-
-I want to refill the gauge with 500 JUNO to a previously created gauge (gauge ID 1914) after the distribution.
-
-```bash
-osmosisd tx incentives add-to-gauge 1914 500000000ibc/46B44899322F3CD854D2D46DEEF881958467CDD4B3B10086DA49296BBED94BED \
---from WALLET_NAME --chain-id osmosis-1
-```
-
-:::
-
-## Queries
-
-In this section we describe the queries required on grpc server.
-
-```protobuf
-// Query defines the gRPC QueryServer service.
-service Query {
- // returns coins that is going to be distributed
- rpc GetModuleCoinsToBeDistributed(GetModuleCoinsToBeDistributedRequest) returns (GetModuleCoinsToBeDistributedResponse) {}
- // returns Gauge by id
- rpc GetGaugeByID(GetGaugeByIDRequest) returns (GetGaugeByIDResponse) {}
- // returns gauges both upcoming and active
- rpc Gauges(GetGaugesActiveUpcomingRequest) returns (GetGaugesActiveUpcomingResponse) {}
- // returns active gauges
- rpc ActiveGauges(ActiveGetGaugesActiveUpcomingRequest) returns (ActiveGetGaugesActiveUpcomingResponse) {}
- // returns scheduled gauges
- rpc UpcomingGauges(UpcomingGetGaugesActiveUpcomingRequest) returns (UpcomingGetGaugesActiveUpcomingResponse) {}
- // RewardsEst returns an estimate of the rewards at a future specific time.
- // The QueryServer either provides an address or a set of stakes
- // for which they want to find the associated rewards.
- rpc RewardsEst(RewardsEstRequest) returns (RewardsEstResponse) {}
- // returns stakeable durations that are valid to give incentives
- rpc StakeableDurations(QueryStakeableDurationsRequest) returns (QueryStakeableDurationsResponse) {}
-}
-```
-
-### active-gauges
-
-Query active gauges
-
-```sh
-osmosisd query incentives active-gauges [flags]
-```
-
-::: details Example
-
-```bash
-osmosisd query incentives active-gauges
-```
-
-An example output
-
-```sh
-- coins: []
- distribute_to:
- denom: gamm/pool/99
- duration: 604800s
- stake_query_type: ByDuration
- timestamp: "0001-01-01T00:00:00Z"
- distributed_coins: []
- filled_epochs: "0"
- id: "297"
- is_perpetual: true
- num_epochs_paid_over: "1"
- start_time: "2021-07-03T12:27:09.323840990Z"
-- coins: []
- distribute_to:
- denom: gamm/pool/99
- duration: 1209600s
- stake_query_type: ByDuration
- timestamp: "0001-01-01T00:00:00Z"
- distributed_coins: []
- filled_epochs: "0"
- id: "298"
- is_perpetual: true
- num_epochs_paid_over: "1"
- start_time: "2021-07-03T12:27:09.323840990Z"
-pagination:
- next_key: BwEAAAAAAAAAHTIwMjEtMDctMDNUMTI6Mjc6MDkuMzIzODQwOTkw
- total: "0"
-...
-```
-
-:::
-
-### active-gauges-per-denom
-
-Query active gauges per denom
-
-```sh
-osmosisd query incentives active-gauges-per-denom [denom] [flags]
-```
-
-::: details Example
-
-Query all active gauges distributing incentives to holders of gamm/pool/341
-
-```bash
-osmosisd query incentives active-gauges-per-denom gamm/pool/341
-```
-
-An example output:
-
-```sh
-- coins: []
- distribute_to:
- denom: gamm/pool/341
- duration: 604800s
- stake_query_type: ByDuration
- timestamp: "0001-01-01T00:00:00Z"
- distributed_coins: []
- filled_epochs: "0"
- id: "1033"
- is_perpetual: true
- num_epochs_paid_over: "1"
- start_time: "2021-09-06T22:42:52.139465318Z"
-- coins: []
- distribute_to:
- denom: gamm/pool/341
- duration: 1209600s
- stake_query_type: ByDuration
- timestamp: "0001-01-01T00:00:00Z"
- distributed_coins: []
- filled_epochs: "0"
- id: "1034"
- is_perpetual: true
- num_epochs_paid_over: "1"
- start_time: "2021-09-06T22:42:52.139465318Z"
-pagination:
- next_key: BwEAAAAAAAAAHTIwMjEtMDctMDNUMTI6Mjc6MDkuMzIzODQwOTkw
- total: "0"
-...
-```
-
-:::
-
-### distributed-coins
-
-Query coins distributed so far
-
-```sh
-osmosisd query incentives distributed-coins [flags]
-```
-
-::: details Example
-
-```bash
-osmosisd query incentives distributed-coins
-```
-
-An example output:
-
-```sh
-coins:
-- amount: "27632051924"
- denom: ibc/0954E1C28EB7AF5B72D24F3BC2B47BBB2FDF91BDDFD57B74B99E133AED40972A
-- amount: "3975960654"
- denom: ibc/0EF15DF2F02480ADE0BB6E85D9EBB5DAEA2836D3860E9F97F9AADE4F57A31AA0
-- amount: "125999980901"
- denom: ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4
-- amount: "434999992789"
- denom: ibc/1DC495FCEFDA068A3820F903EDBD78B942FBD204D7E93D3BA2B432E9669D1A59
-- amount: "3001296"
- denom: ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2
-- amount: "1493887986685"
- denom: ibc/3BCCC93AD5DF58D11A6F8A05FA8BC801CBA0BA61A981F57E91B8B598BF8061CB
-- amount: "372218215714"
- denom: ibc/46B44899322F3CD854D2D46DEEF881958467CDD4B3B10086DA49296BBED94BED
-- amount: "1049999973206"
- denom: ibc/4E5444C35610CC76FC94E7F7886B93121175C28262DDFDDE6F84E82BF2425452
-- amount: "11666666665116"
- denom: ibc/7A08C6F11EF0F59EB841B9F788A87EC9F2361C7D9703157EC13D940DC53031FA
-- amount: "13199999715662"
- denom: ibc/9712DBB13B9631EDFA9BF61B55F1B2D290B2ADB67E3A4EB3A875F3B6081B3B84
-- amount: "1177777428443"
- denom: ibc/D805F1DA50D31B96E4282C1D4181EDDFB1A44A598BFF5666F4B43E4B8BEA95A5
-- amount: "466666567747"
- denom: ibc/EA3E1640F9B1532AB129A571203A0B9F789A7F14BB66E350DCBFA18E1A1931F0
-- amount: "79999999178"
- denom: ibc/F3FF7A84A73B62921538642F9797C423D2B4C4ACB3C7FCFFCE7F12AA69909C4B
-- amount: "65873607694598"
- denom: uosmo
-```
-
-:::
-
-### gauge-by-id
-
-Query gauge by id
-
-```sh
-osmosisd query incentives gauge-by-id [id] [flags]
-```
-
-::: details Example
-
-Query the incentive distribution for gauge ID 1:
-
-```sh
-osmosisd query incentives gauge-by-id 1
-```
-
-```bash
-gauge:
- coins:
- - amount: "16654747773959"
- denom: uosmo
- distribute_to:
- denom: gamm/pool/1
- duration: 86400s
- stake_query_type: ByDuration
- timestamp: "0001-01-01T00:00:00Z"
- distributed_coins:
- - amount: "16589795315655"
- denom: uosmo
- filled_epochs: "182"
- id: "1"
- is_perpetual: true
- num_epochs_paid_over: "1"
- start_time: "2021-06-19T04:30:19.082462364Z"
-```
-
-:::
-
-### gauges
-
-Query available gauges
-
-```sh
-osmosisd query incentives gauges [flags]
-```
-
-::: details Example
-
-Query ALL gauges (by default the limit is 100, so here I will define a much larger number to output all gauges)
-
-```bash
-osmosisd query incentives gauges --limit 2000
-```
-
-An example output:
-
-```sh
-- coins:
- - amount: "1924196414964"
- denom: uosmo
- distribute_to:
- denom: gamm/pool/348
- duration: 604800s
- stake_query_type: ByDuration
- timestamp: "0001-01-01T00:00:00Z"
- distributed_coins: []
- filled_epochs: "0"
- id: "8"
- is_perpetual: true
- num_epochs_paid_over: "1"
- start_time: "2021-10-04T13:59:02.142175968Z"
-- coins:
- - amount: "641398804181"
- denom: uosmo
- distribute_to:
- denom: gamm/pool/348
- duration: 1209600s
- stake_query_type: ByDuration
- timestamp: "0001-01-01T00:00:00Z"
- distributed_coins: []
- filled_epochs: "0"
- id: "9"
- is_perpetual: true
- num_epochs_paid_over: "1"
- start_time: "2021-10-04T13:59:02.142175968Z"
-pagination:
- next_key: null
- total: "0"
-...
-```
-
-:::
-
-### rewards-estimation
-
-Query rewards estimation
-
-// Error: strconv.ParseUint: parsing "": invalid syntax
-
-### to-distribute-coins
-
-Query coins that is going to be distributed
-
-```sh
-osmosisd query incentives to-distribute-coins [flags]
-```
-
-::: details Example
-
-```bash
-osmosisd query incentives to-distribute-coins
-```
-
-An example output:
-
-```sh
-coins:
-- amount: "20000000"
- denom: gamm/pool/87
-- amount: "90791948076"
- denom: ibc/0954E1C28EB7AF5B72D24F3BC2B47BBB2FDF91BDDFD57B74B99E133AED40972A
-- amount: "10000"
- denom: ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4
-- amount: "1000"
- denom: ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2
-- amount: "10728832013315"
- denom: ibc/3BCCC93AD5DF58D11A6F8A05FA8BC801CBA0BA61A981F57E91B8B598BF8061CB
-- amount: "627782783496"
- denom: ibc/46B44899322F3CD854D2D46DEEF881958467CDD4B3B10086DA49296BBED94BED
-- amount: "450000026794"
- denom: ibc/4E5444C35610CC76FC94E7F7886B93121175C28262DDFDDE6F84E82BF2425452
-- amount: "38333333334884"
- denom: ibc/7A08C6F11EF0F59EB841B9F788A87EC9F2361C7D9703157EC13D940DC53031FA
-- amount: "46800000284338"
- denom: ibc/9712DBB13B9631EDFA9BF61B55F1B2D290B2ADB67E3A4EB3A875F3B6081B3B84
-- amount: "2822222571557"
- denom: ibc/D805F1DA50D31B96E4282C1D4181EDDFB1A44A598BFF5666F4B43E4B8BEA95A5
-- amount: "2533333432253"
- denom: ibc/EA3E1640F9B1532AB129A571203A0B9F789A7F14BB66E350DCBFA18E1A1931F0
-- amount: "366164843847"
- denom: uosmo
-```
-
-:::
-
-### upcoming-gauges
-
-Query scheduled gauges (gauges whose `start_time` has not yet occurred)
-
-```sh
-osmosisd query incentives upcoming-gauges [flags]
-```
-
-::: details Example
-
-```bash
-osmosisd query incentives upcoming-gauges
-```
-
-Using this command, we will see the gauge we created earlier, among all other upcoming gauges:
-
-```sh
-- coins:
- - amount: "10000"
- denom: ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4
- distribute_to:
- denom: gamm/pool/3
- duration: 86400s
- stake_query_type: ByDuration
- timestamp: "1970-01-01T00:00:00Z"
- distributed_coins: []
- filled_epochs: "0"
- id: "1914"
- is_perpetual: false
- num_epochs_paid_over: "2"
- start_time: "2021-12-21T10:10:02Z"
-...
-```
-
-:::
diff --git a/x/incentives/README LOCKUP.md b/x/incentives/README LOCKUP.md
deleted file mode 100644
index 43cd1fb39..000000000
--- a/x/incentives/README LOCKUP.md
+++ /dev/null
@@ -1,1054 +0,0 @@
-# Stakeup
-
-## Abstract
-
-Stakeup module provides an interface for users to stake tokens (also known as bonding) into the module to get incentives.
-
-After tokens have been added to a specific pool and turned into LP shares through the GAMM module, users can then stake these LP shares with a specific duration in order to begin earing rewards.
-
-To unstake these LP shares, users must trigger the unstake timer and wait for the unstake period that was set initially to be completed. After the unstake period is over, users can turn LP shares back into their respective share of tokens.
-
-This module provides interfaces for other modules to iterate the stakes efficiently and grpc query to check the status of staked coins.
-
-## Contents
-
-1. **[Concept](#concepts)**
-2. **[State](#state)**
-3. **[Messages](#messages)**
-4. **[Events](#events)**
-5. **[Keeper](#keeper)**
-6. **[Hooks](#hooks)**
-7. **[Queries](#queries)**
-8. **[Transactions](#transactions)**
-9. **[Params](#params)**
-10. **[Endbstakeer](#endbstakeer)**
-
-## Concepts
-
-The purpose of `stakeup` module is to provide the functionality to stake
-tokens for specific period of time for LP token stakers to get
-incentives.
-
-To unstake these LP shares, users must trigger the unstake timer and wait for the unstake period that was set initially to be completed. After the unstake period is over, users can turn LP shares back into their respective share of tokens.
-
-This module provides interfaces for other modules to iterate the stakes efficiently and grpc query to check the status of staked coins.
-
-There are currently three incentivize stakeup periods; `1 day` (24h), `1 week` (168h), and `2 weeks` (336h). When staking tokens in the 2 week period, the liquidity provider is effectively earning rewards for a combination of the 1 day, 1 week, and 2 week bonding periods.
-
-The 2 week period refers to how long it takes to unbond the LP shares. The liquidity provider can keep their LP shares bonded to the 2 week stakeup period indefinitely. Unbonding is only required when the liquidity provider desires access to the underlying assets.
-
-If the liquidity provider begins the unbonding process for their 2 week bonded LP shares, they will earn rewards for all three bonding periods during the first day of unbonding.
-
-After the first day passes, they will only receive rewards for the 1 day and 1 week stakeup periods. After seven days pass, they will only receive the 1 day rewards until the 2 weeks is complete and their LP shares are unstaked. The below chart is a visual example of what was just explained.
-
-
-
- -
- - - - -## State - -### Staked coins management - -Staked coins are all stored in module account for `stakeup` module which -is called `StakePool`. When user stake coins within `stakeup` module, it's -moved from user account to `StakePool` and a record (`PeriodStake` struct) -is created. - -Once the period is over, user can withdraw it at anytime from -`StakePool`. User can withdraw by PeriodStake ID or withdraw all -`UnstakeableCoins` at a time. - -### Period Stake - -A `PeriodStake` is a single unit of stake by period. It's a record of -staked coin at a specific time. It stores owner, duration, unstake time -and the amount of coins staked. - -``` {.go} -type PeriodStake struct { - ID uint64 - Owner sdk.AccAddress - Duration time.Duration - UnstakeTime time.Time - Coins sdk.Coins -} -``` - -All stakes are stored on the KVStore as value at -`{KeyPrefixPeriodStake}{ID}` key. - -### Period stake reference queues - -To provide time efficient queries, several reference queues are managed -by denom, unstake time, and duration. There are two big queues to store -the stake references. (`a_prefix_key`) - -1. Stake references that hasn't started with unstaking yet has prefix of - `KeyPrefixNotUnstaking`. -2. Stake references that has started unstaking already has prefix of - `KeyPrefixUnstaking`. -3. Stake references that has withdrawn, it's removed from the store. - -Regardless the stake has started unstaking or not, it stores below -references. (`b_prefix_key`) - -1. `{KeyPrefixStakeDuration}{Duration}` -2. `{KeyPrefixAccountStakeDuration}{Owner}{Duration}` -3. `{KeyPrefixDenomStakeDuration}{Denom}{Duration}` -4. `{KeyPrefixAccountDenomStakeDuration}{Owner}{Denom}{Duration}` - -If the stake is unstaking, it also stores the below references. - -1. `{KeyPrefixStakeTimestamp}{StakeEndTime}` -2. `{KeyPrefixAccountStakeTimestamp}{Owner}{StakeEndTime}` -3. `{KeyPrefixDenomStakeTimestamp}{Denom}{StakeEndTime}` -4. `{KeyPrefixAccountDenomStakeTimestamp}{Owner}{Denom}{StakeEndTime}` - -For end time keys, they are converted to sortable string by using -`sdk.FormatTimeBytes` function. - -**Note:** Additionally, for stakes that hasn't started unstaking yet, it -stores accumulation store for efficient rewards distribution mechanism. - -For reference management, `addStakeRefByKey` function is used a lot. Here -key is the prefix key to be used for iteration. It is combination of two -prefix keys.(`{a_prefix_key}{b_prefix_key}`) - -``` {.go} -// addStakeRefByKey make a stakeID iterable with the prefix `key` -func (k Keeper) addStakeRefByKey(ctx sdk.Context, key []byte, stakeID uint64) error { - store := ctx.KVStore(k.storeKey) - stakeIDBz := sdk.Uint64ToBigEndian(stakeID) - endKey := combineKeys(key, stakeIDBz) - if store.Has(endKey) { - return fmt.Errorf("stake with same ID exist: %d", stakeID) - } - store.Set(endKey, stakeIDBz) - return nil -} -``` - -## Messages - -### Stake Tokens - -`MsgStake` can be submitted by any token holder via a -`MsgStake` transaction. - -``` {.go} -type MsgStake struct { - Owner sdk.AccAddress - Duration time.Duration - Coins sdk.Coins -} -``` - -**State modifications:** - -- Validate `Owner` has enough tokens -- Generate new `PeriodStake` record -- Save the record inside the keeper's time basis unstake queue -- Transfer the tokens from the `Owner` to stakeup `ModuleAccount`. - -### Begin Unstake of all stakes - -Once time is over, users can withdraw unstaked coins from stakeup -`ModuleAccount`. - -``` {.go} -type MsgBeginUnstakingAll struct { - Owner string -} -``` - -**State modifications:** - -- Fetch all unstakeable `PeriodStake`s that has not started unstaking - yet -- Set `PeriodStake`'s unstake time -- Remove stake references from `NotUnstaking` queue -- Add stake references to `Unstaking` queue - -### Begin unstake for a stake - -Once time is over, users can withdraw unstaked coins from stakeup -`ModuleAccount`. - -``` {.go} -type MsgUnstake struct { - Owner string - ID uint64 -} -``` - -**State modifications:** - -- Check `PeriodStake` with `ID` specified by `MsgUnstake` is not - started unstaking yet -- Set `PeriodStake`'s unstake time -- Remove stake references from `NotUnstaking` queue -- Add stake references to `Unstaking` queue - -Note: If another module needs past `PeriodStake` item, it can log the -details themselves using the hooks. - -## Events - -The stakeup module emits the following events: - -### Handlers - -#### MsgStake - -| Type | Attribute Key | Attribute Value | -| --------------| ------------------| -----------------| -| stake\_tokens | period\_stake\_id | {periodStakeID} | -| stake\_tokens | owner | {owner} | -| stake\_tokens | amount | {amount} | -| stake\_tokens | duration | {duration} | -| stake\_tokens | unstake\_time | {unstakeTime} | -| message | action | stake\_tokens | -| message | sender | {owner} | -| transfer | recipient | {moduleAccount} | -| transfer | sender | {owner} | -| transfer | amount | {amount} | - -#### MsgUnstake - -| Type | Attribute Key | Attribute Value | -| ---------------| ------------------| ------------------| -| begin\_unstake | period\_stake\_id | {periodStakeID} | -| begin\_unstake | owner | {owner} | -| begin\_unstake | amount | {amount} | -| begin\_unstake | duration | {duration} | -| begin\_unstake | unstake\_time | {unstakeTime} | -| message | action | begin\_unstaking | -| message | sender | {owner} | - -#### MsgBeginUnstakingAll - -| Type | Attribute Key | Attribute Value | -| --------------------| ------------------| -----------------------| -| begin\_unstake\_all | owner | {owner} | -| begin\_unstake\_all | unstaked\_coins | {unstakedCoins} | -| begin\_unstake | period\_stake\_id | {periodStakeID} | -| begin\_unstake | owner | {owner} | -| begin\_unstake | amount | {amount} | -| begin\_unstake | duration | {duration} | -| begin\_unstake | unstake\_time | {unstakeTime} | -| message | action | begin\_unstaking\_all | -| message | sender | {owner} | - -### Endbstakeer - -#### Automatic withdraw when unstake time mature - -| Type | Attribute Key | Attribute Value | -| ----------------| ------------------| -----------------| -| message | action | unstake\_tokens | -| message | sender | {owner} | -| transfer\[\] | recipient | {owner} | -| transfer\[\] | sender | {moduleAccount} | -| transfer\[\] | amount | {unstakeAmount} | -| unstake\[\] | period\_stake\_id | {owner} | -| unstake\[\] | owner | {stakeID} | -| unstake\[\] | duration | {stakeDuration} | -| unstake\[\] | unstake\_time | {unstakeTime} | -| unstake\_tokens | owner | {owner} | -| unstake\_tokens | unstaked\_coins | {totalAmount} | - -## Keepers - -### Stakeup Keeper - -Stakeup keeper provides utility functions to store stake queues and query -stakes. - -```go -// Keeper is the interface for stakeup module keeper -type Keeper interface { - // GetModuleBalance Returns full balance of the module - GetModuleBalance(sdk.Context) sdk.Coins - // GetModuleStakedCoins Returns staked balance of the module - GetModuleStakedCoins(sdk.Context) sdk.Coins - // GetAccountUnstakeableCoins Returns whole unstakeable coins which are not withdrawn yet - GetAccountUnstakeableCoins(sdk.Context, addr sdk.AccAddress) sdk.Coins - // GetAccountUnstakingCoins Returns whole unstaking coins - GetAccountUnstakingCoins(sdk.Context, addr sdk.AccAddress) sdk.Coins - // GetAccountStakedCoins Returns a staked coins that can't be withdrawn - GetAccountStakedCoins(sdk.Context, addr sdk.AccAddress) sdk.Coins - // GetAccountStakedPastTime Returns the total stakes of an account whose unstake time is beyond timestamp - GetAccountStakedPastTime(sdk.Context, addr sdk.AccAddress, timestamp time.Time) []types.PeriodStake - // GetAccountUnstakedBeforeTime Returns the total unstakes of an account whose unstake time is before timestamp - GetAccountUnstakedBeforeTime(sdk.Context, addr sdk.AccAddress, timestamp time.Time) []types.PeriodStake - // GetAccountStakedPastTimeDenom is equal to GetAccountStakedPastTime but denom specific - GetAccountStakedPastTimeDenom(ctx sdk.Context, addr sdk.AccAddress, denom string, timestamp time.Time) []types.PeriodStake - - // GetAccountStakedLongerDuration Returns account staked with duration longer than specified - GetAccountStakedLongerDuration(sdk.Context, addr sdk.AccAddress, duration time.Duration) []types.PeriodStake - // GetAccountStakedLongerDurationDenom Returns account staked with duration longer than specified with specific denom - GetAccountStakedLongerDurationDenom(sdk.Context, addr sdk.AccAddress, denom string, duration time.Duration) []types.PeriodStake - // GetStakesPastTimeDenom Returns the stakes whose unstake time is beyond timestamp - GetStakesPastTimeDenom(ctx sdk.Context, addr sdk.AccAddress, denom string, timestamp time.Time) []types.PeriodStake - // GetStakesLongerThanDurationDenom Returns the stakes whose unstake duration is longer than duration - GetStakesLongerThanDurationDenom(ctx sdk.Context, addr sdk.AccAddress, denom string, duration time.Duration) []types.PeriodStake - // GetStakeByID Returns stake from stakeID - GetStakeByID(sdk.Context, stakeID uint64) (*types.PeriodStake, error) - // GetPeriodStakes Returns the period stakes on pool - GetPeriodStakes(sdk.Context) ([]types.PeriodStake, error) - // UnstakeAllUnstakeableCoins Unstake all unstakeable coins - UnstakeAllUnstakeableCoins(sdk.Context, account sdk.AccAddress) (sdk.Coins, error) - // StakeTokens stake tokens from an account for specified duration - StakeTokens(sdk.Context, owner sdk.AccAddress, coins sdk.Coins, duration time.Duration) (types.PeriodStake, error) - // AddTokensToStake stakes more tokens into a stakeup - AddTokensToStake(ctx sdk.Context, owner sdk.AccAddress, stakeID uint64, coins sdk.Coins) (*types.PeriodStake, error) - // Stake is a utility to stake coins into module account - Stake(sdk.Context, stake types.PeriodStake) error - // Unstake is a utility to unstake coins from module account - Unstake(sdk.Context, stake types.PeriodStake) error -``` - -## Hooks - -In this section we describe the "hooks" that `stakeup` module provide for -other modules. - -### Tokens Staked - -On stake/unstake events, stakeup module execute hooks for other modules to -make following actions. - -``` go - OnTokenStaked(ctx sdk.Context, address sdk.AccAddress, stakeID uint64, amount sdk.Coins, stakeDuration time.Duration, unstakeTime time.Time) - OnTokenUnstaked(ctx sdk.Context, address sdk.AccAddress, stakeID uint64, amount sdk.Coins, stakeDuration time.Duration, unstakeTime time.Time) -``` - -## Parameters - -The stakeup module contains the following parameters: - -| Key | Type | Example | -| ---------------------- | --------------- | ------- | - -Note: Currently no parameters are set for `stakeup` module, we will need -to move stakeable durations from incentives module to stakeup module. - -## Endbstakeer - -### Withdraw tokens after unstake time mature - -Once time is over, endbstakeer withdraw coins from matured stakes and -coins are sent from stakeup `ModuleAccount`. - -**State modifications:** - -- Fetch all unstakeable `PeriodStake`s that `Owner` has not withdrawn - yet -- Remove `PeriodStake` records from the state -- Transfer the tokens from stakeup `ModuleAccount` to the - `MsgUnstakeTokens.Owner`. - -### Remove synthetic stakes after removal time mature - -For synthetic stakes, no coin movement is made, but stakeup record and -reference queues are removed. - - -## Transactions - -### stake-tokens - -Bond tokens in a LP for a set duration - -```sh -neutrond tx stakeup stake-tokens [tokens] --duration --from --chain-id -``` - -::: details Example - -To stakeup `15.527546134174465309gamm/pool/3` tokens for a `one day` bonding period from `WALLET_NAME` on the osmosis mainnet: - -```bash -neutrond tx stakeup stake-tokens 15527546134174465309gamm/pool/3 --duration="24h" --from WALLET_NAME --chain-id osmosis-1 -``` - -To stakeup `25.527546134174465309gamm/pool/13` tokens for a `one week` bonding period from `WALLET_NAME` on the osmosis testnet: - -```bash -neutrond tx stakeup stake-tokens 25527546134174465309gamm/pool/13 --duration="168h" --from WALLET_NAME --chain-id osmo-test-4 -``` - -To stakeup `35.527546134174465309 gamm/pool/197` tokens for a `two week` bonding period from `WALLET_NAME` on the osmosis mainnet: - -```bash -neutrond tx stakeup stake-tokens 35527546134174465309gamm/pool/197 --duration="336h" --from WALLET_NAME --chain-id osmosis-1 -``` -::: - - -### begin-unstake-by-id - -Begin the unbonding process for tokens given their unique stake ID - -```sh -neutrond tx stakeup begin-unstake-by-id [id] --from --chain-id -``` - -::: details Example - -To begin the unbonding time for all bonded tokens under id `75` from `WALLET_NAME` on the osmosis mainnet: - -```bash -neutrond tx stakeup begin-unstake-by-id 75 --from WALLET_NAME --chain-id osmosis-1 -``` -::: -::: warning Note -The ID corresponds to the unique ID given to your stakeup transaction (explained more in stake-by-id section) -::: - -### begin-unstake-tokens - -Begin unbonding process for all bonded tokens in a wallet - -```sh -neutrond tx stakeup begin-unstake-tokens --from --chain-id -``` - -::: details Example - -To begin unbonding time for ALL pools and ALL bonded tokens in `WALLET_NAME` on the osmosis mainnet: - - -```bash -neutrond tx stakeup begin-unstake-tokens --from=WALLET_NAME --chain-id=osmosis-1 --yes -``` -::: - -## Queries - -In this section we describe the queries required on grpc server. - -``` protobuf -// Query defines the gRPC QueryServer service. -service Query { - // Return full balance of the module - rpc ModuleBalance(ModuleBalanceRequest) returns (ModuleBalanceResponse); - // Return staked balance of the module - rpc ModuleStakedAmount(ModuleStakedAmountRequest) returns (ModuleStakedAmountResponse); - - // Returns unstakeable coins which are not withdrawn yet - rpc AccountUnstakeableCoins(AccountUnstakeableCoinsRequest) returns (AccountUnstakeableCoinsResponse); - // Returns unstaking coins - rpc AccountUnstakingCoins(AccountUnstakingCoinsRequest) returns (AccountUnstakingCoinsResponse) {} - // Return a staked coins that can't be withdrawn - rpc AccountStakedCoins(AccountStakedCoinsRequest) returns (AccountStakedCoinsResponse); - - // Returns staked records of an account with unstake time beyond timestamp - rpc AccountStakedPastTime(AccountStakedPastTimeRequest) returns (AccountStakedPastTimeResponse); - // Returns staked records of an account with unstake time beyond timestamp excluding tokens started unstaking - rpc AccountStakedPastTimeNotUnstakingOnly(AccountStakedPastTimeNotUnstakingOnlyRequest) returns (AccountStakedPastTimeNotUnstakingOnlyResponse) {} - // Returns unstaked records with unstake time before timestamp - rpc AccountUnstakedBeforeTime(AccountUnstakedBeforeTimeRequest) returns (AccountUnstakedBeforeTimeResponse); - - // Returns stake records by address, timestamp, denom - rpc AccountStakedPastTimeDenom(AccountStakedPastTimeDenomRequest) returns (AccountStakedPastTimeDenomResponse); - // Returns stake record by id - rpc StakedByID(StakedRequest) returns (StakedResponse); - - // Returns account staked records with longer duration - rpc AccountStakedLongerDuration(AccountStakedLongerDurationRequest) returns (AccountStakedLongerDurationResponse); - // Returns account staked records with longer duration excluding tokens started unstaking - rpc AccountStakedLongerDurationNotUnstakingOnly(AccountStakedLongerDurationNotUnstakingOnlyRequest) returns (AccountStakedLongerDurationNotUnstakingOnlyResponse) {} - // Returns account's staked records for a denom with longer duration - rpc AccountStakedLongerDurationDenom(AccountStakedLongerDurationDenomRequest) returns (AccountStakedLongerDurationDenomResponse); - - // Returns account staked records with a specific duration - rpc AccountStakedDuration(AccountStakedDurationRequest) returns (AccountStakedDurationResponse); -} -``` - -### account-staked-beforetime - -Query an account's unstaked records after a specified time (UNIX) has passed - -In other words, if an account unstaked all their bonded tokens the moment the query was executed, only the stakes that would have completed their bond time requirement by the time the `TIMESTAMP` is reached will be returned. - -::: details Example - -In this example, the current UNIX time is `1639776682`, 2 days from now is approx `1639971082`, and 15 days from now is approx `1641094282`. - -An account's `ADDRESS` is staked in both the `1 day` and `1 week` gamm/pool/3. To query the `ADDRESS` with a timestamp 2 days from now `1639971082`: - -```bash -neutrond query stakeup account-staked-beforetime ADDRESS 1639971082 -``` - -In this example will output the `1 day` stake but not the `1 week` stake: - -```bash -stakes: -- ID: "571839" - coins: - - amount: "15527546134174465309" - denom: gamm/pool/3 - duration: 24h - end_time: "2021-12-18T23:32:58.900715388Z" - owner: osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 -``` - -If querying the same `ADDRESS` with a timestamp 15 days from now `1641094282`: - -```bash -neutrond query stakeup account-staked-beforetime ADDRESS 1641094282 -``` - -In this example will output both the `1 day` and `1 week` stake: - -```bash -stakes: -- ID: "572027" - coins: - - amount: "16120691802759484268" - denom: gamm/pool/3 - duration: 604800.000006193s - end_time: "0001-01-01T00:00:00Z" - owner: osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 -- ID: "571839" - coins: - - amount: "15527546134174465309" - denom: gamm/pool/3 - duration: 24h - end_time: "2021-12-18T23:32:58.900715388Z" - owner: osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 -``` -::: - - -### account-staked-coins - -Query an account's staked (bonded) LP tokens - -```sh -neutrond query stakeup account-staked-coins [address] -``` - -:::: details Example - -```bash -neutrond query stakeup account-staked-coins osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 -``` - -An example output: - -```bash -coins: -- amount: "413553955105681228583" - denom: gamm/pool/1 -- amount: "32155370994266157441309" - denom: gamm/pool/10 -- amount: "220957857520769912023" - denom: gamm/pool/3 -- amount: "31648237936933949577" - denom: gamm/pool/42 -- amount: "14162624050980051053569" - denom: gamm/pool/5 -- amount: "1023186951315714985896914" - denom: gamm/pool/9 -``` -::: warning Note -All GAMM amounts listed are 10^18. Move the decimal place to the left 18 places to get the GAMM amount listed in the GUI. - -You may also specify a --height flag to see bonded LP tokens at a specified height (note: if running a pruned node, this may result in an error) -::: -:::: - -### account-staked-longer-duration - -Query an account's staked records that are greater than or equal to a specified stake duration - -```sh -neutrond query stakeup account-staked-longer-duration [address] [duration] -``` - -::: details Example - -Here is an example of querying an `ADDRESS` for all `1 day` or greater bonding periods: - -```bash -neutrond query stakeup account-staked-longer-duration osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 24h -``` - -An example output: - -```bash -stakes: -- ID: "572027" - coins: - - amount: "16120691802759484268" - denom: gamm/pool/3 - duration: 604800.000006193s - end_time: "0001-01-01T00:00:00Z" - owner: osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 -- ID: "571839" - coins: - - amount: "15527546134174465309" - denom: gamm/pool/3 - duration: 24h - end_time: "2021-12-18T23:32:58.900715388Z" - owner: osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 -``` -::: - - -### account-staked-longer-duration-denom - -Query an account's staked records for a denom that is staked equal to or greater than the specified duration AND match a specified denom - -```sh -neutrond query stakeup account-staked-longer-duration-denom [address] [duration] [denom] -``` - -::: details Example - -Here is an example of an `ADDRESS` that is staked in both the `1 day` and `1 week` for both the gamm/pool/3 and gamm/pool/1, then queries the `ADDRESS` for all bonding periods equal to or greater than `1 day` for just the gamm/pool/3: - -```bash -neutrond query stakeup account-staked-longer-duration-denom osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 24h gamm/pool/3 -``` - -An example output: - -```bash -stakes: -- ID: "571839" - coins: - - amount: "15527546134174465309" - denom: gamm/pool/3 - duration: 24h - end_time: "0001-01-01T00:00:00Z" - owner: osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 -- ID: "572027" - coins: - - amount: "16120691802759484268" - denom: gamm/pool/3 - duration: 604800.000006193s - end_time: "0001-01-01T00:00:00Z" - owner: osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 -``` - -As shown, the gamm/pool/3 is returned but not the gamm/pool/1 due to the denom filter. -::: - - -### account-staked-longer-duration-not-unstaking - -Query an account's staked records for a denom that is staked equal to or greater than the specified duration AND is not in the process of being unstaked - -```sh -neutrond query stakeup account-staked-longer-duration-not-unstaking [address] [duration] -``` - -::: details Example - -Here is an example of an `ADDRESS` that is staked in both the `1 day` and `1 week` gamm/pool/3, begins unstaking process for the `1 day` bond, and queries the `ADDRESS` for all bonding periods equal to or greater than `1 day` that are not unbonding: - -```bash -neutrond query stakeup account-staked-longer-duration-not-unstaking osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 24h -``` - -An example output: - -```bash -stakes: -- ID: "571839" - coins: - - amount: "16120691802759484268" - denom: gamm/pool/3 - duration: 604800.000006193s - end_time: "0001-01-01T00:00:00Z" - owner: osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 -``` - -The `1 day` bond does not show since it is in the process of unbonding. -::: - - -### account-staked-pasttime - -Query the staked records of an account with the unstake time beyond timestamp (UNIX) - -```bash -neutrond query stakeup account-staked-pasttime [address] [timestamp] -``` - -::: details Example - -Here is an example of an account that is staked in both the `1 day` and `1 week` gamm/pool/3. In this example, the UNIX time is currently `1639776682` and queries an `ADDRESS` for UNIX time two days later from the current time (which in this example would be `1639971082`) - -```bash -neutrond query stakeup account-staked-pasttime osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 1639971082 -``` - -The example output: - -```bash -stakes: -- ID: "572027" - coins: - - amount: "16120691802759484268" - denom: gamm/pool/3 - duration: 604800.000006193s - end_time: "0001-01-01T00:00:00Z" - owner: osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 -``` - -Note that the `1 day` stake ID did not display because, if the unbonding time began counting down from the time the command was executed, the bonding period would be complete before the two day window given by the UNIX timestamp input. -::: - - -### account-staked-pasttime-denom - -Query the staked records of an account with the unstake time beyond timestamp (unix) and filter by a specific denom - -```bash -neutrond query stakeup account-staked-pasttime-denom osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 [timestamp] [denom] -``` - -::: details Example - -Here is an example of an account that is staked in both the `1 day` and `1 week` gamm/pool/3 and `1 day` and `1 week` gamm/pool/1. In this example, the UNIX time is currently `1639776682` and queries an `ADDRESS` for UNIX time two days later from the current time (which in this example would be `1639971082`) and filters for gamm/pool/3 - -```bash -neutrond query stakeup account-staked-pasttime-denom osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 1639971082 gamm/pool/3 -``` - -The example output: - -```bash -stakes: -- ID: "572027" - coins: - - amount: "16120691802759484268" - denom: gamm/pool/3 - duration: 604800.000006193s - end_time: "0001-01-01T00:00:00Z" - owner: osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 -``` - -Note that the `1 day` stake ID did not display because, if the unbonding time began counting down from the time the command was executed, the bonding period would be complete before the two day window given by the UNIX timestamp input. Additionally, neither of the `1 day` or `1 week` stake IDs for gamm/pool/1 showed due to the denom filter. -::: - - -### account-staked-pasttime-not-unstaking - -Query the staked records of an account with the unstake time beyond timestamp (unix) AND is not in the process of unstaking - -```sh -neutrond query stakeup account-staked-pasttime [address] [timestamp] -``` - -::: details Example - -Here is an example of an account that is staked in both the `1 day` and `1 week` gamm/pool/3. In this example, the UNIX time is currently `1639776682` and queries an `ADDRESS` for UNIX time two days later from the current time (which in this example would be `1639971082`) AND is not unstaking: - -```bash -neutrond query stakeup account-staked-pasttime osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 1639971082 -``` - -The example output: - -```bash -stakes: -- ID: "572027" - coins: - - amount: "16120691802759484268" - denom: gamm/pool/3 - duration: 604800.000006193s - end_time: "0001-01-01T00:00:00Z" - owner: osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 -``` - -Note that the `1 day` stake ID did not display because, if the unbonding time began counting down from the time the command was executed, the bonding period would be complete before the two day window given by the UNIX timestamp input. Additionally, if ID 572027 were to begin the unstaking process, the query would have returned blank. -::: - - -### account-unstakeable-coins - -Query an address's LP shares that have completed the unstaking period and are ready to be withdrawn - -```bash -neutrond query stakeup account-unstakeable-coins ADDRESS -``` - - - -### account-unstaking-coins - -Query an address's LP shares that are currently unstaking - -```sh -neutrond query stakeup account-unstaking-coins [address] -``` - -::: details Example - -```bash -neutrond query stakeup account-unstaking-coins osmo1xqhlshlhs5g0acqgrkafdemvf5kz4pp4c2x259 -``` - -Example output: - -```bash -coins: -- amount: "15527546134174465309" - denom: gamm/pool/3 -``` -::: - - -### stake-by-id - -Query a stake record by its ID - -```sh -neutrond query stakeup stake-by-id [id] -``` - -::: details Example - -Every time a user bonds tokens to an LP, a unique stake ID is created for that transaction. - -Here is an example viewing the stake record for ID 9: - -```bash -neutrond query stakeup stake-by-id 9 -``` - -And its output: - -```bash -stake: - ID: "9" - coins: - - amount: "2449472670508255020346507" - denom: gamm/pool/2 - duration: 336h - end_time: "0001-01-01T00:00:00Z" - owner: osmo16r39ghhwqjcwxa8q3yswlz8jhzldygy66vlm82 -``` - -In summary, this shows wallet `osmo16r39ghhwqjcwxa8q3yswlz8jhzldygy66vlm82` bonded `2449472.670 gamm/pool/2` LP shares for a `2 week` staking period. -::: - - -### module-balance - -Query the balance of all LP shares (bonded and unbonded) - -```sh -neutrond query stakeup module-balance -``` - -::: details Example - -```bash -neutrond query stakeup module-balance -``` - -An example output: - -```bash -coins: -- amount: "118851922644152734549498647" - denom: gamm/pool/1 -- amount: "2165392672114512349039263626" - denom: gamm/pool/10 -- amount: "9346769826591025900804" - denom: gamm/pool/13 -- amount: "229347389639275840044722315" - denom: gamm/pool/15 -- amount: "81217698776012800247869" - denom: gamm/pool/183 -- amount: "284253336860259874753775" - denom: gamm/pool/197 -- amount: "664300804648059580124426710" - denom: gamm/pool/2 -- amount: "5087102794776326441530430" - denom: gamm/pool/22 -- amount: "178900843925960029029567880" - denom: gamm/pool/3 -- amount: "64845148811263846652326124" - denom: gamm/pool/4 -- amount: "177831279847453210600513" - denom: gamm/pool/42 -- amount: "18685913727862493301261661338" - denom: gamm/pool/5 -- amount: "23579028640963777558149250419" - denom: gamm/pool/6 -- amount: "1273329284855460149381904976" - denom: gamm/pool/7 -- amount: "625252103927082207683116933" - denom: gamm/pool/8 -- amount: "1148475247281090606949382402" - denom: gamm/pool/9 -``` -::: - - -### module-staked-amount - -Query the balance of all bonded LP shares - -```sh -neutrond query stakeup module-staked-amount -``` - -::: details Example - -```bash -neutrond query stakeup module-staked-amount -``` - -An example output: - -```bash - - "coins": - { - "denom": "gamm/pool/1", - "amount": "247321084020868094262821308" - }, - { - "denom": "gamm/pool/10", - "amount": "2866946821820635047398966697" - }, - { - "denom": "gamm/pool/13", - "amount": "9366580741745176812984" - }, - { - "denom": "gamm/pool/15", - "amount": "193294911294343602187680438" - }, - { - "denom": "gamm/pool/183", - "amount": "196722012808526595790871" - }, - { - "denom": "gamm/pool/197", - "amount": "1157025085661167198918241" - }, - { - "denom": "gamm/pool/2", - "amount": "633051132033131378888258047" - }, - { - "denom": "gamm/pool/22", - "amount": "3622601406125950733194696" - }, -... - -``` - -NOTE: This command seems to only work on gRPC and on CLI returns an EOF error. -::: - - - -### output-all-stakes - -Output all stakes into a json file - -```sh -neutrond query stakeup output-all-stakes [max stake ID] -``` - -:::: details Example - -This example command outputs stakes 1-1000 and saves to a json file: - -```bash -neutrond query stakeup output-all-stakes 1000 -``` -::: warning Note -If a stakeup has been completed, the stakeup status will show as "0" (or successful) and no further information will be available. To get further information on a completed stake, run the stake-by-id query. -::: -:::: - - -### total-staked-of-denom - -Query staked amount for a specific denom in the duration provided - -```sh -neutrond query stakeup total-staked-of-denom [denom] --min-duration -``` - -:::: details Example - -This example command outputs the amount of `gamm/pool/2` LP shares that staked in the `2 week` bonding period: - -```bash -neutrond query stakeup total-staked-of-denom gamm/pool/2 --min-duration "336h" -``` - -Which, at the time of this writing outputs `14106985399822075248947045` which is equivalent to `14106985.3998 gamm/pool/2` - -NOTE: As of this writing, there is a bug that defaults the min duration to days instead of seconds. Ensure you specify the time in seconds to get the correct response. -::: - -## Commands - -```sh -# 1 day 100stake stake-tokens command -neutrond tx stakeup stake-tokens 200stake --duration="86400s" --from=validator --chain-id=testing --keyring-backend=test --yes - -# 5s 100stake stake-tokens command -neutrond tx stakeup stake-tokens 100stake --duration="5s" --from=validator --chain-id=testing --keyring-backend=test --yes - -# begin unstake tokens, NOTE: add more gas when unstaking more than two stakes in a same command -neutrond tx stakeup begin-unstake-tokens --from=validator --gas=500000 --chain-id=testing --keyring-backend=test --yes - -# unstake tokens, NOTE: add more gas when unstaking more than two stakes in a same command -neutrond tx stakeup unstake-tokens --from=validator --gas=500000 --chain-id=testing --keyring-backend=test --yes - -# unstake specific period stake -neutrond tx stakeup unstake-by-id 1 --from=validator --chain-id=testing --keyring-backend=test --yes - -# account balance -neutrond query bank balances $(neutrond keys show -a validator --keyring-backend=test) - -# query module balance -neutrond query stakeup module-balance - -# query staked amount -neutrond query stakeup module-staked-amount - -# query stake by id -neutrond query stakeup stake-by-id 1 - -# query account unstakeable coins -neutrond query stakeup account-unstakeable-coins $(neutrond keys show -a validator --keyring-backend=test) - -# query account stakes by denom past time -neutrond query stakeup account-staked-pasttime-denom $(neutrond keys show -a validator --keyring-backend=test) 1611879610 stake - -# query account stakes past time -neutrond query stakeup account-staked-pasttime $(neutrond keys show -a validator --keyring-backend=test) 1611879610 - -# query account stakes by denom with longer duration -neutrond query stakeup account-staked-longer-duration-denom $(neutrond keys show -a validator --keyring-backend=test) 5.1s stake - -# query account stakes with longer duration -neutrond query stakeup account-staked-longer-duration $(neutrond keys show -a validator --keyring-backend=test) 5.1s - -# query account staked coins -neutrond query stakeup account-staked-coins $(neutrond keys show -a validator --keyring-backend=test) - -# query account stakes before time -neutrond query stakeup account-staked-beforetime $(neutrond keys show -a validator --keyring-backend=test) 1611879610 -``` diff --git a/x/incentives/client/cli/cli_test.go b/x/incentives/client/cli/cli_test.go deleted file mode 100644 index 526dcda41..000000000 --- a/x/incentives/client/cli/cli_test.go +++ /dev/null @@ -1,340 +0,0 @@ -package cli_test - -import ( - "fmt" - "testing" - "time" - - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/neutron-org/neutron/utils" - "github.com/neutron-org/neutron/utils/dcli" - dextypes "github.com/neutron-org/neutron/x/dex/types" - "github.com/neutron-org/neutron/x/incentives/client/cli" - "github.com/neutron-org/neutron/x/incentives/types" -) - -var testAddresses = utils.CreateRandomAccounts(3) - -// Queries //////////////////////////////////////////////////////////////////// - -func TestGetCmdGetModuleStatus(t *testing.T) { - desc, _ := cli.GetCmdGetModuleStatus() - tcs := map[string]dcli.QueryCliTestCase[*types.GetModuleStatusRequest]{ - "basic test": { - ExpectedQuery: &types.GetModuleStatusRequest{}, - }, - } - dcli.RunQueryTestCases(t, desc, tcs) -} - -func TestGetCmdGetGaugeByID(t *testing.T) { - desc, _ := cli.GetCmdGetGaugeByID() - tcs := map[string]dcli.QueryCliTestCase[*types.GetGaugeByIDRequest]{ - "basic test": { - Cmd: "1", ExpectedQuery: &types.GetGaugeByIDRequest{Id: 1}, - }, - } - dcli.RunQueryTestCases(t, desc, tcs) -} - -func TestGetCmdGauges(t *testing.T) { - desc, _ := cli.GetCmdGauges() - tcs := map[string]dcli.QueryCliTestCase[*types.GetGaugesRequest]{ - "test ACTIVE_UPCOMING": { - Cmd: "ACTIVE_UPCOMING TokenA", - ExpectedQuery: &types.GetGaugesRequest{ - Status: types.GaugeStatus_ACTIVE_UPCOMING, - Denom: "TokenA", - }, - }, - "test UPCOMING": { - Cmd: "UPCOMING TokenA", - ExpectedQuery: &types.GetGaugesRequest{ - Status: types.GaugeStatus_UPCOMING, - Denom: "TokenA", - }, - }, - "test FINISHED": { - Cmd: "FINISHED TokenA", - ExpectedQuery: &types.GetGaugesRequest{ - Status: types.GaugeStatus_FINISHED, - Denom: "TokenA", - }, - }, - } - dcli.RunQueryTestCases(t, desc, tcs) -} - -func TestGetCmdGetStakeByID(t *testing.T) { - desc, _ := cli.GetCmdGetStakeByID() - tcs := map[string]dcli.QueryCliTestCase[*types.GetStakeByIDRequest]{ - "basic test": { - Cmd: "1", ExpectedQuery: &types.GetStakeByIDRequest{StakeId: 1}, - }, - } - dcli.RunQueryTestCases(t, desc, tcs) -} - -func TestGetCmdStakes(t *testing.T) { - desc, _ := cli.GetCmdStakes() - tcs := map[string]dcli.QueryCliTestCase[*types.GetStakesRequest]{ - "basic test": { - Cmd: fmt.Sprintf("%s", testAddresses[0]), - ExpectedQuery: &types.GetStakesRequest{ - Owner: testAddresses[0].String(), - }, - }, - } - dcli.RunQueryTestCases(t, desc, tcs) -} - -func TestGetCmdFutureRewardEstimate(t *testing.T) { - desc, _ := cli.GetCmdGetFutureRewardEstimate() - tcs := map[string]dcli.QueryCliTestCase[*types.GetFutureRewardEstimateRequest]{ - "basic test": { - Cmd: fmt.Sprintf("%s [1,2,3] 1000", testAddresses[0]), - ExpectedQuery: &types.GetFutureRewardEstimateRequest{ - Owner: testAddresses[0].String(), - StakeIds: []uint64{1, 2, 3}, - NumEpochs: 1000, - }, - }, - } - dcli.RunQueryTestCases(t, desc, tcs) -} - -func TestGetAccountHistory(t *testing.T) { - desc, _ := cli.GetCmdGetAccountHistory() - tcs := map[string]dcli.QueryCliTestCase[*types.GetAccountHistoryRequest]{ - "basic test": { - Cmd: fmt.Sprintf("%s", testAddresses[0]), - ExpectedQuery: &types.GetAccountHistoryRequest{ - Account: testAddresses[0].String(), - }, - }, - } - dcli.RunQueryTestCases(t, desc, tcs) -} - -func TestGetGaugeQualifyingValue(t *testing.T) { - desc, _ := cli.GetCmdGaugeQualifyingValue() - tcs := map[string]dcli.QueryCliTestCase[*types.GetGaugeQualifyingValueRequest]{ - "basic test": { - Cmd: "1", - ExpectedQuery: &types.GetGaugeQualifyingValueRequest{ - Id: 1, - }, - }, - } - dcli.RunQueryTestCases(t, desc, tcs) -} - -// TXS //////////////////////////////////////////////////////////////////////// - -func TestNewCreateGaugeCmd(t *testing.T) { - testTime := time.Unix(1681505514, 0).UTC() - desc, _ := cli.NewCreateGaugeCmd() - tcs := map[string]dcli.TxCliTestCase[*types.MsgCreateGauge]{ - "basic test": { - Cmd: fmt.Sprintf( - "TokenA TokenB 0 100 100TokenA,100TokenB 50 0 --from %s", - testAddresses[0], - ), - ExpectedMsg: &types.MsgCreateGauge{ - IsPerpetual: false, - Owner: testAddresses[0].String(), - DistributeTo: types.QueryCondition{ - PairID: &dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, - StartTick: 0, - EndTick: 100, - }, - Coins: sdk.NewCoins( - sdk.NewCoin("TokenA", math.NewInt(100)), - sdk.NewCoin("TokenB", math.NewInt(100)), - ), - StartTime: time.Unix(0, 0).UTC(), - NumEpochsPaidOver: 50, - PricingTick: 0, - }, - }, - "tests with time (RFC3339)": { - Cmd: fmt.Sprintf( - "TokenA TokenB [-20] 20 100TokenA,100TokenB 50 0 --start-time %s --from %s", - testTime.Format(time.RFC3339), - testAddresses[0], - ), - ExpectedMsg: &types.MsgCreateGauge{ - IsPerpetual: false, - Owner: testAddresses[0].String(), - DistributeTo: types.QueryCondition{ - PairID: &dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, - StartTick: -20, - EndTick: 20, - }, - Coins: sdk.NewCoins( - sdk.NewCoin("TokenA", math.NewInt(100)), - sdk.NewCoin("TokenB", math.NewInt(100)), - ), - StartTime: testTime, - NumEpochsPaidOver: 50, - PricingTick: 0, - }, - }, - "tests with time (unix int)": { - Cmd: fmt.Sprintf( - "TokenA TokenB [-20] 20 100TokenA,100TokenB 50 0 --start-time %d --from %s", - testTime.Unix(), - testAddresses[0], - ), - ExpectedMsg: &types.MsgCreateGauge{ - IsPerpetual: false, - Owner: testAddresses[0].String(), - DistributeTo: types.QueryCondition{ - PairID: &dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, - StartTick: -20, - EndTick: 20, - }, - Coins: sdk.NewCoins( - sdk.NewCoin("TokenA", math.NewInt(100)), - sdk.NewCoin("TokenB", math.NewInt(100)), - ), - StartTime: testTime, - NumEpochsPaidOver: 50, - PricingTick: 0, - }, - }, - "tests with perpetual": { - Cmd: fmt.Sprintf( - "TokenA TokenB [-20] 20 100TokenA,100TokenB 50 0 --perpetual --from %s", - testAddresses[0], - ), - ExpectedMsg: &types.MsgCreateGauge{ - IsPerpetual: true, - Owner: testAddresses[0].String(), - DistributeTo: types.QueryCondition{ - PairID: &dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, - StartTick: -20, - EndTick: 20, - }, - Coins: sdk.NewCoins( - sdk.NewCoin("TokenA", math.NewInt(100)), - sdk.NewCoin("TokenB", math.NewInt(100)), - ), - StartTime: time.Unix(0, 0).UTC(), - NumEpochsPaidOver: 1, - PricingTick: 0, - }, - }, - } - dcli.RunTxTestCases(t, desc, tcs) -} - -func TestNewAddToGaugeCmd(t *testing.T) { - desc, _ := cli.NewAddToGaugeCmd() - tcs := map[string]dcli.TxCliTestCase[*types.MsgAddToGauge]{ - "basic test": { - Cmd: fmt.Sprintf("1 1000TokenA --from %s", testAddresses[0]), - ExpectedMsg: &types.MsgAddToGauge{ - Owner: testAddresses[0].String(), - GaugeId: 1, - Rewards: sdk.NewCoins(sdk.NewCoin("TokenA", math.NewInt(1000))), - }, - }, - "multiple tokens": { - Cmd: fmt.Sprintf("1 1000TokenA,1TokenZ --from %s", testAddresses[0]), - ExpectedMsg: &types.MsgAddToGauge{ - Owner: testAddresses[0].String(), - GaugeId: 1, - Rewards: sdk.NewCoins( - sdk.NewCoin("TokenA", math.NewInt(1000)), - sdk.NewCoin("TokenZ", math.NewInt(1)), - ), - }, - }, - } - dcli.RunTxTestCases(t, desc, tcs) -} - -func TestNewStakeCmd(t *testing.T) { - desc, _ := cli.NewStakeCmd() - tcs := map[string]dcli.TxCliTestCase[*types.MsgStake]{ - "basic test": { - Cmd: fmt.Sprintf("1000TokenA --from %s", testAddresses[0]), - ExpectedMsg: &types.MsgStake{ - Owner: testAddresses[0].String(), - Coins: sdk.NewCoins(sdk.NewCoin("TokenA", math.NewInt(1000))), - }, - }, - "multiple tokens": { - Cmd: fmt.Sprintf("1000TokenA,1TokenZ --from %s", testAddresses[0]), - ExpectedMsg: &types.MsgStake{ - Owner: testAddresses[0].String(), - Coins: sdk.NewCoins( - sdk.NewCoin("TokenA", math.NewInt(1000)), - sdk.NewCoin("TokenZ", math.NewInt(1)), - ), - }, - }, - "tokenized share test": { - Cmd: fmt.Sprintf( - "1000neutron/pool/1 --from %s", - testAddresses[0], - ), - ExpectedMsg: &types.MsgStake{ - Owner: testAddresses[0].String(), - Coins: sdk.NewCoins( - sdk.NewCoin("neutron/pool/1", math.NewInt(1000)), - ), - }, - }, - "multiple tokenized shares": { - Cmd: fmt.Sprintf( - "1000neutron/pool/1,1neutron/pool/2 --from %s", - testAddresses[0], - ), - ExpectedMsg: &types.MsgStake{ - Owner: testAddresses[0].String(), - Coins: sdk.NewCoins( - sdk.NewCoin("neutron/pool/1", math.NewInt(1000)), - sdk.NewCoin("neutron/pool/2", math.NewInt(1)), - ), - }, - }, - } - dcli.RunTxTestCases(t, desc, tcs) -} - -func TestNewUnstakeCmd(t *testing.T) { - desc, _ := cli.NewUnstakeCmd() - tcs := map[string]dcli.TxCliTestCase[*types.MsgUnstake]{ - "basic test": { - Cmd: fmt.Sprintf("--from %s", testAddresses[0]), - ExpectedMsg: &types.MsgUnstake{ - Owner: testAddresses[0].String(), - Unstakes: []*types.MsgUnstake_UnstakeDescriptor{}, - }, - }, - "with coins": { - Cmd: fmt.Sprintf("1:10TokenA 10:10TokenA,10TokenC --from %s", testAddresses[0]), - ExpectedMsg: &types.MsgUnstake{ - Owner: testAddresses[0].String(), - Unstakes: []*types.MsgUnstake_UnstakeDescriptor{ - { - ID: 1, - Coins: sdk.NewCoins( - sdk.NewCoin("TokenA", math.NewInt(10)), - ), - }, { - ID: 10, - Coins: sdk.NewCoins( - sdk.NewCoin("TokenA", math.NewInt(10)), - sdk.NewCoin("TokenC", math.NewInt(10)), - ), - }, - }, - }, - }, - } - dcli.RunTxTestCases(t, desc, tcs) -} diff --git a/x/incentives/client/cli/flags.go b/x/incentives/client/cli/flags.go deleted file mode 100644 index fa3467e0f..000000000 --- a/x/incentives/client/cli/flags.go +++ /dev/null @@ -1,22 +0,0 @@ -package cli - -import ( - flag "github.com/spf13/pflag" -) - -// Flags for incentives module tx commands. -const ( - FlagStartTime = "start-time" - FlagPerpetual = "perpetual" - FlagAmount = "amount" -) - -// FlagSetCreateGauge returns flags for creating gauges. -func FlagSetCreateGauge() *flag.FlagSet { - fs := flag.NewFlagSet("", flag.ContinueOnError) - - fs.String(FlagStartTime, "", "Timestamp to begin distribution") - fs.Bool(FlagPerpetual, false, "Perpetual distribution") - - return fs -} diff --git a/x/incentives/client/cli/query.go b/x/incentives/client/cli/query.go deleted file mode 100644 index 13fa2f876..000000000 --- a/x/incentives/client/cli/query.go +++ /dev/null @@ -1,114 +0,0 @@ -package cli - -import ( - "github.com/spf13/cobra" - "github.com/spf13/pflag" - - "github.com/neutron-org/neutron/utils/dcli" - "github.com/neutron-org/neutron/x/incentives/types" -) - -// GetQueryCmd returns the query commands for this module. -func GetQueryCmd() *cobra.Command { - // group incentives queries under a subcommand - cmd := dcli.QueryIndexCmd(types.ModuleName) - qcGetter := types.NewQueryClient - dcli.AddQueryCmd(cmd, qcGetter, GetCmdGetModuleStatus) - dcli.AddQueryCmd(cmd, qcGetter, GetCmdGetGaugeByID) - dcli.AddQueryCmd(cmd, qcGetter, GetCmdGauges) - dcli.AddQueryCmd(cmd, qcGetter, GetCmdGetStakeByID) - dcli.AddQueryCmd(cmd, qcGetter, GetCmdStakes) - dcli.AddQueryCmd(cmd, qcGetter, GetCmdGetFutureRewardEstimate) - dcli.AddQueryCmd(cmd, qcGetter, GetCmdGetAccountHistory) - dcli.AddQueryCmd(cmd, qcGetter, GetCmdGaugeQualifyingValue) - - return cmd -} - -// GetCmdGetModuleStatus returns status of incentive module. -func GetCmdGetModuleStatus() (*dcli.QueryDescriptor, *types.GetModuleStatusRequest) { - return &dcli.QueryDescriptor{ - Use: "module-status", - Short: "Query module status.", - Long: `{{.Short}}`, - }, &types.GetModuleStatusRequest{} -} - -// GetCmdGetGaugeByID returns a gauge by ID. -func GetCmdGetGaugeByID() (*dcli.QueryDescriptor, *types.GetGaugeByIDRequest) { - return &dcli.QueryDescriptor{ - Use: "gauge-by-id [id]", - Short: "Query gauge by id.", - Long: `{{.Short}}{{.ExampleHeader}} gauge-by-id 1`, - }, &types.GetGaugeByIDRequest{} -} - -//nolint:unparam // we can't change return values since we need to match interface -func parseGaugeStatus(arg string, _ *pflag.FlagSet) (any, dcli.FieldReadLocation, error) { - gaugeStatusInt, ok := types.GaugeStatus_value[arg] - if !ok { - return 0, dcli.UsedArg, types.ErrInvalidGaugeStatus - } - gaugeStatus := types.GaugeStatus(gaugeStatusInt) - - return gaugeStatus, dcli.UsedArg, nil -} - -// GetCmdGauges returns all gauges for a given status and denom. -func GetCmdGauges() (*dcli.QueryDescriptor, *types.GetGaugesRequest) { - return &dcli.QueryDescriptor{ - Use: "list-gauges [status] [denom]", - Short: "Query gauges", - Long: `{{.Short}}{{.ExampleHeader}} list-gauges UPCOMING neutron/pool/1`, - CustomFieldParsers: map[string]dcli.CustomFieldParserFn{ - "Status": parseGaugeStatus, - }, - }, &types.GetGaugesRequest{} -} - -// GetCmdGetStakeByID returns a lock by ID. -func GetCmdGetStakeByID() (*dcli.QueryDescriptor, *types.GetStakeByIDRequest) { - return &dcli.QueryDescriptor{ - Use: "stake-by-id [stakeID]", - Short: "Query stake by id.", - Long: `{{.Short}}{{.ExampleHeader}} Stake-by-id 1`, - }, &types.GetStakeByIDRequest{} -} - -// GetCmdStakes returns all gauges for a given status and owner. -func GetCmdStakes() (*dcli.QueryDescriptor, *types.GetStakesRequest) { - return &dcli.QueryDescriptor{ - Use: "list-stakes [owner]", - Short: "Query stakes", - Long: `{{.Short}}{{.ExampleHeader}} list-stakes cosmos1chl62vc593p99z2tfh2pp8tl4anm0w4l8h8svx`, - }, &types.GetStakesRequest{} -} - -// GetCmdGetFutureRewardsEstimate returns a rewards estimate for a given set of stakes. -func GetCmdGetFutureRewardEstimate() (*dcli.QueryDescriptor, *types.GetFutureRewardEstimateRequest) { - return &dcli.QueryDescriptor{ - Use: "reward-estimate [owner] [stakeIDs] [numEpochs]", - Short: "Get rewards estimate for set of stakes", - Long: `{{.Short}}{{.ExampleHeader}} reward-estimate cosmos1chl62vc593p99z2tfh2pp8tl4anm0w4l8h8svx [1,2,3] 365`, - CustomFieldParsers: map[string]dcli.CustomFieldParserFn{ - "StakeIDs": dcli.ParseUintArray, - }, - }, &types.GetFutureRewardEstimateRequest{} -} - -// GetCmdGetFutureRewardsEstimate returns a rewards estimate for a given set of stakes. -func GetCmdGetAccountHistory() (*dcli.QueryDescriptor, *types.GetAccountHistoryRequest) { - return &dcli.QueryDescriptor{ - Use: "account-history [account]", - Short: "Get rewards distribution history for an address", - Long: `{{.Short}}{{.ExampleHeader}} account-history cosmos1chl62vc593p99z2tfh2pp8tl4anm0w4l8h8svx`, - }, &types.GetAccountHistoryRequest{} -} - -func GetCmdGaugeQualifyingValue() (*dcli.QueryDescriptor, *types.GetGaugeQualifyingValueRequest) { - return &dcli.QueryDescriptor{ - Use: "gauge-qualifying-value [gaugeID]", - Short: "Query the qualifying value of a gauge by gauge id.", - Long: `{{.Short}}{{.ExampleHeader}} gauge-qualifying-value 1`, - }, &types.GetGaugeQualifyingValueRequest{} -} diff --git a/x/incentives/client/cli/query_test.go b/x/incentives/client/cli/query_test.go deleted file mode 100644 index 2a60451d3..000000000 --- a/x/incentives/client/cli/query_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package cli_test - -import ( - "testing" - - "cosmossdk.io/math" - "github.com/stretchr/testify/suite" - - "github.com/neutron-org/neutron/testutil/apptesting" - dextypes "github.com/neutron-org/neutron/x/dex/types" - "github.com/neutron-org/neutron/x/incentives/keeper" - "github.com/neutron-org/neutron/x/incentives/types" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -type QueryTestSuite struct { - apptesting.KeeperTestHelper - queryClient types.QueryClient -} - -// StakeTokens funds an account, stakes tokens and returns a stakeID. -func (s *QueryTestSuite) SetupStake( - addr sdk.AccAddress, - coins sdk.Coins, -) (stakeID uint64) { - msgServer := keeper.NewMsgServerImpl(s.App.IncentivesKeeper) - s.FundAcc(addr, coins) - - msgResponse, err := msgServer.Stake( - sdk.WrapSDKContext(s.Ctx), - types.NewMsgSetupStake(addr, coins), - ) - s.Require().NoError(err) - - return msgResponse.ID -} - -func (s *QueryTestSuite) SetupSuite() { - s.Setup() - s.queryClient = types.NewQueryClient(s.QueryHelper) - - pool, _ := s.App.DexKeeper.InitPool(s.Ctx, dextypes.MustNewPairID("tokenA", "tokenB"), 0, 1) - denom := pool.GetPoolDenom() - - // set up stake with id = 1 - addr := apptesting.SetupAddr(0) - s.SetupStake(addr, sdk.Coins{sdk.NewCoin(denom, math.NewInt(1000000))}) - - s.Commit() -} - -func TestQueryTestSuite(t *testing.T) { - suite.Run(t, new(QueryTestSuite)) -} diff --git a/x/incentives/client/cli/tx.go b/x/incentives/client/cli/tx.go deleted file mode 100644 index 0c9517923..000000000 --- a/x/incentives/client/cli/tx.go +++ /dev/null @@ -1,173 +0,0 @@ -package cli - -import ( - "errors" - "fmt" - "strconv" - "strings" - "time" - - "github.com/cosmos/cosmos-sdk/client" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/spf13/cobra" - "github.com/spf13/pflag" - - "github.com/neutron-org/neutron/utils/dcli" - dextypes "github.com/neutron-org/neutron/x/dex/types" - "github.com/neutron-org/neutron/x/incentives/types" -) - -// GetTxCmd returns the transaction commands for this module. -func GetTxCmd() *cobra.Command { - cmd := dcli.TxIndexCmd(types.ModuleName) - - dcli.AddTxCmd(cmd, NewCreateGaugeCmd) - dcli.AddTxCmd(cmd, NewAddToGaugeCmd) - dcli.AddTxCmd(cmd, NewStakeCmd) - dcli.AddTxCmd(cmd, NewUnstakeCmd) - - return cmd -} - -func CreateGaugeCmdBuilder( - clientCtx client.Context, - args []string, - flags *pflag.FlagSet, -) (sdk.Msg, error) { - // "create-gauge [pairTokenA] [pairTokenB] [startTick] [endTick] [coins] [numEpochs] [pricingTick]" - pairID, err := dextypes.NewPairIDFromUnsorted(args[0], args[1]) - if err != nil { - return &types.MsgCreateGauge{}, err - } - - startTick, err := dcli.ParseIntMaybeNegative(args[2], "startTick") - if err != nil { - return &types.MsgCreateGauge{}, err - } - - endTick, err := dcli.ParseIntMaybeNegative(args[3], "endTick") - if err != nil { - return &types.MsgCreateGauge{}, err - } - - coins, err := sdk.ParseCoinsNormalized(args[4]) - if err != nil { - return &types.MsgCreateGauge{}, err - } - - var startTime time.Time - timeStr, err := flags.GetString(FlagStartTime) - if err != nil { - return &types.MsgCreateGauge{}, err - } - if timeStr == "" { // empty start time - startTime = time.Unix(0, 0).UTC() - } else if timeUnix, err := strconv.ParseInt(timeStr, 10, 64); err == nil { // unix time - startTime = time.Unix(timeUnix, 0).UTC() - } else if timeRFC, err := time.Parse(time.RFC3339, timeStr); err == nil { // RFC time - startTime = timeRFC - } else { // invalid input - return &types.MsgCreateGauge{}, errors.New("invalid start time format") - } - - epochs, err := dcli.ParseUint(args[5], "numEpochs") - if err != nil { - return &types.MsgCreateGauge{}, err - } - - perpetual, err := flags.GetBool(FlagPerpetual) - if err != nil { - return &types.MsgCreateGauge{}, err - } - - if perpetual { - epochs = 1 - } - - pricingTick, err := dcli.ParseIntMaybeNegative(args[6], "pricingTick") - if err != nil { - return &types.MsgCreateGauge{}, err - } - - distributeTo := types.QueryCondition{ - PairID: pairID, - StartTick: startTick, - EndTick: endTick, - } - - msg := types.NewMsgCreateGauge( - epochs == 1, - clientCtx.GetFromAddress(), - distributeTo, - coins, - startTime, - epochs, - pricingTick, - ) - - return msg, nil -} - -func NewCreateGaugeCmd() (*dcli.TxCliDesc, *types.MsgCreateGauge) { - return &dcli.TxCliDesc{ - ParseAndBuildMsg: CreateGaugeCmdBuilder, - Use: "create-gauge [pairTokenA] [pairTokenB] [startTick] [endTick] [coins] [numEpochs] [pricingTick]", - Short: "create a gauge to distribute rewards to users", - Long: `{{.Short}}{{.ExampleHeader}} create-gauge TokenA TokenB [-10] 200 100TokenA,200TokenB 6 0 --start-time 2006-01-02T15:04:05Z07:00 --perpetual true`, - Flags: dcli.FlagDesc{OptionalFlags: []*pflag.FlagSet{FlagSetCreateGauge()}}, - NumArgs: 7, - }, &types.MsgCreateGauge{} -} - -func NewAddToGaugeCmd() (*dcli.TxCliDesc, *types.MsgAddToGauge) { - return &dcli.TxCliDesc{ - Use: "add-to-gauge [gauge_id] [coins]", - Short: "add coins to gauge to distribute more rewards to users", - Long: `{{.Short}}{{.ExampleHeader}} add-to-gauge 1 TokenA,TokenB`, - }, &types.MsgAddToGauge{} -} - -func NewStakeCmd() (*dcli.TxCliDesc, *types.MsgStake) { - return &dcli.TxCliDesc{ - Use: "stake-tokens [coins]", - Short: "stake tokens into stake pool from user account", - }, &types.MsgStake{} -} - -func UnstakeCmdBuilder(clientCtx client.Context, args []string, _ *pflag.FlagSet) (sdk.Msg, error) { - // "unstake-tokens [poolID]:[coins] [poolID]:[coins] ..." - unstakes := make([]*types.MsgUnstake_UnstakeDescriptor, 0, len(args)) - for i, unstake := range args { - if strings.HasPrefix(unstake, "-") { - // no more unstakes left, only flags - break - } - - parts := strings.Split(unstake, ":") - if len(parts) != 2 { - return &types.MsgUnstake{}, errors.New("invalid syntax for unstake tokens") - } - poolID, err := dcli.ParseUint(parts[0], fmt.Sprintf("poolID[%d]", i)) - if err != nil { - return &types.MsgUnstake{}, err - } - - coins, err := dcli.ParseCoins(parts[1], fmt.Sprintf("coins[%d]", i)) - if err != nil { - return &types.MsgUnstake{}, err - } - - unstakes = append(unstakes, types.NewMsgUnstakeDescriptor(poolID, coins)) - } - - return types.NewMsgUnstake(clientCtx.GetFromAddress(), unstakes), nil -} - -func NewUnstakeCmd() (*dcli.TxCliDesc, *types.MsgUnstake) { - return &dcli.TxCliDesc{ - Use: "unstake-tokens [poolID]:[coins] [poolID]:[coins] ...", - Short: "Unstake tokens", - ParseAndBuildMsg: UnstakeCmdBuilder, - Long: `{{.Short}}{{.ExampleHeader}} unstake-tokens 1:100TokenA 2:10TokenZ,20TokenB`, - }, &types.MsgUnstake{} -} diff --git a/x/incentives/keeper/account_history.go b/x/incentives/keeper/account_history.go deleted file mode 100644 index 27d787b2b..000000000 --- a/x/incentives/keeper/account_history.go +++ /dev/null @@ -1,83 +0,0 @@ -package keeper - -import ( - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/gogoproto/proto" - "github.com/neutron-org/neutron/x/incentives/types" -) - -func NewAccountHistory(account string, coins sdk.Coins) *types.AccountHistory { - return &types.AccountHistory{ - Account: account, - Coins: coins, - } -} - -// SetAccountHistory set a specific goodTilRecord in the store from its index -func (k Keeper) SetAccountHistory( - ctx sdk.Context, - accountHistory *types.AccountHistory, -) error { - store := ctx.KVStore(k.storeKey) - b, err := proto.Marshal(accountHistory) - if err != nil { - return err - } - store.Set(types.GetKeyAccountHistory( - accountHistory.Account, - ), b) - return nil -} - -// GetAccountHistory returns a goodTilRecord from its index -func (k Keeper) GetAccountHistory( - ctx sdk.Context, - account string, -) (val *types.AccountHistory, found bool) { - store := ctx.KVStore(k.storeKey) - - b := store.Get(types.GetKeyAccountHistory(account)) - if b == nil { - return val, false - } - - val = &types.AccountHistory{} - err := proto.Unmarshal(b, val) - if err != nil { - panic(err) - } - - return val, true -} - -// RemoveAccountHistory removes a goodTilRecord from the store -func (k Keeper) RemoveAccountHistory( - ctx sdk.Context, - account string, -) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.GetKeyAccountHistory(account)) -} - -// GetAllAccountHistory returns all goodTilRecord -func (k Keeper) GetAllAccountHistory(ctx sdk.Context) (list []*types.AccountHistory) { - store := prefix.NewStore( - ctx.KVStore(k.storeKey), - types.KeyPrefixAccountHistory, - ) - iterator := sdk.KVStorePrefixIterator(store, []byte{}) - - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - val := &types.AccountHistory{} - err := proto.Unmarshal(iterator.Value(), val) - if err != nil { - panic(err) - } - list = append(list, val) - } - - return -} diff --git a/x/incentives/keeper/distribute.go b/x/incentives/keeper/distribute.go deleted file mode 100644 index 9ea79d702..000000000 --- a/x/incentives/keeper/distribute.go +++ /dev/null @@ -1,186 +0,0 @@ -package keeper - -import ( - "fmt" - "time" - - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - math_utils "github.com/neutron-org/neutron/utils/math" - dextypes "github.com/neutron-org/neutron/x/dex/types" - "github.com/neutron-org/neutron/x/incentives/types" -) - -var _ DistributorKeeper = Keeper{} - -func (k Keeper) ValueForShares(ctx sdk.Context, coin sdk.Coin, tick int64) (math.Int, error) { - totalShares := k.bk.GetSupply(ctx, coin.Denom).Amount - poolMetadata, err := k.dk.GetPoolMetadataByDenom(ctx, coin.Denom) - if err != nil { - return math.ZeroInt(), err - } - - pool, err := k.dk.GetOrInitPool( - ctx, - poolMetadata.PairID, - poolMetadata.Tick, - poolMetadata.Fee, - ) - if err != nil { - return math.ZeroInt(), err - } - amount0, amount1 := pool.RedeemValue(coin.Amount, totalShares) - price1To0Center, err := dextypes.CalcPrice(-1 * tick) - if err != nil { - return math.ZeroInt(), err - } - return math_utils.NewPrecDecFromInt(amount0).Add(price1To0Center.MulInt(amount1)).TruncateInt(), nil -} - -// Distribute distributes coins from an array of gauges to all eligible stakes. -func (k Keeper) Distribute(ctx sdk.Context, gauges types.Gauges) (types.DistributionSpec, error) { - distSpec := types.DistributionSpec{} - for _, gauge := range gauges { - gaugeDistSpec, err := k.distributor.Distribute(ctx, gauge, nil) - if err != nil { - return nil, err - } - distSpec = distSpec.Add(gaugeDistSpec) - - err = k.setGauge(ctx, gauge) - if err != nil { - return nil, err - } - if gauge.IsFinishedGauge(ctx.BlockTime()) { - if err := k.moveActiveGaugeToFinishedGauge(ctx, gauge); err != nil { - return nil, err - } - } - } - - ctx.Logger().Debug(fmt.Sprintf("Beginning distribution to %d users", len(distSpec))) - for addr, rewards := range distSpec { - decodedAddr, err := sdk.AccAddressFromBech32(addr) - if err != nil { - return nil, err - } - err = k.bk.SendCoinsFromModuleToAccount( - ctx, - types.ModuleName, - decodedAddr, - rewards) - if err != nil { - return nil, err - } - - // Accumulate to account history - accHistory, found := k.GetAccountHistory(ctx, addr) - if found { - accHistory.Coins = accHistory.Coins.Add(rewards...) - } else { - accHistory = NewAccountHistory(addr, rewards) - } - if err := k.SetAccountHistory(ctx, accHistory); err != nil { - return nil, err - } - - // Emit events - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.TypeEvtDistribution, - sdk.NewAttribute(types.AttributeReceiver, addr), - sdk.NewAttribute(types.AttributeAmount, rewards.String()), - ), - }) - } - ctx.Logger().Debug(fmt.Sprintf("Finished Distributing to %d users", len(distSpec))) - k.hooks.AfterEpochDistribution(ctx) - return distSpec, nil -} - -// GetModuleCoinsToBeDistributed returns sum of coins yet to be distributed for all of the module. -func (k Keeper) GetModuleCoinsToBeDistributed(ctx sdk.Context) sdk.Coins { - activeGaugesDistr := k.GetActiveGauges(ctx).GetCoinsRemaining() - upcomingGaugesDistr := k.GetUpcomingGauges(ctx).GetCoinsRemaining() - return activeGaugesDistr.Add(upcomingGaugesDistr...) -} - -// GetModuleDistributedCoins returns sum of coins that have been distributed so far for all of the module. -func (k Keeper) GetModuleDistributedCoins(ctx sdk.Context) sdk.Coins { - activeGaugesDistr := k.GetActiveGauges(ctx).GetCoinsDistributed() - finishedGaugesDistr := k.GetFinishedGauges(ctx).GetCoinsDistributed() - return activeGaugesDistr.Add(finishedGaugesDistr...) -} - -// GetRewardsEstimate returns rewards estimation at a future specific time (by epoch) -// If stakes are nil, it returns the rewards between now and the end epoch associated with address. -// If stakes are not nil, it returns all the rewards for the given stakes between now and end epoch. -func (k Keeper) GetRewardsEstimate( - ctx sdk.Context, - addr sdk.AccAddress, - filterStakes types.Stakes, - numEpochs int64, -) (sdk.Coins, error) { - // if stakes are nil, populate with all stakes associated with the address - if len(filterStakes) == 0 { - filterStakes = k.GetStakesByAccount(ctx, addr) - } - - // for each specified stake get associated pairs - pairSet := map[dextypes.PairID]bool{} - for _, l := range filterStakes { - for _, c := range l.Coins { - poolMetadata, err := k.dk.GetPoolMetadataByDenom(ctx, c.Denom) - if err != nil { - panic("all stakes should be valid deposit denoms") - } - pairSet[*poolMetadata.PairID] = true - } - } - - // for each pair get associated gauges - gauges := types.Gauges{} - for s := range pairSet { - gauges = append(gauges, k.GetGaugesByPair(ctx, &s)...) - } - - // estimate rewards - estimatedRewards := sdk.Coins{} - epochInfo := k.GetEpochInfo(ctx) - - // ensure we don't change storage while doing estimation - cacheCtx, _ := ctx.CacheContext() - for _, gauge := range gauges { - distrBeginEpoch := epochInfo.CurrentEpoch - endEpoch := epochInfo.CurrentEpoch + numEpochs - bstakeTime := ctx.BlockTime() - if gauge.StartTime.After(bstakeTime) { - distrBeginEpoch = epochInfo.CurrentEpoch + 1 + int64( - gauge.StartTime.Sub(bstakeTime)/epochInfo.Duration, - ) - } - - // TODO: Make more efficient by making it possible to call distribute with this - // gaugeStakes := k.GetStakesByQueryCondition(cacheCtx, &gauge.DistributeTo) - gaugeRewards := sdk.Coins{} - for epoch := distrBeginEpoch; epoch <= endEpoch; epoch++ { - epochTime := epochInfo.StartTime.Add( - time.Duration(epoch-epochInfo.CurrentEpoch) * epochInfo.Duration, - ) - if !gauge.IsActiveGauge(epochTime) { - break - } - - futureCtx := cacheCtx.WithBlockTime(epochTime) - distSpec, err := k.distributor.Distribute(futureCtx, gauge, filterStakes) - if err != nil { - return nil, err - } - - gaugeRewards = gaugeRewards.Add(distSpec.GetTotal()...) - } - estimatedRewards = estimatedRewards.Add(gaugeRewards...) - } - - return estimatedRewards, nil -} diff --git a/x/incentives/keeper/distribute_test.go b/x/incentives/keeper/distribute_test.go deleted file mode 100644 index 656ed771d..000000000 --- a/x/incentives/keeper/distribute_test.go +++ /dev/null @@ -1,363 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/neutron-org/neutron/testutil/apptesting" - dextypes "github.com/neutron-org/neutron/x/dex/types" - "github.com/neutron-org/neutron/x/incentives/types" -) - -var _ = suite.TestingSuite(nil) - -type balanceAssertion struct { - addr sdk.AccAddress - balances sdk.Coins -} - -func (suite *IncentivesTestSuite) TestValueForShares() { - addrs := apptesting.SetupAddrs(3) - - tests := []struct { - name string - deposits []depositSpec - coin sdk.Coin - tick int64 - expectation math.Int - err error - }{ - // gauge 1 gives 3k coins. three stakes, all eligible. 1k coins per stake. - // 1k should go to oneStakeUser and 2k to twoStakeUser. - { - name: "one deposit", - deposits: []depositSpec{ - { - addr: addrs[0], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - }, - coin: sdk.NewInt64Coin(dextypes.NewPoolDenom(0), 20), - tick: 1000, - expectation: math.NewInt(21), - }, - { - name: "one deposit: no adjustment", - deposits: []depositSpec{ - { - addr: addrs[0], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - }, - coin: sdk.NewInt64Coin(dextypes.NewPoolDenom(0), 20), - tick: 0, - expectation: math.NewInt(20), - }, - { - name: "two deposits: one extraneous", - deposits: []depositSpec{ - { - addr: addrs[0], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - { - addr: addrs[0], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 2, - }, - }, - coin: sdk.NewInt64Coin(dextypes.NewPoolDenom(0), 20), - tick: 1000, - expectation: math.NewInt(21), - }, - { - name: "two deposits: both relevant", - deposits: []depositSpec{ - { - addr: addrs[0], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - { - addr: addrs[0], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - }, - coin: sdk.NewInt64Coin(dextypes.NewPoolDenom(0), 20), - tick: 1000, - expectation: math.NewInt(21), - }, - } - for _, tc := range tests { - suite.T().Run(tc.name, func(t *testing.T) { - suite.SetupTest() - _ = suite.SetupDeposit(tc.deposits) - value, err := suite.App.IncentivesKeeper.ValueForShares(suite.Ctx, tc.coin, tc.tick) - if tc.err == nil { - require.NoError(t, err) - require.Equal(t, tc.expectation, value) - } else { - require.Error(t, err) - } - }) - } -} - -// TestDistribute tests that when the distribute command is executed on a provided gauge -// that the correct amount of rewards is sent to the correct stake owners. -func (suite *IncentivesTestSuite) TestDistribute() { - addrs := apptesting.SetupAddrs(3) - tests := []struct { - name string - addrs []sdk.AccAddress - depositStakeSpecs []depositStakeSpec - gaugeSpecs []gaugeSpec - assertions []balanceAssertion - }{ - { - name: "one gauge", - depositStakeSpecs: []depositStakeSpec{ - { - depositSpecs: []depositSpec{ - { - addr: addrs[0], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }, - { - depositSpecs: []depositSpec{ - { - addr: addrs[1], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }, - { - depositSpecs: []depositSpec{ - { - addr: addrs[1], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }, - }, - gaugeSpecs: []gaugeSpec{ - { - isPerpetual: false, - rewards: sdk.Coins{sdk.NewInt64Coin("reward", 3000)}, - startTick: -10, - endTick: 10, - paidOver: 1, - pricingTick: 0, - }, - }, - assertions: []balanceAssertion{ - {addr: addrs[0], balances: sdk.Coins{sdk.NewInt64Coin("reward", 1000)}}, - {addr: addrs[1], balances: sdk.Coins{sdk.NewInt64Coin("reward", 2000)}}, - }, - }, - { - name: "two gauges", - depositStakeSpecs: []depositStakeSpec{ - { - depositSpecs: []depositSpec{ - { - addr: addrs[0], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }, - { - depositSpecs: []depositSpec{ - { - addr: addrs[1], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }, - { - depositSpecs: []depositSpec{ - { - addr: addrs[1], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }, - { - depositSpecs: []depositSpec{ - { - addr: addrs[0], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - }, - stakeDistEpochOffset: -1, - }, - }, - gaugeSpecs: []gaugeSpec{ - { - isPerpetual: false, - rewards: sdk.Coins{sdk.NewInt64Coin("reward", 3000)}, - startTick: -10, - endTick: 10, - paidOver: 1, - pricingTick: 0, - }, - { - isPerpetual: false, - rewards: sdk.Coins{sdk.NewInt64Coin("reward", 3000)}, - startTick: -10, - endTick: 10, - paidOver: 2, - pricingTick: 0, - }, - }, - assertions: []balanceAssertion{ - {addr: addrs[0], balances: sdk.Coins{sdk.NewInt64Coin("reward", 1500)}}, - {addr: addrs[1], balances: sdk.Coins{sdk.NewInt64Coin("reward", 3000)}}, - }, - }, - { - name: "one stake with adjustment", - depositStakeSpecs: []depositStakeSpec{ - { - depositSpecs: []depositSpec{ - { - addr: addrs[0], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 999, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }, - { - depositSpecs: []depositSpec{ - { - addr: addrs[1], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 999, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }, - { - depositSpecs: []depositSpec{ - { - addr: addrs[1], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 999, - fee: 50, - }, - }, - stakeDistEpochOffset: -2, - }, - { - depositSpecs: []depositSpec{ - { - addr: addrs[1], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 999, - fee: 50, - }, - }, - stakeDistEpochOffset: -1, - }, - }, - gaugeSpecs: []gaugeSpec{ - { - isPerpetual: false, - rewards: sdk.Coins{sdk.NewInt64Coin("reward", 3000)}, - startTick: -1000, - endTick: 1000, - paidOver: 1, - pricingTick: 0, - }, - }, - assertions: []balanceAssertion{ - {addr: addrs[0], balances: sdk.Coins{sdk.NewInt64Coin("reward", 1500)}}, - {addr: addrs[1], balances: sdk.Coins{sdk.NewInt64Coin("reward", 1500)}}, - }, - }, - } - for _, tc := range tests { - suite.T().Run(tc.name, func(t *testing.T) { - suite.SetupTest() - for _, depositSpec := range tc.depositStakeSpecs { - suite.SetupDepositAndStake(depositSpec) - } - gauges := make(types.Gauges, len(tc.gaugeSpecs)) - for i, gaugeSpec := range tc.gaugeSpecs { - gauge := suite.SetupGauge(gaugeSpec) - gauges[i] = gauge - } - _, err := suite.App.IncentivesKeeper.Distribute(suite.Ctx, gauges) - require.NoError(t, err) - // check expected rewards against actual rewards received - for i, assertion := range tc.assertions { - bal := suite.App.BankKeeper.GetAllBalances(suite.Ctx, assertion.addr) - assert.Equal( - t, - assertion.balances.String(), - bal.String(), - "test %v, person %d", - tc.name, - i, - ) - } - }) - } -} diff --git a/x/incentives/keeper/distributor.go b/x/incentives/keeper/distributor.go deleted file mode 100644 index 46197d28d..000000000 --- a/x/incentives/keeper/distributor.go +++ /dev/null @@ -1,92 +0,0 @@ -package keeper - -import ( - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/neutron-org/neutron/x/incentives/types" -) - -type DistributorKeeper interface { - ValueForShares(ctx sdk.Context, coin sdk.Coin, tick int64) (math.Int, error) - GetStakesByQueryCondition(ctx sdk.Context, distrTo *types.QueryCondition) types.Stakes - StakeCoinsPassingQueryCondition(ctx sdk.Context, stake *types.Stake, distrTo types.QueryCondition) sdk.Coins -} - -type Distributor struct { - keeper DistributorKeeper -} - -func NewDistributor(keeper DistributorKeeper) Distributor { - return Distributor{ - keeper: keeper, - } -} - -func (d Distributor) Distribute( - ctx sdk.Context, - gauge *types.Gauge, - filterStakes types.Stakes, -) (types.DistributionSpec, error) { - if !gauge.IsActiveGauge(ctx.BlockTime()) { - return nil, types.ErrGaugeNotActive - } - - distSpec := types.DistributionSpec{} - - rewardsNextEpoch := gauge.RewardsNextEpoch() - - adjustedGaugeTotal := math.ZeroInt() - - gaugeStakes := d.keeper.GetStakesByQueryCondition(ctx, &gauge.DistributeTo) - if filterStakes == nil { - filterStakes = gaugeStakes - } - - stakeSumCache := make(map[uint64]math.Int, len(gaugeStakes)) - for _, stake := range gaugeStakes { - stakeCoins := d.keeper.StakeCoinsPassingQueryCondition(ctx, stake, gauge.DistributeTo) - stakeTotal := math.ZeroInt() - for _, stakeCoin := range stakeCoins { - adjustedPositionValue, err := d.keeper.ValueForShares(ctx, stakeCoin, gauge.PricingTick) - if err != nil { - return nil, err - } - stakeTotal = stakeTotal.Add(adjustedPositionValue) - } - adjustedGaugeTotal = adjustedGaugeTotal.Add(stakeTotal) - stakeSumCache[stake.ID] = stakeTotal - } - - if adjustedGaugeTotal.IsZero() { - return distSpec, nil - } - - for _, stake := range filterStakes { - stakeAmt := stakeSumCache[stake.ID] - distCoins := sdk.Coins{} - for _, epochRewards := range rewardsNextEpoch { - // distribution amount = gauge_size * denom_stake_amount / (total_denom_stake_amount * remain_epochs) - amount := sdk.NewDecFromInt(epochRewards.Amount). - Mul(sdk.NewDecFromInt(stakeAmt)). - Quo(sdk.NewDecFromInt(adjustedGaugeTotal)). - TruncateInt() - reward := sdk.Coin{Denom: epochRewards.Denom, Amount: amount} - distCoins = distCoins.Add(reward) - } - - // update the amount for that address - if distCoins.Empty() { - continue - } - - if spec, ok := distSpec[stake.Owner]; ok { - distSpec[stake.Owner] = spec.Add(distCoins...) - } else { - distSpec[stake.Owner] = distCoins - } - } - - gauge.DistributedCoins = gauge.DistributedCoins.Add(rewardsNextEpoch...) - gauge.FilledEpochs++ - return distSpec, nil -} diff --git a/x/incentives/keeper/distributor_test.go b/x/incentives/keeper/distributor_test.go deleted file mode 100644 index a9989c065..000000000 --- a/x/incentives/keeper/distributor_test.go +++ /dev/null @@ -1,144 +0,0 @@ -package keeper_test - -import ( - "testing" - time "time" - - "cosmossdk.io/math" - tmtypes "github.com/cometbft/cometbft/proto/tendermint/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/neutron-org/neutron/testutil" - dextypes "github.com/neutron-org/neutron/x/dex/types" - . "github.com/neutron-org/neutron/x/incentives/keeper" - "github.com/neutron-org/neutron/x/incentives/types" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -var _ DistributorKeeper = MockKeeper{} - -type MockKeeper struct { - stakes types.Stakes - keeper DistributorKeeper -} - -func NewMockKeeper(keeper DistributorKeeper, stakes types.Stakes) MockKeeper { - return MockKeeper{ - stakes: stakes, - keeper: keeper, - } -} - -func (k MockKeeper) ValueForShares(_ sdk.Context, coin sdk.Coin, _ int64) (math.Int, error) { - return coin.Amount.Mul(math.NewInt(2)), nil -} - -func (k MockKeeper) GetStakesByQueryCondition( - _ sdk.Context, - _ *types.QueryCondition, -) types.Stakes { - return k.stakes -} - -func (k MockKeeper) StakeCoinsPassingQueryCondition(ctx sdk.Context, stake *types.Stake, distrTo types.QueryCondition) sdk.Coins { - return k.keeper.StakeCoinsPassingQueryCondition(ctx, stake, distrTo) -} - -func TestDistributor(t *testing.T) { - app := testutil.Setup(t) - ctx := app.BaseApp.NewContext( - false, - tmtypes.Header{Height: 1, ChainID: "neutron-1", Time: time.Now().UTC()}, - ) - - gauge := types.NewGauge( - 1, - false, - types.QueryCondition{ - PairID: &dextypes.PairID{ - Token0: "TokenA", - Token1: "TokenB", - }, - StartTick: -10, - EndTick: 10, - }, - sdk.Coins{sdk.NewCoin("coin1", math.NewInt(100))}, - ctx.BlockTime(), - 10, - 0, - sdk.Coins{}, - 0, - ) - rewardPool, _ := app.DexKeeper.GetOrInitPool(ctx, &dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, 5, 1) - rewardedDenom := rewardPool.GetPoolDenom() - nonRewardPool, _ := app.DexKeeper.GetOrInitPool(ctx, &dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, 12, 1) - nonRewardedDenom := nonRewardPool.GetPoolDenom() - addr1 := sdk.AccAddress("addr1") - addr2 := sdk.AccAddress("addr2") - addr3 := sdk.AccAddress("addr3") - allStakes := types.Stakes{ - types.NewStake(1, addr1, sdk.Coins{sdk.NewCoin(rewardedDenom, math.NewInt(50))}, ctx.BlockTime(), 0), - types.NewStake(2, addr2, sdk.Coins{sdk.NewCoin(rewardedDenom, math.NewInt(25))}, ctx.BlockTime(), 0), - types.NewStake(3, addr2, sdk.Coins{sdk.NewCoin(rewardedDenom, math.NewInt(25))}, ctx.BlockTime(), 0), - types.NewStake(4, addr3, sdk.Coins{sdk.NewCoin(nonRewardedDenom, math.NewInt(50))}, ctx.BlockTime(), 0), - } - - distributor := NewDistributor(NewMockKeeper(app.IncentivesKeeper, allStakes)) - - testCases := []struct { - name string - timeOffset time.Duration - filterStakes types.Stakes - expected types.DistributionSpec - expectedErr error - }{ - { - name: "Error case: gauge not active", - timeOffset: -1 * time.Minute, - filterStakes: allStakes, - expected: nil, - expectedErr: types.ErrGaugeNotActive, - }, - { - name: "Successful case: distribute to all stakes", - timeOffset: 0, - filterStakes: allStakes, - expected: types.DistributionSpec{ - addr1.String(): sdk.Coins{sdk.NewCoin("coin1", math.NewInt(5))}, - addr2.String(): sdk.Coins{sdk.NewCoin("coin1", math.NewInt(4))}, - }, - expectedErr: nil, - }, - { - name: "Successful case: distribute to one stake", - timeOffset: 0, - filterStakes: types.Stakes{allStakes[0]}, - expected: types.DistributionSpec{ - addr1.String(): sdk.Coins{sdk.NewCoin("coin1", math.NewInt(5))}, - }, - expectedErr: nil, - }, - { - name: "No distribution: empty filterStakes", - filterStakes: types.Stakes{}, - expected: types.DistributionSpec{}, - expectedErr: nil, - }, - } - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - distSpec, err := distributor.Distribute( - ctx.WithBlockTime(ctx.BlockTime().Add(tc.timeOffset)), - &gauge, - tc.filterStakes, - ) - if tc.expectedErr != nil { - assert.Equal(t, tc.expectedErr, err) - } else { - require.NoError(t, err) - } - assert.Equal(t, tc.expected, distSpec) - }) - } -} diff --git a/x/incentives/keeper/export_test.go b/x/incentives/keeper/export_test.go deleted file mode 100644 index 71baec5fe..000000000 --- a/x/incentives/keeper/export_test.go +++ /dev/null @@ -1,44 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/neutron-org/neutron/x/incentives/types" -) - -// AddGaugeRefByKey appends the provided gauge ID into an array associated with the provided key. -func (k Keeper) AddRefByKey(ctx sdk.Context, key []byte, gaugeID uint64) error { - return k.addRefByKey(ctx, key, gaugeID) -} - -// DeleteGaugeRefByKey removes the provided gauge ID from an array associated with the provided key. -func (k Keeper) DeleteRefByKey(ctx sdk.Context, key []byte, guageID uint64) error { - return k.deleteRefByKey(ctx, key, guageID) -} - -// GetGaugeRefs returns the gauge IDs specified by the provided key. -func (k Keeper) GetRefs(ctx sdk.Context, key []byte) []uint64 { - return k.getRefs(ctx, key) -} - -// MoveUpcomingGaugeToActiveGauge moves a gauge that has reached it's start time from an upcoming to an active status. -func (k Keeper) MoveUpcomingGaugeToActiveGauge(ctx sdk.Context, gauge *types.Gauge) error { - return k.moveUpcomingGaugeToActiveGauge(ctx, gauge) -} - -// MoveActiveGaugeToFinishedGauge moves a gauge that has completed its distribution from an active to a finished status. -func (k Keeper) MoveActiveGaugeToFinishedGauge(ctx sdk.Context, gauge *types.Gauge) error { - return k.moveActiveGaugeToFinishedGauge(ctx, gauge) -} - -func (k Keeper) GetStakeRefKeys(ctx sdk.Context, stake *types.Stake) ([][]byte, error) { - return k.getStakeRefKeys(ctx, stake) -} - -func RemoveValue(ids []uint64, id uint64) ([]uint64, int) { - return removeValue(ids, id) -} - -func FindIndex(ids []uint64, id uint64) int { - return findIndex(ids, id) -} diff --git a/x/incentives/keeper/gas_test.go b/x/incentives/keeper/gas_test.go deleted file mode 100644 index c52c2abcf..000000000 --- a/x/incentives/keeper/gas_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package keeper_test - -// import ( -// sdk "github.com/cosmos/cosmos-sdk/types" -// ) - -// var ( -// defaultAddr sdk.AccAddress = sdk.AccAddress([]byte("addr1---------------")) -// defaultCoins sdk.Coins = sdk.Coins{sdk.NewInt64Coin("stake", 10)} -// ) - -// func (suite *KeeperTestSuite) measureStakeGas(addr sdk.AccAddress, coins sdk.Coins, dur time.Duration) uint64 { -// // fundAccount outside of gas measurement -// suite.FundAcc(addr, coins) -// // start measuring gas -// alreadySpent := suite.Ctx.GasMeter().GasConsumed() -// _, err := suite.App.IncentivesKeeper.CreateStake(suite.Ctx, addr, coins, dur) -// suite.Require().NoError(err) -// newSpent := suite.Ctx.GasMeter().GasConsumed() -// spentNow := newSpent - alreadySpent -// return spentNow -// } - -// func (suite *KeeperTestSuite) measureAvgAndMaxStakeGas( -// numIterations int, -// addr sdk.AccAddress, -// coinsFn func(int) sdk.Coins, -// durFn func(int) time.Duration, -// ) (avg uint64, maxGas uint64) { -// runningTotal := uint64(0) -// maxGas = uint64(0) -// for i := 1; i <= numIterations; i++ { -// stakeGas := suite.measureStakeGas(addr, coinsFn(i), durFn(i)) -// runningTotal += stakeGas -// if stakeGas > maxGas { -// maxGas = stakeGas -// // fmt.Println(suite.Ctx.GasMeter().String()) -// } -// } -// avg = runningTotal / uint64(numIterations) -// return avg, maxGas -// } - -// // This maintains hard coded gas test vector changes, -// // so we can easily track changes -// func (suite *KeeperTestSuite) TestRepeatedStakeTokensGas() { -// suite.SetupTest() - -// coinsFn := func(int) sdk.Coins { return defaultCoins } -// durFn := func(int) time.Duration { return time.Second } -// startAveragingAt := 1000 -// totalNumStakes := 10000 - -// firstStakeGasAmount := suite.measureStakeGas(defaultAddr, defaultCoins, time.Second) -// suite.Assert().LessOrEqual(int(firstStakeGasAmount), 100000) - -// for i := 1; i < startAveragingAt; i++ { -// suite.SetupStake(defaultAddr, defaultCoins) -// } -// avgGas, maxGas := suite.measureAvgAndMaxStakeGas(totalNumStakes-startAveragingAt, defaultAddr, coinsFn, durFn) -// fmt.Printf("test deets: total stakes created %d, begin average at %d\n", totalNumStakes, startAveragingAt) -// suite.Assert().LessOrEqual(int(avgGas), 100000, "average gas / stake") -// suite.Assert().LessOrEqual(int(maxGas), 100000, "max gas / stake") -// } - -// func (suite *KeeperTestSuite) TestRepeatedStakeTokensDistinctDurationGas() { -// suite.SetupTest() - -// coinsFn := func(int) sdk.Coins { return defaultCoins } -// durFn := func(i int) time.Duration { return time.Duration(i+1) * time.Second } -// totalNumStakes := 10000 - -// avgGas, maxGas := suite.measureAvgAndMaxStakeGas(totalNumStakes, defaultAddr, coinsFn, durFn) -// fmt.Printf("test deets: total stakes created %d\n", totalNumStakes) -// suite.Assert().LessOrEqual(int(avgGas), 150000, "average gas / stake") -// suite.Assert().LessOrEqual(int(maxGas), 300000, "max gas / stake") -// } diff --git a/x/incentives/keeper/gauge.go b/x/incentives/keeper/gauge.go deleted file mode 100644 index 180b3d101..000000000 --- a/x/incentives/keeper/gauge.go +++ /dev/null @@ -1,309 +0,0 @@ -package keeper - -import ( - "encoding/json" - "errors" - "fmt" - "time" - - db "github.com/cometbft/cometbft-db" - "github.com/cosmos/gogoproto/proto" - - dextypes "github.com/neutron-org/neutron/x/dex/types" - epochtypes "github.com/neutron-org/neutron/x/epochs/types" - "github.com/neutron-org/neutron/x/incentives/types" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// GetLastGaugeID returns the last used gauge ID. -func (k Keeper) GetLastGaugeID(ctx sdk.Context) uint64 { - store := ctx.KVStore(k.storeKey) - - bz := store.Get(types.KeyLastGaugeID) - if bz == nil { - return 0 - } - - return sdk.BigEndianToUint64(bz) -} - -// SetLastGaugeID sets the last used gauge ID to the provided ID. -func (k Keeper) SetLastGaugeID(ctx sdk.Context, id uint64) { - store := ctx.KVStore(k.storeKey) - store.Set(types.KeyLastGaugeID, sdk.Uint64ToBigEndian(id)) -} - -// getGaugesFromIterator iterates over everything in a gauge's iterator, until it reaches the end. Return all gauges iterated over. -func (k Keeper) getGaugesFromIterator(ctx sdk.Context, iterator db.Iterator) types.Gauges { - gauges := []*types.Gauge{} - defer iterator.Close() - for ; iterator.Valid(); iterator.Next() { - gaugeIDs := []uint64{} - err := json.Unmarshal(iterator.Value(), &gaugeIDs) - if err != nil { - panic(err) - } - for _, gaugeID := range gaugeIDs { - gauge, err := k.GetGaugeByID(ctx, gaugeID) - if err != nil { - panic(err) - } - gauges = append(gauges, gauge) - } - } - return gauges -} - -func (k Keeper) setGaugeRefs(ctx sdk.Context, gauge *types.Gauge) error { - switch { - case gauge.IsUpcomingGauge(ctx.BlockTime()): - if err := k.addRefByKey(ctx, types.CombineKeys(types.KeyPrefixGaugeIndexUpcoming, types.GetTimeKey(gauge.StartTime)), gauge.Id); err != nil { - return err - } - err := k.addRefByKey( - ctx, - types.GetKeyGaugeIndexByPair(gauge.DistributeTo.PairID.CanonicalString()), - gauge.Id, - ) - if err != nil { - return err - } - case gauge.IsActiveGauge(ctx.BlockTime()): - err := k.addRefByKey(ctx, types.CombineKeys(types.KeyPrefixGaugeIndexActive, types.GetTimeKey(gauge.StartTime)), gauge.Id) - if err != nil { - return err - } - err = k.addRefByKey(ctx, types.GetKeyGaugeIndexByPair(gauge.DistributeTo.PairID.CanonicalString()), gauge.Id) - if err != nil { - return err - } - default: // finished gauge - err := k.addRefByKey(ctx, types.CombineKeys(types.KeyPrefixGaugeIndexFinished, types.GetTimeKey(gauge.StartTime)), gauge.Id) - if err != nil { - return err - } - } - return nil -} - -// setGauge set the gauge inside store. -func (k Keeper) setGauge(ctx sdk.Context, gauge *types.Gauge) error { - store := ctx.KVStore(k.storeKey) - bz, err := proto.Marshal(gauge) - if err != nil { - return err - } - store.Set(types.GetKeyGaugeStore(gauge.Id), bz) - return nil -} - -// CreateGauge creates a gauge and sends coins to the gauge. -func (k Keeper) CreateGauge( - ctx sdk.Context, - isPerpetual bool, - owner sdk.AccAddress, - coins sdk.Coins, - distrTo types.QueryCondition, - startTime time.Time, - numEpochsPaidOver uint64, - pricingTick int64, -) (*types.Gauge, error) { - numGauges := k.GetLastGaugeID(ctx) - params := k.GetParams(ctx) - if params.MaxGauges < numGauges+1 { - return nil, types.ErrMaxGaugesReached - } - - // Perhaps overly defensive checks, these validations are also being performed - // in the ValidateBasic() for CreateGaugeMsg. - if dextypes.IsTickOutOfRange(pricingTick) { - return nil, types.ErrGaugePricingTickOutOfRange - } - - if dextypes.IsTickOutOfRange(distrTo.StartTick) { - return nil, types.ErrGaugeDistrToTickOutOfRange - } - - if dextypes.IsTickOutOfRange(distrTo.EndTick) { - return nil, types.ErrGaugeDistrToTickOutOfRange - } - - gauge := &types.Gauge{ - Id: numGauges + 1, - IsPerpetual: isPerpetual, - DistributeTo: distrTo, - Coins: coins, - StartTime: startTime, - NumEpochsPaidOver: numEpochsPaidOver, - // If this is outside the tick range then the distribution step will fail - PricingTick: pricingTick, - } - - if err := k.bk.SendCoinsFromAccountToModule(ctx, owner, types.ModuleName, gauge.Coins); err != nil { - return nil, err - } - - err := k.setGauge(ctx, gauge) - if err != nil { - return nil, err - } - - k.SetLastGaugeID(ctx, gauge.Id) - - err = k.setGaugeRefs(ctx, gauge) - if err != nil { - return nil, err - } - - k.hooks.AfterCreateGauge(ctx, gauge.Id) - return gauge, nil -} - -// AddToGaugeRewards adds coins to gauge. -func (k Keeper) AddToGaugeRewards( - ctx sdk.Context, - owner sdk.AccAddress, - coins sdk.Coins, - gaugeID uint64, -) error { - gauge, err := k.GetGaugeByID(ctx, gaugeID) - if err != nil { - return err - } - if gauge.IsFinishedGauge(ctx.BlockTime()) { - return errors.New("gauge is already completed") - } - if err := k.bk.SendCoinsFromAccountToModule(ctx, owner, types.ModuleName, coins); err != nil { - return err - } - - gauge.Coins = gauge.Coins.Add(coins...) - err = k.setGauge(ctx, gauge) - if err != nil { - return err - } - k.hooks.AfterAddToGauge(ctx, gauge.Id) - return nil -} - -// GetGaugeByID returns gauge from gauge ID. -func (k Keeper) GetGaugeByID(ctx sdk.Context, gaugeID uint64) (*types.Gauge, error) { - gauge := types.Gauge{} - store := ctx.KVStore(k.storeKey) - gaugeKey := types.GetKeyGaugeStore(gaugeID) - if !store.Has(gaugeKey) { - return nil, fmt.Errorf("gauge with ID %d does not exist", gaugeID) - } - bz := store.Get(gaugeKey) - if err := proto.Unmarshal(bz, &gauge); err != nil { - return nil, err - } - return &gauge, nil -} - -// GetGaugeQualifyingValue returns gauge qualifying value from gauge ID. -func (k Keeper) GetGaugeQualifyingValue(ctx sdk.Context, gaugeID uint64) (uint64, error) { - gauge := types.Gauge{} - store := ctx.KVStore(k.storeKey) - gaugeKey := types.GetKeyGaugeStore(gaugeID) - if !store.Has(gaugeKey) { - return 0, fmt.Errorf("gauge with ID %d does not exist", gaugeID) - } - bz := store.Get(gaugeKey) - if err := proto.Unmarshal(bz, &gauge); err != nil { - return 0, err - } - var value uint64 - stakes := k.GetStakesByQueryCondition(ctx, &gauge.DistributeTo) - for _, stake := range stakes { - stakeCoins := k.StakeCoinsPassingQueryCondition(ctx, stake, gauge.DistributeTo) - for _, stakeCoin := range stakeCoins { - adjustedPositionValue, err := k.ValueForShares(ctx, stakeCoin, gauge.PricingTick) - if err != nil { - return 0, err - } - value += value + adjustedPositionValue.Uint64() - } - } - return value, nil -} - -// GetGauges returns upcoming, active, and finished gauges. -func (k Keeper) GetGauges(ctx sdk.Context) types.Gauges { - return k.getGaugesFromIterator(ctx, k.iterator(ctx, types.KeyPrefixGaugeIndex)) -} - -// GetNotFinishedGauges returns both upcoming and active gauges. -func (k Keeper) GetNotFinishedGauges(ctx sdk.Context) types.Gauges { - return append(k.GetActiveGauges(ctx), k.GetUpcomingGauges(ctx)...) -} - -// GetEpochInfo returns EpochInfo struct given context. -func (k Keeper) GetEpochInfo(ctx sdk.Context) epochtypes.EpochInfo { - params := k.GetParams(ctx) - return k.ek.GetEpochInfo(ctx, params.DistrEpochIdentifier) -} - -// moveUpcomingGaugeToActiveGauge moves a gauge that has reached it's start time from an upcoming to an active status. -func (k Keeper) moveUpcomingGaugeToActiveGauge(ctx sdk.Context, gauge *types.Gauge) error { - // validation for current time and distribution start time - if ctx.BlockTime().Before(gauge.StartTime) { - return fmt.Errorf( - "gauge is not able to start distribution yet: %s >= %s", - ctx.BlockTime().String(), - gauge.StartTime.String(), - ) - } - - timeKey := types.GetTimeKey(gauge.StartTime) - if err := k.deleteRefByKey(ctx, types.CombineKeys(types.KeyPrefixGaugeIndexUpcoming, timeKey), gauge.Id); err != nil { - return err - } - - err := k.addRefByKey(ctx, types.CombineKeys(types.KeyPrefixGaugeIndexActive, timeKey), gauge.Id) - return err -} - -// moveActiveGaugeToFinishedGauge moves a gauge that has completed its distribution from an active to a finished status. -func (k Keeper) moveActiveGaugeToFinishedGauge(ctx sdk.Context, gauge *types.Gauge) error { - timeKey := types.GetTimeKey(gauge.StartTime) - if err := k.deleteRefByKey(ctx, types.CombineKeys(types.KeyPrefixGaugeIndexActive, timeKey), gauge.Id); err != nil { - return err - } - if err := k.addRefByKey(ctx, types.CombineKeys(types.KeyPrefixGaugeIndexFinished, timeKey), gauge.Id); err != nil { - return err - } - err := k.deleteRefByKey( - ctx, - types.GetKeyGaugeIndexByPair(gauge.DistributeTo.PairID.CanonicalString()), - gauge.Id, - ) - if err != nil { - return err - } - k.hooks.AfterFinishDistribution(ctx, gauge.Id) - return nil -} - -// GetActiveGauges returns active gauges. -func (k Keeper) GetActiveGauges(ctx sdk.Context) types.Gauges { - return k.getGaugesFromIterator(ctx, k.iterator(ctx, types.KeyPrefixGaugeIndexActive)) -} - -// GetUpcomingGauges returns upcoming gauges. -func (k Keeper) GetUpcomingGauges(ctx sdk.Context) types.Gauges { - return k.getGaugesFromIterator(ctx, k.iterator(ctx, types.KeyPrefixGaugeIndexUpcoming)) -} - -// GetFinishedGauges returns finished gauges. -func (k Keeper) GetFinishedGauges(ctx sdk.Context) types.Gauges { - return k.getGaugesFromIterator(ctx, k.iterator(ctx, types.KeyPrefixGaugeIndexFinished)) -} - -func (k Keeper) GetGaugesByPair(ctx sdk.Context, pair *dextypes.PairID) []*types.Gauge { - return k.getGaugesFromIterator( - ctx, - k.iterator(ctx, types.GetKeyGaugeIndexByPair(pair.CanonicalString())), - ) -} diff --git a/x/incentives/keeper/gauge_test.go b/x/incentives/keeper/gauge_test.go deleted file mode 100644 index ac8ae4396..000000000 --- a/x/incentives/keeper/gauge_test.go +++ /dev/null @@ -1,285 +0,0 @@ -package keeper_test - -import ( - "testing" - "time" - - "github.com/neutron-org/neutron/testutil/apptesting" - dextypes "github.com/neutron-org/neutron/x/dex/types" - "github.com/neutron-org/neutron/x/incentives/types" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var _ = suite.TestingSuite(nil) - -func (suite *IncentivesTestSuite) TestGaugeLifecycle() { - addr0 := suite.SetupAddr(0) - - // setup dex deposit and stake of those shares - suite.SetupDepositAndStake(depositStakeSpec{ - depositSpecs: []depositSpec{ - { - addr: addr0, - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }) - - // setup gauge starting 24 hours in the future - suite.SetupGauge(gaugeSpec{ - startTime: suite.Ctx.BlockTime().Add(24 * time.Hour), - isPerpetual: false, - rewards: sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10)), - paidOver: 2, - startTick: -10, - endTick: 10, - pricingTick: 0, - }) - - // assert that the gauge is not in effect yet by triggering an epoch end before gauge start - err := suite.App.IncentivesKeeper.AfterEpochEnd(suite.Ctx, "day") - require.NoError(suite.T(), err) - // no distribution yet - require.Equal( - suite.T(), - "0foocoin", - suite.App.BankKeeper.GetBalance(suite.Ctx, addr0, "foocoin").String(), - ) - // assert that gauge state is well-managed - require.Equal(suite.T(), len(suite.QueryServer.GetUpcomingGauges(suite.Ctx)), 1) - require.Equal(suite.T(), len(suite.QueryServer.GetActiveGauges(suite.Ctx)), 0) - require.Equal(suite.T(), len(suite.QueryServer.GetFinishedGauges(suite.Ctx)), 0) - - // advance time to epoch at or after the gauge starts, triggering distribution - suite.Ctx = suite.Ctx.WithBlockTime(suite.Ctx.BlockTime().Add(24 * time.Hour)) - err = suite.App.IncentivesKeeper.AfterEpochEnd(suite.Ctx, "day") - require.NoError(suite.T(), err) - - // assert that the gauge distributed - require.Equal( - suite.T(), - "5foocoin", - suite.App.BankKeeper.GetBalance(suite.Ctx, addr0, "foocoin").String(), - ) - // assert that gauge state is well-managed - require.Equal(suite.T(), len(suite.QueryServer.GetUpcomingGauges(suite.Ctx)), 0) - require.Equal(suite.T(), len(suite.QueryServer.GetActiveGauges(suite.Ctx)), 1) - require.Equal(suite.T(), len(suite.QueryServer.GetFinishedGauges(suite.Ctx)), 0) - - // advance to next epoch - suite.Ctx = suite.Ctx.WithBlockTime(suite.Ctx.BlockTime().Add(24 * time.Hour)) - err = suite.App.IncentivesKeeper.AfterEpochEnd(suite.Ctx, "day") - require.NoError(suite.T(), err) - - // assert new distribution - require.Equal( - suite.T(), - "10foocoin", - suite.App.BankKeeper.GetBalance(suite.Ctx, addr0, "foocoin").String(), - ) - // assert that gauge state is well-managed - require.Equal(suite.T(), len(suite.QueryServer.GetUpcomingGauges(suite.Ctx)), 0) - require.Equal(suite.T(), len(suite.QueryServer.GetActiveGauges(suite.Ctx)), 0) - require.Equal(suite.T(), len(suite.QueryServer.GetFinishedGauges(suite.Ctx)), 1) - - // repeat advancing to next epoch until gauge should be finished - suite.Ctx = suite.Ctx.WithBlockTime(suite.Ctx.BlockTime().Add(24 * time.Hour)) - err = suite.App.IncentivesKeeper.AfterEpochEnd(suite.Ctx, "day") - require.NoError(suite.T(), err) - - // assert no additional distribution from finished gauge - require.Equal( - suite.T(), - "10foocoin", - suite.App.BankKeeper.GetBalance(suite.Ctx, addr0, "foocoin").String(), - ) - // assert that gauge state is well-managed - require.Equal(suite.T(), len(suite.QueryServer.GetUpcomingGauges(suite.Ctx)), 0) - require.Equal(suite.T(), len(suite.QueryServer.GetActiveGauges(suite.Ctx)), 0) - require.Equal(suite.T(), len(suite.QueryServer.GetFinishedGauges(suite.Ctx)), 1) - // fin. -} - -func (suite *IncentivesTestSuite) TestGaugeLimit() { - // We set the gauge limit to 20. On the 21st gauge, we should encounter an error. - params := suite.App.IncentivesKeeper.GetParams(suite.Ctx) - params.MaxGauges = 20 - err := suite.App.IncentivesKeeper.SetParams(suite.Ctx, params) - suite.Require().NoError(err) - - addr0 := suite.SetupAddr(0) - - // setup dex deposit and stake of those shares - suite.SetupDepositAndStake(depositStakeSpec{ - depositSpecs: []depositSpec{ - { - addr: addr0, - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }) - - for i := 0; i < 20; i++ { - // setup gauge starting 24 hours in the future - suite.SetupGauge(gaugeSpec{ - startTime: suite.Ctx.BlockTime().Add(24 * time.Hour), - isPerpetual: false, - rewards: sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10)), - paidOver: 2, - startTick: -10, - endTick: 10, - pricingTick: 0, - }) - } - - addr := sdk.AccAddress([]byte("Gauge_Creation_Addr_")) - - // fund reward tokens - suite.FundAcc(addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10))) - - // create gauge - _, err = suite.App.IncentivesKeeper.CreateGauge( - suite.Ctx, - false, - addr, - sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10)), - types.QueryCondition{ - PairID: &dextypes.PairID{ - Token0: "TokenA", - Token1: "TokenB", - }, - StartTick: -10, - EndTick: 10, - }, - suite.Ctx.BlockTime().Add(24*time.Hour), - 2, - 0, - ) - suite.Require().Error(err) -} - -// TestGaugeCreateFails tests that when the distribute command is executed on a provided bad gauge -// that the step fails gracefully. -func (suite *IncentivesTestSuite) TestGaugeCreateFails() { - addrs := apptesting.SetupAddrs(3) - tests := []struct { - name string - addrs []sdk.AccAddress - depositStakeSpecs []depositStakeSpec - gaugeSpecs []gaugeSpec - assertions []balanceAssertion - }{ - { - name: "one stake with bad gauge", - depositStakeSpecs: []depositStakeSpec{ - { - depositSpecs: []depositSpec{ - { - addr: addrs[0], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 999, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }, - { - depositSpecs: []depositSpec{ - { - addr: addrs[1], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 999, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }, - { - depositSpecs: []depositSpec{ - { - addr: addrs[1], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 999, - fee: 50, - }, - }, - stakeDistEpochOffset: -2, - }, - { - depositSpecs: []depositSpec{ - { - addr: addrs[1], - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 999, - fee: 50, - }, - }, - stakeDistEpochOffset: -1, - }, - }, - gaugeSpecs: []gaugeSpec{ - { - isPerpetual: false, - rewards: sdk.Coins{sdk.NewInt64Coin("reward", 3000)}, - startTick: -1000, - endTick: 1000, - paidOver: 1, - pricingTick: 9999999, - }, - }, - assertions: []balanceAssertion{ - {addr: addrs[0], balances: sdk.Coins{sdk.NewInt64Coin("reward", 1500)}}, - {addr: addrs[1], balances: sdk.Coins{sdk.NewInt64Coin("reward", 1500)}}, - }, - }, - } - for _, tc := range tests { - suite.T().Run(tc.name, func(t *testing.T) { - suite.SetupTest() - for _, depositSpec := range tc.depositStakeSpecs { - suite.SetupDepositAndStake(depositSpec) - } - for _, s := range tc.gaugeSpecs { - addr := sdk.AccAddress([]byte("Gauge_Creation_Addr_")) - - // fund reward tokens - suite.FundAcc(addr, s.rewards) - - // create gauge - _, err := suite.App.IncentivesKeeper.CreateGauge( - suite.Ctx, - s.isPerpetual, - addr, - s.rewards, - types.QueryCondition{ - PairID: &dextypes.PairID{ - Token0: "TokenA", - Token1: "TokenB", - }, - StartTick: s.startTick, - EndTick: s.endTick, - }, - s.startTime, - s.paidOver, - s.pricingTick, - ) - require.Error(t, err) - } - }) - } -} diff --git a/x/incentives/keeper/genesis.go b/x/incentives/keeper/genesis.go deleted file mode 100644 index 710671120..000000000 --- a/x/incentives/keeper/genesis.go +++ /dev/null @@ -1,80 +0,0 @@ -package keeper - -import ( - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/neutron-org/neutron/x/incentives/types" -) - -// InitGenesis initializes the incentives module's state from a provided genesis state. -func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { - if err := k.SetParams(ctx, genState.Params); err != nil { - panic(err) - } - if err := k.InitializeAllStakes(ctx, genState.Stakes); err != nil { - panic(err) - } - if err := k.InitializeAllGauges(ctx, genState.Gauges); err != nil { - panic(err) - } - k.SetLastStakeID(ctx, genState.LastStakeId) - k.SetLastGaugeID(ctx, genState.LastGaugeId) - for _, accountHistory := range genState.AccountHistories { - err := k.SetAccountHistory(ctx, accountHistory) - if err != nil { - panic(err) - } - } -} - -// ExportGenesis returns the x/incentives module's exported genesis. -func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - return &types.GenesisState{ - Params: k.GetParams(ctx), - Gauges: k.GetNotFinishedGauges(ctx), - LastGaugeId: k.GetLastGaugeID(ctx), - LastStakeId: k.GetLastStakeID(ctx), - Stakes: k.GetStakes(ctx), - AccountHistories: k.GetAllAccountHistory(ctx), - } -} - -// InitializeAllStakes takes a set of stakes, and initializes state to be storing -// them all correctly. -func (k Keeper) InitializeAllStakes(ctx sdk.Context, stakes types.Stakes) error { - for i, stake := range stakes { - if i%25000 == 0 { - msg := fmt.Sprintf("Reset %d stake refs, cur stake ID %d", i, stake.ID) - ctx.Logger().Info(msg) - } - err := k.setStake(ctx, stake) - if err != nil { - return err - } - - err = k.addStakeRefs(ctx, stake) - if err != nil { - return err - } - } - - return nil -} - -// InitializeAllGauges takes a set of gauges, and initializes state to be storing -// them all correctly. -func (k Keeper) InitializeAllGauges(ctx sdk.Context, gauges types.Gauges) error { - for _, gauge := range gauges { - err := k.setGauge(ctx, gauge) - if err != nil { - return err - } - err = k.setGaugeRefs(ctx, gauge) - if err != nil { - return err - } - } - return nil -} diff --git a/x/incentives/keeper/genesis_test.go b/x/incentives/keeper/genesis_test.go deleted file mode 100644 index d1747b173..000000000 --- a/x/incentives/keeper/genesis_test.go +++ /dev/null @@ -1,57 +0,0 @@ -package keeper_test - -import ( - "time" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/neutron-org/neutron/testutil/apptesting" - "github.com/neutron-org/neutron/testutil/dex/nullify" - dextypes "github.com/neutron-org/neutron/x/dex/types" - "github.com/neutron-org/neutron/x/incentives/types" - "github.com/stretchr/testify/require" -) - -// TestIncentivesExportGenesis tests export genesis command for the incentives module. -func (suite *IncentivesTestSuite) TestGenesis() { - validAddr, _ := apptesting.GenerateTestAddrs() - genesisState := types.GenesisState{ - Params: types.DefaultParams(), - LastStakeId: 10, - Stakes: []*types.Stake{ - { - ID: 0, - Owner: validAddr, - StartTime: time.Time{}, - Coins: sdk.NewCoins(sdk.NewInt64Coin(suite.LPDenom0, 10)), - }, - }, - LastGaugeId: 10, - Gauges: []*types.Gauge{ - { - IsPerpetual: false, - Coins: sdk.Coins{sdk.NewInt64Coin("reward", 3000)}, - DistributeTo: types.QueryCondition{ - StartTick: -10, - EndTick: 10, - PairID: &dextypes.PairID{ - Token0: "TokenA", - Token1: "TokenB", - }, - }, - NumEpochsPaidOver: 1, - PricingTick: 0, - }, - }, - } - suite.App.IncentivesKeeper.InitGenesis(suite.Ctx, genesisState) - got := suite.App.IncentivesKeeper.ExportGenesis(suite.Ctx) - require.NotNil(suite.T(), got) - - nullify.Fill(&genesisState) - nullify.Fill(got) - - require.ElementsMatch(suite.T(), genesisState.Gauges, got.Gauges) - require.ElementsMatch(suite.T(), genesisState.Stakes, got.Stakes) - require.Equal(suite.T(), genesisState.LastStakeId, got.LastStakeId) - require.Equal(suite.T(), genesisState.LastGaugeId, got.LastGaugeId) -} diff --git a/x/incentives/keeper/hooks.go b/x/incentives/keeper/hooks.go deleted file mode 100644 index 6d8fb1911..000000000 --- a/x/incentives/keeper/hooks.go +++ /dev/null @@ -1,60 +0,0 @@ -package keeper - -import ( - epochstypes "github.com/neutron-org/neutron/x/epochs/types" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// BeforeEpochStart is the epoch start hook. -func (k Keeper) BeforeEpochStart(_ sdk.Context, _ string) error { - return nil -} - -// AfterEpochEnd is the epoch end hook. -func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string) error { - params := k.GetParams(ctx) - if epochIdentifier == params.DistrEpochIdentifier { - // begin distribution if it's start time - gauges := k.GetUpcomingGauges(ctx) - for _, gauge := range gauges { - if gauge.IsActiveGauge(ctx.BlockTime()) { - if err := k.moveUpcomingGaugeToActiveGauge(ctx, gauge); err != nil { - return err - } - } - } - - // distribute due to epoch event - gauges = k.GetActiveGauges(ctx) - _, err := k.Distribute(ctx, gauges) - if err != nil { - return err - } - } - return nil -} - -// ___________________________________________________________________________________________________ - -// Hooks is the wrapper struct for the incentives keeper. -type Hooks struct { - k Keeper -} - -var _ epochstypes.EpochHooks = Hooks{} - -// Hooks returns the hook wrapper struct. -func (k Keeper) Hooks() Hooks { - return Hooks{k} -} - -// BeforeEpochStart is the epoch start hook. -func (h Hooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string) error { - return h.k.BeforeEpochStart(ctx, epochIdentifier) -} - -// AfterEpochEnd is the epoch end hook. -func (h Hooks) AfterEpochEnd(ctx sdk.Context, epochIdentifier string) error { - return h.k.AfterEpochEnd(ctx, epochIdentifier) -} diff --git a/x/incentives/keeper/iterator.go b/x/incentives/keeper/iterator.go deleted file mode 100644 index 4fdaa3cc6..000000000 --- a/x/incentives/keeper/iterator.go +++ /dev/null @@ -1,58 +0,0 @@ -package keeper - -import ( - "encoding/json" - - db "github.com/cometbft/cometbft-db" - "github.com/neutron-org/neutron/x/incentives/types" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// iterator returns an iterator over all gauges in the {prefix} space of state. -func (k Keeper) iterator(ctx sdk.Context, prefix []byte) sdk.Iterator { - store := ctx.KVStore(k.storeKey) - return sdk.KVStorePrefixIterator(store, prefix) -} - -// iterator returns an iterator over all gauges in the {prefix} space of state. -func (k Keeper) iteratorStartEnd(ctx sdk.Context, start, end []byte) sdk.Iterator { - store := ctx.KVStore(k.storeKey) - return store.Iterator(start, end) -} - -func UnmarshalRefArray(bz []byte) []uint64 { - ids := []uint64{} - err := json.Unmarshal(bz, &ids) - if err != nil { - panic(err) - } - return ids -} - -// getStakesFromIterator returns an array of single stake units by period defined by the x/stake module. -func (k Keeper) getStakesFromIterator(ctx sdk.Context, iterator db.Iterator) types.Stakes { - stakes := types.Stakes{} - defer iterator.Close() - for ; iterator.Valid(); iterator.Next() { - stakeIDs := UnmarshalRefArray(iterator.Value()) - for _, stakeID := range stakeIDs { - stake, err := k.GetStakeByID(ctx, stakeID) - if err != nil { - panic(err) - } - stakes = append(stakes, stake) - } - } - return stakes -} - -func (k Keeper) getIDsFromIterator(iterator db.Iterator) []uint64 { - allIds := []uint64{} - defer iterator.Close() - for ; iterator.Valid(); iterator.Next() { - ids := UnmarshalRefArray(iterator.Value()) - allIds = append(allIds, ids...) - } - return allIds -} diff --git a/x/incentives/keeper/keeper.go b/x/incentives/keeper/keeper.go deleted file mode 100644 index f9fcfe12a..000000000 --- a/x/incentives/keeper/keeper.go +++ /dev/null @@ -1,77 +0,0 @@ -package keeper - -import ( - "fmt" - - "github.com/cometbft/cometbft/libs/log" - - "github.com/neutron-org/neutron/x/incentives/types" - - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// Keeper provides a way to manage incentives module storage. -type Keeper struct { - storeKey storetypes.StoreKey - hooks types.IncentiveHooks - ak types.AccountKeeper - bk types.BankKeeper - ek types.EpochKeeper - dk types.DexKeeper - distributor Distributor - authority string -} - -// NewKeeper returns a new instance of the incentive module keeper struct. -func NewKeeper( - storeKey storetypes.StoreKey, - ak types.AccountKeeper, - bk types.BankKeeper, - ek types.EpochKeeper, - dk types.DexKeeper, - authority string, -) *Keeper { - keeper := &Keeper{ - storeKey: storeKey, - ak: ak, - bk: bk, - ek: ek, - dk: dk, - authority: authority, - } - keeper.distributor = NewDistributor(keeper) - return keeper -} - -// SetHooks sets the incentives hooks. -func (k *Keeper) SetHooks(ih types.IncentiveHooks) *Keeper { - if k.hooks != nil { - panic("cannot set incentive hooks twice") - } - - k.hooks = ih - - return k -} - -// Logger returns a logger instance for the incentives module. -func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) -} - -// GetModuleBalance returns full balance of the module. -func (k Keeper) GetModuleBalance(ctx sdk.Context) sdk.Coins { - acc := k.ak.GetModuleAccount(ctx, types.ModuleName) - return k.bk.GetAllBalances(ctx, acc.GetAddress()) -} - -// GetModuleStakedCoins Returns staked balance of the module. -func (k Keeper) GetModuleStakedCoins(ctx sdk.Context) sdk.Coins { - // all not unstaking + not finished unstaking - return k.GetStakes(ctx).GetCoins() -} - -func (k Keeper) GetAuthority() string { - return k.authority -} diff --git a/x/incentives/keeper/keeper_test.go b/x/incentives/keeper/keeper_test.go deleted file mode 100644 index 6268a0516..000000000 --- a/x/incentives/keeper/keeper_test.go +++ /dev/null @@ -1,52 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/stretchr/testify/suite" - - "github.com/neutron-org/neutron/testutil/apptesting" - dextypes "github.com/neutron-org/neutron/x/dex/types" - "github.com/neutron-org/neutron/x/incentives/keeper" - "github.com/neutron-org/neutron/x/incentives/types" -) - -type IncentivesTestSuite struct { - apptesting.KeeperTestHelper - - QueryServer keeper.QueryServer - MsgServer types.MsgServer - LPDenom0 string - LPDenom1 string -} - -// SetupTest sets incentives parameters from the suite's context -func (suite *IncentivesTestSuite) SetupTest() { - suite.Setup() - suite.QueryServer = keeper.NewQueryServer(suite.App.IncentivesKeeper) - suite.MsgServer = keeper.NewMsgServerImpl(suite.App.IncentivesKeeper) - pool0, _ := suite.App.DexKeeper.GetOrInitPool(suite.Ctx, - &dextypes.PairID{ - Token0: "TokenA", - Token1: "TokenB", - }, - 0, - 1, - ) - suite.LPDenom0 = pool0.GetPoolDenom() - pool1, _ := suite.App.DexKeeper.GetOrInitPool(suite.Ctx, - &dextypes.PairID{ - Token0: "TokenA", - Token1: "TokenB", - }, - 1, - 1, - ) - suite.LPDenom1 = pool1.GetPoolDenom() - - suite.SetEpochStartTime() -} - -func TestIncentivesTestSuite(t *testing.T) { - suite.Run(t, new(IncentivesTestSuite)) -} diff --git a/x/incentives/keeper/msg_server.go b/x/incentives/keeper/msg_server.go deleted file mode 100644 index c0feb7306..000000000 --- a/x/incentives/keeper/msg_server.go +++ /dev/null @@ -1,199 +0,0 @@ -package keeper - -import ( - "context" - "fmt" - "strconv" - - "github.com/neutron-org/neutron/x/incentives/types" - - sdkerrors "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var _ types.MsgServer = msgServer{} - -// msgServer provides a way to reference keeper pointer in the message server interface. -type msgServer struct { - keeper *Keeper -} - -// NewMsgServerImpl returns an instance of MsgServer for the provided keeper. -func NewMsgServerImpl(keeper *Keeper) types.MsgServer { - return &msgServer{ - keeper: keeper, - } -} - -// CreateGauge creates a gauge and sends coins to the gauge. -// Emits create gauge event and returns the create gauge response. -func (server msgServer) CreateGauge( - goCtx context.Context, - msg *types.MsgCreateGauge, -) (*types.MsgCreateGaugeResponse, error) { - if server.keeper.authority != msg.Owner { - return nil, sdkerrors.Wrapf( - types.ErrInvalidSigner, - "invalid authority; expected %s, got %s", - server.keeper.authority, - msg.Owner, - ) - } - - ctx := sdk.UnwrapSDKContext(goCtx) - owner, err := sdk.AccAddressFromBech32(msg.Owner) - if err != nil { - return nil, err - } - - gauge, err := server.keeper.CreateGauge( - ctx, - msg.IsPerpetual, - owner, - msg.Coins, - msg.DistributeTo, - msg.StartTime, - msg.NumEpochsPaidOver, - msg.PricingTick, - ) - if err != nil { - return nil, sdkerrors.Wrap(types.ErrInvalidRequest, err.Error()) - } - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.TypeEvtCreateGauge, - sdk.NewAttribute(types.AttributeGaugeID, strconv.FormatUint(gauge.Id, 10)), - ), - }) - - return &types.MsgCreateGaugeResponse{}, nil -} - -// AddToGauge adds coins to gauge. -// Emits add to gauge event and returns the add to gauge response. -func (server msgServer) AddToGauge( - goCtx context.Context, - msg *types.MsgAddToGauge, -) (*types.MsgAddToGaugeResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - owner, err := sdk.AccAddressFromBech32(msg.Owner) - if err != nil { - return nil, err - } - - err = server.keeper.AddToGaugeRewards(ctx, owner, msg.Rewards, msg.GaugeId) - if err != nil { - return nil, sdkerrors.Wrap(types.ErrInvalidRequest, err.Error()) - } - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.TypeEvtAddToGauge, - sdk.NewAttribute(types.AttributeGaugeID, strconv.FormatUint(msg.GaugeId, 10)), - ), - }) - - return &types.MsgAddToGaugeResponse{}, nil -} - -// StakeTokens stakes tokens in either two ways. -// 1. Add to an existing stake if a stake with the same owner and same duration exists. -// 2. Create a new stake if not. -// A sanity check to ensure given tokens is a single token is done in ValidateBaic. -// That is, a stake with multiple tokens cannot be created. -func (server msgServer) Stake( - goCtx context.Context, - msg *types.MsgStake, -) (*types.MsgStakeResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - owner, err := sdk.AccAddressFromBech32(msg.Owner) - if err != nil { - return nil, err - } - - params := server.keeper.GetParams(ctx) - startDistEpoch := server.keeper.ek.GetEpochInfo(ctx, params.DistrEpochIdentifier).CurrentEpoch - - // if the owner + duration combination is new, create a new stake. - stake, err := server.keeper.CreateStake(ctx, owner, msg.Coins, ctx.BlockTime(), startDistEpoch) - if err != nil { - return nil, err - } - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.TypeEvtStake, - sdk.NewAttribute(types.AttributeStakeID, strconv.FormatUint(stake.ID, 10)), - sdk.NewAttribute(types.AttributeStakeOwner, stake.Owner), - sdk.NewAttribute(types.AttributeStakeAmount, stake.Coins.String()), - ), - }) - - return &types.MsgStakeResponse{ID: stake.ID}, nil -} - -// BeginUnstaking begins unstaking of the specified stake. -// The stake would enter the unstaking queue, with the endtime of the stake set as block time + duration. -func (server msgServer) Unstake( - goCtx context.Context, - msg *types.MsgUnstake, -) (*types.MsgUnstakeResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - unstakes := msg.Unstakes - if len(msg.Unstakes) == 0 { - stakes := server.keeper.GetStakesByAccount(ctx, sdk.AccAddress(msg.Owner)) - unstakes = make([]*types.MsgUnstake_UnstakeDescriptor, len(stakes)) - for i, stake := range stakes { - unstakes[i] = &types.MsgUnstake_UnstakeDescriptor{ - ID: stake.ID, - Coins: sdk.NewCoins(), - } - } - } - - for _, unstake := range unstakes { - stake, err := server.keeper.GetStakeByID(ctx, unstake.ID) - if err != nil { - return nil, sdkerrors.Wrap(types.ErrInvalidRequest, err.Error()) - } - - if msg.Owner != stake.Owner { - return nil, sdkerrors.Wrap( - types.ErrNotStakeOwner, - fmt.Sprintf( - "msg sender (%s) and stake owner (%s) does not match", - msg.Owner, - stake.Owner, - ), - ) - } - - _, err = server.keeper.Unstake(ctx, stake, unstake.Coins) - if err != nil { - return nil, sdkerrors.Wrap(types.ErrInvalidRequest, err.Error()) - } - } - - // N.B. begin unstake event is emitted downstream in the keeper method. - return &types.MsgUnstakeResponse{}, nil -} - -func (server msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { - if err := req.ValidateBasic(); err != nil { - return nil, err - } - authority := server.keeper.GetAuthority() - if authority != req.Authority { - return nil, sdkerrors.Wrapf(types.ErrInvalidRequest, "invalid authority; expected %s, got %s", authority, req.Authority) - } - - ctx := sdk.UnwrapSDKContext(goCtx) - if err := server.keeper.SetParams(ctx, req.Params); err != nil { - return nil, err - } - - return &types.MsgUpdateParamsResponse{}, nil -} diff --git a/x/incentives/keeper/params.go b/x/incentives/keeper/params.go deleted file mode 100644 index 9a684f11c..000000000 --- a/x/incentives/keeper/params.go +++ /dev/null @@ -1,34 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/gogoproto/proto" - "github.com/neutron-org/neutron/x/incentives/types" -) - -// GetParams returns all of the parameters in the incentive module. -func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.KeyParams) - if bz == nil { - return params - } - - if err := proto.Unmarshal(bz, ¶ms); err != nil { - panic(err) - } - - return params -} - -// SetParams sets all of the parameters in the incentive module. -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { - store := ctx.KVStore(k.storeKey) - bz, err := proto.Marshal(¶ms) - if err != nil { - return err - } - - store.Set(types.KeyParams, bz) - return nil -} diff --git a/x/incentives/keeper/query_server.go b/x/incentives/keeper/query_server.go deleted file mode 100644 index 4d2426ca8..000000000 --- a/x/incentives/keeper/query_server.go +++ /dev/null @@ -1,267 +0,0 @@ -package keeper - -import ( - "context" - "encoding/json" - - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - sdkerrors "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - - dextypes "github.com/neutron-org/neutron/x/dex/types" - "github.com/neutron-org/neutron/x/incentives/types" -) - -var _ types.QueryServer = QueryServer{} - -// QueryServer defines a wrapper around the incentives module keeper providing gRPC method handlers. -type QueryServer struct { - *Keeper -} - -// NewQueryServer creates a new QueryServer struct. -func NewQueryServer(k *Keeper) QueryServer { - return QueryServer{Keeper: k} -} - -func (q QueryServer) GetModuleStatus( - goCtx context.Context, - _ *types.GetModuleStatusRequest, -) (*types.GetModuleStatusResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - return &types.GetModuleStatusResponse{ - RewardCoins: q.Keeper.GetModuleCoinsToBeDistributed(ctx), - StakedCoins: q.Keeper.GetModuleStakedCoins(ctx), - Params: q.Keeper.GetParams(ctx), - }, nil -} - -func (q QueryServer) GetGaugeByID( - goCtx context.Context, - req *types.GetGaugeByIDRequest, -) (*types.GetGaugeByIDResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - gauge, err := q.Keeper.GetGaugeByID(ctx, req.Id) - if err != nil { - return nil, err - } - return &types.GetGaugeByIDResponse{Gauge: gauge}, nil -} - -func (q QueryServer) GetGaugeQualifyingValue( - goCtx context.Context, - req *types.GetGaugeQualifyingValueRequest, -) (*types.GetGaugeQualifyingValueResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - value, err := q.Keeper.GetGaugeQualifyingValue(ctx, req.Id) - if err != nil { - return nil, err - } - return &types.GetGaugeQualifyingValueResponse{QualifyingValue: value}, nil -} - -func (q QueryServer) GetGauges( - goCtx context.Context, - req *types.GetGaugesRequest, -) (*types.GetGaugesResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - ctx := sdk.UnwrapSDKContext(goCtx) - - var prefix []byte - switch req.Status { - case types.GaugeStatus_ACTIVE_UPCOMING: - prefix = types.KeyPrefixGaugeIndex - case types.GaugeStatus_ACTIVE: - prefix = types.KeyPrefixGaugeIndexActive - case types.GaugeStatus_UPCOMING: - prefix = types.KeyPrefixGaugeIndexUpcoming - case types.GaugeStatus_FINISHED: - prefix = types.KeyPrefixGaugeIndexFinished - default: - return nil, sdkerrors.Wrap(types.ErrInvalidRequest, "invalid status filter value") - } - - var lowerTick, upperTick int64 - var poolMetadata *dextypes.PoolMetadata - if req.Denom != "" { - poolMetadata, err := q.dk.GetPoolMetadataByDenom(ctx, req.Denom) - if err != nil { - return nil, err - } - lowerTick = poolMetadata.Tick - int64(poolMetadata.Fee) - upperTick = poolMetadata.Tick + int64(poolMetadata.Fee) - } - - gauges := types.Gauges{} - store := ctx.KVStore(q.Keeper.storeKey) - iterator := sdk.KVStorePrefixIterator(store, prefix) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - // this may return multiple gauges at once if two gauges start at the same time. - // for now this is treated as an edge case that is not of importance - newGauges, err := q.getGaugeFromIDJsonBytes(ctx, iterator.Value()) - if err != nil { - return nil, err - } - if req.Denom != "" { - for _, gauge := range newGauges { - if *gauge.DistributeTo.PairID != *poolMetadata.PairID { - continue - } - lowerTickInRange := gauge.DistributeTo.StartTick <= lowerTick && - lowerTick <= gauge.DistributeTo.EndTick - upperTickInRange := gauge.DistributeTo.StartTick <= upperTick && - upperTick <= gauge.DistributeTo.EndTick - if !lowerTickInRange || !upperTickInRange { - continue - } - gauges = append(gauges, gauge) - } - } else { - gauges = append(gauges, newGauges...) - } - } - - return &types.GetGaugesResponse{ - Gauges: gauges, - }, nil -} - -func (q QueryServer) GetStakeByID( - goCtx context.Context, - req *types.GetStakeByIDRequest, -) (*types.GetStakeByIDResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - ctx := sdk.UnwrapSDKContext(goCtx) - stake, err := q.Keeper.GetStakeByID(ctx, req.StakeId) - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - return &types.GetStakeByIDResponse{Stake: stake}, nil -} - -func (q QueryServer) GetStakes( - goCtx context.Context, - req *types.GetStakesRequest, -) (*types.GetStakesResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - hasOwner := len(req.Owner) > 0 - if !hasOwner { - // TODO: Verify this protection is necessary - return nil, status.Error( - codes.InvalidArgument, - "for performance reasons will not return all stakes", - ) - } - - owner, err := sdk.AccAddressFromBech32(req.Owner) - if err != nil { - return nil, err - } - - stakes := q.Keeper.getStakesByAccount(ctx, owner) - return &types.GetStakesResponse{ - Stakes: stakes, - }, nil -} - -func (q QueryServer) GetFutureRewardEstimate( - goCtx context.Context, - req *types.GetFutureRewardEstimateRequest, -) (*types.GetFutureRewardEstimateResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - if len(req.Owner) == 0 && len(req.StakeIds) == 0 { - return nil, sdkerrors.Wrap(types.ErrInvalidRequest, "empty owner") - } - - if req.NumEpochs > 365 { - return nil, sdkerrors.Wrap(types.ErrInvalidRequest, "end epoch out of ranges") - } - - var ownerAddress sdk.AccAddress - if len(req.Owner) != 0 { - owner, err := sdk.AccAddressFromBech32(req.Owner) - if err != nil { - return nil, err - } - ownerAddress = owner - } - - stakes := make(types.Stakes, 0, len(req.StakeIds)) - for _, stakeID := range req.StakeIds { - stake, err := q.Keeper.GetStakeByID(ctx, stakeID) - if err != nil { - return nil, err - } - stakes = append(stakes, stake) - } - - rewards, err := q.Keeper.GetRewardsEstimate(ctx, ownerAddress, stakes, req.NumEpochs) - if err != nil { - return nil, err - } - return &types.GetFutureRewardEstimateResponse{Coins: rewards}, nil -} - -func (q QueryServer) GetAccountHistory( - goCtx context.Context, - req *types.GetAccountHistoryRequest, -) (*types.GetAccountHistoryResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - ctx := sdk.UnwrapSDKContext(goCtx) - accountHistory, found := q.Keeper.GetAccountHistory(ctx, req.Account) - if !found { - return nil, status.Error( - codes.NotFound, - "Could not locate an account history with that address", - ) - } - return &types.GetAccountHistoryResponse{Coins: accountHistory.Coins}, nil -} - -// getGaugeFromIDJsonBytes returns gauges from the json bytes of gaugeIDs. -func (q QueryServer) getGaugeFromIDJsonBytes( - ctx sdk.Context, - refValue []byte, -) (types.Gauges, error) { - gauges := types.Gauges{} - gaugeIDs := []uint64{} - - err := json.Unmarshal(refValue, &gaugeIDs) - if err != nil { - return gauges, err - } - - for _, gaugeID := range gaugeIDs { - gauge, err := q.Keeper.GetGaugeByID(ctx, gaugeID) - if err != nil { - return types.Gauges{}, err - } - - gauges = append(gauges, gauge) - } - - return gauges, nil -} diff --git a/x/incentives/keeper/query_server_test.go b/x/incentives/keeper/query_server_test.go deleted file mode 100644 index 953c67876..000000000 --- a/x/incentives/keeper/query_server_test.go +++ /dev/null @@ -1,126 +0,0 @@ -package keeper_test - -import ( - "time" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/neutron-org/neutron/x/incentives/types" - "github.com/stretchr/testify/suite" -) - -var _ = suite.TestingSuite(nil) - -func (suite *IncentivesTestSuite) TestGetFutureRewardEstimate() { - addr1 := suite.SetupAddr(0) - suite.SetupDepositAndStake(depositStakeSpec{ - depositSpecs: []depositSpec{ - { - addr: addr1, - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }) - addr2 := suite.SetupAddr(1) - suite.SetupDepositAndStake(depositStakeSpec{ - depositSpecs: []depositSpec{ - { - addr: addr2, - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }) - suite.SetupGauge(gaugeSpec{ - isPerpetual: false, - rewards: sdk.NewCoins(sdk.NewInt64Coin("foocoin", 1000)), - paidOver: 100, - startTick: -10, - endTick: 10, - pricingTick: 0, - startTime: suite.Ctx.BlockTime(), - }) - suite.SetupGauge(gaugeSpec{ - isPerpetual: false, - rewards: sdk.NewCoins(sdk.NewInt64Coin("foocoin", 1000)), - paidOver: 100, - startTick: -10, - endTick: 10, - pricingTick: 0, - startTime: suite.Ctx.BlockTime().Add(315 * 24 * time.Hour), - }) - estimate, err := suite.QueryServer.GetFutureRewardEstimate( - suite.GoCtx, - &types.GetFutureRewardEstimateRequest{ - Owner: addr1.String(), - StakeIds: nil, - NumEpochs: 365, - }, - ) - suite.Require().NoError(err) - suite.Require().Equal(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 750)), estimate.Coins) -} - -func (suite *IncentivesTestSuite) TestGetGauges() { - addr1 := suite.SetupAddr(0) - suite.SetupDepositAndStake(depositStakeSpec{ - depositSpecs: []depositSpec{ - { - addr: addr1, - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }) - addr2 := suite.SetupAddr(1) - suite.SetupDepositAndStake(depositStakeSpec{ - depositSpecs: []depositSpec{ - { - addr: addr2, - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }) - gauge1 := suite.SetupGauge(gaugeSpec{ - isPerpetual: false, - rewards: sdk.NewCoins(sdk.NewInt64Coin("foocoin", 1000)), - paidOver: 100, - startTick: -10, - endTick: 10, - pricingTick: 0, - startTime: suite.Ctx.BlockTime(), - }) - gauge2 := suite.SetupGauge(gaugeSpec{ - isPerpetual: false, - rewards: sdk.NewCoins(sdk.NewInt64Coin("foocoin", 1000)), - paidOver: 100, - startTick: -10, - endTick: 10, - pricingTick: 0, - startTime: suite.Ctx.BlockTime().Add(315 * 24 * time.Hour), - }) - - response, err := suite.QueryServer.GetGauges(suite.GoCtx, &types.GetGaugesRequest{ - Status: types.GaugeStatus_ACTIVE_UPCOMING, - Denom: "", - }) - - suite.Require().NoError(err) - suite.Require().Equal([]*types.Gauge{ - gauge2, - gauge1, - }, response.Gauges) -} diff --git a/x/incentives/keeper/stake.go b/x/incentives/keeper/stake.go deleted file mode 100644 index 90ef98fb4..000000000 --- a/x/incentives/keeper/stake.go +++ /dev/null @@ -1,249 +0,0 @@ -package keeper - -import ( - "fmt" - "strconv" - "time" - - sdkerrors "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/gogoproto/proto" - - "github.com/neutron-org/neutron/x/incentives/types" -) - -// GetLastStakeID returns ID used last time. -func (k Keeper) GetLastStakeID(ctx sdk.Context) uint64 { - store := ctx.KVStore(k.storeKey) - - bz := store.Get(types.KeyLastStakeID) - if bz == nil { - return 0 - } - - return sdk.BigEndianToUint64(bz) -} - -// SetLastStakeID save ID used by last stake. -func (k Keeper) SetLastStakeID(ctx sdk.Context, id uint64) { - store := ctx.KVStore(k.storeKey) - store.Set(types.KeyLastStakeID, sdk.Uint64ToBigEndian(id)) -} - -func (k Keeper) Unstake(ctx sdk.Context, stake *types.Stake, coins sdk.Coins) (uint64, error) { - if coins.Empty() { - coins = stake.Coins - } - - if !coins.IsAllLTE(stake.Coins) { - return 0, fmt.Errorf("requested amount to unstake exceeds locked tokens") - } - - // remove existing stake refs from not unlocking queue - err := k.deleteStakeRefs(ctx, stake) - if err != nil { - return 0, err - } - - if len(coins) != 0 && !coins.IsEqual(stake.Coins) { - stake.Coins = stake.Coins.Sub(coins...) - err := k.setStake(ctx, stake) - if err != nil { - return 0, err - } - - // re-add remaining stake refs - err = k.addStakeRefs(ctx, stake) - if err != nil { - return 0, err - } - } else { - k.deleteStake(ctx, stake.ID) - } - - err = k.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, stake.OwnerAddress(), coins) - if err != nil { - return 0, err - } - - if k.hooks != nil { - k.hooks.OnTokenUnstaked(ctx, stake.OwnerAddress(), stake.ID, stake.Coins, ctx.BlockTime()) - } - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.TypeEvtUnstake, - sdk.NewAttribute(types.AttributeStakeID, strconv.FormatUint(stake.ID, 10)), - sdk.NewAttribute(types.AttributeStakeOwner, stake.Owner), - sdk.NewAttribute(types.AttributeStakeStakeTime, stake.StartTime.String()), - sdk.NewAttribute(types.AttributeUnstakedCoins, coins.String()), - ), - }) - - return stake.ID, err -} - -// setStake is a utility to store stake object into the store. -func (k Keeper) setStake(ctx sdk.Context, stake *types.Stake) error { - store := ctx.KVStore(k.storeKey) - bz, err := proto.Marshal(stake) - if err != nil { - return err - } - store.Set(types.GetStakeStoreKey(stake.ID), bz) - return nil -} - -// deleteStake removes the stake object from the state. -func (k Keeper) deleteStake(ctx sdk.Context, id uint64) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.GetStakeStoreKey(id)) -} - -// GetStakeByID Returns stake from stakeID. -func (k Keeper) GetStakeByID(ctx sdk.Context, stakeID uint64) (*types.Stake, error) { - stake := types.Stake{} - store := ctx.KVStore(k.storeKey) - lockKey := types.GetStakeStoreKey(stakeID) - if !store.Has(lockKey) { - return nil, sdkerrors.Wrap( - types.ErrStakeNotFound, - fmt.Sprintf("stake with ID %d does not exist", stakeID), - ) - } - bz := store.Get(lockKey) - err := proto.Unmarshal(bz, &stake) - return &stake, err -} - -// GetAccountStakes Returns the period locks associated to an account. -func (k Keeper) GetStakesByQueryCondition( - ctx sdk.Context, - distrTo *types.QueryCondition, -) types.Stakes { - pairIDString := distrTo.PairID.CanonicalString() - tickStakeIds := k.getIDsFromIterator( - k.iteratorStartEnd( - ctx, - types.GetKeyStakeIndexByPairTick(pairIDString, distrTo.StartTick), - types.GetKeyStakeIndexByPairTick(pairIDString, distrTo.EndTick+1), - ), - ) - - idMemo := make(map[uint64]bool) - for _, id := range tickStakeIds { - idMemo[id] = true - } - - params := k.GetParams(ctx) - curEpoch := k.ek.GetEpochInfo(ctx, params.GetDistrEpochIdentifier()) - timeStakeIds := k.getIDsFromIterator( - k.iteratorStartEnd( - ctx, - types.CombineKeys( - types.KeyPrefixStakeIndexPairDistEpoch, - []byte(pairIDString), - ), - sdk.PrefixEndBytes(types.GetKeyStakeIndexByDistEpoch( - pairIDString, - curEpoch.CurrentEpoch-2, - )), - ), - ) - - resultIds := []uint64{} - for _, id := range timeStakeIds { - if _, ok := idMemo[id]; ok { - resultIds = append(resultIds, id) - } - } - - results := make([]*types.Stake, len(resultIds)) - for i, stakeID := range resultIds { - stake, err := k.GetStakeByID(ctx, stakeID) - if err != nil { - // This represents a db inconsistency - panic(err) - } - results[i] = stake - } - return results -} - -func (k Keeper) GetStakes(ctx sdk.Context) types.Stakes { - return k.getStakesFromIterator(ctx, k.iterator(ctx, types.KeyPrefixStakeIndex)) -} - -func (k Keeper) getStakesByAccount(ctx sdk.Context, acct sdk.AccAddress) types.Stakes { - return k.getStakesFromIterator(ctx, k.iterator(ctx, types.GetKeyStakeIndexByAccount(acct))) -} - -// GetAccountStakes Returns the period locks associated to an account. -func (k Keeper) GetStakesByAccount(ctx sdk.Context, addr sdk.AccAddress) types.Stakes { - return k.getStakesFromIterator(ctx, k.iterator(ctx, types.GetKeyStakeIndexByAccount(addr))) -} - -func (k Keeper) CreateStake( - ctx sdk.Context, - owner sdk.AccAddress, - coins sdk.Coins, - startTime time.Time, - startDistEpoch int64, -) (*types.Stake, error) { - ID := k.GetLastStakeID(ctx) + 1 - - // unlock time is initially set without a value, gets set as unlock start time + duration - // when unlocking starts. - stake := types.NewStake(ID, owner, coins, startTime, startDistEpoch) - - owner, err := sdk.AccAddressFromBech32(stake.Owner) - if err != nil { - return nil, sdkerrors.Wrap(types.ErrInvalidRequest, err.Error()) - } - - err = stake.ValidateBasic() - if err != nil { - return nil, sdkerrors.Wrap(types.ErrInvalidRequest, err.Error()) - } - - if err := k.bk.SendCoinsFromAccountToModule(ctx, owner, types.ModuleName, stake.Coins); err != nil { - return nil, sdkerrors.Wrap(types.ErrInvalidRequest, err.Error()) - } - - // store stake object into the store - err = k.setStake(ctx, stake) - if err != nil { - return nil, sdkerrors.Wrap(types.ErrInvalidRequest, err.Error()) - } - - k.hooks.OnTokenStaked(ctx, owner, stake.ID, stake.Coins, ctx.BlockTime()) - k.SetLastStakeID(ctx, stake.ID) - - // add stake refs into not unlocking queue - err = k.addStakeRefs(ctx, stake) - if err != nil { - return nil, sdkerrors.Wrap(types.ErrInvalidRequest, err.Error()) - } - - return stake, nil -} - -func (k Keeper) StakeCoinsPassingQueryCondition( - ctx sdk.Context, - stake *types.Stake, - distrTo types.QueryCondition, -) sdk.Coins { - coins := stake.Coins - result := sdk.NewCoins() - for _, c := range coins { - poolMetadata, err := k.dk.GetPoolMetadataByDenom(ctx, c.Denom) - if err != nil { - continue - } - - if distrTo.Test(poolMetadata) { - result = result.Add(c) - } - } - return result -} diff --git a/x/incentives/keeper/stake_refs.go b/x/incentives/keeper/stake_refs.go deleted file mode 100644 index 93d9c66d5..000000000 --- a/x/incentives/keeper/stake_refs.go +++ /dev/null @@ -1,72 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - dextypes "github.com/neutron-org/neutron/x/dex/types" - "github.com/neutron-org/neutron/x/incentives/types" -) - -// addStakeRefs adds appropriate reference keys preceded by a prefix. -// A prefix indicates whether the stake is unstaking or not. -func (k Keeper) addStakeRefs(ctx sdk.Context, stake *types.Stake) error { - refKeys, err := k.getStakeRefKeys(ctx, stake) - if err != nil { - return err - } - for _, refKey := range refKeys { - if err := k.addRefByKey(ctx, refKey, stake.ID); err != nil { - return err - } - } - return nil -} - -// deleteStakeRefs deletes all the stake references of the stake with the given stake prefix. -func (k Keeper) deleteStakeRefs(ctx sdk.Context, stake *types.Stake) error { - refKeys, err := k.getStakeRefKeys(ctx, stake) - if err != nil { - return err - } - for _, refKey := range refKeys { - err = k.deleteRefByKey(ctx, refKey, stake.ID) - if err != nil { - return err - } - } - return nil -} - -func (k Keeper) getStakeRefKeys(ctx sdk.Context, stake *types.Stake) ([][]byte, error) { - owner, err := sdk.AccAddressFromBech32(stake.Owner) - if err != nil { - return nil, err - } - - refKeys := make(map[string]bool) - refKeys[string(types.KeyPrefixStakeIndex)] = true - refKeys[string(types.CombineKeys(types.KeyPrefixStakeIndexAccount, owner))] = true - - for _, coin := range stake.Coins { - poolMetadata, err := k.dk.GetPoolMetadataByDenom(ctx, coin.Denom) - if err != nil { - panic("Only valid LP tokens should be staked") - } - denomBz := []byte(coin.Denom) - pairIDBz := []byte(poolMetadata.PairID.CanonicalString()) - tickBz := dextypes.TickIndexToBytes(poolMetadata.Tick) - refKeys[string(types.CombineKeys(types.KeyPrefixStakeIndexDenom, denomBz))] = true - refKeys[string(types.CombineKeys(types.KeyPrefixStakeIndexPairTick, pairIDBz, tickBz))] = true - refKeys[string(types.CombineKeys(types.KeyPrefixStakeIndexAccountDenom, owner, denomBz))] = true - refKeys[string(types.CombineKeys( - types.KeyPrefixStakeIndexPairDistEpoch, - pairIDBz, - types.GetKeyInt64(stake.StartDistEpoch), - ))] = true - } - - refKeyBytes := make([][]byte, 0, len(refKeys)) - for k := range refKeys { - refKeyBytes = append(refKeyBytes, []byte(k)) - } - return refKeyBytes, nil -} diff --git a/x/incentives/keeper/stake_test.go b/x/incentives/keeper/stake_test.go deleted file mode 100644 index d39cda26e..000000000 --- a/x/incentives/keeper/stake_test.go +++ /dev/null @@ -1,122 +0,0 @@ -package keeper_test - -import ( - "github.com/stretchr/testify/suite" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var _ = suite.TestingSuite(nil) - -func (suite *IncentivesTestSuite) TestStakeLifecycle() { - addr0 := suite.SetupAddr(0) - - // setup dex deposit and stake of those shares - stake := suite.SetupDepositAndStake(depositStakeSpec{ - depositSpecs: []depositSpec{ - { - addr: addr0, - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }) - - retrievedStake, err := suite.App.IncentivesKeeper.GetStakeByID(suite.Ctx, stake.ID) - suite.Require().NoError(err) - suite.Require().NotNil(retrievedStake) - - // unstake the full amount - _, err = suite.App.IncentivesKeeper.Unstake(suite.Ctx, stake, sdk.Coins{}) - suite.Require().NoError(err) - balances := suite.App.BankKeeper.GetAllBalances(suite.Ctx, addr0) - suite.Require().Equal(sdk.NewCoins(sdk.NewInt64Coin(suite.LPDenom0, 2000)), balances) - _, err = suite.App.IncentivesKeeper.GetStakeByID(suite.Ctx, stake.ID) - // should be deleted - suite.Require().Error(err) -} - -func (suite *IncentivesTestSuite) TestMultipleStakeLifecycle() { - addr0 := suite.SetupAddr(0) - - // setup dex deposit and stake of those shares - stake := suite.SetupDepositAndStake(depositStakeSpec{ - depositSpecs: []depositSpec{ - { - addr: addr0, - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - { - addr: addr0, - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 1, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }) - - retrievedStake, err := suite.App.IncentivesKeeper.GetStakeByID(suite.Ctx, stake.ID) - suite.Require().NoError(err) - suite.Require().NotNil(retrievedStake) - - // unstake the full amount - _, err = suite.App.IncentivesKeeper.Unstake(suite.Ctx, stake, sdk.Coins{}) - suite.Require().NoError(err) - balances := suite.App.BankKeeper.GetAllBalances(suite.Ctx, addr0) - suite.Require().Equal( - sdk.NewCoins( - sdk.NewInt64Coin(suite.LPDenom0, 2000), - sdk.NewInt64Coin(suite.LPDenom1, 2000), - ), balances) - _, err = suite.App.IncentivesKeeper.GetStakeByID(suite.Ctx, stake.ID) - // should be deleted - suite.Require().Error(err) -} - -func (suite *IncentivesTestSuite) TestStakeUnstakePartial() { - addr0 := suite.SetupAddr(0) - - // setup dex deposit and stake of those shares - stake := suite.SetupDepositAndStake(depositStakeSpec{ - depositSpecs: []depositSpec{ - { - addr: addr0, - token0: sdk.NewInt64Coin("TokenA", 1000), - token1: sdk.NewInt64Coin("TokenB", 1000), - tick: 0, - fee: 1, - }, - }, - stakeDistEpochOffset: -2, - }) - - retrievedStake, err := suite.App.IncentivesKeeper.GetStakeByID(suite.Ctx, stake.ID) - suite.Require().NoError(err) - suite.Require().NotNil(retrievedStake) - - // unstake the partial amount - _, err = suite.App.IncentivesKeeper.Unstake( - suite.Ctx, - stake, - sdk.Coins{sdk.NewInt64Coin(suite.LPDenom0, 900)}, - ) - suite.Require().NoError(err) - balances := suite.App.BankKeeper.GetAllBalances(suite.Ctx, addr0) - suite.Require().ElementsMatch(sdk.NewCoins(sdk.NewInt64Coin(suite.LPDenom0, 900)), balances) - // should still be accessible - retrievedStake, err = suite.App.IncentivesKeeper.GetStakeByID(suite.Ctx, stake.ID) - suite.Require().NoError(err) - suite.Require().NotNil(retrievedStake) - suite.Require(). - ElementsMatch(sdk.NewCoins(sdk.NewInt64Coin(suite.LPDenom0, 1100)), retrievedStake.Coins) - - // fin. -} diff --git a/x/incentives/keeper/store_test.go b/x/incentives/keeper/store_test.go deleted file mode 100644 index 0391f90ad..000000000 --- a/x/incentives/keeper/store_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package keeper_test - -// func (suite *KeeperTestSuite) TestGaugeReferencesManagement() { -// key1 := []byte{0x11} -// key2 := []byte{0x12} - -// suite.SetupTest() - -// // set two gauge references to key 1 and three gauge references to key 2 -// _ = suite.App.IncentivesKeeper.addRefByKey(suite.Ctx, key1, 1) -// _ = suite.App.IncentivesKeeper.addRefByKey(suite.Ctx, key2, 1) -// _ = suite.App.IncentivesKeeper.addRefByKey(suite.Ctx, key1, 2) -// _ = suite.App.IncentivesKeeper.addRefByKey(suite.Ctx, key2, 2) -// _ = suite.App.IncentivesKeeper.addRefByKey(suite.Ctx, key2, 3) - -// // ensure key1 only has 2 entires -// gaugeRefs1 := suite.App.IncentivesKeeper.getRefs(suite.Ctx, key1) -// suite.Require().Equal(len(gaugeRefs1), 2) - -// // ensure key2 only has 3 entries -// gaugeRefs2 := suite.App.IncentivesKeeper.getRefs(suite.Ctx, key2) -// suite.Require().Equal(len(gaugeRefs2), 3) - -// // remove gauge 1 from key2, resulting in a reduction from 3 to 2 entries -// err := suite.App.IncentivesKeeper.deleteRefByKey(suite.Ctx, key2, 1) -// suite.Require().NoError(err) - -// // ensure key2 now only has 2 entires -// gaugeRefs3 := suite.App.IncentivesKeeper.getRefs(suite.Ctx, key2) -// suite.Require().Equal(len(gaugeRefs3), 2) -// } - -// var _ = suite.TestingSuite(nil) - -// func (suite *KeeperTestSuite) TestStakeReferencesManagement() { -// key1 := []byte{0x11} -// key2 := []byte{0x12} - -// suite.SetupTest() -// _ = suite.App.IncentivesKeeper.addRefByKey(suite.Ctx, key1, 1) -// _ = suite.App.IncentivesKeeper.addRefByKey(suite.Ctx, key2, 1) -// _ = suite.App.IncentivesKeeper.addRefByKey(suite.Ctx, key1, 2) -// _ = suite.App.IncentivesKeeper.addRefByKey(suite.Ctx, key2, 2) -// _ = suite.App.IncentivesKeeper.addRefByKey(suite.Ctx, key2, 3) - -// stakeIDs1 := suite.App.IncentivesKeeper.getRefs(suite.Ctx, key1) -// suite.Require().Equal(len(stakeIDs1), 2) -// stakeIDs2 := suite.App.IncentivesKeeper.getRefs(suite.Ctx, key2) -// suite.Require().Equal(len(stakeIDs2), 3) - -// suite.App.IncentivesKeeper.deleteRefByKey(suite.Ctx, key2, 1) -// stakeIDs2 = suite.App.IncentivesKeeper.getRefs(suite.Ctx, key2) -// suite.Require().Equal(len(stakeIDs2), 2) -// } diff --git a/x/incentives/keeper/suite_test.go b/x/incentives/keeper/suite_test.go deleted file mode 100644 index 7668ea9b1..000000000 --- a/x/incentives/keeper/suite_test.go +++ /dev/null @@ -1,124 +0,0 @@ -package keeper_test - -import ( - "time" - - "cosmossdk.io/math" - dextypes "github.com/neutron-org/neutron/x/dex/types" - "github.com/neutron-org/neutron/x/incentives/types" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -type depositStakeSpec struct { - depositSpecs []depositSpec - stakeDistEpochOffset int // used for simulating the time of staking -} - -type depositSpec struct { - addr sdk.AccAddress - token0 sdk.Coin - token1 sdk.Coin - tick int64 - fee uint64 -} - -type gaugeSpec struct { - isPerpetual bool - rewards sdk.Coins - paidOver uint64 - startTick int64 - endTick int64 - pricingTick int64 - startTime time.Time -} - -// AddToGauge adds coins to the specified gauge. -func (suite *IncentivesTestSuite) AddToGauge(coins sdk.Coins, gaugeID uint64) uint64 { - addr := sdk.AccAddress([]byte("addrx---------------")) - suite.FundAcc(addr, coins) - err := suite.App.IncentivesKeeper.AddToGaugeRewards(suite.Ctx, addr, coins, gaugeID) - suite.Require().NoError(err) - return gaugeID -} - -func (suite *IncentivesTestSuite) SetupDeposit(ss []depositSpec) sdk.Coins { - shares := sdk.NewCoins() - for _, s := range ss { - suite.FundAcc(s.addr, sdk.Coins{s.token0, s.token1}) - _, _, indivShares, err := suite.App.DexKeeper.DepositCore( - sdk.WrapSDKContext(suite.Ctx), - dextypes.MustNewPairID(s.token0.Denom, s.token1.Denom), - s.addr, - s.addr, - []math.Int{s.token0.Amount}, - []math.Int{s.token1.Amount}, - []int64{s.tick}, - []uint64{s.fee}, - []*dextypes.DepositOptions{{}}, - ) - suite.Require().NoError(err) - suite.Require().NotEmpty(indivShares) - shares = shares.Add(indivShares...) - } - return shares -} - -func (suite *IncentivesTestSuite) SetupDepositAndStake(s depositStakeSpec) *types.Stake { - shares := suite.SetupDeposit(s.depositSpecs) - return suite.SetupStake(s.depositSpecs[0].addr, shares, s.stakeDistEpochOffset) -} - -// StakeTokens stakes tokens for the specified duration -func (suite *IncentivesTestSuite) SetupStake( - addr sdk.AccAddress, - shares sdk.Coins, - distEpochOffset int, -) *types.Stake { - params := suite.App.IncentivesKeeper.GetParams(suite.Ctx) - epoch := suite.App.EpochsKeeper.GetEpochInfo(suite.Ctx, params.GetDistrEpochIdentifier()) - stake, err := suite.App.IncentivesKeeper.CreateStake( - suite.Ctx, - addr, - shares, - suite.Ctx.BlockTime(), // irrelevant now - epoch.CurrentEpoch+int64(distEpochOffset), - ) - suite.Require().NoError(err) - return stake -} - -// setupNewGauge creates a gauge with the specified duration. -func (suite *IncentivesTestSuite) SetupGauge(s gaugeSpec) *types.Gauge { - addr := sdk.AccAddress([]byte("Gauge_Creation_Addr_")) - - // fund reward tokens - suite.FundAcc(addr, s.rewards) - - // create gauge - gauge, err := suite.App.IncentivesKeeper.CreateGauge( - suite.Ctx, - s.isPerpetual, - addr, - s.rewards, - types.QueryCondition{ - PairID: &dextypes.PairID{ - Token0: "TokenA", - Token1: "TokenB", - }, - StartTick: s.startTick, - EndTick: s.endTick, - }, - s.startTime, - s.paidOver, - s.pricingTick, - ) - suite.Require().NoError(err) - return gauge -} - -func (suite *IncentivesTestSuite) SetupGauges(specs []gaugeSpec) { - for _, s := range specs { - suite.SetupGauge(s) - } -} diff --git a/x/incentives/keeper/utils.go b/x/incentives/keeper/utils.go deleted file mode 100644 index 9a75f8eb2..000000000 --- a/x/incentives/keeper/utils.go +++ /dev/null @@ -1,78 +0,0 @@ -package keeper - -import ( - "encoding/json" - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// findIndex takes an array of IDs. Then return the index of a specific ID. -func findIndex(ids []uint64, id uint64) int { - for index, inspectID := range ids { - if inspectID == id { - return index - } - } - return -1 -} - -// removeValue takes an array of IDs. Then finds the index of the IDs and remove those IDs from the array. -func removeValue(ids []uint64, id uint64) ([]uint64, int) { - index := findIndex(ids, id) - if index < 0 { - return ids, index - } - ids[index] = ids[len(ids)-1] // set last element to index - return ids[:len(ids)-1], index -} - -// getRefs returns the IDs specified by the provided key. -func (k Keeper) getRefs(ctx sdk.Context, key []byte) []uint64 { - store := ctx.KVStore(k.storeKey) - ids := []uint64{} - if store.Has(key) { - bz := store.Get(key) - err := json.Unmarshal(bz, &ids) - if err != nil { - panic(err) - } - } - return ids -} - -// addRefByKey appends the provided object ID into an array associated with the provided key. -func (k Keeper) addRefByKey(ctx sdk.Context, key []byte, id uint64) error { - store := ctx.KVStore(k.storeKey) - ids := k.getRefs(ctx, key) - if findIndex(ids, id) > -1 { - return fmt.Errorf("object with same ID exists: %d", id) - } - ids = append(ids, id) - bz, err := json.Marshal(ids) - if err != nil { - return err - } - store.Set(key, bz) - return nil -} - -// deleteRefByKey removes the provided object ID from an array associated with the provided key. -func (k Keeper) deleteRefByKey(ctx sdk.Context, key []byte, id uint64) error { - store := ctx.KVStore(k.storeKey) - ids := k.getRefs(ctx, key) - ids, index := removeValue(ids, id) - if index < 0 { - return fmt.Errorf("specific object with ID %d not found by reference %s", id, key) - } - if len(ids) == 0 { - store.Delete(key) - } else { - bz, err := json.Marshal(ids) - if err != nil { - return err - } - store.Set(key, bz) - } - return nil -} diff --git a/x/incentives/keeper/utils_test.go b/x/incentives/keeper/utils_test.go deleted file mode 100644 index 6a63d401e..000000000 --- a/x/incentives/keeper/utils_test.go +++ /dev/null @@ -1,129 +0,0 @@ -package keeper_test - -import ( - "testing" - "time" - - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - - "github.com/neutron-org/neutron/testutil" - dextypes "github.com/neutron-org/neutron/x/dex/types" - . "github.com/neutron-org/neutron/x/incentives/keeper" - "github.com/neutron-org/neutron/x/incentives/types" -) - -func TestCombineKeys(t *testing.T) { - // create three keys, each different byte arrays - key1 := []byte{0x11} - key2 := []byte{0x12} - key3 := []byte{0x13} - - // combine the three keys into a single key - key := types.CombineKeys(key1, key2, key3) - - // three keys plus two separators is equal to a length of 5 - require.Len(t, key, 3+2) - - // ensure the newly created key is made up of the three previous keys (and the two key index separators) - require.Equal(t, key[0], key1[0]) - require.Equal(t, key[1], types.KeyIndexSeparator[0]) - require.Equal(t, key[2], key2[0]) - require.Equal(t, key[3], types.KeyIndexSeparator[0]) - require.Equal(t, key[4], key3[0]) -} - -func TestFindIndex(t *testing.T) { - // create an array of 5 IDs - IDs := []uint64{1, 2, 3, 4, 5} - - // use the FindIndex function to find the index of the respective IDs - // if it doesn't exist, return -1 - require.Equal(t, FindIndex(IDs, 1), 0) - require.Equal(t, FindIndex(IDs, 3), 2) - require.Equal(t, FindIndex(IDs, 5), 4) - require.Equal(t, FindIndex(IDs, 6), -1) -} - -func TestRemoveValue(t *testing.T) { - // create an array of 5 IDs - IDs := []uint64{1, 2, 3, 4, 5} - - // remove an ID - // ensure if ID exists, the length is reduced by one and the index of the removed ID is returned - IDs, index1 := RemoveValue(IDs, 5) - require.Len(t, IDs, 4) - require.Equal(t, index1, 4) - IDs, index2 := RemoveValue(IDs, 3) - require.Len(t, IDs, 3) - require.Equal(t, index2, 2) - IDs, index3 := RemoveValue(IDs, 1) - require.Len(t, IDs, 2) - require.Equal(t, index3, 0) - IDs, index4 := RemoveValue(IDs, 6) - require.Len(t, IDs, 2) - require.Equal(t, index4, -1) -} - -func TestStakeRefKeys(t *testing.T) { - addr1 := sdk.AccAddress([]byte("addr1---------------")) - app := testutil.Setup(t) - ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - - pool1, err := app.DexKeeper.InitPool(ctx, &dextypes.PairID{Token0: "TokenA", Token1: "TokenB"}, 0, 1) - require.NoError(t, err) - - denom1 := pool1.GetPoolDenom() - - pool2, err := app.DexKeeper.InitPool(ctx, &dextypes.PairID{Token0: "TokenA", Token1: "TokenC"}, 0, 1) - require.NoError(t, err) - - denom2 := pool2.GetPoolDenom() - - // empty address and 1 coin - stake1 := types.NewStake( - 1, - sdk.AccAddress{}, - sdk.Coins{sdk.NewInt64Coin(denom1, 10)}, - time.Now(), - 10, - ) - _, err = app.IncentivesKeeper.GetStakeRefKeys(ctx, stake1) - require.Error(t, err) - - // empty address and 2 coins - stake2 := types.NewStake( - 1, - sdk.AccAddress{}, - sdk.Coins{sdk.NewInt64Coin(denom1, 10), sdk.NewInt64Coin(denom2, 1)}, - time.Now(), - 10, - ) - _, err = app.IncentivesKeeper.GetStakeRefKeys(ctx, stake2) - require.Error(t, err) - - // not empty address and 1 coin - stake3 := types.NewStake(1, addr1, sdk.Coins{sdk.NewInt64Coin(denom1, 10)}, time.Now(), 10) - keys3, err := app.IncentivesKeeper.GetStakeRefKeys(ctx, stake3) - require.NoError(t, err) - require.Len(t, keys3, 6) - - // not empty address and empty coin - stake4 := types.NewStake(1, addr1, sdk.Coins{sdk.NewInt64Coin(denom1, 10)}, time.Now(), 10) - keys4, err := app.IncentivesKeeper.GetStakeRefKeys(ctx, stake4) - require.NoError(t, err) - require.Len(t, keys4, 6) - - // not empty address and 2 coins - stake5 := types.NewStake( - 1, - addr1, - sdk.Coins{sdk.NewInt64Coin(denom1, 10), sdk.NewInt64Coin(denom2, 1)}, - time.Now(), - 10, - ) - keys5, err := app.IncentivesKeeper.GetStakeRefKeys(ctx, stake5) - require.NoError(t, err) - require.Len(t, keys5, 10) -} diff --git a/x/incentives/module.go b/x/incentives/module.go deleted file mode 100644 index 9fdfc6439..000000000 --- a/x/incentives/module.go +++ /dev/null @@ -1,180 +0,0 @@ -/* -Incentives module provides general interface to give yield to stakers. The yield to be given -to stakers are stored in gauges and is distributed on epoch basis -to the stakers who meet specific conditions. - - Gauge queries, gauge creation and add tokens to gauge - - Upcoming-gauges related queries - - Gauge infos and gauge queues -*/package incentives - -import ( - "context" - "encoding/json" - "fmt" - - abci "github.com/cometbft/cometbft/abci/types" - "github.com/gorilla/mux" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - "github.com/neutron-org/neutron/x/incentives/client/cli" - "github.com/neutron-org/neutron/x/incentives/keeper" - "github.com/neutron-org/neutron/x/incentives/types" -) - -var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} -) - -// ---------------------------------------------------------------------------- -// AppModuleBasic -// ---------------------------------------------------------------------------- - -// Implements the AppModuleBasic interface for the module. -type AppModuleBasic struct{} - -// NewAppModuleBasic creates a new AppModuleBasic struct. -func NewAppModuleBasic() AppModuleBasic { - return AppModuleBasic{} -} - -// Name returns the module's name. -func (AppModuleBasic) Name() string { - return types.ModuleName -} - -// RegisterLegacyAminoCodec registers the module's types on the LegacyAmino codec. -func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - types.RegisterCodec(cdc) -} - -// RegisterInterfaces registers the module's interface types. -func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { - types.RegisterInterfaces(reg) -} - -// DefaultGenesis returns the module's default genesis state. -func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - return cdc.MustMarshalJSON(types.DefaultGenesis()) -} - -// ValidateGenesis performs genesis state validation for the module. -func (AppModuleBasic) ValidateGenesis( - cdc codec.JSONCodec, - _ client.TxEncodingConfig, - bz json.RawMessage, -) error { - var genState types.GenesisState - if err := cdc.UnmarshalJSON(bz, &genState); err != nil { - return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) - } - return genState.Validate() -} - -// RegisterRESTRoutes registers the module's REST service handlers. -func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) { -} - -// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. -func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { - return - } -} - -// GetTxCmd returns the module's root tx command. -func (a AppModuleBasic) GetTxCmd() *cobra.Command { - return cli.GetTxCmd() -} - -// GetQueryCmd returns the module's root query command. -func (AppModuleBasic) GetQueryCmd() *cobra.Command { - return cli.GetQueryCmd() -} - -// ---------------------------------------------------------------------------- -// AppModule -// ---------------------------------------------------------------------------- - -// AppModule implements the AppModule interface for the module. -type AppModule struct { - AppModuleBasic - - keeper *keeper.Keeper - - accountKeeper stakingtypes.AccountKeeper - bankKeeper stakingtypes.BankKeeper - epochKeeper types.EpochKeeper -} - -// NewAppModule creates a new AppModule struct. -func NewAppModule(keeper *keeper.Keeper, - accountKeeper stakingtypes.AccountKeeper, bankKeeper stakingtypes.BankKeeper, - epochKeeper types.EpochKeeper, -) AppModule { - return AppModule{ - AppModuleBasic: NewAppModuleBasic(), - keeper: keeper, - accountKeeper: accountKeeper, - bankKeeper: bankKeeper, - epochKeeper: epochKeeper, - } -} - -// Name returns the module's name. -func (am AppModule) Name() string { - return am.AppModuleBasic.Name() -} - -// QuerierRoute returns the module's query routing key. -func (AppModule) QuerierRoute() string { return types.QuerierRoute } - -// RegisterServices registers the module's services. -func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) - types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServer(am.keeper)) -} - -// RegisterInvariants registers the module's invariants. -func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} - -// InitGenesis performs the module's genesis initialization. -// Returns an empty ValidatorUpdate array. -func (am AppModule) InitGenesis( - ctx sdk.Context, - cdc codec.JSONCodec, - gs json.RawMessage, -) []abci.ValidatorUpdate { - var genState types.GenesisState - // initialize global index to index in genesis state. - cdc.MustUnmarshalJSON(gs, &genState) - - am.keeper.InitGenesis(ctx, genState) - - return []abci.ValidatorUpdate{} -} - -// ExportGenesis returns the module's exported genesis state as raw JSON bytes. -func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - return cdc.MustMarshalJSON(am.keeper.ExportGenesis(ctx)) -} - -// BeginBlock executes all ABCI BeginBlock logic respective to the module. -func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} - -// EndBlock executes all ABCI EndBlock logic respective to the module. -// Returns a nil validatorUpdate struct array. -func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - return []abci.ValidatorUpdate{} -} - -// ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 1 } diff --git a/x/incentives/module_simulation.go b/x/incentives/module_simulation.go deleted file mode 100644 index c79664124..000000000 --- a/x/incentives/module_simulation.go +++ /dev/null @@ -1,33 +0,0 @@ -package incentives - -import ( - "github.com/CosmWasm/wasmd/x/wasm/simulation" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" -) - -// AppModuleSimulation functions - -// GenerateGenesisState creates a randomized GenState of the incentives module. -func (AppModule) GenerateGenesisState(simState *module.SimulationState) { - simulation.RandomizedGenState(simState) -} - -// ProposalContents returns nil for governance proposals contents. -// Should eventually be deleted in a future update. -func (AppModule) ProposalContents( - _ module.SimulationState, -) []simtypes.WeightedProposalMsg { - return nil -} - -// RegisterStoreDecoder has an unknown purpose. Should eventually be deleted in a future update. -func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) { -} - -// WeightedOperations returns the all the module's operations with their respective weights. -func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { - operations := make([]simtypes.WeightedOperation, 0) - return operations -} diff --git a/x/incentives/types/account_history.pb.go b/x/incentives/types/account_history.pb.go deleted file mode 100644 index de7676f41..000000000 --- a/x/incentives/types/account_history.pb.go +++ /dev/null @@ -1,391 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: neutron/incentives/account_history.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/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// Describes the total distributions to an account over time -type AccountHistory struct { - // the address of this account - Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` - // coins describes the total amount of coins that have been distributed to this user over time - Coins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=coins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coins"` -} - -func (m *AccountHistory) Reset() { *m = AccountHistory{} } -func (m *AccountHistory) String() string { return proto.CompactTextString(m) } -func (*AccountHistory) ProtoMessage() {} -func (*AccountHistory) Descriptor() ([]byte, []int) { - return fileDescriptor_6b167edf56b0451f, []int{0} -} -func (m *AccountHistory) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AccountHistory) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AccountHistory.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 *AccountHistory) XXX_Merge(src proto.Message) { - xxx_messageInfo_AccountHistory.Merge(m, src) -} -func (m *AccountHistory) XXX_Size() int { - return m.Size() -} -func (m *AccountHistory) XXX_DiscardUnknown() { - xxx_messageInfo_AccountHistory.DiscardUnknown(m) -} - -var xxx_messageInfo_AccountHistory proto.InternalMessageInfo - -func (m *AccountHistory) GetAccount() string { - if m != nil { - return m.Account - } - return "" -} - -func (m *AccountHistory) GetCoins() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.Coins - } - return nil -} - -func init() { - proto.RegisterType((*AccountHistory)(nil), "neutron.incentives.AccountHistory") -} - -func init() { - proto.RegisterFile("neutron/incentives/account_history.proto", fileDescriptor_6b167edf56b0451f) -} - -var fileDescriptor_6b167edf56b0451f = []byte{ - // 262 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xc8, 0x4b, 0x2d, 0x2d, - 0x29, 0xca, 0xcf, 0xd3, 0xcf, 0xcc, 0x4b, 0x4e, 0xcd, 0x2b, 0xc9, 0x2c, 0x4b, 0x2d, 0xd6, 0x4f, - 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0x89, 0xcf, 0xc8, 0x2c, 0x2e, 0xc9, 0x2f, 0xaa, 0xd4, 0x2b, - 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x82, 0xaa, 0xd4, 0x43, 0xa8, 0x94, 0x12, 0x49, 0xcf, 0x4f, - 0xcf, 0x07, 0x4b, 0xeb, 0x83, 0x58, 0x10, 0x95, 0x52, 0x72, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, - 0xfa, 0x49, 0x89, 0xc5, 0xa9, 0xfa, 0x65, 0x86, 0x49, 0xa9, 0x25, 0x89, 0x86, 0xfa, 0xc9, 0xf9, - 0x99, 0x79, 0x10, 0x79, 0xa5, 0x5e, 0x46, 0x2e, 0x3e, 0x47, 0x88, 0x1d, 0x1e, 0x10, 0x2b, 0x84, - 0x24, 0xb8, 0xd8, 0xa1, 0xb6, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0xc1, 0xb8, 0x42, 0x89, - 0x5c, 0xac, 0x20, 0xad, 0xc5, 0x12, 0x4c, 0x0a, 0xcc, 0x1a, 0xdc, 0x46, 0x92, 0x7a, 0x10, 0xc3, - 0xf5, 0x40, 0x86, 0xeb, 0x41, 0x0d, 0xd7, 0x73, 0xce, 0xcf, 0xcc, 0x73, 0x32, 0x38, 0x71, 0x4f, - 0x9e, 0x61, 0xd5, 0x7d, 0x79, 0x8d, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, - 0x7d, 0xa8, 0x4b, 0x20, 0x94, 0x6e, 0x71, 0x4a, 0xb6, 0x7e, 0x49, 0x65, 0x41, 0x6a, 0x31, 0x58, - 0x43, 0x71, 0x10, 0xc4, 0x64, 0x27, 0xef, 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, 0x32, 0x44, 0x32, 0x0a, 0xea, 0x7d, 0xdd, 0xfc, 0xa2, 0x74, 0x18, 0x5b, 0xbf, 0x02, 0x39, - 0xd8, 0xc0, 0x26, 0x27, 0xb1, 0x81, 0xfd, 0x68, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x43, 0xc5, - 0xdc, 0x5f, 0x59, 0x01, 0x00, 0x00, -} - -func (m *AccountHistory) 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 *AccountHistory) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AccountHistory) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Coins) > 0 { - for iNdEx := len(m.Coins) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Coins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintAccountHistory(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.Account) > 0 { - i -= len(m.Account) - copy(dAtA[i:], m.Account) - i = encodeVarintAccountHistory(dAtA, i, uint64(len(m.Account))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintAccountHistory(dAtA []byte, offset int, v uint64) int { - offset -= sovAccountHistory(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *AccountHistory) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Account) - if l > 0 { - n += 1 + l + sovAccountHistory(uint64(l)) - } - if len(m.Coins) > 0 { - for _, e := range m.Coins { - l = e.Size() - n += 1 + l + sovAccountHistory(uint64(l)) - } - } - return n -} - -func sovAccountHistory(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozAccountHistory(x uint64) (n int) { - return sovAccountHistory(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *AccountHistory) 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 ErrIntOverflowAccountHistory - } - 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: AccountHistory: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AccountHistory: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Account", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAccountHistory - } - 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 ErrInvalidLengthAccountHistory - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAccountHistory - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Account = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Coins", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAccountHistory - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAccountHistory - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAccountHistory - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Coins = append(m.Coins, types.Coin{}) - if err := m.Coins[len(m.Coins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAccountHistory(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAccountHistory - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipAccountHistory(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, ErrIntOverflowAccountHistory - } - 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, ErrIntOverflowAccountHistory - } - 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, ErrIntOverflowAccountHistory - } - 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, ErrInvalidLengthAccountHistory - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupAccountHistory - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthAccountHistory - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthAccountHistory = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowAccountHistory = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupAccountHistory = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/incentives/types/codec.go b/x/incentives/types/codec.go deleted file mode 100644 index d58ef0655..000000000 --- a/x/incentives/types/codec.go +++ /dev/null @@ -1,35 +0,0 @@ -package types - -import ( - "github.com/cosmos/cosmos-sdk/codec" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/msgservice" -) - -var ( - amino = codec.NewLegacyAmino() - ModuleCdc = codec.NewAminoCodec(amino) -) - -// RegisterCodec registers the necessary x/incentives interfaces and concrete types on the provided -// LegacyAmino codec. These types are used for Amino JSON serialization. -func RegisterCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgCreateGauge{}, "neutron/incentives/create-gauge", nil) - cdc.RegisterConcrete(&MsgAddToGauge{}, "neutron/incentives/add-to-gauge", nil) - cdc.RegisterConcrete(&MsgStake{}, "neutron/stake/stake-tokens", nil) - cdc.RegisterConcrete(&MsgUnstake{}, "neutron/stake/begin-unstake-period-stake", nil) -} - -// RegisterInterfaces registers interfaces and implementations of the incentives module. -func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { - registry.RegisterImplementations( - (*sdk.Msg)(nil), - &MsgCreateGauge{}, - &MsgAddToGauge{}, - &MsgStake{}, - &MsgUnstake{}, - ) - - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) -} diff --git a/x/incentives/types/distribution_spec.go b/x/incentives/types/distribution_spec.go deleted file mode 100644 index ecb89dac7..000000000 --- a/x/incentives/types/distribution_spec.go +++ /dev/null @@ -1,25 +0,0 @@ -package types - -import sdk "github.com/cosmos/cosmos-sdk/types" - -type DistributionSpec map[string]sdk.Coins - -func (spec *DistributionSpec) Add(other DistributionSpec) DistributionSpec { - result := *spec - for k, v := range other { - if vv, ok := result[k]; ok { - result[k] = vv.Add(v...) - } else { - result[k] = v - } - } - return result -} - -func (spec DistributionSpec) GetTotal() sdk.Coins { - coins := sdk.Coins{} - for _, v := range spec { - coins = coins.Add(v...) - } - return coins -} diff --git a/x/incentives/types/distribution_spec_test.go b/x/incentives/types/distribution_spec_test.go deleted file mode 100644 index 942173480..000000000 --- a/x/incentives/types/distribution_spec_test.go +++ /dev/null @@ -1,44 +0,0 @@ -package types_test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" - - "github.com/neutron-org/neutron/x/incentives/types" -) - -func TestDistributionSpec_Add(t *testing.T) { - spec1 := types.DistributionSpec{ - "alice": sdk.Coins{sdk.NewInt64Coin("coin1", 100), sdk.NewInt64Coin("coin2", 200)}, - "bob": sdk.Coins{sdk.NewInt64Coin("coin1", 300), sdk.NewInt64Coin("coin2", 400)}, - } - - spec2 := types.DistributionSpec{ - "alice": sdk.Coins{sdk.NewInt64Coin("coin1", 100), sdk.NewInt64Coin("coin2", 200)}, - "carol": sdk.Coins{sdk.NewInt64Coin("coin1", 500), sdk.NewInt64Coin("coin2", 600)}, - } - - expected := types.DistributionSpec{ - "alice": sdk.Coins{sdk.NewInt64Coin("coin1", 200), sdk.NewInt64Coin("coin2", 400)}, - "bob": sdk.Coins{sdk.NewInt64Coin("coin1", 300), sdk.NewInt64Coin("coin2", 400)}, - "carol": sdk.Coins{sdk.NewInt64Coin("coin1", 500), sdk.NewInt64Coin("coin2", 600)}, - } - - result := spec1.Add(spec2) - assert.Equal(t, expected, result) -} - -func TestDistributionSpec_GetTotal(t *testing.T) { - spec := types.DistributionSpec{ - "alice": sdk.Coins{sdk.NewInt64Coin("coin1", 100), sdk.NewInt64Coin("coin2", 200)}, - "bob": sdk.Coins{sdk.NewInt64Coin("coin1", 300), sdk.NewInt64Coin("coin2", 400)}, - "carol": sdk.Coins{sdk.NewInt64Coin("coin1", 500), sdk.NewInt64Coin("coin2", 600)}, - } - - expected := sdk.Coins{sdk.NewInt64Coin("coin1", 900), sdk.NewInt64Coin("coin2", 1200)} - - total := spec.GetTotal() - assert.Equal(t, expected, total) -} diff --git a/x/incentives/types/errors.go b/x/incentives/types/errors.go deleted file mode 100644 index f54f5c663..000000000 --- a/x/incentives/types/errors.go +++ /dev/null @@ -1,53 +0,0 @@ -package types - -// DONTCOVER - -import ( - sdkerrors "cosmossdk.io/errors" -) - -// x/incentives module sentinel errors. -var ( - ErrNotStakeOwner = sdkerrors.Register( - ModuleName, - 1, - "msg sender is not the owner of specified stake", - ) - ErrStakeNotFound = sdkerrors.Register(ModuleName, 2, "stake not found") - ErrGaugeNotActive = sdkerrors.Register( - ModuleName, - 3, - "cannot distribute from gauges when it is not active", - ) - ErrInvalidGaugeStatus = sdkerrors.Register( - ModuleName, - 4, - "Gauge status filter must be one of: ACTIVE_UPCOMING, ACTIVE, UPCOMING, FINISHED", - ) - ErrMaxGaugesReached = sdkerrors.Register( - ModuleName, - 5, - "Gauge limit has been reached; additional gauges may be created once the gauge limit has been raised via governance proposal", - ) - ErrGaugePricingTickOutOfRange = sdkerrors.Register( - ModuleName, - 6, - "cannot use an invalid price tick", - ) - ErrGaugeDistrToTickOutOfRange = sdkerrors.Register(ModuleName, 7, "cannot use an distrTo tick") - ErrInvalidSigner = sdkerrors.Register( - ModuleName, - 8, - "owner must be module authority", - ) - ErrInvalidRequest = sdkerrors.Register( - ModuleName, - 9, - "invalid request", - ) - ErrInvalidAddress = sdkerrors.Register( - ModuleName, - 10, - "Invalid Address", - ) -) diff --git a/x/incentives/types/events.go b/x/incentives/types/events.go deleted file mode 100644 index c03383fed..000000000 --- a/x/incentives/types/events.go +++ /dev/null @@ -1,21 +0,0 @@ -package types - -// Incentive module event types. -const ( - TypeEvtCreateGauge = "create_gauge" - TypeEvtAddToGauge = "add_to_gauge" - TypeEvtDistribution = "distribution" - - AttributeGaugeID = "gauge_id" - AttributeReceiver = "receiver" - AttributeAmount = "amount" - - TypeEvtStake = "stake" - TypeEvtUnstake = "unstake" - - AttributeStakeID = "stake_id" - AttributeStakeOwner = "owner" - AttributeStakeAmount = "amount" - AttributeStakeStakeTime = "stake_time" - AttributeUnstakedCoins = "unstaked_coins" -) diff --git a/x/incentives/types/expected_keepers.go b/x/incentives/types/expected_keepers.go deleted file mode 100644 index 4e11a97ff..000000000 --- a/x/incentives/types/expected_keepers.go +++ /dev/null @@ -1,33 +0,0 @@ -package types - -import ( - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - dextypes "github.com/neutron-org/neutron/x/dex/types" - epochstypes "github.com/neutron-org/neutron/x/epochs/types" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// BankKeeper defines the expected interface needed to retrieve account balances. -type BankKeeper interface { - GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins - GetSupply(ctx sdk.Context, denom string) sdk.Coin - - SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error - SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error -} - -// EpochKeeper defines the expected interface needed to retrieve epoch info. -type EpochKeeper interface { - GetEpochInfo(ctx sdk.Context, identifier string) epochstypes.EpochInfo -} - -type AccountKeeper interface { - GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.ModuleAccountI - GetModuleAddress(moduleName string) sdk.AccAddress -} - -type DexKeeper interface { - GetOrInitPool(ctx sdk.Context, pairID *dextypes.PairID, centerTickIndex int64, fee uint64) (*dextypes.Pool, error) - GetPoolMetadataByDenom(ctx sdk.Context, id string) (dextypes.PoolMetadata, error) -} diff --git a/x/incentives/types/gauge.go b/x/incentives/types/gauge.go deleted file mode 100644 index 94a43dc16..000000000 --- a/x/incentives/types/gauge.go +++ /dev/null @@ -1,83 +0,0 @@ -package types - -import ( - time "time" - - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// NewGauge creates a new gauge struct given the required gauge parameters. -func NewGauge( - id uint64, - isPerpetual bool, - distrTo QueryCondition, - coins sdk.Coins, - startTime time.Time, - numEpochsPaidOver uint64, - filledEpochs uint64, - distCoins sdk.Coins, - pricingTick int64, -) Gauge { - return Gauge{ - Id: id, - IsPerpetual: isPerpetual, - DistributeTo: distrTo, - Coins: coins, - StartTime: startTime, - NumEpochsPaidOver: numEpochsPaidOver, - FilledEpochs: filledEpochs, - DistributedCoins: distCoins, - PricingTick: pricingTick, - } -} - -func (gauge Gauge) hasEpochsRemaining() bool { - return gauge.IsPerpetual || gauge.FilledEpochs < gauge.NumEpochsPaidOver -} - -func (gauge Gauge) hasStarted(now time.Time) bool { - return !now.Before(gauge.StartTime) -} - -// IsUpcomingGauge returns true if the gauge's distribution start time is after the provided time. -func (gauge Gauge) IsUpcomingGauge(now time.Time) bool { - return !gauge.hasStarted(now) && gauge.hasEpochsRemaining() -} - -// IsActiveGauge returns true if the gauge is in an active state during the provided time. -func (gauge Gauge) IsActiveGauge(now time.Time) bool { - return gauge.hasStarted(now) && gauge.hasEpochsRemaining() -} - -// IsFinishedGauge returns true if the gauge is in a finished state during the provided time. -func (gauge Gauge) IsFinishedGauge(now time.Time) bool { - return gauge.hasStarted(now) && !gauge.hasEpochsRemaining() -} - -func (gauge Gauge) RewardsNextEpoch() sdk.Coins { - result := sdk.Coins{} - epochsRemaining := gauge.EpochsRemaining() - if epochsRemaining == 0 { - return result - } - - for _, rewardRemainingCoin := range gauge.CoinsRemaining() { - amount := rewardRemainingCoin.Amount.Quo(math.NewInt(int64(epochsRemaining))) - result = result.Add(sdk.Coin{Denom: rewardRemainingCoin.Denom, Amount: amount}) - } - - return result -} - -func (gauge Gauge) EpochsRemaining() uint64 { - if !gauge.IsPerpetual { - return gauge.NumEpochsPaidOver - gauge.FilledEpochs - } - - return 1 -} - -func (gauge Gauge) CoinsRemaining() sdk.Coins { - return gauge.Coins.Sub(gauge.DistributedCoins...) -} diff --git a/x/incentives/types/gauge.pb.go b/x/incentives/types/gauge.pb.go deleted file mode 100644 index 5265a1dc6..000000000 --- a/x/incentives/types/gauge.pb.go +++ /dev/null @@ -1,1021 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: neutron/incentives/gauge.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/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" - types1 "github.com/neutron-org/neutron/x/dex/types" - _ "google.golang.org/protobuf/types/known/durationpb" - _ "google.golang.org/protobuf/types/known/timestamppb" - io "io" - math "math" - math_bits "math/bits" - time "time" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf -var _ = time.Kitchen - -// 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 - -// Gauge is an object that describes an LP incentivization plan and its state. -type Gauge struct { - // id is the unique ID of a Gauge - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // There are two kinds of gauges: perpetual and non-perpetual. Perpetual - // gauges describe an incentivization program for which the token rewards - // distributed on any given day must be added to the gauge prior to that day's - // distribution using an AddToGauge message. When distribute is called on a - // perpetual gauge, all of the remaining rewards in the gauge are distributed. - // Because of this, all perpetual gauges must have `num_epochs_paid_over` set - // to 1. A non-perpetual gauge by contrast distributes its rewards over a - // schedule as determined by `num_epochs_paid_over`. If a non-perpetual gauge - // is created with coins=[100atom] and num_epochs_paid_over=10, this means - // that for 10 days (10 epochs) the gauge will distribute 10atom each day to - // the staked LP positions qualifying for the gauge. - IsPerpetual bool `protobuf:"varint,2,opt,name=is_perpetual,json=isPerpetual,proto3" json:"is_perpetual,omitempty"` - // distribute_to describes a set of staked LP positions that should be - // distributed to from this gauge. - DistributeTo QueryCondition `protobuf:"bytes,3,opt,name=distribute_to,json=distributeTo,proto3" json:"distribute_to"` - // coins describes the total amount of coins that have been added to this - // gauge for distribution. - Coins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=coins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coins"` - // start_time describes when this gauge should begin distributing rewards. - // This allows gauge creators to schedule gauges into the future, in the event - // that an earlier gauge is expected to expire. - StartTime time.Time `protobuf:"bytes,5,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"` - // num_epochs_paid_over is the number of total epochs (days) the rewards in - // this gauge will be distributed over. - NumEpochsPaidOver uint64 `protobuf:"varint,6,opt,name=num_epochs_paid_over,json=numEpochsPaidOver,proto3" json:"num_epochs_paid_over,omitempty"` - // filled_epochs describes the number of epochs distribution have been completed - // already - FilledEpochs uint64 `protobuf:"varint,7,opt,name=filled_epochs,json=filledEpochs,proto3" json:"filled_epochs,omitempty"` - // distributed_coins describes coins that have been distributed already from - // this gauge. - DistributedCoins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,8,rep,name=distributed_coins,json=distributedCoins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"distributed_coins"` - // pricing_tick is necessary for fairly distributing rewards over a range of - // ticks. Without pricing_tick, we might naively distribute rewards in - // proportion to the number of deposit shares staked within the gauge's - // qualifying tick range. - // - // For example, a gauge with a distribute_to tick range of [-10, 10] would - // distribute to staked LP tokens where both tick-fee and tick+fee are within - // [-10, 10]. Let's say for pair "tokenA<>tokenB", the current trading tick is - // 0. If Alice were to LP (10tokenA, 0tokenB) @ tick -8, fee 2, this would - // mean Alice would be issued 10 shares (10 + 0 * 1.0001^-8), since shares are - // in terms of token0. Let's further assume Bob LPs (0tokenA, 10tokenB) @ tick - // 8, fee 2, such that Bob is issued 10.008 shares (0 + 10 * 1.0001^8). Under - // this naive approach, if Alice and Bob were to stake their shares, Bob would - // receive more in rewards, purely on the basis of the relative locations of - // their liquidity. - // - // This disparity originates in the fact that LP deposit denominations are not - // fungible across ticks. To avoid this, we can use a single price throughout - // the gauge's tick range for relating the relative value of token0 and - // token1, as specified by pricing_tick. - // - // Let's run through the earier example using the more sophisticated approach, - // where the gauge has pricing_tick set to 0. For the purpose of calculating - // reward distribution weight, Alice's shares are worth 10 + 0 * 1.0001^0 = 10 - // and Bob's shares are worth 0 + 10 * 1.0001^0 = 10. With the distribution - // weight of both shares set according to a gauge-specific tick, we do not - // distribute more or less rewards according to the relative location of - // liquidity within the gauge's tick range, freeing users to place liquidity - // whereever they deem most profitable in the gauge's range and still equally - // qualify for rewards. - PricingTick int64 `protobuf:"varint,9,opt,name=pricing_tick,json=pricingTick,proto3" json:"pricing_tick,omitempty"` -} - -func (m *Gauge) Reset() { *m = Gauge{} } -func (m *Gauge) String() string { return proto.CompactTextString(m) } -func (*Gauge) ProtoMessage() {} -func (*Gauge) Descriptor() ([]byte, []int) { - return fileDescriptor_2467fab98b594cb6, []int{0} -} -func (m *Gauge) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Gauge) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Gauge.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 *Gauge) XXX_Merge(src proto.Message) { - xxx_messageInfo_Gauge.Merge(m, src) -} -func (m *Gauge) XXX_Size() int { - return m.Size() -} -func (m *Gauge) XXX_DiscardUnknown() { - xxx_messageInfo_Gauge.DiscardUnknown(m) -} - -var xxx_messageInfo_Gauge proto.InternalMessageInfo - -func (m *Gauge) GetId() uint64 { - if m != nil { - return m.Id - } - return 0 -} - -func (m *Gauge) GetIsPerpetual() bool { - if m != nil { - return m.IsPerpetual - } - return false -} - -func (m *Gauge) GetDistributeTo() QueryCondition { - if m != nil { - return m.DistributeTo - } - return QueryCondition{} -} - -func (m *Gauge) GetCoins() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.Coins - } - return nil -} - -func (m *Gauge) GetStartTime() time.Time { - if m != nil { - return m.StartTime - } - return time.Time{} -} - -func (m *Gauge) GetNumEpochsPaidOver() uint64 { - if m != nil { - return m.NumEpochsPaidOver - } - return 0 -} - -func (m *Gauge) GetFilledEpochs() uint64 { - if m != nil { - return m.FilledEpochs - } - return 0 -} - -func (m *Gauge) GetDistributedCoins() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.DistributedCoins - } - return nil -} - -func (m *Gauge) GetPricingTick() int64 { - if m != nil { - return m.PricingTick - } - return 0 -} - -// QueryCondition describes a set of staked LP positions that a gauge is -// configured to distribute to. LP tokens qualifying for a given QueryCondition -// must have both tick-fee and tick+fee fall within the range [startTick, endTick], -// such that all of the tradable liquidity for the pool is within that range. -type QueryCondition struct { - // pairID is the token pair which should be distributed to. - PairID *types1.PairID `protobuf:"bytes,1,opt,name=pairID,proto3" json:"pairID,omitempty"` - // start_tick is the inclusive lower bound on the location of LP tokens that - // qualify for a gauge's distribution. - StartTick int64 `protobuf:"varint,2,opt,name=startTick,proto3" json:"startTick,omitempty"` - // end_tick is the inclusive upper bound on the location of LP tokens that - // qualify for a gauge's distribution. - EndTick int64 `protobuf:"varint,3,opt,name=endTick,proto3" json:"endTick,omitempty"` -} - -func (m *QueryCondition) Reset() { *m = QueryCondition{} } -func (m *QueryCondition) String() string { return proto.CompactTextString(m) } -func (*QueryCondition) ProtoMessage() {} -func (*QueryCondition) Descriptor() ([]byte, []int) { - return fileDescriptor_2467fab98b594cb6, []int{1} -} -func (m *QueryCondition) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryCondition) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryCondition.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 *QueryCondition) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryCondition.Merge(m, src) -} -func (m *QueryCondition) XXX_Size() int { - return m.Size() -} -func (m *QueryCondition) XXX_DiscardUnknown() { - xxx_messageInfo_QueryCondition.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryCondition proto.InternalMessageInfo - -func (m *QueryCondition) GetPairID() *types1.PairID { - if m != nil { - return m.PairID - } - return nil -} - -func (m *QueryCondition) GetStartTick() int64 { - if m != nil { - return m.StartTick - } - return 0 -} - -func (m *QueryCondition) GetEndTick() int64 { - if m != nil { - return m.EndTick - } - return 0 -} - -func init() { - proto.RegisterType((*Gauge)(nil), "neutron.incentives.Gauge") - proto.RegisterType((*QueryCondition)(nil), "neutron.incentives.QueryCondition") -} - -func init() { proto.RegisterFile("neutron/incentives/gauge.proto", fileDescriptor_2467fab98b594cb6) } - -var fileDescriptor_2467fab98b594cb6 = []byte{ - // 566 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0xcd, 0x6e, 0xd3, 0x4c, - 0x14, 0x8d, 0x9b, 0x9f, 0xb6, 0x93, 0xb4, 0xfa, 0x32, 0x5f, 0x17, 0x6e, 0x04, 0x4e, 0x08, 0x1b, - 0x4b, 0xa8, 0x33, 0x24, 0xec, 0x58, 0xa6, 0x20, 0x84, 0x10, 0x22, 0x58, 0x59, 0x20, 0x36, 0xd6, - 0xd8, 0x33, 0x75, 0x47, 0x89, 0x3d, 0xd6, 0xcc, 0x38, 0x4a, 0xde, 0xa2, 0xcf, 0xc1, 0x1b, 0xf0, - 0x06, 0x5d, 0x76, 0xc9, 0xaa, 0x45, 0xc9, 0x1b, 0xf0, 0x04, 0xc8, 0x63, 0x9b, 0x04, 0xd8, 0xb2, - 0xf2, 0xcc, 0x39, 0xf7, 0xce, 0xbd, 0xe7, 0xdc, 0x6b, 0xe0, 0x24, 0x2c, 0xd3, 0x52, 0x24, 0x98, - 0x27, 0x21, 0x4b, 0x34, 0x5f, 0x32, 0x85, 0x23, 0x92, 0x45, 0x0c, 0xa5, 0x52, 0x68, 0x01, 0x61, - 0xc9, 0xa3, 0x1d, 0xdf, 0x3b, 0x8b, 0x44, 0x24, 0x0c, 0x8d, 0xf3, 0x53, 0x11, 0xd9, 0x73, 0x22, - 0x21, 0xa2, 0x05, 0xc3, 0xe6, 0x16, 0x64, 0x57, 0x98, 0x66, 0x92, 0x68, 0x2e, 0x92, 0x92, 0xef, - 0xff, 0xc9, 0x6b, 0x1e, 0x33, 0xa5, 0x49, 0x9c, 0x56, 0x0f, 0x84, 0x42, 0xc5, 0x42, 0xe1, 0x80, - 0x28, 0x86, 0x97, 0xa3, 0x80, 0x69, 0x32, 0xc2, 0xa1, 0xe0, 0xd5, 0x03, 0xe7, 0x55, 0xab, 0x94, - 0xad, 0x70, 0x4a, 0xb8, 0xf4, 0x39, 0x2d, 0xa8, 0xe1, 0xd7, 0x06, 0x68, 0xbe, 0xc9, 0xbb, 0x86, - 0xa7, 0xe0, 0x80, 0x53, 0xdb, 0x1a, 0x58, 0x6e, 0xc3, 0x3b, 0xe0, 0x14, 0x3e, 0x01, 0x1d, 0xae, - 0xfc, 0x94, 0xc9, 0x94, 0xe9, 0x8c, 0x2c, 0xec, 0x83, 0x81, 0xe5, 0x1e, 0x79, 0x6d, 0xae, 0xa6, - 0x15, 0x04, 0xdf, 0x83, 0x13, 0xca, 0x95, 0x96, 0x3c, 0xc8, 0x34, 0xf3, 0xb5, 0xb0, 0xeb, 0x03, - 0xcb, 0x6d, 0x8f, 0x87, 0xe8, 0x6f, 0xe9, 0xe8, 0x63, 0xc6, 0xe4, 0xfa, 0x52, 0x24, 0x94, 0xe7, - 0xca, 0x26, 0x8d, 0xdb, 0xfb, 0x7e, 0xcd, 0xeb, 0xec, 0xd2, 0x67, 0x02, 0x12, 0xd0, 0xcc, 0x9b, - 0x56, 0x76, 0x63, 0x50, 0x77, 0xdb, 0xe3, 0x73, 0x54, 0xc8, 0x42, 0xb9, 0x2c, 0x54, 0xca, 0x42, - 0x97, 0x82, 0x27, 0x93, 0xe7, 0x79, 0xf6, 0x97, 0x87, 0xbe, 0x1b, 0x71, 0x7d, 0x9d, 0x05, 0x28, - 0x14, 0x31, 0x2e, 0x3d, 0x28, 0x3e, 0x17, 0x8a, 0xce, 0xb1, 0x5e, 0xa7, 0x4c, 0x99, 0x04, 0xe5, - 0x15, 0x2f, 0xc3, 0x4f, 0x00, 0x28, 0x4d, 0xa4, 0xf6, 0x73, 0x0b, 0xed, 0xa6, 0x69, 0xb7, 0x87, - 0x0a, 0x7f, 0x51, 0xe5, 0x2f, 0x9a, 0x55, 0xfe, 0x4e, 0x1e, 0xe7, 0x85, 0x7e, 0xdc, 0xf7, 0xbb, - 0x6b, 0x12, 0x2f, 0x5e, 0x0e, 0x77, 0xb9, 0xc3, 0x9b, 0x87, 0xbe, 0xe5, 0x1d, 0x1b, 0x20, 0x0f, - 0x87, 0x18, 0x9c, 0x25, 0x59, 0xec, 0xb3, 0x54, 0x84, 0xd7, 0xca, 0x4f, 0x09, 0xa7, 0xbe, 0x58, - 0x32, 0x69, 0xb7, 0x8c, 0xa1, 0xdd, 0x24, 0x8b, 0x5f, 0x1b, 0x6a, 0x4a, 0x38, 0xfd, 0xb0, 0x64, - 0x12, 0x3e, 0x05, 0x27, 0x57, 0x7c, 0xb1, 0x60, 0xb4, 0xcc, 0xb1, 0x0f, 0x4d, 0x64, 0xa7, 0x00, - 0x8b, 0x60, 0xb8, 0x02, 0xdd, 0x9d, 0x45, 0xd4, 0x2f, 0xec, 0x39, 0xfa, 0xf7, 0xf6, 0xfc, 0xb7, - 0x57, 0xc5, 0x20, 0xf9, 0xf8, 0x53, 0xc9, 0x43, 0x9e, 0x44, 0xbe, 0xe6, 0xe1, 0xdc, 0x3e, 0x1e, - 0x58, 0x6e, 0xdd, 0x6b, 0x97, 0xd8, 0x8c, 0x87, 0xf3, 0x61, 0x06, 0x4e, 0x7f, 0x9f, 0x2a, 0x7c, - 0x06, 0x5a, 0xf9, 0x7a, 0xbd, 0x7d, 0x65, 0xf6, 0xa8, 0x3d, 0xfe, 0xff, 0xd7, 0x26, 0x50, 0xb6, - 0x42, 0x53, 0x43, 0x79, 0x65, 0x08, 0x7c, 0x04, 0x2a, 0xfb, 0xc2, 0xb9, 0xd9, 0xae, 0xba, 0xb7, - 0x03, 0xa0, 0x0d, 0x0e, 0x59, 0x42, 0x0d, 0x57, 0x37, 0x5c, 0x75, 0x9d, 0xbc, 0xbb, 0xdd, 0x38, - 0xd6, 0xdd, 0xc6, 0xb1, 0xbe, 0x6f, 0x1c, 0xeb, 0x66, 0xeb, 0xd4, 0xee, 0xb6, 0x4e, 0xed, 0xdb, - 0xd6, 0xa9, 0x7d, 0x1e, 0xed, 0xe9, 0x2d, 0x0b, 0x5f, 0x08, 0x19, 0x55, 0x67, 0xbc, 0xda, 0xff, - 0x57, 0x8d, 0xfc, 0xa0, 0x65, 0x86, 0xfe, 0xe2, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf6, 0xde, - 0x74, 0xfa, 0xce, 0x03, 0x00, 0x00, -} - -func (m *Gauge) 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 *Gauge) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Gauge) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.PricingTick != 0 { - i = encodeVarintGauge(dAtA, i, uint64(m.PricingTick)) - i-- - dAtA[i] = 0x48 - } - if len(m.DistributedCoins) > 0 { - for iNdEx := len(m.DistributedCoins) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.DistributedCoins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGauge(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - } - } - if m.FilledEpochs != 0 { - i = encodeVarintGauge(dAtA, i, uint64(m.FilledEpochs)) - i-- - dAtA[i] = 0x38 - } - if m.NumEpochsPaidOver != 0 { - i = encodeVarintGauge(dAtA, i, uint64(m.NumEpochsPaidOver)) - i-- - dAtA[i] = 0x30 - } - n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime):]) - if err1 != nil { - return 0, err1 - } - i -= n1 - i = encodeVarintGauge(dAtA, i, uint64(n1)) - i-- - dAtA[i] = 0x2a - if len(m.Coins) > 0 { - for iNdEx := len(m.Coins) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Coins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGauge(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - { - size, err := m.DistributeTo.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGauge(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if m.IsPerpetual { - i-- - if m.IsPerpetual { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x10 - } - if m.Id != 0 { - i = encodeVarintGauge(dAtA, i, uint64(m.Id)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryCondition) 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 *QueryCondition) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryCondition) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.EndTick != 0 { - i = encodeVarintGauge(dAtA, i, uint64(m.EndTick)) - i-- - dAtA[i] = 0x18 - } - if m.StartTick != 0 { - i = encodeVarintGauge(dAtA, i, uint64(m.StartTick)) - i-- - dAtA[i] = 0x10 - } - if m.PairID != nil { - { - size, err := m.PairID.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGauge(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintGauge(dAtA []byte, offset int, v uint64) int { - offset -= sovGauge(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Gauge) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Id != 0 { - n += 1 + sovGauge(uint64(m.Id)) - } - if m.IsPerpetual { - n += 2 - } - l = m.DistributeTo.Size() - n += 1 + l + sovGauge(uint64(l)) - if len(m.Coins) > 0 { - for _, e := range m.Coins { - l = e.Size() - n += 1 + l + sovGauge(uint64(l)) - } - } - l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime) - n += 1 + l + sovGauge(uint64(l)) - if m.NumEpochsPaidOver != 0 { - n += 1 + sovGauge(uint64(m.NumEpochsPaidOver)) - } - if m.FilledEpochs != 0 { - n += 1 + sovGauge(uint64(m.FilledEpochs)) - } - if len(m.DistributedCoins) > 0 { - for _, e := range m.DistributedCoins { - l = e.Size() - n += 1 + l + sovGauge(uint64(l)) - } - } - if m.PricingTick != 0 { - n += 1 + sovGauge(uint64(m.PricingTick)) - } - return n -} - -func (m *QueryCondition) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PairID != nil { - l = m.PairID.Size() - n += 1 + l + sovGauge(uint64(l)) - } - if m.StartTick != 0 { - n += 1 + sovGauge(uint64(m.StartTick)) - } - if m.EndTick != 0 { - n += 1 + sovGauge(uint64(m.EndTick)) - } - return n -} - -func sovGauge(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozGauge(x uint64) (n int) { - return sovGauge(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Gauge) 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 ErrIntOverflowGauge - } - 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: Gauge: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Gauge: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGauge - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsPerpetual", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGauge - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.IsPerpetual = bool(v != 0) - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DistributeTo", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGauge - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGauge - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGauge - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.DistributeTo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Coins", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGauge - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGauge - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGauge - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Coins = append(m.Coins, types.Coin{}) - if err := m.Coins[len(m.Coins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGauge - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGauge - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGauge - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NumEpochsPaidOver", wireType) - } - m.NumEpochsPaidOver = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGauge - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.NumEpochsPaidOver |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field FilledEpochs", wireType) - } - m.FilledEpochs = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGauge - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.FilledEpochs |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DistributedCoins", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGauge - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGauge - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGauge - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DistributedCoins = append(m.DistributedCoins, types.Coin{}) - if err := m.DistributedCoins[len(m.DistributedCoins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 9: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PricingTick", wireType) - } - m.PricingTick = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGauge - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PricingTick |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipGauge(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGauge - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryCondition) 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 ErrIntOverflowGauge - } - 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: QueryCondition: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryCondition: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PairID", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGauge - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGauge - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGauge - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.PairID == nil { - m.PairID = &types1.PairID{} - } - if err := m.PairID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StartTick", wireType) - } - m.StartTick = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGauge - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.StartTick |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EndTick", wireType) - } - m.EndTick = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGauge - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.EndTick |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipGauge(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGauge - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipGauge(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, ErrIntOverflowGauge - } - 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, ErrIntOverflowGauge - } - 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, ErrIntOverflowGauge - } - 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, ErrInvalidLengthGauge - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupGauge - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthGauge - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthGauge = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowGauge = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupGauge = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/incentives/types/gauge_test.go b/x/incentives/types/gauge_test.go deleted file mode 100644 index 431aeb815..000000000 --- a/x/incentives/types/gauge_test.go +++ /dev/null @@ -1,66 +0,0 @@ -package types_test - -import ( - "testing" - "time" - - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - . "github.com/neutron-org/neutron/x/incentives/types" - "github.com/stretchr/testify/assert" -) - -func TestGaugeIsUpcomingGauge(t *testing.T) { - now := time.Now() - gauge := NewGauge(1, false, QueryCondition{}, sdk.Coins{}, now.Add(time.Minute), 10, 0, sdk.Coins{}, 0) - - assert.True(t, gauge.IsUpcomingGauge(now)) - assert.False(t, gauge.IsUpcomingGauge(now.Add(time.Minute))) -} - -func TestGaugeIsActiveGauge(t *testing.T) { - now := time.Now() - gauge := NewGauge(1, false, QueryCondition{}, sdk.Coins{}, now.Add(time.Minute), 10, 0, sdk.Coins{}, 0) - - assert.False(t, gauge.IsActiveGauge(now)) - assert.True(t, gauge.IsActiveGauge(now.Add(11*time.Minute))) - - gauge.IsPerpetual = true - assert.False(t, gauge.IsActiveGauge(now)) - assert.True(t, gauge.IsActiveGauge(now.Add(11*time.Minute))) -} - -func TestGaugeIsFinishedGauge(t *testing.T) { - now := time.Now() - gauge := NewGauge(1, false, QueryCondition{}, sdk.Coins{}, now.Add(-time.Minute), 10, 10, sdk.Coins{}, 0) - assert.True(t, gauge.IsFinishedGauge(now)) - - gauge = NewGauge(1, false, QueryCondition{}, sdk.Coins{}, now.Add(-time.Minute), 10, 8, sdk.Coins{}, 0) - assert.False(t, gauge.IsFinishedGauge(now)) -} - -func TestGaugeEpochsRemaining(t *testing.T) { - gauge := NewGauge(1, false, QueryCondition{}, sdk.Coins{}, time.Time{}, 10, 5, sdk.Coins{}, 0) - - assert.Equal(t, uint64(5), gauge.EpochsRemaining()) - - gauge.IsPerpetual = true - assert.Equal(t, uint64(1), gauge.EpochsRemaining()) -} - -func TestGaugeCoinsRemaining(t *testing.T) { - coins := sdk.Coins{sdk.NewCoin("coin1", math.NewInt(100))} - distCoins := sdk.Coins{sdk.NewCoin("coin1", math.NewInt(50))} - gauge := NewGauge(1, false, QueryCondition{}, coins, time.Time{}, 10, 5, distCoins, 0) - assert.Equal(t, sdk.Coins{sdk.NewCoin("coin1", math.NewInt(50))}, gauge.CoinsRemaining()) -} - -func TestGaugeGetTotal(t *testing.T) { - distSpec := DistributionSpec{ - "addr1": sdk.Coins{sdk.NewCoin("coin1", math.NewInt(10))}, - "addr2": sdk.Coins{sdk.NewCoin("coin1", math.NewInt(20))}, - "addr3": sdk.Coins{sdk.NewCoin("coin1", math.NewInt(30))}, - } - - assert.Equal(t, sdk.Coins{sdk.NewCoin("coin1", math.NewInt(60))}, distSpec.GetTotal()) -} diff --git a/x/incentives/types/gauges.go b/x/incentives/types/gauges.go deleted file mode 100644 index 32dbb878f..000000000 --- a/x/incentives/types/gauges.go +++ /dev/null @@ -1,24 +0,0 @@ -package types - -import sdk "github.com/cosmos/cosmos-sdk/types" - -type Gauges []*Gauge - -func (g Gauges) GetCoinsDistributed() sdk.Coins { - result := sdk.Coins{} - for _, gauge := range g { - result = result.Add(gauge.DistributedCoins...) - } - - return result -} - -// getToDistributeCoinsFromGauges returns coins that have not been distributed yet from the provided gauges -func (g Gauges) GetCoinsRemaining() sdk.Coins { - result := sdk.Coins{} - - for _, gauge := range g { - result = result.Add(gauge.CoinsRemaining()...) - } - return result -} diff --git a/x/incentives/types/genesis.go b/x/incentives/types/genesis.go deleted file mode 100644 index e4d616d9a..000000000 --- a/x/incentives/types/genesis.go +++ /dev/null @@ -1,23 +0,0 @@ -package types - -import ( - "errors" -) - -// DefaultIndex is the default incentive module's global index. -const DefaultIndex uint64 = 1 - -// DefaultGenesis returns the incentive module's default genesis state. -func DefaultGenesis() *GenesisState { - return &GenesisState{ - Params: DefaultParams(), - } -} - -// Validate performs basic genesis state validation, returning an error upon any failure. -func (gs GenesisState) Validate() error { - if gs.Params.DistrEpochIdentifier == "" { - return errors.New("epoch identifier should NOT be empty") - } - return nil -} diff --git a/x/incentives/types/genesis.pb.go b/x/incentives/types/genesis.pb.go deleted file mode 100644 index 5455123db..000000000 --- a/x/incentives/types/genesis.pb.go +++ /dev/null @@ -1,590 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: neutron/incentives/genesis.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// GenesisState defines the incentives module's various parameters when first -// initialized -type GenesisState struct { - // params are all the parameters of the module - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - // gauges are all gauges that should exist at genesis - Gauges []*Gauge `protobuf:"bytes,2,rep,name=gauges,proto3" json:"gauges,omitempty"` - // last_gauge_id is what the gauge number will increment from when creating - // the next gauge after genesis - LastGaugeId uint64 `protobuf:"varint,3,opt,name=last_gauge_id,json=lastGaugeId,proto3" json:"last_gauge_id,omitempty"` - LastStakeId uint64 `protobuf:"varint,4,opt,name=last_stake_id,json=lastStakeId,proto3" json:"last_stake_id,omitempty"` - Stakes []*Stake `protobuf:"bytes,5,rep,name=stakes,proto3" json:"stakes,omitempty"` - AccountHistories []*AccountHistory `protobuf:"bytes,6,rep,name=accountHistories,proto3" json:"accountHistories,omitempty"` -} - -func (m *GenesisState) Reset() { *m = GenesisState{} } -func (m *GenesisState) String() string { return proto.CompactTextString(m) } -func (*GenesisState) ProtoMessage() {} -func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_98ecc78531d9ace2, []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) GetGauges() []*Gauge { - if m != nil { - return m.Gauges - } - return nil -} - -func (m *GenesisState) GetLastGaugeId() uint64 { - if m != nil { - return m.LastGaugeId - } - return 0 -} - -func (m *GenesisState) GetLastStakeId() uint64 { - if m != nil { - return m.LastStakeId - } - return 0 -} - -func (m *GenesisState) GetStakes() []*Stake { - if m != nil { - return m.Stakes - } - return nil -} - -func (m *GenesisState) GetAccountHistories() []*AccountHistory { - if m != nil { - return m.AccountHistories - } - return nil -} - -func init() { - proto.RegisterType((*GenesisState)(nil), "neutron.incentives.GenesisState") -} - -func init() { proto.RegisterFile("neutron/incentives/genesis.proto", fileDescriptor_98ecc78531d9ace2) } - -var fileDescriptor_98ecc78531d9ace2 = []byte{ - // 332 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0x4f, 0x4f, 0xc2, 0x30, - 0x18, 0xc6, 0x37, 0xc0, 0x1d, 0x8a, 0x26, 0xa6, 0xf1, 0x30, 0x77, 0x28, 0x0b, 0xa7, 0x5d, 0xdc, - 0x02, 0x5e, 0xbc, 0xca, 0x05, 0x89, 0x89, 0x31, 0xe3, 0xe6, 0x85, 0x94, 0xd1, 0x94, 0x46, 0x69, - 0xc9, 0xda, 0x19, 0xf9, 0x16, 0x7e, 0x2a, 0xc3, 0x91, 0xa3, 0x27, 0x63, 0xd8, 0x17, 0x31, 0xed, - 0x8a, 0x90, 0x30, 0xbd, 0xb5, 0xef, 0xf3, 0x7b, 0xde, 0xbf, 0x20, 0xe4, 0xa4, 0x50, 0xb9, 0xe0, - 0x09, 0xe3, 0x19, 0xe1, 0x8a, 0xbd, 0x12, 0x99, 0x50, 0xc2, 0x89, 0x64, 0x32, 0x5e, 0xe6, 0x42, - 0x09, 0x08, 0x2d, 0x11, 0xef, 0x89, 0xe0, 0x82, 0x0a, 0x2a, 0x8c, 0x9c, 0xe8, 0x57, 0x45, 0x06, - 0x9d, 0x9a, 0x5c, 0x4b, 0x9c, 0xe3, 0x85, 0x4d, 0x15, 0xa0, 0xba, 0x62, 0xb8, 0xa0, 0xe4, 0x1f, - 0x5d, 0x2a, 0xfc, 0xbc, 0xd3, 0xa3, 0x1a, 0x1d, 0x67, 0x99, 0x28, 0xb8, 0x9a, 0xcc, 0x99, 0x54, - 0x22, 0x5f, 0x55, 0x64, 0xf7, 0xa3, 0x01, 0x4e, 0x87, 0xd5, 0x18, 0x63, 0x85, 0x15, 0x81, 0x37, - 0xc0, 0xab, 0x5a, 0xf1, 0xdd, 0xd0, 0x8d, 0xda, 0xfd, 0x20, 0x3e, 0x1e, 0x2b, 0x7e, 0x34, 0xc4, - 0xa0, 0xb5, 0xfe, 0xea, 0x38, 0xa9, 0xe5, 0x61, 0x0f, 0x78, 0xa6, 0x47, 0xe9, 0x37, 0xc2, 0x66, - 0xd4, 0xee, 0x5f, 0xd6, 0x39, 0x87, 0x9a, 0x48, 0x2d, 0x08, 0xbb, 0xe0, 0xec, 0x05, 0x4b, 0x35, - 0x31, 0xdf, 0x09, 0x9b, 0xf9, 0xcd, 0xd0, 0x8d, 0x5a, 0x69, 0x5b, 0x07, 0x0d, 0x39, 0x9a, 0xfd, - 0x32, 0x66, 0x3e, 0xcd, 0xb4, 0xf6, 0xcc, 0x58, 0xc7, 0x46, 0x33, 0x5d, 0xda, 0xc8, 0xd2, 0x3f, - 0xf9, 0xbb, 0xb4, 0x81, 0x53, 0x0b, 0xc2, 0x07, 0x70, 0x6e, 0x37, 0x72, 0x67, 0x16, 0xc2, 0x88, - 0xf4, 0x3d, 0x63, 0xee, 0xd6, 0x99, 0x6f, 0x0f, 0xd9, 0x55, 0x7a, 0xe4, 0x1d, 0xdc, 0xaf, 0xb7, - 0xc8, 0xdd, 0x6c, 0x91, 0xfb, 0xbd, 0x45, 0xee, 0x7b, 0x89, 0x9c, 0x4d, 0x89, 0x9c, 0xcf, 0x12, - 0x39, 0x4f, 0x3d, 0xca, 0xd4, 0xbc, 0x98, 0xc6, 0x99, 0x58, 0x24, 0x36, 0xf3, 0x95, 0xc8, 0xe9, - 0xee, 0x9d, 0xbc, 0x1d, 0x5e, 0x49, 0xad, 0x96, 0x44, 0x4e, 0x3d, 0x73, 0x9c, 0xeb, 0x9f, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x78, 0xe5, 0x26, 0xb9, 0x75, 0x02, 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.AccountHistories) > 0 { - for iNdEx := len(m.AccountHistories) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.AccountHistories[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - } - if len(m.Stakes) > 0 { - for iNdEx := len(m.Stakes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Stakes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - } - if m.LastStakeId != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.LastStakeId)) - i-- - dAtA[i] = 0x20 - } - if m.LastGaugeId != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.LastGaugeId)) - i-- - dAtA[i] = 0x18 - } - if len(m.Gauges) > 0 { - for iNdEx := len(m.Gauges) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Gauges[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.Gauges) > 0 { - for _, e := range m.Gauges { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if m.LastGaugeId != 0 { - n += 1 + sovGenesis(uint64(m.LastGaugeId)) - } - if m.LastStakeId != 0 { - n += 1 + sovGenesis(uint64(m.LastStakeId)) - } - if len(m.Stakes) > 0 { - for _, e := range m.Stakes { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.AccountHistories) > 0 { - for _, e := range m.AccountHistories { - 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 Gauges", 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.Gauges = append(m.Gauges, &Gauge{}) - if err := m.Gauges[len(m.Gauges)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LastGaugeId", wireType) - } - m.LastGaugeId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LastGaugeId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LastStakeId", wireType) - } - m.LastStakeId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LastStakeId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Stakes", 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.Stakes = append(m.Stakes, &Stake{}) - if err := m.Stakes[len(m.Stakes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AccountHistories", 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.AccountHistories = append(m.AccountHistories, &AccountHistory{}) - if err := m.AccountHistories[len(m.AccountHistories)-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/incentives/types/hooks.go b/x/incentives/types/hooks.go deleted file mode 100644 index bcb37bbc7..000000000 --- a/x/incentives/types/hooks.go +++ /dev/null @@ -1,82 +0,0 @@ -package types - -import ( - time "time" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -type IncentiveHooks interface { - AfterCreateGauge(ctx sdk.Context, gaugeID uint64) - AfterAddToGauge(ctx sdk.Context, gaugeID uint64) - AfterStartDistribution(ctx sdk.Context, gaugeID uint64) - AfterFinishDistribution(ctx sdk.Context, gaugeID uint64) - AfterEpochDistribution(ctx sdk.Context) - AfterAddTokensToStake(ctx sdk.Context, address sdk.AccAddress, stakeID uint64, amount sdk.Coins) - OnTokenStaked(ctx sdk.Context, address sdk.AccAddress, stakeID uint64, amount sdk.Coins, unstakeTime time.Time) - OnTokenUnstaked(ctx sdk.Context, address sdk.AccAddress, stakeID uint64, amount sdk.Coins, unstakeTime time.Time) -} - -var _ IncentiveHooks = MultiIncentiveHooks{} - -// MultiIncentiveHooks combines multiple incentive hooks. All hook functions are run in array sequence. -type MultiIncentiveHooks []IncentiveHooks - -// NewMultiIncentiveHooks combines multiple incentive hooks into a single IncentiveHooks array. -func NewMultiIncentiveHooks(hooks ...IncentiveHooks) MultiIncentiveHooks { - return hooks -} - -func (h MultiIncentiveHooks) AfterCreateGauge(ctx sdk.Context, gaugeID uint64) { - for i := range h { - h[i].AfterCreateGauge(ctx, gaugeID) - } -} - -func (h MultiIncentiveHooks) AfterAddToGauge(ctx sdk.Context, gaugeID uint64) { - for i := range h { - h[i].AfterAddToGauge(ctx, gaugeID) - } -} - -func (h MultiIncentiveHooks) AfterStartDistribution(ctx sdk.Context, gaugeID uint64) { - for i := range h { - h[i].AfterStartDistribution(ctx, gaugeID) - } -} - -func (h MultiIncentiveHooks) AfterFinishDistribution(ctx sdk.Context, gaugeID uint64) { - for i := range h { - h[i].AfterFinishDistribution(ctx, gaugeID) - } -} - -func (h MultiIncentiveHooks) AfterEpochDistribution(ctx sdk.Context) { - for i := range h { - h[i].AfterEpochDistribution(ctx) - } -} - -func (h MultiIncentiveHooks) AfterAddTokensToStake(ctx sdk.Context, address sdk.AccAddress, stakeID uint64, amount sdk.Coins) { - for i := range h { - h[i].AfterAddTokensToStake(ctx, address, stakeID, amount) - } -} - -func (h MultiIncentiveHooks) OnTokenStaked(ctx sdk.Context, address sdk.AccAddress, stakeID uint64, amount sdk.Coins, unstakeTime time.Time) { - for i := range h { - h[i].OnTokenStaked(ctx, address, stakeID, amount, unstakeTime) - } -} - -func (h MultiIncentiveHooks) OnTokenUnstaked(ctx sdk.Context, address sdk.AccAddress, stakeID uint64, amount sdk.Coins, unstakeTime time.Time) { - for i := range h { - h[i].OnTokenUnstaked(ctx, address, stakeID, amount, unstakeTime) - } -} - -// func (h MultiIncentiveHooks) OnStakeExtend(ctx sdk.Context, stakeID uint64, prevDuration, newDuration time.Duration) { -// for i := range h { -// h[i].OnStakeExtend(ctx, stakeID, prevDuration, newDuration) -// } -// } diff --git a/x/incentives/types/keys.go b/x/incentives/types/keys.go deleted file mode 100644 index 7afce2652..000000000 --- a/x/incentives/types/keys.go +++ /dev/null @@ -1,176 +0,0 @@ -package types - -import ( - "bytes" - time "time" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var ( - // ModuleName defines the module name. - ModuleName = "incentives" - - // StoreKey defines the primary module store key. - StoreKey = ModuleName - - // RouterKey is the message route for slashing. - RouterKey = ModuleName - - // QuerierRoute defines the module's query routing key. - QuerierRoute = ModuleName - - // MemStoreKey defines the in-memory store key. - MemStoreKey = "mem_capability" - - // KeyPrefixTimestamp defines prefix key for timestamp iterator key. - KeyPrefixTimestamp = []byte{0x01} - - // KeyLastGaugeID defines key for setting last gauge ID. - KeyLastGaugeID = []byte{0x02} - - // KeyPrefixGauge defines prefix key for storing gauges. - KeyPrefixGauge = []byte{0x03} - - // KeyPrefixGaugeIndex defines prefix key for storing reference key for all gauges. - KeyPrefixGaugeIndex = []byte{0x04} - - // KeyPrefixGaugeIndexUpcoming defines prefix key for storing reference key for upcoming gauges. - KeyPrefixGaugeIndexUpcoming = []byte{0x04, 0x00} - - // KeyPrefixGaugeIndexActive defines prefix key for storing reference key for active gauges. - KeyPrefixGaugeIndexActive = []byte{0x04, 0x01} - - // KeyPrefixGaugeIndexFinished defines prefix key for storing reference key for finished gauges. - KeyPrefixGaugeIndexFinished = []byte{0x04, 0x02} - - // KeyPrefixGaugeIndexByPair defines prefix key for storing indexes of gauge IDs by denomination. - KeyPrefixGaugeIndexByPair = []byte{0x05} - - // KeyLastStakeID defines key to store stake ID used by last. - KeyLastStakeID = []byte{0x06} - - // KeyPrefixStake defines prefix to store period stake by ID. - KeyPrefixStake = []byte{0x07} - - // KeyPrefixStakeIndexAccount defines prefix for the iteration of stake IDs by account. - KeyPrefixStakeIndex = []byte{0x08} - - // KeyPrefixStakeIndexAccount defines prefix for the iteration of stake IDs by account. - KeyPrefixStakeIndexAccount = []byte{0x09} - - // KeyPrefixStakeIndexDenom defines prefix for the iteration of stake IDs by denom. - KeyPrefixStakeIndexDenom = []byte{0x0c} - - // KeyPrefixStakeIndexPairTick defines prefix for the iteration of stake IDs by pairId and tick index. - KeyPrefixStakeIndexPairTick = []byte{0x0d} - - // KeyPrefixStakeIndexAccountDenom defines prefix for the iteration of stake IDs by account, denomination. - KeyPrefixStakeIndexAccountDenom = []byte{0x0e} - - // KeyPrefixStakeIndexTimestamp defines prefix for the iteration of stake IDs by day epoch integer. - KeyPrefixStakeIndexPairDistEpoch = []byte{0x0f} - - // KeyPrefixAccountHistory defines the prefix for storing account histories. - KeyPrefixAccountHistory = []byte{0x10} - - KeyParams = []byte{0x11} - // KeyndexSeparator defines separator between keys when combine, it should be one that is not used in denom expression. - KeyIndexSeparator = []byte{0xFF} -) - -// stakeStoreKey returns action store key from ID. -func GetStakeStoreKey(id uint64) []byte { - return CombineKeys(KeyPrefixStake, sdk.Uint64ToBigEndian(id)) -} - -// combineKeys combine bytes array into a single bytes. -func CombineKeys(keys ...[]byte) []byte { - return bytes.Join(keys, KeyIndexSeparator) -} - -// getTimeKey returns the key used for getting a set of period stakes -// where unstakeTime is after a specific time. -func GetTimeKey(timestamp time.Time) []byte { - timeBz := sdk.FormatTimeBytes(timestamp) - timeBzL := len(timeBz) - prefixL := len(KeyPrefixTimestamp) - - bz := make([]byte, prefixL+8+timeBzL) - - // copy the prefix - copy(bz[:prefixL], KeyPrefixTimestamp) - - // copy the encoded time bytes length - copy(bz[prefixL:prefixL+8], sdk.Uint64ToBigEndian(uint64(timeBzL))) - - // copy the encoded time bytes - copy(bz[prefixL+8:prefixL+8+timeBzL], timeBz) - return bz -} - -// gaugeStoreKey returns the combined byte array (store key) of the provided gauge ID's key prefix and the ID itself. -func GetKeyGaugeStore(id uint64) []byte { - return CombineKeys(KeyPrefixGauge, sdk.Uint64ToBigEndian(id)) -} - -// gaugePairStoreKey returns the combined byte array (store key) of the provided gauge denom key prefix and the denom itself. -func GetKeyGaugeIndexByPair(pairID string) []byte { - return CombineKeys(KeyPrefixGaugeIndexByPair, []byte(pairID)) -} - -func GetKeyStakeIndexByAccount(account sdk.AccAddress) []byte { - return CombineKeys( - KeyPrefixStakeIndexAccount, - account, - ) -} - -func GetKeyStakeIndexByDenom(denom string) []byte { - return CombineKeys( - KeyPrefixStakeIndexDenom, - []byte(denom), - ) -} - -func GetKeyStakeIndexByAccountDenom(account sdk.AccAddress, denom string) []byte { - return CombineKeys( - KeyPrefixStakeIndexAccountDenom, - account, - []byte(denom), - ) -} - -func GetKeyStakeIndexByDistEpoch(pairID string, distEpoch int64) []byte { - return CombineKeys( - KeyPrefixStakeIndexPairDistEpoch, - []byte(pairID), - GetKeyInt64(distEpoch), - ) -} - -func GetKeyStakeIndexByPairTick(pairID string, tickIndex int64) []byte { - return CombineKeys( - KeyPrefixStakeIndexPairTick, - []byte(pairID), - GetKeyInt64(tickIndex), - ) -} - -func GetKeyAccountHistory(address string) []byte { - return CombineKeys( - KeyPrefixStakeIndexPairTick, - []byte(address), - ) -} - -func GetKeyInt64(a int64) []byte { - key := make([]byte, 9) - if a < 0 { - copy(key[1:], sdk.Uint64ToBigEndian(uint64(a))) - } else { - copy(key[:1], []byte{0x01}) - copy(key[1:], sdk.Uint64ToBigEndian(uint64(a))) - } - return key -} diff --git a/x/incentives/types/keys_test.go b/x/incentives/types/keys_test.go deleted file mode 100644 index 8ea98bdda..000000000 --- a/x/incentives/types/keys_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package types_test - -import ( - "bytes" - "testing" - time "time" - - sdk "github.com/cosmos/cosmos-sdk/types" - . "github.com/neutron-org/neutron/x/incentives/types" - "github.com/stretchr/testify/require" -) - -func TestGetTimeKey(t *testing.T) { - now := time.Now() - timeKey := GetTimeKey(now) - require.True(t, bytes.HasPrefix(timeKey, KeyPrefixTimestamp)) - require.True(t, bytes.HasSuffix(timeKey, sdk.FormatTimeBytes(now))) -} diff --git a/x/incentives/types/msgs.go b/x/incentives/types/msgs.go deleted file mode 100644 index 92e5e49fa..000000000 --- a/x/incentives/types/msgs.go +++ /dev/null @@ -1,259 +0,0 @@ -package types - -import ( - "fmt" - "time" - - sdkerrors "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - dextypes "github.com/neutron-org/neutron/x/dex/types" -) - -const ( - TypeMsgCreateGauge = "create_gauge" - TypeMsgAddToGauge = "add_to_gauge" - TypeMsgStakeTokens = "stake_tokens" - TypeMsgBeginUnstaking = "begin_unstaking" - TypeMsgUpdateParams = "update-params" -) - -var _ sdk.Msg = &MsgCreateGauge{} - -// NewMsgCreateGauge creates a message to create a gauge with the provided parameters. -func NewMsgCreateGauge( - isPerpetual bool, - owner sdk.AccAddress, - distributeTo QueryCondition, - coins sdk.Coins, - startTime time.Time, - numEpochsPaidOver uint64, - pricingTick int64, -) *MsgCreateGauge { - return &MsgCreateGauge{ - IsPerpetual: isPerpetual, - Owner: owner.String(), - DistributeTo: distributeTo, - Coins: coins, - StartTime: startTime, - NumEpochsPaidOver: numEpochsPaidOver, - PricingTick: pricingTick, - } -} - -// Route takes a create gauge message, then returns the RouterKey used for slashing. -func (m MsgCreateGauge) Route() string { return RouterKey } - -// Type takes a create gauge message, then returns a create gauge message type. -func (m MsgCreateGauge) Type() string { return TypeMsgCreateGauge } - -// ValidateBasic checks that the create gauge message is valid. -func (m MsgCreateGauge) ValidateBasic() error { - if m.Owner == "" { - return sdkerrors.Wrapf(ErrInvalidRequest, "owner should be set") - } - // TODO: If this is not set, infer start time as "now" - if m.StartTime.Equal(time.Time{}) { - return sdkerrors.Wrapf(ErrInvalidRequest, "distribution start time should be set") - } - if m.NumEpochsPaidOver == 0 { - return sdkerrors.Wrapf( - ErrInvalidRequest, - "distribution period should be at least 1 epoch", - ) - } - if m.IsPerpetual && m.NumEpochsPaidOver != 1 { - return sdkerrors.Wrapf( - ErrInvalidRequest, - "distribution period should be 1 epoch for perpetual gauge", - ) - } - if dextypes.IsTickOutOfRange(m.PricingTick) { - return sdkerrors.Wrapf( - ErrInvalidRequest, - "pricing tick is out of range, must be between %d and %d", - int64(dextypes.MaxTickExp)*-1, - dextypes.MaxTickExp, - ) - } - if dextypes.IsTickOutOfRange(m.DistributeTo.StartTick) { - return sdkerrors.Wrapf( - ErrInvalidRequest, - "start tick is out of range, must be between %d and %d", - int64(dextypes.MaxTickExp)*-1, - dextypes.MaxTickExp, - ) - } - if dextypes.IsTickOutOfRange(m.DistributeTo.EndTick) { - return sdkerrors.Wrapf( - ErrInvalidRequest, - "start tick is out of range, must be between %d and %d", - int64(dextypes.MaxTickExp)*-1, - dextypes.MaxTickExp, - ) - } - - return nil -} - -// GetSignBytes takes a create gauge message and turns it into a byte array. -func (m MsgCreateGauge) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -// GetSigners takes a create gauge message and returns the owner in a byte array. -func (m MsgCreateGauge) GetSigners() []sdk.AccAddress { - owner, _ := sdk.AccAddressFromBech32(m.Owner) - return []sdk.AccAddress{owner} -} - -var _ sdk.Msg = &MsgAddToGauge{} - -// NewMsgAddToGauge creates a message to add rewards to a specific gauge. -func NewMsgAddToGauge(owner sdk.AccAddress, gaugeID uint64, rewards sdk.Coins) *MsgAddToGauge { - return &MsgAddToGauge{ - Owner: owner.String(), - GaugeId: gaugeID, - Rewards: rewards, - } -} - -// Route takes an add to gauge message, then returns the RouterKey used for slashing. -func (m MsgAddToGauge) Route() string { return RouterKey } - -// Type takes an add to gauge message, then returns an add to gauge message type. -func (m MsgAddToGauge) Type() string { return TypeMsgAddToGauge } - -// ValidateBasic checks that the add to gauge message is valid. -func (m MsgAddToGauge) ValidateBasic() error { - if m.Owner == "" { - return sdkerrors.Wrapf(ErrInvalidRequest, "owner should be set") - } - if m.Rewards.Empty() { - return sdkerrors.Wrapf( - ErrInvalidRequest, - "additional rewards should not be empty", - ) - } - - return nil -} - -// GetSignBytes takes an add to gauge message and turns it into a byte array. -func (m MsgAddToGauge) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -// GetSigners takes an add to gauge message and returns the owner in a byte array. -func (m MsgAddToGauge) GetSigners() []sdk.AccAddress { - owner, _ := sdk.AccAddressFromBech32(m.Owner) - return []sdk.AccAddress{owner} -} - -var _ sdk.Msg = &MsgStake{} - -// NewMsgStakeTokens creates a message to stake tokens. -func NewMsgSetupStake(owner sdk.AccAddress, coins sdk.Coins) *MsgStake { - return &MsgStake{ - Owner: owner.String(), - Coins: coins, - } -} - -func (m MsgStake) Route() string { return RouterKey } -func (m MsgStake) Type() string { return TypeMsgStakeTokens } -func (m MsgStake) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(m.Owner) - if err != nil { - return sdkerrors.Wrapf(ErrInvalidAddress, "Invalid owner address (%s)", err) - } - - if !m.Coins.IsAllPositive() { - return fmt.Errorf("cannot stake up a zero or negative amount") - } - - return nil -} - -func (m MsgStake) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -func (m MsgStake) GetSigners() []sdk.AccAddress { - owner, _ := sdk.AccAddressFromBech32(m.Owner) - return []sdk.AccAddress{owner} -} - -var _ sdk.Msg = &MsgUnstake{} - -func NewMsgUnstakeDescriptor(id uint64, coins sdk.Coins) *MsgUnstake_UnstakeDescriptor { - return &MsgUnstake_UnstakeDescriptor{ - ID: id, - Coins: coins, - } -} - -// NewMsgUnstake creates a message to unstake the tokens of a set of stake records. -func NewMsgUnstake(owner sdk.AccAddress, unstakes []*MsgUnstake_UnstakeDescriptor) *MsgUnstake { - return &MsgUnstake{ - Owner: owner.String(), - Unstakes: unstakes, - } -} - -func (m MsgUnstake) Route() string { return RouterKey } -func (m MsgUnstake) Type() string { return TypeMsgBeginUnstaking } -func (m MsgUnstake) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(m.Owner) - if err != nil { - return sdkerrors.Wrapf(ErrInvalidAddress, "Invalid owner address (%s)", err) - } - - for _, unstake := range m.Unstakes { - if unstake.ID == 0 { - return fmt.Errorf("invalid stake ID, got %v", unstake.ID) - } - - if !unstake.Coins.Empty() && !unstake.Coins.IsAllPositive() { - return fmt.Errorf("cannot unstake a zero or negative amount") - } - } - - return nil -} - -func (m MsgUnstake) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -func (m MsgUnstake) GetSigners() []sdk.AccAddress { - owner, _ := sdk.AccAddressFromBech32(m.Owner) - return []sdk.AccAddress{owner} -} - -var _ sdk.Msg = &MsgUpdateParams{} - -func (msg *MsgUpdateParams) Route() string { return RouterKey } - -func (msg *MsgUpdateParams) Type() string { return TypeMsgUpdateParams } - -func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress { - authority, err := sdk.AccAddressFromBech32(msg.Authority) - if err != nil { // should never happen as valid basic rejects invalid addresses - panic(err.Error()) - } - return []sdk.AccAddress{authority} -} - -func (msg *MsgUpdateParams) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(msg) - return sdk.MustSortJSON(bz) -} - -func (msg *MsgUpdateParams) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { - return sdkerrors.Wrap(err, "authority is invalid") - } - - err := msg.Params.Validate() - return err -} diff --git a/x/incentives/types/msgs_test.go b/x/incentives/types/msgs_test.go deleted file mode 100644 index 4ebdde3ea..000000000 --- a/x/incentives/types/msgs_test.go +++ /dev/null @@ -1,324 +0,0 @@ -package types_test - -import ( - "testing" - time "time" - - "github.com/cometbft/cometbft/crypto/ed25519" - "github.com/stretchr/testify/require" - - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/neutron-org/neutron/testutil/apptesting" - dextypes "github.com/neutron-org/neutron/x/dex/types" - . "github.com/neutron-org/neutron/x/incentives/types" -) - -// TestMsgCreatePool tests if valid/invalid create pool messages are properly validated/invalidated -func TestMsgCreatePool(t *testing.T) { - // generate a private/public key pair and get the respective address - pk1 := ed25519.GenPrivKey().PubKey() - addr1 := sdk.AccAddress(pk1.Address()) - - // make a proper createPool message - createMsg := func(after func(msg MsgCreateGauge) MsgCreateGauge) MsgCreateGauge { - distributeTo := QueryCondition{ - PairID: &dextypes.PairID{ - Token0: "TokenA", - Token1: "TokenB", - }, - StartTick: -10, - EndTick: 10, - } - - properMsg := *NewMsgCreateGauge( - false, - addr1, - distributeTo, - sdk.Coins{}, - time.Now(), - 2, - 0, - ) - - return after(properMsg) - } - - // validate createPool message was created as intended - msg := createMsg(func(msg MsgCreateGauge) MsgCreateGauge { - return msg - }) - require.Equal(t, msg.Route(), RouterKey) - require.Equal(t, msg.Type(), "create_gauge") - signers := msg.GetSigners() - require.Equal(t, len(signers), 1) - require.Equal(t, signers[0].String(), addr1.String()) - - tests := []struct { - name string - msg MsgCreateGauge - expectPass bool - }{ - { - name: "proper msg", - msg: createMsg(func(msg MsgCreateGauge) MsgCreateGauge { - return msg - }), - expectPass: true, - }, - { - name: "empty owner", - msg: createMsg(func(msg MsgCreateGauge) MsgCreateGauge { - msg.Owner = "" - return msg - }), - expectPass: false, - }, - { - name: "invalid distribution start time", - msg: createMsg(func(msg MsgCreateGauge) MsgCreateGauge { - msg.StartTime = time.Time{} - return msg - }), - expectPass: false, - }, - { - name: "invalid num epochs paid over", - msg: createMsg(func(msg MsgCreateGauge) MsgCreateGauge { - msg.NumEpochsPaidOver = 0 - return msg - }), - expectPass: false, - }, - { - name: "invalid num epochs paid over for perpetual gauge", - msg: createMsg(func(msg MsgCreateGauge) MsgCreateGauge { - msg.NumEpochsPaidOver = 2 - msg.IsPerpetual = true - return msg - }), - expectPass: false, - }, - { - name: "valid num epochs paid over for perpetual gauge", - msg: createMsg(func(msg MsgCreateGauge) MsgCreateGauge { - msg.NumEpochsPaidOver = 1 - msg.IsPerpetual = true - return msg - }), - expectPass: true, - }, - } - - for _, test := range tests { - if test.expectPass { - require.NoError(t, test.msg.ValidateBasic(), "test: %v", test.name) - } else { - require.Error(t, test.msg.ValidateBasic(), "test: %v", test.name) - } - } -} - -// TestMsgAddToGauge tests if valid/invalid add to gauge messages are properly validated/invalidated -func TestMsgAddToGauge(t *testing.T) { - // generate a private/public key pair and get the respective address - pk1 := ed25519.GenPrivKey().PubKey() - addr1 := sdk.AccAddress(pk1.Address()) - - // make a proper addToGauge message - createMsg := func(after func(msg MsgAddToGauge) MsgAddToGauge) MsgAddToGauge { - properMsg := *NewMsgAddToGauge( - addr1, - 1, - sdk.Coins{sdk.NewInt64Coin("stake", 10)}, - ) - - return after(properMsg) - } - - // validate addToGauge message was created as intended - msg := createMsg(func(msg MsgAddToGauge) MsgAddToGauge { - return msg - }) - require.Equal(t, msg.Route(), RouterKey) - require.Equal(t, msg.Type(), "add_to_gauge") - signers := msg.GetSigners() - require.Equal(t, len(signers), 1) - require.Equal(t, signers[0].String(), addr1.String()) - - tests := []struct { - name string - msg MsgAddToGauge - expectPass bool - }{ - { - name: "proper msg", - msg: createMsg(func(msg MsgAddToGauge) MsgAddToGauge { - return msg - }), - expectPass: true, - }, - { - name: "empty owner", - msg: createMsg(func(msg MsgAddToGauge) MsgAddToGauge { - msg.Owner = "" - return msg - }), - expectPass: false, - }, - { - name: "empty rewards", - msg: createMsg(func(msg MsgAddToGauge) MsgAddToGauge { - msg.Rewards = sdk.Coins{} - return msg - }), - expectPass: false, - }, - } - - for _, test := range tests { - if test.expectPass { - require.NoError(t, test.msg.ValidateBasic(), "test: %v", test.name) - } else { - require.Error(t, test.msg.ValidateBasic(), "test: %v", test.name) - } - } -} - -func TestMsgSetupStake(t *testing.T) { - addr1, invalidAddr := apptesting.GenerateTestAddrs() - - tests := []struct { - name string - msg MsgStake - expectPass bool - }{ - { - name: "proper msg", - msg: MsgStake{ - Owner: addr1, - Coins: sdk.NewCoins(sdk.NewCoin("test", math.NewInt(100))), - }, - expectPass: true, - }, - { - name: "invalid owner", - msg: MsgStake{ - Owner: invalidAddr, - Coins: sdk.NewCoins(sdk.NewCoin("test", math.NewInt(100))), - }, - }, - { - name: "zero token amount", - msg: MsgStake{ - Owner: addr1, - Coins: sdk.NewCoins(sdk.NewCoin("test", math.NewInt(0))), - }, - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - if test.expectPass { - require.NoError(t, test.msg.ValidateBasic(), "test: %v", test.name) - require.Equal(t, test.msg.Route(), RouterKey) - require.Equal(t, test.msg.Type(), "stake_tokens") - signers := test.msg.GetSigners() - require.Equal(t, len(signers), 1) - require.Equal(t, signers[0].String(), addr1) - } else { - require.Error(t, test.msg.ValidateBasic(), "test: %v", test.name) - } - }) - } -} - -func TestMsgUnstake(t *testing.T) { - addr1, invalidAddr := apptesting.GenerateTestAddrs() - - tests := []struct { - name string - msg MsgUnstake - expectPass bool - }{ - { - name: "proper msg", - msg: MsgUnstake{ - Owner: addr1, - Unstakes: []*MsgUnstake_UnstakeDescriptor{ - { - ID: 1, - Coins: sdk.NewCoins(sdk.NewCoin("test", math.NewInt(100))), - }, - }, - }, - expectPass: true, - }, - { - name: "invalid owner", - msg: MsgUnstake{ - Owner: invalidAddr, - Unstakes: []*MsgUnstake_UnstakeDescriptor{ - { - ID: 1, - Coins: sdk.NewCoins(sdk.NewCoin("test", math.NewInt(100))), - }, - }, - }, - }, - { - name: "invalid stake ID", - msg: MsgUnstake{ - Owner: addr1, - Unstakes: []*MsgUnstake_UnstakeDescriptor{ - { - ID: 0, - Coins: sdk.NewCoins(sdk.NewCoin("test", math.NewInt(100))), - }, - }, - }, - }, - { - name: "zero coins (same as nil)", - msg: MsgUnstake{ - Owner: addr1, - Unstakes: []*MsgUnstake_UnstakeDescriptor{ - { - ID: 1, - Coins: sdk.NewCoins(sdk.NewCoin("test1", math.NewInt(0))), - }, - }, - }, - expectPass: true, - }, - { - name: "nil coins (unstake by ID)", - msg: MsgUnstake{ - Owner: addr1, - Unstakes: []*MsgUnstake_UnstakeDescriptor{ - { - ID: 1, - Coins: sdk.NewCoins(), - }, - }, - }, - expectPass: true, - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - if test.expectPass { - require.NoError(t, test.msg.ValidateBasic(), "test: %v", test.name) - require.Equal(t, test.msg.Route(), RouterKey) - require.Equal(t, test.msg.Type(), "begin_unstaking") - signers := test.msg.GetSigners() - require.Equal(t, len(signers), 1) - require.Equal(t, signers[0].String(), addr1) - } else { - require.Error(t, test.msg.ValidateBasic(), "test: %v", test.name) - } - }) - } -} diff --git a/x/incentives/types/params.go b/x/incentives/types/params.go deleted file mode 100644 index 51747339d..000000000 --- a/x/incentives/types/params.go +++ /dev/null @@ -1,47 +0,0 @@ -package types - -import ( - epochtypes "github.com/neutron-org/neutron/x/epochs/types" - - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" -) - -// Incentives parameters key store. -var ( - KeyDistrEpochIdentifier = []byte("DistrEpochIdentifier") - KeyMaxGauges = []byte("MaxGauges") -) - -// ParamKeyTable returns the key table for the incentive module's parameters. -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} - -// NewParams takes an epoch distribution identifier, then returns an incentives Params struct. -func NewParams(distrEpochIdentifier string, maxGauges uint64) Params { - return Params{ - DistrEpochIdentifier: distrEpochIdentifier, - MaxGauges: maxGauges, - } -} - -// DefaultParams returns the default incentives module parameters. -func DefaultParams() Params { - return Params{ - DistrEpochIdentifier: "day", - MaxGauges: 20, - } -} - -// Validate checks that the incentives module parameters are valid. -func (p Params) Validate() error { - return epochtypes.ValidateEpochIdentifierInterface(p.DistrEpochIdentifier) -} - -// ParamSetPairs takes the parameter struct and associates the paramsubspace key and field of the parameters as a KVStore. -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyDistrEpochIdentifier, &p.DistrEpochIdentifier, epochtypes.ValidateEpochIdentifierInterface), - paramtypes.NewParamSetPair(KeyMaxGauges, &p.MaxGauges, func(interface{}) error { return nil }), - } -} diff --git a/x/incentives/types/params.pb.go b/x/incentives/types/params.pb.go deleted file mode 100644 index 43335aa08..000000000 --- a/x/incentives/types/params.pb.go +++ /dev/null @@ -1,359 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: neutron/incentives/params.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// Params holds parameters for the incentives module -type Params struct { - // distr_epoch_identifier is what epoch type distribution will be triggered by - // (day, week, etc.) - DistrEpochIdentifier string `protobuf:"bytes,1,opt,name=distr_epoch_identifier,json=distrEpochIdentifier,proto3" json:"distr_epoch_identifier,omitempty" yaml:"distr_epoch_identifier"` - MaxGauges uint64 `protobuf:"varint,2,opt,name=max_gauges,json=maxGauges,proto3" json:"max_gauges,omitempty" yaml:"max_gauges"` -} - -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_26b1e31ea29bccbb, []int{0} -} -func (m *Params) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Params.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Params) XXX_Merge(src proto.Message) { - xxx_messageInfo_Params.Merge(m, src) -} -func (m *Params) XXX_Size() int { - return m.Size() -} -func (m *Params) XXX_DiscardUnknown() { - xxx_messageInfo_Params.DiscardUnknown(m) -} - -var xxx_messageInfo_Params proto.InternalMessageInfo - -func (m *Params) GetDistrEpochIdentifier() string { - if m != nil { - return m.DistrEpochIdentifier - } - return "" -} - -func (m *Params) GetMaxGauges() uint64 { - if m != nil { - return m.MaxGauges - } - return 0 -} - -func init() { - proto.RegisterType((*Params)(nil), "neutron.incentives.Params") -} - -func init() { proto.RegisterFile("neutron/incentives/params.proto", fileDescriptor_26b1e31ea29bccbb) } - -var fileDescriptor_26b1e31ea29bccbb = []byte{ - // 242 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcf, 0x4b, 0x2d, 0x2d, - 0x29, 0xca, 0xcf, 0xd3, 0xcf, 0xcc, 0x4b, 0x4e, 0xcd, 0x2b, 0xc9, 0x2c, 0x4b, 0x2d, 0xd6, 0x2f, - 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x82, 0x2a, 0xd0, - 0x43, 0x28, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x4b, 0xeb, 0x83, 0x58, 0x10, 0x95, 0x4a, - 0xd3, 0x19, 0xb9, 0xd8, 0x02, 0xc0, 0x5a, 0x85, 0xc2, 0xb9, 0xc4, 0x52, 0x32, 0x8b, 0x4b, 0x8a, - 0xe2, 0x53, 0x0b, 0xf2, 0x93, 0x33, 0xe2, 0x33, 0x53, 0x40, 0x3a, 0xd3, 0x32, 0x53, 0x8b, 0x24, - 0x18, 0x15, 0x18, 0x35, 0x38, 0x9d, 0x14, 0x3f, 0xdd, 0x93, 0x97, 0xad, 0x4c, 0xcc, 0xcd, 0xb1, - 0x52, 0xc2, 0xae, 0x4e, 0x29, 0x48, 0x04, 0x2c, 0xe1, 0x0a, 0x12, 0xf7, 0x84, 0x0b, 0x0b, 0x99, - 0x70, 0x71, 0xe5, 0x26, 0x56, 0xc4, 0xa7, 0x27, 0x96, 0xa6, 0xa7, 0x16, 0x4b, 0x30, 0x29, 0x30, - 0x6a, 0xb0, 0x38, 0x89, 0x7e, 0xba, 0x27, 0x2f, 0x08, 0x31, 0x0c, 0x21, 0xa7, 0x14, 0xc4, 0x99, - 0x9b, 0x58, 0xe1, 0x0e, 0x66, 0x3b, 0x79, 0x9f, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, - 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, - 0x43, 0x94, 0x61, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xd4, 0xa3, - 0xba, 0xf9, 0x45, 0xe9, 0x30, 0xb6, 0x7e, 0x05, 0x72, 0xb8, 0x94, 0x54, 0x16, 0xa4, 0x16, 0x27, - 0xb1, 0x81, 0x7d, 0x6b, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x2b, 0x9e, 0xe5, 0x1b, 0x3a, 0x01, - 0x00, 0x00, -} - -func (m *Params) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Params) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.MaxGauges != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.MaxGauges)) - i-- - dAtA[i] = 0x10 - } - if len(m.DistrEpochIdentifier) > 0 { - i -= len(m.DistrEpochIdentifier) - copy(dAtA[i:], m.DistrEpochIdentifier) - i = encodeVarintParams(dAtA, i, uint64(len(m.DistrEpochIdentifier))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintParams(dAtA []byte, offset int, v uint64) int { - offset -= sovParams(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Params) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DistrEpochIdentifier) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - if m.MaxGauges != 0 { - n += 1 + sovParams(uint64(m.MaxGauges)) - } - return n -} - -func sovParams(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozParams(x uint64) (n int) { - return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Params) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Params: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DistrEpochIdentifier", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DistrEpochIdentifier = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxGauges", wireType) - } - m.MaxGauges = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MaxGauges |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipParams(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthParams - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupParams - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthParams - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/incentives/types/query.pb.go b/x/incentives/types/query.pb.go deleted file mode 100644 index 633166dcd..000000000 --- a/x/incentives/types/query.pb.go +++ /dev/null @@ -1,3584 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: neutron/incentives/query.proto - -package types - -import ( - context "context" - fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/cosmos-sdk/types/query" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/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 - -type GaugeStatus int32 - -const ( - GaugeStatus_ACTIVE_UPCOMING GaugeStatus = 0 - GaugeStatus_ACTIVE GaugeStatus = 1 - GaugeStatus_UPCOMING GaugeStatus = 2 - GaugeStatus_FINISHED GaugeStatus = 3 -) - -var GaugeStatus_name = map[int32]string{ - 0: "ACTIVE_UPCOMING", - 1: "ACTIVE", - 2: "UPCOMING", - 3: "FINISHED", -} - -var GaugeStatus_value = map[string]int32{ - "ACTIVE_UPCOMING": 0, - "ACTIVE": 1, - "UPCOMING": 2, - "FINISHED": 3, -} - -func (x GaugeStatus) String() string { - return proto.EnumName(GaugeStatus_name, int32(x)) -} - -func (GaugeStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_04f05289607f461a, []int{0} -} - -type GetModuleStatusRequest struct { -} - -func (m *GetModuleStatusRequest) Reset() { *m = GetModuleStatusRequest{} } -func (m *GetModuleStatusRequest) String() string { return proto.CompactTextString(m) } -func (*GetModuleStatusRequest) ProtoMessage() {} -func (*GetModuleStatusRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_04f05289607f461a, []int{0} -} -func (m *GetModuleStatusRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetModuleStatusRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetModuleStatusRequest.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 *GetModuleStatusRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetModuleStatusRequest.Merge(m, src) -} -func (m *GetModuleStatusRequest) XXX_Size() int { - return m.Size() -} -func (m *GetModuleStatusRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetModuleStatusRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetModuleStatusRequest proto.InternalMessageInfo - -type GetModuleStatusResponse struct { - // Coins that have yet to be distributed - RewardCoins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=reward_coins,json=rewardCoins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"reward_coins"` - StakedCoins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=staked_coins,json=stakedCoins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"staked_coins"` - Params Params `protobuf:"bytes,3,opt,name=params,proto3" json:"params"` -} - -func (m *GetModuleStatusResponse) Reset() { *m = GetModuleStatusResponse{} } -func (m *GetModuleStatusResponse) String() string { return proto.CompactTextString(m) } -func (*GetModuleStatusResponse) ProtoMessage() {} -func (*GetModuleStatusResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_04f05289607f461a, []int{1} -} -func (m *GetModuleStatusResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetModuleStatusResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetModuleStatusResponse.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 *GetModuleStatusResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetModuleStatusResponse.Merge(m, src) -} -func (m *GetModuleStatusResponse) XXX_Size() int { - return m.Size() -} -func (m *GetModuleStatusResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetModuleStatusResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GetModuleStatusResponse proto.InternalMessageInfo - -func (m *GetModuleStatusResponse) GetRewardCoins() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.RewardCoins - } - return nil -} - -func (m *GetModuleStatusResponse) GetStakedCoins() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.StakedCoins - } - return nil -} - -func (m *GetModuleStatusResponse) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -type GetGaugeByIDRequest struct { - // Gague ID being queried - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` -} - -func (m *GetGaugeByIDRequest) Reset() { *m = GetGaugeByIDRequest{} } -func (m *GetGaugeByIDRequest) String() string { return proto.CompactTextString(m) } -func (*GetGaugeByIDRequest) ProtoMessage() {} -func (*GetGaugeByIDRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_04f05289607f461a, []int{2} -} -func (m *GetGaugeByIDRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetGaugeByIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetGaugeByIDRequest.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 *GetGaugeByIDRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetGaugeByIDRequest.Merge(m, src) -} -func (m *GetGaugeByIDRequest) XXX_Size() int { - return m.Size() -} -func (m *GetGaugeByIDRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetGaugeByIDRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetGaugeByIDRequest proto.InternalMessageInfo - -func (m *GetGaugeByIDRequest) GetId() uint64 { - if m != nil { - return m.Id - } - return 0 -} - -type GetGaugeByIDResponse struct { - // Gauge that corresponds to provided gague ID - Gauge *Gauge `protobuf:"bytes,1,opt,name=gauge,proto3" json:"gauge,omitempty"` -} - -func (m *GetGaugeByIDResponse) Reset() { *m = GetGaugeByIDResponse{} } -func (m *GetGaugeByIDResponse) String() string { return proto.CompactTextString(m) } -func (*GetGaugeByIDResponse) ProtoMessage() {} -func (*GetGaugeByIDResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_04f05289607f461a, []int{3} -} -func (m *GetGaugeByIDResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetGaugeByIDResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetGaugeByIDResponse.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 *GetGaugeByIDResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetGaugeByIDResponse.Merge(m, src) -} -func (m *GetGaugeByIDResponse) XXX_Size() int { - return m.Size() -} -func (m *GetGaugeByIDResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetGaugeByIDResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GetGaugeByIDResponse proto.InternalMessageInfo - -func (m *GetGaugeByIDResponse) GetGauge() *Gauge { - if m != nil { - return m.Gauge - } - return nil -} - -type GetGaugeQualifyingValueRequest struct { - // Gague ID being queried - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` -} - -func (m *GetGaugeQualifyingValueRequest) Reset() { *m = GetGaugeQualifyingValueRequest{} } -func (m *GetGaugeQualifyingValueRequest) String() string { return proto.CompactTextString(m) } -func (*GetGaugeQualifyingValueRequest) ProtoMessage() {} -func (*GetGaugeQualifyingValueRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_04f05289607f461a, []int{4} -} -func (m *GetGaugeQualifyingValueRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetGaugeQualifyingValueRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetGaugeQualifyingValueRequest.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 *GetGaugeQualifyingValueRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetGaugeQualifyingValueRequest.Merge(m, src) -} -func (m *GetGaugeQualifyingValueRequest) XXX_Size() int { - return m.Size() -} -func (m *GetGaugeQualifyingValueRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetGaugeQualifyingValueRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetGaugeQualifyingValueRequest proto.InternalMessageInfo - -func (m *GetGaugeQualifyingValueRequest) GetId() uint64 { - if m != nil { - return m.Id - } - return 0 -} - -type GetGaugeQualifyingValueResponse struct { - // The amount of value at the gauge's pricing tick currently qualifying for the gauge. - QualifyingValue uint64 `protobuf:"varint,1,opt,name=qualifying_value,json=qualifyingValue,proto3" json:"qualifying_value,omitempty"` -} - -func (m *GetGaugeQualifyingValueResponse) Reset() { *m = GetGaugeQualifyingValueResponse{} } -func (m *GetGaugeQualifyingValueResponse) String() string { return proto.CompactTextString(m) } -func (*GetGaugeQualifyingValueResponse) ProtoMessage() {} -func (*GetGaugeQualifyingValueResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_04f05289607f461a, []int{5} -} -func (m *GetGaugeQualifyingValueResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetGaugeQualifyingValueResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetGaugeQualifyingValueResponse.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 *GetGaugeQualifyingValueResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetGaugeQualifyingValueResponse.Merge(m, src) -} -func (m *GetGaugeQualifyingValueResponse) XXX_Size() int { - return m.Size() -} -func (m *GetGaugeQualifyingValueResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetGaugeQualifyingValueResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GetGaugeQualifyingValueResponse proto.InternalMessageInfo - -func (m *GetGaugeQualifyingValueResponse) GetQualifyingValue() uint64 { - if m != nil { - return m.QualifyingValue - } - return 0 -} - -type GetGaugesRequest struct { - Status GaugeStatus `protobuf:"varint,1,opt,name=status,proto3,enum=neutron.incentives.GaugeStatus" json:"status,omitempty"` - Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` -} - -func (m *GetGaugesRequest) Reset() { *m = GetGaugesRequest{} } -func (m *GetGaugesRequest) String() string { return proto.CompactTextString(m) } -func (*GetGaugesRequest) ProtoMessage() {} -func (*GetGaugesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_04f05289607f461a, []int{6} -} -func (m *GetGaugesRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetGaugesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetGaugesRequest.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 *GetGaugesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetGaugesRequest.Merge(m, src) -} -func (m *GetGaugesRequest) XXX_Size() int { - return m.Size() -} -func (m *GetGaugesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetGaugesRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetGaugesRequest proto.InternalMessageInfo - -func (m *GetGaugesRequest) GetStatus() GaugeStatus { - if m != nil { - return m.Status - } - return GaugeStatus_ACTIVE_UPCOMING -} - -func (m *GetGaugesRequest) GetDenom() string { - if m != nil { - return m.Denom - } - return "" -} - -type GetGaugesResponse struct { - // Upcoming and active gauges - Gauges []*Gauge `protobuf:"bytes,1,rep,name=gauges,proto3" json:"gauges,omitempty"` -} - -func (m *GetGaugesResponse) Reset() { *m = GetGaugesResponse{} } -func (m *GetGaugesResponse) String() string { return proto.CompactTextString(m) } -func (*GetGaugesResponse) ProtoMessage() {} -func (*GetGaugesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_04f05289607f461a, []int{7} -} -func (m *GetGaugesResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetGaugesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetGaugesResponse.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 *GetGaugesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetGaugesResponse.Merge(m, src) -} -func (m *GetGaugesResponse) XXX_Size() int { - return m.Size() -} -func (m *GetGaugesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetGaugesResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GetGaugesResponse proto.InternalMessageInfo - -func (m *GetGaugesResponse) GetGauges() []*Gauge { - if m != nil { - return m.Gauges - } - return nil -} - -type GetStakeByIDRequest struct { - StakeId uint64 `protobuf:"varint,1,opt,name=stake_id,json=stakeId,proto3" json:"stake_id,omitempty"` -} - -func (m *GetStakeByIDRequest) Reset() { *m = GetStakeByIDRequest{} } -func (m *GetStakeByIDRequest) String() string { return proto.CompactTextString(m) } -func (*GetStakeByIDRequest) ProtoMessage() {} -func (*GetStakeByIDRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_04f05289607f461a, []int{8} -} -func (m *GetStakeByIDRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetStakeByIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetStakeByIDRequest.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 *GetStakeByIDRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetStakeByIDRequest.Merge(m, src) -} -func (m *GetStakeByIDRequest) XXX_Size() int { - return m.Size() -} -func (m *GetStakeByIDRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetStakeByIDRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetStakeByIDRequest proto.InternalMessageInfo - -func (m *GetStakeByIDRequest) GetStakeId() uint64 { - if m != nil { - return m.StakeId - } - return 0 -} - -type GetStakeByIDResponse struct { - Stake *Stake `protobuf:"bytes,1,opt,name=stake,proto3" json:"stake,omitempty"` -} - -func (m *GetStakeByIDResponse) Reset() { *m = GetStakeByIDResponse{} } -func (m *GetStakeByIDResponse) String() string { return proto.CompactTextString(m) } -func (*GetStakeByIDResponse) ProtoMessage() {} -func (*GetStakeByIDResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_04f05289607f461a, []int{9} -} -func (m *GetStakeByIDResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetStakeByIDResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetStakeByIDResponse.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 *GetStakeByIDResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetStakeByIDResponse.Merge(m, src) -} -func (m *GetStakeByIDResponse) XXX_Size() int { - return m.Size() -} -func (m *GetStakeByIDResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetStakeByIDResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GetStakeByIDResponse proto.InternalMessageInfo - -func (m *GetStakeByIDResponse) GetStake() *Stake { - if m != nil { - return m.Stake - } - return nil -} - -type GetStakesRequest struct { - Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"` -} - -func (m *GetStakesRequest) Reset() { *m = GetStakesRequest{} } -func (m *GetStakesRequest) String() string { return proto.CompactTextString(m) } -func (*GetStakesRequest) ProtoMessage() {} -func (*GetStakesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_04f05289607f461a, []int{10} -} -func (m *GetStakesRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetStakesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetStakesRequest.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 *GetStakesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetStakesRequest.Merge(m, src) -} -func (m *GetStakesRequest) XXX_Size() int { - return m.Size() -} -func (m *GetStakesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetStakesRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetStakesRequest proto.InternalMessageInfo - -func (m *GetStakesRequest) GetOwner() string { - if m != nil { - return m.Owner - } - return "" -} - -type GetStakesResponse struct { - Stakes []*Stake `protobuf:"bytes,1,rep,name=stakes,proto3" json:"stakes,omitempty"` -} - -func (m *GetStakesResponse) Reset() { *m = GetStakesResponse{} } -func (m *GetStakesResponse) String() string { return proto.CompactTextString(m) } -func (*GetStakesResponse) ProtoMessage() {} -func (*GetStakesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_04f05289607f461a, []int{11} -} -func (m *GetStakesResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetStakesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetStakesResponse.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 *GetStakesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetStakesResponse.Merge(m, src) -} -func (m *GetStakesResponse) XXX_Size() int { - return m.Size() -} -func (m *GetStakesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetStakesResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GetStakesResponse proto.InternalMessageInfo - -func (m *GetStakesResponse) GetStakes() []*Stake { - if m != nil { - return m.Stakes - } - return nil -} - -type GetFutureRewardEstimateRequest struct { - // Address that is being queried for future estimated rewards - Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"` - // Stake IDs included in future reward estimation - StakeIds []uint64 `protobuf:"varint,2,rep,packed,name=stake_ids,json=stakeIds,proto3" json:"stake_ids,omitempty"` - // Determines upper time limit of reward estimation - // reward estimation goes up to current_epoch + num_epochs - NumEpochs int64 `protobuf:"varint,3,opt,name=num_epochs,json=numEpochs,proto3" json:"num_epochs,omitempty"` -} - -func (m *GetFutureRewardEstimateRequest) Reset() { *m = GetFutureRewardEstimateRequest{} } -func (m *GetFutureRewardEstimateRequest) String() string { return proto.CompactTextString(m) } -func (*GetFutureRewardEstimateRequest) ProtoMessage() {} -func (*GetFutureRewardEstimateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_04f05289607f461a, []int{12} -} -func (m *GetFutureRewardEstimateRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetFutureRewardEstimateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetFutureRewardEstimateRequest.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 *GetFutureRewardEstimateRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetFutureRewardEstimateRequest.Merge(m, src) -} -func (m *GetFutureRewardEstimateRequest) XXX_Size() int { - return m.Size() -} -func (m *GetFutureRewardEstimateRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetFutureRewardEstimateRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetFutureRewardEstimateRequest proto.InternalMessageInfo - -func (m *GetFutureRewardEstimateRequest) GetOwner() string { - if m != nil { - return m.Owner - } - return "" -} - -func (m *GetFutureRewardEstimateRequest) GetStakeIds() []uint64 { - if m != nil { - return m.StakeIds - } - return nil -} - -func (m *GetFutureRewardEstimateRequest) GetNumEpochs() int64 { - if m != nil { - return m.NumEpochs - } - return 0 -} - -type GetFutureRewardEstimateResponse struct { - // Estimated coin rewards that will be recieved at provided address - // from specified locks between current time and end epoch - Coins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=coins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coins"` -} - -func (m *GetFutureRewardEstimateResponse) Reset() { *m = GetFutureRewardEstimateResponse{} } -func (m *GetFutureRewardEstimateResponse) String() string { return proto.CompactTextString(m) } -func (*GetFutureRewardEstimateResponse) ProtoMessage() {} -func (*GetFutureRewardEstimateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_04f05289607f461a, []int{13} -} -func (m *GetFutureRewardEstimateResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetFutureRewardEstimateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetFutureRewardEstimateResponse.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 *GetFutureRewardEstimateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetFutureRewardEstimateResponse.Merge(m, src) -} -func (m *GetFutureRewardEstimateResponse) XXX_Size() int { - return m.Size() -} -func (m *GetFutureRewardEstimateResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetFutureRewardEstimateResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GetFutureRewardEstimateResponse proto.InternalMessageInfo - -func (m *GetFutureRewardEstimateResponse) GetCoins() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.Coins - } - return nil -} - -type GetAccountHistoryRequest struct { - // Address that is being queried for account history - Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty" yaml:"account"` -} - -func (m *GetAccountHistoryRequest) Reset() { *m = GetAccountHistoryRequest{} } -func (m *GetAccountHistoryRequest) String() string { return proto.CompactTextString(m) } -func (*GetAccountHistoryRequest) ProtoMessage() {} -func (*GetAccountHistoryRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_04f05289607f461a, []int{14} -} -func (m *GetAccountHistoryRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetAccountHistoryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetAccountHistoryRequest.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 *GetAccountHistoryRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetAccountHistoryRequest.Merge(m, src) -} -func (m *GetAccountHistoryRequest) XXX_Size() int { - return m.Size() -} -func (m *GetAccountHistoryRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetAccountHistoryRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetAccountHistoryRequest proto.InternalMessageInfo - -func (m *GetAccountHistoryRequest) GetAccount() string { - if m != nil { - return m.Account - } - return "" -} - -type GetAccountHistoryResponse struct { - // Gauge rewards that have been distributed to this address to date - Coins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=coins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coins"` -} - -func (m *GetAccountHistoryResponse) Reset() { *m = GetAccountHistoryResponse{} } -func (m *GetAccountHistoryResponse) String() string { return proto.CompactTextString(m) } -func (*GetAccountHistoryResponse) ProtoMessage() {} -func (*GetAccountHistoryResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_04f05289607f461a, []int{15} -} -func (m *GetAccountHistoryResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetAccountHistoryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetAccountHistoryResponse.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 *GetAccountHistoryResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetAccountHistoryResponse.Merge(m, src) -} -func (m *GetAccountHistoryResponse) XXX_Size() int { - return m.Size() -} -func (m *GetAccountHistoryResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetAccountHistoryResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GetAccountHistoryResponse proto.InternalMessageInfo - -func (m *GetAccountHistoryResponse) GetCoins() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.Coins - } - return nil -} - -func init() { - proto.RegisterEnum("neutron.incentives.GaugeStatus", GaugeStatus_name, GaugeStatus_value) - proto.RegisterType((*GetModuleStatusRequest)(nil), "neutron.incentives.GetModuleStatusRequest") - proto.RegisterType((*GetModuleStatusResponse)(nil), "neutron.incentives.GetModuleStatusResponse") - proto.RegisterType((*GetGaugeByIDRequest)(nil), "neutron.incentives.GetGaugeByIDRequest") - proto.RegisterType((*GetGaugeByIDResponse)(nil), "neutron.incentives.GetGaugeByIDResponse") - proto.RegisterType((*GetGaugeQualifyingValueRequest)(nil), "neutron.incentives.GetGaugeQualifyingValueRequest") - proto.RegisterType((*GetGaugeQualifyingValueResponse)(nil), "neutron.incentives.GetGaugeQualifyingValueResponse") - proto.RegisterType((*GetGaugesRequest)(nil), "neutron.incentives.GetGaugesRequest") - proto.RegisterType((*GetGaugesResponse)(nil), "neutron.incentives.GetGaugesResponse") - proto.RegisterType((*GetStakeByIDRequest)(nil), "neutron.incentives.GetStakeByIDRequest") - proto.RegisterType((*GetStakeByIDResponse)(nil), "neutron.incentives.GetStakeByIDResponse") - proto.RegisterType((*GetStakesRequest)(nil), "neutron.incentives.GetStakesRequest") - proto.RegisterType((*GetStakesResponse)(nil), "neutron.incentives.GetStakesResponse") - proto.RegisterType((*GetFutureRewardEstimateRequest)(nil), "neutron.incentives.GetFutureRewardEstimateRequest") - proto.RegisterType((*GetFutureRewardEstimateResponse)(nil), "neutron.incentives.GetFutureRewardEstimateResponse") - proto.RegisterType((*GetAccountHistoryRequest)(nil), "neutron.incentives.GetAccountHistoryRequest") - proto.RegisterType((*GetAccountHistoryResponse)(nil), "neutron.incentives.GetAccountHistoryResponse") -} - -func init() { proto.RegisterFile("neutron/incentives/query.proto", fileDescriptor_04f05289607f461a) } - -var fileDescriptor_04f05289607f461a = []byte{ - // 1075 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4f, 0x4f, 0x1b, 0xc7, - 0x1b, 0x66, 0x0d, 0x76, 0xf0, 0x80, 0xc0, 0xbf, 0x09, 0xfa, 0xd5, 0xb8, 0xa9, 0x8d, 0x46, 0xa1, - 0x18, 0x12, 0xbc, 0xd8, 0x51, 0x95, 0x2a, 0x55, 0x0e, 0x31, 0x01, 0xe3, 0xb6, 0x49, 0x93, 0xa5, - 0xcd, 0xa1, 0x97, 0xd5, 0x62, 0x4f, 0x96, 0x55, 0xec, 0x1d, 0xb3, 0x33, 0x4b, 0x6a, 0x51, 0x7a, - 0xa8, 0xf2, 0x01, 0xa2, 0xf6, 0x56, 0xa9, 0x5f, 0xa0, 0x97, 0x1e, 0xfa, 0x21, 0x9a, 0x63, 0xa4, - 0x5e, 0x7a, 0xa2, 0x15, 0xf4, 0x13, 0xe4, 0x13, 0x54, 0xfb, 0xce, 0xac, 0xb1, 0x61, 0x77, 0x21, - 0x87, 0xf4, 0x64, 0xef, 0xbc, 0xff, 0x9e, 0xf7, 0x79, 0x67, 0x9e, 0x19, 0x54, 0x74, 0xa9, 0x2f, - 0x3c, 0xe6, 0xea, 0x8e, 0xdb, 0xa2, 0xae, 0x70, 0xf6, 0x29, 0xd7, 0xf7, 0x7c, 0xea, 0xf5, 0x2b, - 0x3d, 0x8f, 0x09, 0x86, 0xb1, 0xb2, 0x57, 0x4e, 0xed, 0x85, 0x39, 0x9b, 0xd9, 0x0c, 0xcc, 0x7a, - 0xf0, 0x4f, 0x7a, 0x16, 0xae, 0xd9, 0x8c, 0xd9, 0x1d, 0xaa, 0x5b, 0x3d, 0x47, 0xb7, 0x5c, 0x97, - 0x09, 0x4b, 0x38, 0xcc, 0xe5, 0xca, 0x5a, 0x6c, 0x31, 0xde, 0x65, 0x5c, 0xdf, 0xb1, 0x38, 0xd5, - 0xf7, 0xab, 0x3b, 0x54, 0x58, 0x55, 0xbd, 0xc5, 0x1c, 0x57, 0xd9, 0x57, 0x86, 0xed, 0x00, 0x60, - 0xe0, 0xd5, 0xb3, 0x6c, 0xc7, 0x85, 0x64, 0x61, 0xae, 0x08, 0xcc, 0xb6, 0xe5, 0xdb, 0x34, 0xc1, - 0xce, 0x85, 0xf5, 0x2c, 0xb4, 0x97, 0x22, 0xec, 0x3d, 0xcb, 0xb3, 0xba, 0x0a, 0x2c, 0xc9, 0xa3, - 0xff, 0x37, 0xa8, 0x78, 0xc0, 0xda, 0x7e, 0x87, 0x6e, 0x0b, 0x4b, 0xf8, 0xdc, 0xa0, 0x7b, 0x3e, - 0xe5, 0x82, 0xfc, 0x96, 0x42, 0xef, 0x9d, 0x33, 0xf1, 0x1e, 0x73, 0x39, 0xc5, 0x2e, 0x9a, 0xf6, - 0xe8, 0x73, 0xcb, 0x6b, 0x9b, 0x41, 0x5f, 0x3c, 0xaf, 0x2d, 0x8c, 0x97, 0xa7, 0x6a, 0xf3, 0x15, - 0xd9, 0x59, 0x25, 0xe8, 0xac, 0xa2, 0x7a, 0xaa, 0xac, 0x33, 0xc7, 0xad, 0xaf, 0xbd, 0x3a, 0x2a, - 0x8d, 0xfd, 0xf2, 0x57, 0xa9, 0x6c, 0x3b, 0x62, 0xd7, 0xdf, 0xa9, 0xb4, 0x58, 0x57, 0x57, 0x34, - 0xc8, 0x9f, 0x55, 0xde, 0x7e, 0xa6, 0x8b, 0x7e, 0x8f, 0x72, 0x08, 0xe0, 0xc6, 0x94, 0x2c, 0x00, - 0x1f, 0x41, 0x3d, 0xe8, 0x2a, 0xac, 0x97, 0x7a, 0x07, 0xf5, 0x64, 0x01, 0x59, 0xef, 0x63, 0x94, - 0x91, 0x2c, 0xe5, 0xc7, 0x17, 0xb4, 0xf2, 0x54, 0xad, 0x50, 0x39, 0xbf, 0x37, 0x2a, 0x8f, 0xc0, - 0xa3, 0x3e, 0x11, 0x94, 0x32, 0x94, 0x3f, 0x59, 0x44, 0x57, 0x1b, 0x54, 0x34, 0x82, 0x11, 0xd5, - 0xfb, 0xcd, 0xfb, 0x8a, 0x4c, 0x3c, 0x83, 0x52, 0x4e, 0x3b, 0xaf, 0x2d, 0x68, 0xe5, 0x09, 0x23, - 0xe5, 0xb4, 0x49, 0x03, 0xcd, 0x8d, 0xba, 0x29, 0x62, 0x75, 0x94, 0x86, 0xf1, 0x82, 0x6b, 0xd0, - 0x61, 0x44, 0x5d, 0x88, 0x32, 0xa4, 0x1f, 0x59, 0x43, 0xc5, 0x30, 0xd1, 0x63, 0xdf, 0xea, 0x38, - 0x4f, 0xfb, 0x8e, 0x6b, 0x3f, 0xb1, 0x3a, 0x3e, 0x8d, 0x2b, 0xfd, 0x39, 0x2a, 0xc5, 0x46, 0x28, - 0x14, 0xcb, 0x28, 0xb7, 0x37, 0x30, 0x99, 0xfb, 0x81, 0x4d, 0x25, 0x98, 0xdd, 0x1b, 0x0d, 0x21, - 0x16, 0xca, 0x85, 0xd9, 0xc2, 0x9d, 0x83, 0x6f, 0xa3, 0x0c, 0x87, 0xfd, 0x02, 0x41, 0x33, 0xb5, - 0x52, 0x6c, 0x17, 0x6a, 0x5b, 0x29, 0x77, 0x3c, 0x87, 0xd2, 0x6d, 0xea, 0xb2, 0x6e, 0x3e, 0xb5, - 0xa0, 0x95, 0xb3, 0x86, 0xfc, 0x20, 0x9b, 0xe8, 0x7f, 0x43, 0x25, 0x14, 0xc4, 0x2a, 0xca, 0x00, - 0x01, 0xa7, 0x7b, 0x2f, 0x96, 0x29, 0xe5, 0x48, 0xd6, 0x60, 0x34, 0xdb, 0xc1, 0x98, 0x87, 0x47, - 0x33, 0x8f, 0x26, 0x61, 0xf4, 0xe6, 0x80, 0xa5, 0x2b, 0xf0, 0xdd, 0x0c, 0xa7, 0x34, 0x14, 0x71, - 0x3a, 0x25, 0x70, 0x49, 0x9a, 0x12, 0x44, 0x19, 0xd2, 0x8f, 0xdc, 0x01, 0x96, 0x60, 0x69, 0xc0, - 0xd2, 0x87, 0x28, 0xcd, 0x9e, 0xbb, 0xd4, 0x83, 0x24, 0xd9, 0x7a, 0xee, 0xcd, 0x51, 0x69, 0xba, - 0x6f, 0x75, 0x3b, 0x77, 0x08, 0x2c, 0x13, 0x43, 0x9a, 0x55, 0xfb, 0x61, 0xec, 0x69, 0xfb, 0x90, - 0x39, 0xb1, 0x7d, 0x09, 0x41, 0x39, 0x92, 0x17, 0x1a, 0x6c, 0x95, 0x4d, 0x5f, 0xf8, 0x1e, 0x35, - 0xe0, 0x70, 0x6d, 0x70, 0xe1, 0x74, 0x2d, 0x41, 0xdf, 0x12, 0x12, 0x7e, 0x1f, 0x65, 0x43, 0xca, - 0xe4, 0x59, 0x9c, 0x30, 0x26, 0x15, 0x67, 0x1c, 0x7f, 0x80, 0x90, 0xeb, 0x77, 0x4d, 0xda, 0x63, - 0xad, 0x5d, 0x79, 0x7e, 0xc6, 0x8d, 0xac, 0xeb, 0x77, 0x37, 0x60, 0x21, 0x80, 0x51, 0x8a, 0x85, - 0xa1, 0xba, 0xb3, 0x50, 0xfa, 0x9d, 0xe9, 0x8a, 0xcc, 0x4c, 0xb6, 0x50, 0xbe, 0x41, 0xc5, 0xbd, - 0x56, 0x8b, 0xf9, 0xae, 0xd8, 0x72, 0xb8, 0x60, 0x5e, 0x3f, 0xa4, 0xe1, 0x26, 0xba, 0x62, 0x49, - 0x83, 0x22, 0x02, 0xbf, 0x39, 0x2a, 0xcd, 0x48, 0x22, 0x94, 0x81, 0x18, 0xa1, 0x0b, 0xf9, 0x0e, - 0xcd, 0x47, 0x64, 0xfa, 0xcf, 0x3a, 0x59, 0xf9, 0x14, 0x4d, 0x0d, 0x9d, 0x25, 0x7c, 0x15, 0xcd, - 0xde, 0x5b, 0xff, 0xb2, 0xf9, 0x64, 0xc3, 0xfc, 0xea, 0xd1, 0xfa, 0x17, 0x0f, 0x9a, 0x0f, 0x1b, - 0xb9, 0x31, 0x8c, 0x50, 0x46, 0x2e, 0xe6, 0x34, 0x3c, 0x8d, 0x26, 0x07, 0x96, 0x54, 0xf0, 0xb5, - 0xd9, 0x7c, 0xd8, 0xdc, 0xde, 0xda, 0xb8, 0x9f, 0x1b, 0xaf, 0xfd, 0x84, 0x50, 0xfa, 0x71, 0x70, - 0x23, 0xe1, 0x9f, 0x35, 0x34, 0x7b, 0x46, 0xfd, 0xf1, 0x4a, 0xe4, 0x19, 0x8b, 0xbc, 0x3d, 0x0a, - 0x37, 0x2e, 0xe5, 0x2b, 0x59, 0x22, 0xd5, 0xef, 0xff, 0xf8, 0xe7, 0xc7, 0xd4, 0x0d, 0xbc, 0xac, - 0x47, 0x5c, 0x57, 0xe1, 0xdd, 0xd8, 0x85, 0x48, 0x53, 0x49, 0xc5, 0x0f, 0x1a, 0x9a, 0x1e, 0x56, - 0x50, 0xbc, 0x14, 0x53, 0xf0, 0xac, 0x14, 0x17, 0xca, 0x17, 0x3b, 0x2a, 0x58, 0x3a, 0xc0, 0x5a, - 0xc6, 0x4b, 0x49, 0xb0, 0xa4, 0xb8, 0xe8, 0x07, 0x4e, 0xfb, 0x10, 0xbf, 0xd0, 0x50, 0x76, 0x20, - 0x55, 0xf8, 0x7a, 0x52, 0xa1, 0x01, 0x51, 0x8b, 0x17, 0x78, 0x29, 0x2c, 0x2b, 0x80, 0xe5, 0x3a, - 0x26, 0x17, 0x63, 0xc1, 0x2f, 0x25, 0x37, 0x03, 0xdd, 0x8a, 0xe5, 0xe6, 0xac, 0x16, 0xc6, 0x72, - 0x73, 0x4e, 0x02, 0xc9, 0x2a, 0xe0, 0x59, 0xc2, 0x8b, 0x7a, 0xdc, 0x0b, 0x84, 0xeb, 0x07, 0xa1, - 0x48, 0x1c, 0xe2, 0x6f, 0x81, 0x18, 0x29, 0x62, 0xb1, 0xc4, 0x8c, 0xe8, 0x63, 0x2c, 0x31, 0xa3, - 0x4a, 0x48, 0x08, 0x00, 0xb9, 0x86, 0x0b, 0xf1, 0x40, 0xf0, 0xef, 0x1a, 0x3c, 0x65, 0xa2, 0x34, - 0x07, 0xd7, 0x62, 0xca, 0x24, 0xe8, 0x64, 0xe1, 0xd6, 0x5b, 0xc5, 0x28, 0xa0, 0xeb, 0x00, 0xf4, - 0x2e, 0xfe, 0x24, 0x69, 0x82, 0x4f, 0x21, 0x83, 0x29, 0xdf, 0x3e, 0xdc, 0xa4, 0x2a, 0x89, 0x7e, - 0x00, 0xc2, 0x7b, 0x88, 0x7f, 0xd5, 0xe0, 0x36, 0x18, 0x55, 0x1b, 0x7c, 0x33, 0x06, 0x4f, 0xa4, - 0xbc, 0x15, 0x56, 0x2f, 0xe9, 0xad, 0x70, 0xdf, 0x05, 0xdc, 0xb7, 0xf1, 0x47, 0x49, 0xb8, 0x95, - 0x18, 0x9a, 0xbb, 0x32, 0x58, 0x3f, 0x50, 0x0b, 0x87, 0x21, 0xf7, 0x51, 0xef, 0x8d, 0x58, 0xee, - 0x13, 0x9e, 0x33, 0xb1, 0xdc, 0x27, 0x3d, 0x68, 0x2e, 0xc7, 0xbd, 0x4d, 0x85, 0x09, 0x27, 0xc8, - 0x3c, 0xfb, 0xf8, 0x81, 0xd3, 0x5d, 0xff, 0xec, 0xd5, 0x71, 0x51, 0x7b, 0x7d, 0x5c, 0xd4, 0xfe, - 0x3e, 0x2e, 0x6a, 0x2f, 0x4f, 0x8a, 0x63, 0xaf, 0x4f, 0x8a, 0x63, 0x7f, 0x9e, 0x14, 0xc7, 0xbe, - 0xae, 0x0e, 0x69, 0xb6, 0x2a, 0xb0, 0xca, 0x3c, 0x7b, 0x50, 0xec, 0x9b, 0xe1, 0x72, 0x20, 0xe1, - 0x3b, 0x19, 0x78, 0x7e, 0xdf, 0xfa, 0x37, 0x00, 0x00, 0xff, 0xff, 0xc4, 0xcb, 0x7d, 0x4c, 0x95, - 0x0c, 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 { - // GetModuleStatus returns a rundown of coins in the module and their status - GetModuleStatus(ctx context.Context, in *GetModuleStatusRequest, opts ...grpc.CallOption) (*GetModuleStatusResponse, error) - // GetGaugeByID returns a gauge by its ID - GetGaugeByID(ctx context.Context, in *GetGaugeByIDRequest, opts ...grpc.CallOption) (*GetGaugeByIDResponse, error) - // GetGauges returns gauges according to the filter provided - GetGauges(ctx context.Context, in *GetGaugesRequest, opts ...grpc.CallOption) (*GetGaugesResponse, error) - // GetStakeByID returns a stake by its ID - GetStakeByID(ctx context.Context, in *GetStakeByIDRequest, opts ...grpc.CallOption) (*GetStakeByIDResponse, error) - // GetStakes returns stakes by the filter provided. At least one filter must be provided. - GetStakes(ctx context.Context, in *GetStakesRequest, opts ...grpc.CallOption) (*GetStakesResponse, error) - // GetFutureRewardsEstimate returns an estimate of the rewards from now until a specified - // time in the future. The requestor either provides an address or a set of locks - // for which they want to find the associated rewards. - GetFutureRewardEstimate(ctx context.Context, in *GetFutureRewardEstimateRequest, opts ...grpc.CallOption) (*GetFutureRewardEstimateResponse, error) - // GetAccountHistory returns the total accumulated rewards per denom for a given user. - GetAccountHistory(ctx context.Context, in *GetAccountHistoryRequest, opts ...grpc.CallOption) (*GetAccountHistoryResponse, error) - // Returns the total amount of value currently qualifying for the gauge. This is useful for calculating - // the prospective future rewards of staking. - GetGaugeQualifyingValue(ctx context.Context, in *GetGaugeQualifyingValueRequest, opts ...grpc.CallOption) (*GetGaugeQualifyingValueResponse, error) -} - -type queryClient struct { - cc grpc1.ClientConn -} - -func NewQueryClient(cc grpc1.ClientConn) QueryClient { - return &queryClient{cc} -} - -func (c *queryClient) GetModuleStatus(ctx context.Context, in *GetModuleStatusRequest, opts ...grpc.CallOption) (*GetModuleStatusResponse, error) { - out := new(GetModuleStatusResponse) - err := c.cc.Invoke(ctx, "/neutron.incentives.Query/GetModuleStatus", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) GetGaugeByID(ctx context.Context, in *GetGaugeByIDRequest, opts ...grpc.CallOption) (*GetGaugeByIDResponse, error) { - out := new(GetGaugeByIDResponse) - err := c.cc.Invoke(ctx, "/neutron.incentives.Query/GetGaugeByID", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) GetGauges(ctx context.Context, in *GetGaugesRequest, opts ...grpc.CallOption) (*GetGaugesResponse, error) { - out := new(GetGaugesResponse) - err := c.cc.Invoke(ctx, "/neutron.incentives.Query/GetGauges", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) GetStakeByID(ctx context.Context, in *GetStakeByIDRequest, opts ...grpc.CallOption) (*GetStakeByIDResponse, error) { - out := new(GetStakeByIDResponse) - err := c.cc.Invoke(ctx, "/neutron.incentives.Query/GetStakeByID", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) GetStakes(ctx context.Context, in *GetStakesRequest, opts ...grpc.CallOption) (*GetStakesResponse, error) { - out := new(GetStakesResponse) - err := c.cc.Invoke(ctx, "/neutron.incentives.Query/GetStakes", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) GetFutureRewardEstimate(ctx context.Context, in *GetFutureRewardEstimateRequest, opts ...grpc.CallOption) (*GetFutureRewardEstimateResponse, error) { - out := new(GetFutureRewardEstimateResponse) - err := c.cc.Invoke(ctx, "/neutron.incentives.Query/GetFutureRewardEstimate", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) GetAccountHistory(ctx context.Context, in *GetAccountHistoryRequest, opts ...grpc.CallOption) (*GetAccountHistoryResponse, error) { - out := new(GetAccountHistoryResponse) - err := c.cc.Invoke(ctx, "/neutron.incentives.Query/GetAccountHistory", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) GetGaugeQualifyingValue(ctx context.Context, in *GetGaugeQualifyingValueRequest, opts ...grpc.CallOption) (*GetGaugeQualifyingValueResponse, error) { - out := new(GetGaugeQualifyingValueResponse) - err := c.cc.Invoke(ctx, "/neutron.incentives.Query/GetGaugeQualifyingValue", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// QueryServer is the server API for Query service. -type QueryServer interface { - // GetModuleStatus returns a rundown of coins in the module and their status - GetModuleStatus(context.Context, *GetModuleStatusRequest) (*GetModuleStatusResponse, error) - // GetGaugeByID returns a gauge by its ID - GetGaugeByID(context.Context, *GetGaugeByIDRequest) (*GetGaugeByIDResponse, error) - // GetGauges returns gauges according to the filter provided - GetGauges(context.Context, *GetGaugesRequest) (*GetGaugesResponse, error) - // GetStakeByID returns a stake by its ID - GetStakeByID(context.Context, *GetStakeByIDRequest) (*GetStakeByIDResponse, error) - // GetStakes returns stakes by the filter provided. At least one filter must be provided. - GetStakes(context.Context, *GetStakesRequest) (*GetStakesResponse, error) - // GetFutureRewardsEstimate returns an estimate of the rewards from now until a specified - // time in the future. The requestor either provides an address or a set of locks - // for which they want to find the associated rewards. - GetFutureRewardEstimate(context.Context, *GetFutureRewardEstimateRequest) (*GetFutureRewardEstimateResponse, error) - // GetAccountHistory returns the total accumulated rewards per denom for a given user. - GetAccountHistory(context.Context, *GetAccountHistoryRequest) (*GetAccountHistoryResponse, error) - // Returns the total amount of value currently qualifying for the gauge. This is useful for calculating - // the prospective future rewards of staking. - GetGaugeQualifyingValue(context.Context, *GetGaugeQualifyingValueRequest) (*GetGaugeQualifyingValueResponse, error) -} - -// UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} - -func (*UnimplementedQueryServer) GetModuleStatus(ctx context.Context, req *GetModuleStatusRequest) (*GetModuleStatusResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetModuleStatus not implemented") -} -func (*UnimplementedQueryServer) GetGaugeByID(ctx context.Context, req *GetGaugeByIDRequest) (*GetGaugeByIDResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetGaugeByID not implemented") -} -func (*UnimplementedQueryServer) GetGauges(ctx context.Context, req *GetGaugesRequest) (*GetGaugesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetGauges not implemented") -} -func (*UnimplementedQueryServer) GetStakeByID(ctx context.Context, req *GetStakeByIDRequest) (*GetStakeByIDResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetStakeByID not implemented") -} -func (*UnimplementedQueryServer) GetStakes(ctx context.Context, req *GetStakesRequest) (*GetStakesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetStakes not implemented") -} -func (*UnimplementedQueryServer) GetFutureRewardEstimate(ctx context.Context, req *GetFutureRewardEstimateRequest) (*GetFutureRewardEstimateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetFutureRewardEstimate not implemented") -} -func (*UnimplementedQueryServer) GetAccountHistory(ctx context.Context, req *GetAccountHistoryRequest) (*GetAccountHistoryResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetAccountHistory not implemented") -} -func (*UnimplementedQueryServer) GetGaugeQualifyingValue(ctx context.Context, req *GetGaugeQualifyingValueRequest) (*GetGaugeQualifyingValueResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetGaugeQualifyingValue not implemented") -} - -func RegisterQueryServer(s grpc1.Server, srv QueryServer) { - s.RegisterService(&_Query_serviceDesc, srv) -} - -func _Query_GetModuleStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetModuleStatusRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GetModuleStatus(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/neutron.incentives.Query/GetModuleStatus", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetModuleStatus(ctx, req.(*GetModuleStatusRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_GetGaugeByID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetGaugeByIDRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GetGaugeByID(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/neutron.incentives.Query/GetGaugeByID", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetGaugeByID(ctx, req.(*GetGaugeByIDRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_GetGauges_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetGaugesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GetGauges(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/neutron.incentives.Query/GetGauges", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetGauges(ctx, req.(*GetGaugesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_GetStakeByID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetStakeByIDRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GetStakeByID(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/neutron.incentives.Query/GetStakeByID", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetStakeByID(ctx, req.(*GetStakeByIDRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_GetStakes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetStakesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GetStakes(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/neutron.incentives.Query/GetStakes", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetStakes(ctx, req.(*GetStakesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_GetFutureRewardEstimate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetFutureRewardEstimateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GetFutureRewardEstimate(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/neutron.incentives.Query/GetFutureRewardEstimate", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetFutureRewardEstimate(ctx, req.(*GetFutureRewardEstimateRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_GetAccountHistory_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetAccountHistoryRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GetAccountHistory(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/neutron.incentives.Query/GetAccountHistory", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetAccountHistory(ctx, req.(*GetAccountHistoryRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_GetGaugeQualifyingValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetGaugeQualifyingValueRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GetGaugeQualifyingValue(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/neutron.incentives.Query/GetGaugeQualifyingValue", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetGaugeQualifyingValue(ctx, req.(*GetGaugeQualifyingValueRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "neutron.incentives.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "GetModuleStatus", - Handler: _Query_GetModuleStatus_Handler, - }, - { - MethodName: "GetGaugeByID", - Handler: _Query_GetGaugeByID_Handler, - }, - { - MethodName: "GetGauges", - Handler: _Query_GetGauges_Handler, - }, - { - MethodName: "GetStakeByID", - Handler: _Query_GetStakeByID_Handler, - }, - { - MethodName: "GetStakes", - Handler: _Query_GetStakes_Handler, - }, - { - MethodName: "GetFutureRewardEstimate", - Handler: _Query_GetFutureRewardEstimate_Handler, - }, - { - MethodName: "GetAccountHistory", - Handler: _Query_GetAccountHistory_Handler, - }, - { - MethodName: "GetGaugeQualifyingValue", - Handler: _Query_GetGaugeQualifyingValue_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "neutron/incentives/query.proto", -} - -func (m *GetModuleStatusRequest) 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 *GetModuleStatusRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetModuleStatusRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *GetModuleStatusResponse) 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 *GetModuleStatusResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetModuleStatusResponse) 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] = 0x1a - if len(m.StakedCoins) > 0 { - for iNdEx := len(m.StakedCoins) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.StakedCoins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.RewardCoins) > 0 { - for iNdEx := len(m.RewardCoins) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.RewardCoins[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 *GetGaugeByIDRequest) 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 *GetGaugeByIDRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetGaugeByIDRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Id != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Id)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *GetGaugeByIDResponse) 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 *GetGaugeByIDResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetGaugeByIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Gauge != nil { - { - size, err := m.Gauge.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 *GetGaugeQualifyingValueRequest) 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 *GetGaugeQualifyingValueRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetGaugeQualifyingValueRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Id != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Id)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *GetGaugeQualifyingValueResponse) 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 *GetGaugeQualifyingValueResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetGaugeQualifyingValueResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.QualifyingValue != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.QualifyingValue)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *GetGaugesRequest) 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 *GetGaugesRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetGaugesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) - i-- - dAtA[i] = 0x12 - } - if m.Status != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Status)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *GetGaugesResponse) 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 *GetGaugesResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetGaugesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Gauges) > 0 { - for iNdEx := len(m.Gauges) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Gauges[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 *GetStakeByIDRequest) 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 *GetStakeByIDRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetStakeByIDRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.StakeId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.StakeId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *GetStakeByIDResponse) 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 *GetStakeByIDResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetStakeByIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Stake != nil { - { - size, err := m.Stake.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 *GetStakesRequest) 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 *GetStakesRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetStakesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Owner) > 0 { - i -= len(m.Owner) - copy(dAtA[i:], m.Owner) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Owner))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *GetStakesResponse) 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 *GetStakesResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetStakesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Stakes) > 0 { - for iNdEx := len(m.Stakes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Stakes[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 *GetFutureRewardEstimateRequest) 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 *GetFutureRewardEstimateRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetFutureRewardEstimateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.NumEpochs != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.NumEpochs)) - i-- - dAtA[i] = 0x18 - } - if len(m.StakeIds) > 0 { - dAtA5 := make([]byte, len(m.StakeIds)*10) - var j4 int - for _, num := range m.StakeIds { - for num >= 1<<7 { - dAtA5[j4] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j4++ - } - dAtA5[j4] = uint8(num) - j4++ - } - i -= j4 - copy(dAtA[i:], dAtA5[:j4]) - i = encodeVarintQuery(dAtA, i, uint64(j4)) - i-- - dAtA[i] = 0x12 - } - if len(m.Owner) > 0 { - i -= len(m.Owner) - copy(dAtA[i:], m.Owner) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Owner))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *GetFutureRewardEstimateResponse) 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 *GetFutureRewardEstimateResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetFutureRewardEstimateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Coins) > 0 { - for iNdEx := len(m.Coins) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Coins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *GetAccountHistoryRequest) 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 *GetAccountHistoryRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetAccountHistoryRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Account) > 0 { - i -= len(m.Account) - copy(dAtA[i:], m.Account) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Account))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *GetAccountHistoryResponse) 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 *GetAccountHistoryResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetAccountHistoryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Coins) > 0 { - for iNdEx := len(m.Coins) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Coins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = 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 *GetModuleStatusRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *GetModuleStatusResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.RewardCoins) > 0 { - for _, e := range m.RewardCoins { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if len(m.StakedCoins) > 0 { - for _, e := range m.StakedCoins { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *GetGaugeByIDRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Id != 0 { - n += 1 + sovQuery(uint64(m.Id)) - } - return n -} - -func (m *GetGaugeByIDResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Gauge != nil { - l = m.Gauge.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *GetGaugeQualifyingValueRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Id != 0 { - n += 1 + sovQuery(uint64(m.Id)) - } - return n -} - -func (m *GetGaugeQualifyingValueResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.QualifyingValue != 0 { - n += 1 + sovQuery(uint64(m.QualifyingValue)) - } - return n -} - -func (m *GetGaugesRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Status != 0 { - n += 1 + sovQuery(uint64(m.Status)) - } - l = len(m.Denom) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *GetGaugesResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Gauges) > 0 { - for _, e := range m.Gauges { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *GetStakeByIDRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.StakeId != 0 { - n += 1 + sovQuery(uint64(m.StakeId)) - } - return n -} - -func (m *GetStakeByIDResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Stake != nil { - l = m.Stake.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *GetStakesRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *GetStakesResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Stakes) > 0 { - for _, e := range m.Stakes { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *GetFutureRewardEstimateRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if len(m.StakeIds) > 0 { - l = 0 - for _, e := range m.StakeIds { - l += sovQuery(uint64(e)) - } - n += 1 + sovQuery(uint64(l)) + l - } - if m.NumEpochs != 0 { - n += 1 + sovQuery(uint64(m.NumEpochs)) - } - return n -} - -func (m *GetFutureRewardEstimateResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Coins) > 0 { - for _, e := range m.Coins { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *GetAccountHistoryRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Account) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *GetAccountHistoryResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Coins) > 0 { - for _, e := range m.Coins { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *GetModuleStatusRequest) 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: GetModuleStatusRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetModuleStatusRequest: 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 *GetModuleStatusResponse) 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: GetModuleStatusResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetModuleStatusResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RewardCoins", 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.RewardCoins = append(m.RewardCoins, types.Coin{}) - if err := m.RewardCoins[len(m.RewardCoins)-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 StakedCoins", 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.StakedCoins = append(m.StakedCoins, types.Coin{}) - if err := m.StakedCoins[len(m.StakedCoins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - 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 (m *GetGaugeByIDRequest) 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: GetGaugeByIDRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetGaugeByIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *GetGaugeByIDResponse) 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: GetGaugeByIDResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetGaugeByIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Gauge", 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.Gauge == nil { - m.Gauge = &Gauge{} - } - if err := m.Gauge.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 *GetGaugeQualifyingValueRequest) 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: GetGaugeQualifyingValueRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetGaugeQualifyingValueRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *GetGaugeQualifyingValueResponse) 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: GetGaugeQualifyingValueResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetGaugeQualifyingValueResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field QualifyingValue", wireType) - } - m.QualifyingValue = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.QualifyingValue |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *GetGaugesRequest) 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: GetGaugesRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetGaugesRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - m.Status = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Status |= GaugeStatus(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", 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.Denom = 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 *GetGaugesResponse) 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: GetGaugesResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetGaugesResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Gauges", 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.Gauges = append(m.Gauges, &Gauge{}) - if err := m.Gauges[len(m.Gauges)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetStakeByIDRequest) 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: GetStakeByIDRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetStakeByIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StakeId", wireType) - } - m.StakeId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.StakeId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *GetStakeByIDResponse) 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: GetStakeByIDResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetStakeByIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Stake", 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.Stake == nil { - m.Stake = &Stake{} - } - if err := m.Stake.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 *GetStakesRequest) 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: GetStakesRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetStakesRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Owner = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - 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 *GetStakesResponse) 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: GetStakesResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetStakesResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Stakes", 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.Stakes = append(m.Stakes, &Stake{}) - if err := m.Stakes[len(m.Stakes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetFutureRewardEstimateRequest) 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: GetFutureRewardEstimateRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetFutureRewardEstimateRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Owner = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType == 0 { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.StakeIds = append(m.StakeIds, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.StakeIds) == 0 { - m.StakeIds = make([]uint64, 0, elementCount) - } - for iNdEx < postIndex { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.StakeIds = append(m.StakeIds, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field StakeIds", wireType) - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NumEpochs", wireType) - } - m.NumEpochs = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.NumEpochs |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *GetFutureRewardEstimateResponse) 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: GetFutureRewardEstimateResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetFutureRewardEstimateResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Coins", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 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.Coins = append(m.Coins, types.Coin{}) - if err := m.Coins[len(m.Coins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := 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 *GetAccountHistoryRequest) 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: GetAccountHistoryRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetAccountHistoryRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Account", 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.Account = 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 *GetAccountHistoryResponse) 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: GetAccountHistoryResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetAccountHistoryResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Coins", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 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.Coins = append(m.Coins, types.Coin{}) - if err := m.Coins[len(m.Coins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := 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/incentives/types/query.pb.gw.go b/x/incentives/types/query.pb.gw.go deleted file mode 100644 index 7d95daa11..000000000 --- a/x/incentives/types/query.pb.gw.go +++ /dev/null @@ -1,842 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: neutron/incentives/query.proto - -/* -Package types is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package types - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -func request_Query_GetModuleStatus_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetModuleStatusRequest - var metadata runtime.ServerMetadata - - msg, err := client.GetModuleStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_GetModuleStatus_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetModuleStatusRequest - var metadata runtime.ServerMetadata - - msg, err := server.GetModuleStatus(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_GetGaugeByID_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetGaugeByIDRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - - protoReq.Id, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - - msg, err := client.GetGaugeByID(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_GetGaugeByID_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetGaugeByIDRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - - protoReq.Id, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - - msg, err := server.GetGaugeByID(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_GetGauges_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_GetGauges_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetGaugesRequest - 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_GetGauges_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.GetGauges(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_GetGauges_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetGaugesRequest - 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_GetGauges_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.GetGauges(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_GetStakeByID_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetStakeByIDRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["stake_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "stake_id") - } - - protoReq.StakeId, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "stake_id", err) - } - - msg, err := client.GetStakeByID(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_GetStakeByID_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetStakeByIDRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["stake_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "stake_id") - } - - protoReq.StakeId, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "stake_id", err) - } - - msg, err := server.GetStakeByID(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_GetStakes_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_GetStakes_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetStakesRequest - 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_GetStakes_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.GetStakes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_GetStakes_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetStakesRequest - 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_GetStakes_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.GetStakes(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_GetFutureRewardEstimate_0 = &utilities.DoubleArray{Encoding: map[string]int{"owner": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} -) - -func request_Query_GetFutureRewardEstimate_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetFutureRewardEstimateRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["owner"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "owner") - } - - protoReq.Owner, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "owner", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetFutureRewardEstimate_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.GetFutureRewardEstimate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_GetFutureRewardEstimate_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetFutureRewardEstimateRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["owner"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "owner") - } - - protoReq.Owner, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "owner", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetFutureRewardEstimate_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.GetFutureRewardEstimate(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_GetAccountHistory_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetAccountHistoryRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["account"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "account") - } - - protoReq.Account, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "account", err) - } - - msg, err := client.GetAccountHistory(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_GetAccountHistory_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetAccountHistoryRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["account"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "account") - } - - protoReq.Account, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "account", err) - } - - msg, err := server.GetAccountHistory(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_GetGaugeQualifyingValue_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetGaugeQualifyingValueRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - - protoReq.Id, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - - msg, err := client.GetGaugeQualifyingValue(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_GetGaugeQualifyingValue_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetGaugeQualifyingValueRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - - protoReq.Id, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - - msg, err := server.GetGaugeQualifyingValue(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". -// UnaryRPC :call QueryServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_GetModuleStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_GetModuleStatus_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_GetModuleStatus_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_GetGaugeByID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_GetGaugeByID_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_GetGaugeByID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_GetGauges_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_GetGauges_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_GetGauges_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_GetStakeByID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_GetStakeByID_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_GetStakeByID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_GetStakes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_GetStakes_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_GetStakes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_GetFutureRewardEstimate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_GetFutureRewardEstimate_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_GetFutureRewardEstimate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_GetAccountHistory_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_GetAccountHistory_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_GetAccountHistory_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_GetGaugeQualifyingValue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_GetGaugeQualifyingValue_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_GetGaugeQualifyingValue_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_GetModuleStatus_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_GetModuleStatus_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_GetModuleStatus_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_GetGaugeByID_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_GetGaugeByID_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_GetGaugeByID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_GetGauges_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_GetGauges_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_GetGauges_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_GetStakeByID_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_GetStakeByID_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_GetStakeByID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_GetStakes_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_GetStakes_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_GetStakes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_GetFutureRewardEstimate_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_GetFutureRewardEstimate_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_GetFutureRewardEstimate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_GetAccountHistory_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_GetAccountHistory_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_GetAccountHistory_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_GetGaugeQualifyingValue_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_GetGaugeQualifyingValue_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_GetGaugeQualifyingValue_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_GetModuleStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"neutron", "incentives", "v1beta1", "module_status"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_GetGaugeByID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"neutron", "incentives", "v1beta1", "gauges", "id"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_GetGauges_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"neutron", "incentives", "v1beta1", "gauges"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_GetStakeByID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"neutron", "incentives", "stakes", "stake_id"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_GetStakes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"neutron", "incentives", "stakes"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_GetFutureRewardEstimate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"neutron", "incentives", "v1beta1", "future_rewards_estimate", "owner"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_GetAccountHistory_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"neutron", "incentives", "v1beta1", "account_history", "account"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_GetGaugeQualifyingValue_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"neutron", "incentives", "v1beta1", "get_gauge_qualifying_value", "id"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_GetModuleStatus_0 = runtime.ForwardResponseMessage - - forward_Query_GetGaugeByID_0 = runtime.ForwardResponseMessage - - forward_Query_GetGauges_0 = runtime.ForwardResponseMessage - - forward_Query_GetStakeByID_0 = runtime.ForwardResponseMessage - - forward_Query_GetStakes_0 = runtime.ForwardResponseMessage - - forward_Query_GetFutureRewardEstimate_0 = runtime.ForwardResponseMessage - - forward_Query_GetAccountHistory_0 = runtime.ForwardResponseMessage - - forward_Query_GetGaugeQualifyingValue_0 = runtime.ForwardResponseMessage -) diff --git a/x/incentives/types/query_condition.go b/x/incentives/types/query_condition.go deleted file mode 100644 index 0a9d45d26..000000000 --- a/x/incentives/types/query_condition.go +++ /dev/null @@ -1,18 +0,0 @@ -package types - -import ( - dextypes "github.com/neutron-org/neutron/x/dex/types" -) - -func (qc QueryCondition) Test(poolMetadata dextypes.PoolMetadata) bool { - if !poolMetadata.PairID.Equal(qc.PairID) { - return false - } - - lowerTick := poolMetadata.Tick - int64(poolMetadata.Fee) - upperTick := poolMetadata.Tick + int64(poolMetadata.Fee) - lowerTickQualifies := qc.StartTick <= lowerTick && lowerTick <= qc.EndTick - upperTickQualifies := qc.StartTick <= upperTick && upperTick <= qc.EndTick - - return lowerTickQualifies && upperTickQualifies -} diff --git a/x/incentives/types/query_condition_test.go b/x/incentives/types/query_condition_test.go deleted file mode 100644 index 13a0fe619..000000000 --- a/x/incentives/types/query_condition_test.go +++ /dev/null @@ -1,62 +0,0 @@ -package types_test - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - dextypes "github.com/neutron-org/neutron/x/dex/types" - . "github.com/neutron-org/neutron/x/incentives/types" -) - -func TestQueryCondition(t *testing.T) { - pairID := &dextypes.PairID{ - Token0: "coin1", - Token1: "coin2", - } - - tests := []struct { - name string - queryCond QueryCondition - poolMetadata dextypes.PoolMetadata - testResult bool - }{ - { - name: "Matching denom and tick range", - queryCond: QueryCondition{PairID: pairID, StartTick: 10, EndTick: 20}, - poolMetadata: dextypes.NewPoolMetadata(pairID, 15, 5, 0), - testResult: true, - }, - { - name: "Non-matching denom", - queryCond: QueryCondition{PairID: pairID, StartTick: 10, EndTick: 20}, - poolMetadata: dextypes.NewPoolMetadata(&dextypes.PairID{Token0: "coin1", Token1: "coin3"}, 15, 5, 0), - testResult: false, - }, - { - name: "Non-matching tick range", - queryCond: QueryCondition{PairID: pairID, StartTick: 30, EndTick: 40}, - poolMetadata: dextypes.NewPoolMetadata(pairID, 15, 6, 0), - testResult: false, - }, - { - name: "Non-matching tick fee range lower", - queryCond: QueryCondition{PairID: pairID, StartTick: 30, EndTick: 40}, - poolMetadata: dextypes.NewPoolMetadata(pairID, 10, 5, 0), - testResult: false, - }, - { - name: "Non-matching tick fee range upper", - queryCond: QueryCondition{PairID: pairID, StartTick: 30, EndTick: 40}, - poolMetadata: dextypes.NewPoolMetadata(pairID, 20, 5, 0), - testResult: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - result := tt.queryCond.Test(tt.poolMetadata) - assert.Equal(t, tt.testResult, result) - }) - } -} diff --git a/x/incentives/types/stake.go b/x/incentives/types/stake.go deleted file mode 100644 index 7d2507cbb..000000000 --- a/x/incentives/types/stake.go +++ /dev/null @@ -1,53 +0,0 @@ -package types - -import ( - "fmt" - "time" - - sdk "github.com/cosmos/cosmos-sdk/types" - dextypes "github.com/neutron-org/neutron/x/dex/types" -) - -// NewStake returns a new instance of period stake. -func NewStake( - id uint64, - owner sdk.AccAddress, - coins sdk.Coins, - startTime time.Time, - startDistEpoch int64, -) *Stake { - coins = coins.Sort() - return &Stake{ - ID: id, - Owner: owner.String(), - Coins: coins, - StartTime: startTime, - StartDistEpoch: startDistEpoch, - } -} - -// OwnerAddress returns stakes owner address. -func (p Stake) OwnerAddress() sdk.AccAddress { - addr, err := sdk.AccAddressFromBech32(p.Owner) - if err != nil { - panic(err) - } - return addr -} - -func (p Stake) SingleCoin() (sdk.Coin, error) { - if len(p.Coins) != 1 { - return sdk.Coin{}, fmt.Errorf("Stake %d has no single coin: %s", p.ID, p.Coins) - } - return p.Coins[0], nil -} - -func (p Stake) ValidateBasic() error { - for _, coin := range p.Coins { - err := dextypes.ValidatePoolDenom(coin.Denom) - if err != nil { - return err - } - } - return nil -} diff --git a/x/incentives/types/stake.pb.go b/x/incentives/types/stake.pb.go deleted file mode 100644 index fd18e7e04..000000000 --- a/x/incentives/types/stake.pb.go +++ /dev/null @@ -1,531 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: neutron/incentives/stake.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/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" - _ "google.golang.org/protobuf/types/known/timestamppb" - io "io" - math "math" - math_bits "math/bits" - time "time" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf -var _ = time.Kitchen - -// 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 - -// Stake records what coins are staked when by who for the purpose of -// calculating gauge reward distributions. -type Stake struct { - // ID is the "autoincrementing" id of the stake, assigned at creation. - ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` - // owner is the account originating the stake. Only the owner can withdraw - // coins from the stake. - Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"` - // start_time is the time at which the coins in the lock were staked. - StartTime time.Time `protobuf:"bytes,3,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time,omitempty" yaml:"start_time"` - // coins are the tokens staked, and managed by the module account. - Coins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=coins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coins"` - // start_dist_epoch is the dist epoch (defaulting to the day) at which the - // coins in the lock were staked. This is used by distribution logic to filter - // on stakes that have existed for longer than the distribution period (you - // can only qualify for today's rewards if you staked your LP tokens - // yesterday). We use int64 instead of uint64 to make testing easier. - StartDistEpoch int64 `protobuf:"varint,5,opt,name=start_dist_epoch,json=startDistEpoch,proto3" json:"start_dist_epoch,omitempty"` -} - -func (m *Stake) Reset() { *m = Stake{} } -func (m *Stake) String() string { return proto.CompactTextString(m) } -func (*Stake) ProtoMessage() {} -func (*Stake) Descriptor() ([]byte, []int) { - return fileDescriptor_6900551d6712f42b, []int{0} -} -func (m *Stake) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Stake) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Stake.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 *Stake) XXX_Merge(src proto.Message) { - xxx_messageInfo_Stake.Merge(m, src) -} -func (m *Stake) XXX_Size() int { - return m.Size() -} -func (m *Stake) XXX_DiscardUnknown() { - xxx_messageInfo_Stake.DiscardUnknown(m) -} - -var xxx_messageInfo_Stake proto.InternalMessageInfo - -func (m *Stake) GetID() uint64 { - if m != nil { - return m.ID - } - return 0 -} - -func (m *Stake) GetOwner() string { - if m != nil { - return m.Owner - } - return "" -} - -func (m *Stake) GetStartTime() time.Time { - if m != nil { - return m.StartTime - } - return time.Time{} -} - -func (m *Stake) GetCoins() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.Coins - } - return nil -} - -func (m *Stake) GetStartDistEpoch() int64 { - if m != nil { - return m.StartDistEpoch - } - return 0 -} - -func init() { - proto.RegisterType((*Stake)(nil), "neutron.incentives.Stake") -} - -func init() { proto.RegisterFile("neutron/incentives/stake.proto", fileDescriptor_6900551d6712f42b) } - -var fileDescriptor_6900551d6712f42b = []byte{ - // 396 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x51, 0xb1, 0x6e, 0xdb, 0x30, - 0x10, 0x15, 0xe5, 0xa8, 0x40, 0x98, 0x22, 0x48, 0x85, 0x0c, 0xaa, 0x07, 0x4a, 0xd0, 0x50, 0x68, - 0x68, 0xc8, 0x3a, 0x45, 0x97, 0x8e, 0xaa, 0x3b, 0x04, 0xdd, 0xd4, 0x4e, 0x5d, 0x02, 0x49, 0x61, - 0x15, 0x22, 0x91, 0x4e, 0x10, 0xe9, 0xb4, 0xfe, 0x0b, 0x7f, 0x47, 0x3f, 0xa2, 0xb3, 0x47, 0x8f, - 0x9d, 0xe4, 0xc2, 0xde, 0x3a, 0xfa, 0x0b, 0x02, 0x92, 0x32, 0xec, 0x49, 0xd4, 0x7b, 0x77, 0xf7, - 0xde, 0xbb, 0xc3, 0xa4, 0xe1, 0x33, 0xd5, 0x41, 0xc3, 0x44, 0x53, 0xf2, 0x46, 0x89, 0x27, 0x2e, - 0x99, 0x54, 0xf9, 0x03, 0xa7, 0x6d, 0x07, 0x0a, 0x7c, 0x7f, 0xe0, 0xe9, 0x81, 0x1f, 0x5f, 0x56, - 0x50, 0x81, 0xa1, 0x99, 0x7e, 0xd9, 0xca, 0x71, 0x58, 0x01, 0x54, 0x8f, 0x9c, 0x99, 0xbf, 0x62, - 0xf6, 0x83, 0x29, 0x51, 0x73, 0xa9, 0xf2, 0xba, 0x1d, 0x0a, 0x48, 0x09, 0xb2, 0x06, 0xc9, 0x8a, - 0x5c, 0x72, 0xf6, 0x34, 0x29, 0xb8, 0xca, 0x27, 0xac, 0x04, 0xd1, 0x58, 0x3e, 0xfe, 0xe3, 0x62, - 0xef, 0xab, 0x96, 0xf6, 0xcf, 0xb1, 0x7b, 0x33, 0x0d, 0x50, 0x84, 0x92, 0x93, 0xcc, 0xbd, 0x99, - 0xfa, 0x6f, 0xb0, 0x07, 0x3f, 0x1b, 0xde, 0x05, 0x6e, 0x84, 0x92, 0xd3, 0xf4, 0x62, 0xd7, 0x87, - 0x2f, 0xe7, 0x79, 0xfd, 0xf8, 0x31, 0x36, 0x70, 0x9c, 0x59, 0xda, 0x6f, 0x31, 0x96, 0x2a, 0xef, - 0xd4, 0xad, 0x96, 0x0e, 0x46, 0x11, 0x4a, 0xce, 0xae, 0xc7, 0xd4, 0xfa, 0xa2, 0x7b, 0x5f, 0xf4, - 0xdb, 0xde, 0x57, 0xfa, 0x61, 0xd9, 0x87, 0xce, 0xff, 0x3e, 0xbc, 0x3c, 0x74, 0xbd, 0x85, 0x5a, - 0x28, 0x5e, 0xb7, 0x6a, 0xbe, 0xeb, 0xc3, 0x57, 0x56, 0xe4, 0xc0, 0xc6, 0x8b, 0x75, 0x88, 0xb2, - 0x53, 0x03, 0xe8, 0x31, 0x7e, 0x8e, 0x3d, 0x9d, 0x40, 0x06, 0x27, 0xd1, 0x28, 0x39, 0xbb, 0x7e, - 0x4d, 0x6d, 0x46, 0xaa, 0x33, 0xd2, 0x21, 0x23, 0xfd, 0x04, 0xa2, 0x49, 0xdf, 0x69, 0xad, 0xdf, - 0xeb, 0x30, 0xa9, 0x84, 0xba, 0x9f, 0x15, 0xb4, 0x84, 0x9a, 0x0d, 0x0b, 0xb1, 0x9f, 0x2b, 0x79, - 0xf7, 0xc0, 0xd4, 0xbc, 0xe5, 0xd2, 0x34, 0xc8, 0xcc, 0x4e, 0xf6, 0x13, 0x7c, 0x61, 0x0d, 0xdc, - 0x09, 0xa9, 0x6e, 0x79, 0x0b, 0xe5, 0x7d, 0xe0, 0x45, 0x28, 0x19, 0x65, 0xe7, 0x06, 0x9f, 0x0a, - 0xa9, 0x3e, 0x6b, 0x34, 0xfd, 0xb2, 0xdc, 0x10, 0xb4, 0xda, 0x10, 0xf4, 0x6f, 0x43, 0xd0, 0x62, - 0x4b, 0x9c, 0xd5, 0x96, 0x38, 0x7f, 0xb7, 0xc4, 0xf9, 0x3e, 0x39, 0x12, 0x1d, 0x0e, 0x7a, 0x05, - 0x5d, 0xb5, 0x7f, 0xb3, 0x5f, 0xc7, 0xe7, 0x37, 0x1e, 0x8a, 0x17, 0x66, 0x5f, 0xef, 0x9f, 0x03, - 0x00, 0x00, 0xff, 0xff, 0xad, 0x4f, 0xba, 0xca, 0x21, 0x02, 0x00, 0x00, -} - -func (m *Stake) 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 *Stake) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Stake) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.StartDistEpoch != 0 { - i = encodeVarintStake(dAtA, i, uint64(m.StartDistEpoch)) - i-- - dAtA[i] = 0x28 - } - if len(m.Coins) > 0 { - for iNdEx := len(m.Coins) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Coins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStake(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime):]) - if err1 != nil { - return 0, err1 - } - i -= n1 - i = encodeVarintStake(dAtA, i, uint64(n1)) - i-- - dAtA[i] = 0x1a - if len(m.Owner) > 0 { - i -= len(m.Owner) - copy(dAtA[i:], m.Owner) - i = encodeVarintStake(dAtA, i, uint64(len(m.Owner))) - i-- - dAtA[i] = 0x12 - } - if m.ID != 0 { - i = encodeVarintStake(dAtA, i, uint64(m.ID)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintStake(dAtA []byte, offset int, v uint64) int { - offset -= sovStake(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Stake) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ID != 0 { - n += 1 + sovStake(uint64(m.ID)) - } - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovStake(uint64(l)) - } - l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime) - n += 1 + l + sovStake(uint64(l)) - if len(m.Coins) > 0 { - for _, e := range m.Coins { - l = e.Size() - n += 1 + l + sovStake(uint64(l)) - } - } - if m.StartDistEpoch != 0 { - n += 1 + sovStake(uint64(m.StartDistEpoch)) - } - return n -} - -func sovStake(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozStake(x uint64) (n int) { - return sovStake(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Stake) 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 ErrIntOverflowStake - } - 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: Stake: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Stake: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) - } - m.ID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStake - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ID |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStake - } - 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 ErrInvalidLengthStake - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Owner = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStake - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStake - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Coins", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStake - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStake - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStake - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Coins = append(m.Coins, types.Coin{}) - if err := m.Coins[len(m.Coins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StartDistEpoch", wireType) - } - m.StartDistEpoch = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStake - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.StartDistEpoch |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipStake(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStake - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipStake(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, ErrIntOverflowStake - } - 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, ErrIntOverflowStake - } - 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, ErrIntOverflowStake - } - 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, ErrInvalidLengthStake - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupStake - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthStake - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthStake = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowStake = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupStake = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/incentives/types/stakes.go b/x/incentives/types/stakes.go deleted file mode 100644 index e2b0240b7..000000000 --- a/x/incentives/types/stakes.go +++ /dev/null @@ -1,16 +0,0 @@ -package types - -import sdk "github.com/cosmos/cosmos-sdk/types" - -type Stakes []*Stake - -func (stakes Stakes) GetCoins() sdk.Coins { - coins := sdk.Coins{} - for _, stake := range stakes { - coinsToAdd := stake.GetCoins() - if !coinsToAdd.Empty() { - coins = coins.Add(coinsToAdd...) - } - } - return coins -} diff --git a/x/incentives/types/tx.pb.go b/x/incentives/types/tx.pb.go deleted file mode 100644 index aa9553cc0..000000000 --- a/x/incentives/types/tx.pb.go +++ /dev/null @@ -1,2713 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: neutron/incentives/tx.proto - -package types - -import ( - context "context" - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/cosmos-sdk/types/msgservice" - _ "github.com/cosmos/cosmos-sdk/types/tx/amino" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/proto" - github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - _ "google.golang.org/protobuf/types/known/durationpb" - _ "google.golang.org/protobuf/types/known/timestamppb" - io "io" - math "math" - math_bits "math/bits" - time "time" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf -var _ = time.Kitchen - -// 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 - -// MsgCreateGauge creates a gague to distribute rewards to users -type MsgCreateGauge struct { - // is_perpetual shows if it's a perpetual or non-perpetual gauge - // Non-perpetual gauges distribute their tokens equally per epoch while the - // gauge is in the active period. Perpetual gauges distribute all their tokens - // at a single time and only distribute their tokens again once the gauge is - // refilled - IsPerpetual bool `protobuf:"varint,1,opt,name=is_perpetual,json=isPerpetual,proto3" json:"is_perpetual,omitempty"` - // owner is the address of gauge creator, should be the module authority - Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"` - // distribute_to show which lock the gauge should distribute to by time - // duration or by timestamp - DistributeTo QueryCondition `protobuf:"bytes,3,opt,name=distribute_to,json=distributeTo,proto3" json:"distribute_to"` - // coins are coin(s) to be distributed by the gauge - Coins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=coins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coins"` - // start_time is the distribution start time - StartTime time.Time `protobuf:"bytes,5,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"timestamp"` - // num_epochs_paid_over is the number of epochs distribution will be completed - // over - NumEpochsPaidOver uint64 `protobuf:"varint,6,opt,name=num_epochs_paid_over,json=numEpochsPaidOver,proto3" json:"num_epochs_paid_over,omitempty"` - // pricing_tick is the price that liquidity within the gauge range will be priced at - PricingTick int64 `protobuf:"varint,7,opt,name=pricing_tick,json=pricingTick,proto3" json:"pricing_tick,omitempty"` -} - -func (m *MsgCreateGauge) Reset() { *m = MsgCreateGauge{} } -func (m *MsgCreateGauge) String() string { return proto.CompactTextString(m) } -func (*MsgCreateGauge) ProtoMessage() {} -func (*MsgCreateGauge) Descriptor() ([]byte, []int) { - return fileDescriptor_5fe3d35711153e8d, []int{0} -} -func (m *MsgCreateGauge) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgCreateGauge) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgCreateGauge.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 *MsgCreateGauge) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateGauge.Merge(m, src) -} -func (m *MsgCreateGauge) XXX_Size() int { - return m.Size() -} -func (m *MsgCreateGauge) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateGauge.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgCreateGauge proto.InternalMessageInfo - -func (m *MsgCreateGauge) GetIsPerpetual() bool { - if m != nil { - return m.IsPerpetual - } - return false -} - -func (m *MsgCreateGauge) GetOwner() string { - if m != nil { - return m.Owner - } - return "" -} - -func (m *MsgCreateGauge) GetDistributeTo() QueryCondition { - if m != nil { - return m.DistributeTo - } - return QueryCondition{} -} - -func (m *MsgCreateGauge) GetCoins() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.Coins - } - return nil -} - -func (m *MsgCreateGauge) GetStartTime() time.Time { - if m != nil { - return m.StartTime - } - return time.Time{} -} - -func (m *MsgCreateGauge) GetNumEpochsPaidOver() uint64 { - if m != nil { - return m.NumEpochsPaidOver - } - return 0 -} - -func (m *MsgCreateGauge) GetPricingTick() int64 { - if m != nil { - return m.PricingTick - } - return 0 -} - -type MsgCreateGaugeResponse struct { -} - -func (m *MsgCreateGaugeResponse) Reset() { *m = MsgCreateGaugeResponse{} } -func (m *MsgCreateGaugeResponse) String() string { return proto.CompactTextString(m) } -func (*MsgCreateGaugeResponse) ProtoMessage() {} -func (*MsgCreateGaugeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5fe3d35711153e8d, []int{1} -} -func (m *MsgCreateGaugeResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgCreateGaugeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgCreateGaugeResponse.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 *MsgCreateGaugeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateGaugeResponse.Merge(m, src) -} -func (m *MsgCreateGaugeResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgCreateGaugeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateGaugeResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgCreateGaugeResponse proto.InternalMessageInfo - -// MsgAddToGauge adds coins to a previously created gauge -type MsgAddToGauge struct { - // owner is the gauge owner's address - Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"` - // gauge_id is the ID of gauge that rewards are getting added to - GaugeId uint64 `protobuf:"varint,2,opt,name=gauge_id,json=gaugeId,proto3" json:"gauge_id,omitempty"` - // rewards are the coin(s) to add to gauge - Rewards github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=rewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"rewards"` -} - -func (m *MsgAddToGauge) Reset() { *m = MsgAddToGauge{} } -func (m *MsgAddToGauge) String() string { return proto.CompactTextString(m) } -func (*MsgAddToGauge) ProtoMessage() {} -func (*MsgAddToGauge) Descriptor() ([]byte, []int) { - return fileDescriptor_5fe3d35711153e8d, []int{2} -} -func (m *MsgAddToGauge) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgAddToGauge) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgAddToGauge.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 *MsgAddToGauge) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAddToGauge.Merge(m, src) -} -func (m *MsgAddToGauge) XXX_Size() int { - return m.Size() -} -func (m *MsgAddToGauge) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAddToGauge.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgAddToGauge proto.InternalMessageInfo - -func (m *MsgAddToGauge) GetOwner() string { - if m != nil { - return m.Owner - } - return "" -} - -func (m *MsgAddToGauge) GetGaugeId() uint64 { - if m != nil { - return m.GaugeId - } - return 0 -} - -func (m *MsgAddToGauge) GetRewards() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.Rewards - } - return nil -} - -type MsgAddToGaugeResponse struct { -} - -func (m *MsgAddToGaugeResponse) Reset() { *m = MsgAddToGaugeResponse{} } -func (m *MsgAddToGaugeResponse) String() string { return proto.CompactTextString(m) } -func (*MsgAddToGaugeResponse) ProtoMessage() {} -func (*MsgAddToGaugeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5fe3d35711153e8d, []int{3} -} -func (m *MsgAddToGaugeResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgAddToGaugeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgAddToGaugeResponse.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 *MsgAddToGaugeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAddToGaugeResponse.Merge(m, src) -} -func (m *MsgAddToGaugeResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgAddToGaugeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAddToGaugeResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgAddToGaugeResponse proto.InternalMessageInfo - -type MsgStake struct { - Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"` - Coins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=coins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coins"` -} - -func (m *MsgStake) Reset() { *m = MsgStake{} } -func (m *MsgStake) String() string { return proto.CompactTextString(m) } -func (*MsgStake) ProtoMessage() {} -func (*MsgStake) Descriptor() ([]byte, []int) { - return fileDescriptor_5fe3d35711153e8d, []int{4} -} -func (m *MsgStake) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgStake) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgStake.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 *MsgStake) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgStake.Merge(m, src) -} -func (m *MsgStake) XXX_Size() int { - return m.Size() -} -func (m *MsgStake) XXX_DiscardUnknown() { - xxx_messageInfo_MsgStake.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgStake proto.InternalMessageInfo - -func (m *MsgStake) GetOwner() string { - if m != nil { - return m.Owner - } - return "" -} - -func (m *MsgStake) GetCoins() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.Coins - } - return nil -} - -type MsgStakeResponse struct { - ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` -} - -func (m *MsgStakeResponse) Reset() { *m = MsgStakeResponse{} } -func (m *MsgStakeResponse) String() string { return proto.CompactTextString(m) } -func (*MsgStakeResponse) ProtoMessage() {} -func (*MsgStakeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5fe3d35711153e8d, []int{5} -} -func (m *MsgStakeResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgStakeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgStakeResponse.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 *MsgStakeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgStakeResponse.Merge(m, src) -} -func (m *MsgStakeResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgStakeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgStakeResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgStakeResponse proto.InternalMessageInfo - -func (m *MsgStakeResponse) GetID() uint64 { - if m != nil { - return m.ID - } - return 0 -} - -type MsgUnstake struct { - Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"` - // If unstake is left empty, this is interpreted as "unstake all" - Unstakes []*MsgUnstake_UnstakeDescriptor `protobuf:"bytes,2,rep,name=unstakes,proto3" json:"unstakes,omitempty"` -} - -func (m *MsgUnstake) Reset() { *m = MsgUnstake{} } -func (m *MsgUnstake) String() string { return proto.CompactTextString(m) } -func (*MsgUnstake) ProtoMessage() {} -func (*MsgUnstake) Descriptor() ([]byte, []int) { - return fileDescriptor_5fe3d35711153e8d, []int{6} -} -func (m *MsgUnstake) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUnstake) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUnstake.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 *MsgUnstake) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUnstake.Merge(m, src) -} -func (m *MsgUnstake) XXX_Size() int { - return m.Size() -} -func (m *MsgUnstake) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUnstake.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUnstake proto.InternalMessageInfo - -func (m *MsgUnstake) GetOwner() string { - if m != nil { - return m.Owner - } - return "" -} - -func (m *MsgUnstake) GetUnstakes() []*MsgUnstake_UnstakeDescriptor { - if m != nil { - return m.Unstakes - } - return nil -} - -type MsgUnstake_UnstakeDescriptor struct { - ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` - Coins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=coins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coins"` -} - -func (m *MsgUnstake_UnstakeDescriptor) Reset() { *m = MsgUnstake_UnstakeDescriptor{} } -func (m *MsgUnstake_UnstakeDescriptor) String() string { return proto.CompactTextString(m) } -func (*MsgUnstake_UnstakeDescriptor) ProtoMessage() {} -func (*MsgUnstake_UnstakeDescriptor) Descriptor() ([]byte, []int) { - return fileDescriptor_5fe3d35711153e8d, []int{6, 0} -} -func (m *MsgUnstake_UnstakeDescriptor) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUnstake_UnstakeDescriptor) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUnstake_UnstakeDescriptor.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 *MsgUnstake_UnstakeDescriptor) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUnstake_UnstakeDescriptor.Merge(m, src) -} -func (m *MsgUnstake_UnstakeDescriptor) XXX_Size() int { - return m.Size() -} -func (m *MsgUnstake_UnstakeDescriptor) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUnstake_UnstakeDescriptor.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUnstake_UnstakeDescriptor proto.InternalMessageInfo - -func (m *MsgUnstake_UnstakeDescriptor) GetID() uint64 { - if m != nil { - return m.ID - } - return 0 -} - -func (m *MsgUnstake_UnstakeDescriptor) GetCoins() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.Coins - } - return nil -} - -type MsgUnstakeResponse struct { -} - -func (m *MsgUnstakeResponse) Reset() { *m = MsgUnstakeResponse{} } -func (m *MsgUnstakeResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUnstakeResponse) ProtoMessage() {} -func (*MsgUnstakeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5fe3d35711153e8d, []int{7} -} -func (m *MsgUnstakeResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUnstakeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUnstakeResponse.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 *MsgUnstakeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUnstakeResponse.Merge(m, src) -} -func (m *MsgUnstakeResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUnstakeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUnstakeResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUnstakeResponse proto.InternalMessageInfo - -type MsgUpdateParams struct { - // Authority is the address of the governance account. - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - // NOTE: All parameters must be supplied. - Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` -} - -func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } -func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParams) ProtoMessage() {} -func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_5fe3d35711153e8d, []int{8} -} -func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParams.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 *MsgUpdateParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParams.Merge(m, src) -} -func (m *MsgUpdateParams) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParams) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo - -func (m *MsgUpdateParams) GetAuthority() string { - if m != nil { - return m.Authority - } - return "" -} - -func (m *MsgUpdateParams) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -// MsgUpdateParamsResponse defines the response structure for executing a -// MsgUpdateParams message. -// -// Since: 0.47 -type MsgUpdateParamsResponse struct { -} - -func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } -func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateParamsResponse) ProtoMessage() {} -func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5fe3d35711153e8d, []int{9} -} -func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateParamsResponse.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 *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) -} -func (m *MsgUpdateParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*MsgCreateGauge)(nil), "neutron.incentives.MsgCreateGauge") - proto.RegisterType((*MsgCreateGaugeResponse)(nil), "neutron.incentives.MsgCreateGaugeResponse") - proto.RegisterType((*MsgAddToGauge)(nil), "neutron.incentives.MsgAddToGauge") - proto.RegisterType((*MsgAddToGaugeResponse)(nil), "neutron.incentives.MsgAddToGaugeResponse") - proto.RegisterType((*MsgStake)(nil), "neutron.incentives.MsgStake") - proto.RegisterType((*MsgStakeResponse)(nil), "neutron.incentives.MsgStakeResponse") - proto.RegisterType((*MsgUnstake)(nil), "neutron.incentives.MsgUnstake") - proto.RegisterType((*MsgUnstake_UnstakeDescriptor)(nil), "neutron.incentives.MsgUnstake.UnstakeDescriptor") - proto.RegisterType((*MsgUnstakeResponse)(nil), "neutron.incentives.MsgUnstakeResponse") - proto.RegisterType((*MsgUpdateParams)(nil), "neutron.incentives.MsgUpdateParams") - proto.RegisterType((*MsgUpdateParamsResponse)(nil), "neutron.incentives.MsgUpdateParamsResponse") -} - -func init() { proto.RegisterFile("neutron/incentives/tx.proto", fileDescriptor_5fe3d35711153e8d) } - -var fileDescriptor_5fe3d35711153e8d = []byte{ - // 907 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcf, 0x6f, 0xdc, 0x44, - 0x18, 0x8d, 0x77, 0x37, 0xbf, 0xbe, 0x4d, 0x4b, 0x62, 0x02, 0x71, 0x4c, 0xe5, 0xdd, 0x1a, 0x14, - 0x2d, 0x41, 0xb1, 0x9b, 0x20, 0x71, 0xa8, 0xc4, 0xa1, 0x9b, 0x20, 0x14, 0x95, 0x15, 0xa9, 0x1b, - 0x84, 0x54, 0x09, 0x99, 0x59, 0x7b, 0x70, 0x46, 0x89, 0x3d, 0xd6, 0xcc, 0x78, 0x9b, 0x5c, 0x39, - 0x70, 0x80, 0x4b, 0x2f, 0xfc, 0x0f, 0x88, 0x53, 0x0e, 0x5c, 0xe0, 0xc8, 0xa9, 0xc7, 0x8a, 0x13, - 0xa7, 0x14, 0x25, 0x87, 0xdc, 0xfb, 0x17, 0xa0, 0x19, 0xff, 0xd8, 0x4d, 0x9a, 0x6c, 0x8b, 0x04, - 0x5c, 0x62, 0x7b, 0xde, 0xf7, 0x3d, 0xbf, 0x6f, 0xde, 0x1b, 0x67, 0xe1, 0x9d, 0x04, 0x67, 0x82, - 0xd1, 0xc4, 0x25, 0x49, 0x80, 0x13, 0x41, 0x06, 0x98, 0xbb, 0xe2, 0xd0, 0x49, 0x19, 0x15, 0x54, - 0xd7, 0x0b, 0xd0, 0x19, 0x82, 0xe6, 0x62, 0x44, 0x23, 0xaa, 0x60, 0x57, 0xde, 0xe5, 0x95, 0x66, - 0x2b, 0xa2, 0x34, 0x3a, 0xc0, 0xae, 0x7a, 0xea, 0x67, 0xdf, 0xb8, 0x82, 0xc4, 0x98, 0x0b, 0x14, - 0xa7, 0x45, 0x81, 0x15, 0x50, 0x1e, 0x53, 0xee, 0xf6, 0x11, 0xc7, 0xee, 0x60, 0xbd, 0x8f, 0x05, - 0x5a, 0x77, 0x03, 0x4a, 0x92, 0x12, 0xbf, 0x42, 0x47, 0x84, 0xb2, 0x08, 0x8f, 0xc1, 0xb9, 0x40, - 0xfb, 0x15, 0x7e, 0x59, 0x40, 0x98, 0x31, 0x24, 0x08, 0x2d, 0xf9, 0x17, 0x50, 0x4c, 0x12, 0xea, - 0xaa, 0xbf, 0xa5, 0xe6, 0x2b, 0x28, 0x53, 0xc4, 0x50, 0xcc, 0x8b, 0x82, 0xa5, 0x42, 0x73, 0xcc, - 0x23, 0x77, 0xb0, 0x2e, 0x2f, 0x05, 0xb0, 0x9c, 0x03, 0x7e, 0xbe, 0x0d, 0xf9, 0x43, 0x0e, 0xd9, - 0xbf, 0xd5, 0xe1, 0x66, 0x8f, 0x47, 0x9b, 0x0c, 0x23, 0x81, 0x3f, 0x95, 0x03, 0xe8, 0xb7, 0x61, - 0x8e, 0x70, 0x3f, 0xc5, 0x2c, 0xc5, 0x22, 0x43, 0x07, 0x86, 0xd6, 0xd6, 0x3a, 0x33, 0x5e, 0x93, - 0xf0, 0x9d, 0x72, 0x49, 0x5f, 0x81, 0x49, 0xfa, 0x38, 0xc1, 0xcc, 0xa8, 0xb5, 0xb5, 0xce, 0x6c, - 0x77, 0xfe, 0xc5, 0x49, 0x6b, 0xee, 0x08, 0xc5, 0x07, 0x77, 0x6d, 0xb5, 0x6c, 0x7b, 0x39, 0xac, - 0xf7, 0xe0, 0x46, 0x48, 0xb8, 0x60, 0xa4, 0x9f, 0x09, 0xec, 0x0b, 0x6a, 0xd4, 0xdb, 0x5a, 0xa7, - 0xb9, 0x61, 0x3b, 0x2f, 0x1b, 0xe5, 0x3c, 0xc8, 0x30, 0x3b, 0xda, 0xa4, 0x49, 0x48, 0xe4, 0x36, - 0x74, 0x1b, 0x4f, 0x4f, 0x5a, 0x13, 0xde, 0xdc, 0xb0, 0x7d, 0x97, 0xea, 0x08, 0x26, 0xa5, 0x05, - 0xdc, 0x68, 0xb4, 0xeb, 0x9d, 0xe6, 0xc6, 0xb2, 0x53, 0x8c, 0x22, 0x4d, 0x72, 0x0a, 0x93, 0x9c, - 0x4d, 0x4a, 0x92, 0xee, 0x1d, 0xd9, 0xfd, 0xf3, 0xf3, 0x56, 0x27, 0x22, 0x62, 0x2f, 0xeb, 0x3b, - 0x01, 0x8d, 0x8b, 0xb9, 0x8b, 0xcb, 0x1a, 0x0f, 0xf7, 0x5d, 0x71, 0x94, 0x62, 0xae, 0x1a, 0xb8, - 0x97, 0x33, 0xeb, 0x5f, 0x02, 0x70, 0x81, 0x98, 0xf0, 0x65, 0x20, 0x8c, 0x49, 0x25, 0xd7, 0x74, - 0x72, 0xb3, 0x9c, 0xd2, 0x2c, 0x67, 0xb7, 0x4c, 0x4b, 0xf7, 0x96, 0x7c, 0xd1, 0x8b, 0x93, 0xd6, - 0x7c, 0x3e, 0x7e, 0x15, 0x23, 0xfb, 0xc9, 0xf3, 0x96, 0xe6, 0xcd, 0x2a, 0x2e, 0x59, 0xad, 0xbb, - 0xb0, 0x98, 0x64, 0xb1, 0x8f, 0x53, 0x1a, 0xec, 0x71, 0x3f, 0x45, 0x24, 0xf4, 0xe9, 0x00, 0x33, - 0x63, 0xaa, 0xad, 0x75, 0x1a, 0xde, 0x42, 0x92, 0xc5, 0x9f, 0x28, 0x68, 0x07, 0x91, 0xf0, 0xf3, - 0x01, 0x66, 0xd2, 0x86, 0x94, 0x91, 0x80, 0x24, 0x91, 0x2f, 0x48, 0xb0, 0x6f, 0x4c, 0xb7, 0xb5, - 0x4e, 0xdd, 0x6b, 0x16, 0x6b, 0xbb, 0x24, 0xd8, 0xb7, 0x0d, 0x78, 0xfb, 0xa2, 0x77, 0x1e, 0xe6, - 0x29, 0x4d, 0x38, 0xb6, 0x7f, 0xd5, 0xe0, 0x46, 0x8f, 0x47, 0xf7, 0xc2, 0x70, 0x97, 0xe6, 0xae, - 0x56, 0x96, 0x69, 0xe3, 0x2d, 0x5b, 0x86, 0x19, 0x95, 0x63, 0x9f, 0x84, 0xca, 0xdd, 0x86, 0x37, - 0xad, 0x9e, 0xb7, 0x43, 0x1d, 0xc3, 0x34, 0xc3, 0x8f, 0x11, 0x0b, 0xb9, 0x51, 0xff, 0xf7, 0x0d, - 0x28, 0xb9, 0xed, 0x25, 0x78, 0xeb, 0x82, 0xf4, 0x6a, 0xa8, 0x1f, 0x35, 0x98, 0xe9, 0xf1, 0xe8, - 0xa1, 0x3c, 0x46, 0xaf, 0x3d, 0x4f, 0x95, 0x99, 0xda, 0x7f, 0x95, 0x19, 0xdb, 0x86, 0xf9, 0x52, - 0x56, 0xa9, 0x55, 0xbf, 0x09, 0xb5, 0xed, 0x2d, 0xa5, 0xad, 0xe1, 0xd5, 0xb6, 0xb7, 0xec, 0x1f, - 0x6a, 0x00, 0x3d, 0x1e, 0x7d, 0x91, 0xf0, 0x7f, 0xa4, 0xfe, 0x33, 0x98, 0xc9, 0xf2, 0x96, 0x72, - 0x80, 0x3b, 0x57, 0x9d, 0x9d, 0x21, 0xb3, 0x53, 0x5c, 0xb7, 0x30, 0x0f, 0x18, 0x49, 0x05, 0x65, - 0x5e, 0xc5, 0x60, 0x7e, 0xa7, 0xc1, 0xc2, 0x4b, 0xf8, 0x65, 0xa9, 0xff, 0xc7, 0x8e, 0x2d, 0x82, - 0x3e, 0x94, 0x5c, 0xf9, 0x7b, 0xac, 0xc1, 0x1b, 0x72, 0x39, 0x0d, 0x91, 0xc0, 0x3b, 0xea, 0xcb, - 0xa6, 0x7f, 0x04, 0xb3, 0x28, 0x13, 0x7b, 0x94, 0x11, 0x71, 0x54, 0x6c, 0x96, 0xf1, 0xc7, 0x2f, - 0x6b, 0x8b, 0x85, 0xa6, 0x7b, 0x61, 0xc8, 0x30, 0xe7, 0x0f, 0x05, 0x23, 0x49, 0xe4, 0x0d, 0x4b, - 0xf5, 0x8f, 0x61, 0x2a, 0xff, 0x36, 0xaa, 0x10, 0xcb, 0x33, 0x7c, 0xc5, 0xb6, 0xe5, 0xef, 0xe8, - 0xce, 0xca, 0x31, 0x7e, 0x3a, 0x3f, 0x5e, 0xd5, 0xbc, 0xa2, 0xe9, 0xee, 0xca, 0xb7, 0xe7, 0xc7, - 0xab, 0x43, 0xba, 0xef, 0xcf, 0x8f, 0x57, 0xdf, 0x0c, 0xf1, 0xa1, 0x7b, 0x49, 0x9e, 0xbd, 0x0c, - 0x4b, 0x97, 0x96, 0xca, 0x69, 0x36, 0x7e, 0xaf, 0x43, 0xbd, 0xc7, 0x23, 0xfd, 0x2b, 0x68, 0x8e, - 0x7e, 0x5d, 0xed, 0x6b, 0xfc, 0x1b, 0xa9, 0x31, 0x57, 0x5f, 0x5d, 0x53, 0x05, 0xed, 0x11, 0xc0, - 0xc8, 0x29, 0xbf, 0x7d, 0x4d, 0xe7, 0xb0, 0xc4, 0x7c, 0xff, 0x95, 0x25, 0x15, 0xf7, 0x7d, 0x98, - 0xcc, 0x0f, 0xdb, 0xad, 0x6b, 0x7a, 0x14, 0x6a, 0xbe, 0x37, 0x0e, 0xad, 0xc8, 0x1e, 0xc0, 0x74, - 0x99, 0x7e, 0x6b, 0x7c, 0x86, 0xcd, 0x95, 0xf1, 0x78, 0x45, 0xf9, 0x35, 0xcc, 0x5d, 0x08, 0xcb, - 0xbb, 0xd7, 0xf5, 0x8d, 0x14, 0x99, 0x1f, 0xbc, 0x46, 0x51, 0xf9, 0x86, 0xee, 0xfd, 0xa7, 0xa7, - 0x96, 0xf6, 0xec, 0xd4, 0xd2, 0xfe, 0x3a, 0xb5, 0xb4, 0x27, 0x67, 0xd6, 0xc4, 0xb3, 0x33, 0x6b, - 0xe2, 0xcf, 0x33, 0x6b, 0xe2, 0xd1, 0xfa, 0x48, 0xe6, 0x0b, 0xc2, 0x35, 0xca, 0xa2, 0xf2, 0xde, - 0x3d, 0xbc, 0xf0, 0x0b, 0x45, 0x1e, 0x81, 0xfe, 0x94, 0xfa, 0xff, 0xf1, 0xe1, 0xdf, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x55, 0x20, 0x0f, 0x95, 0xc4, 0x08, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// 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 { - // Create an incentive program - CreateGauge(ctx context.Context, in *MsgCreateGauge, opts ...grpc.CallOption) (*MsgCreateGaugeResponse, error) - // Add rewards to an existing incentives program - AddToGauge(ctx context.Context, in *MsgAddToGauge, opts ...grpc.CallOption) (*MsgAddToGaugeResponse, error) - // Deposit LP tokens to the module, qualifying for rewards from gauges - Stake(ctx context.Context, in *MsgStake, opts ...grpc.CallOption) (*MsgStakeResponse, error) - // Withdraw LP tokens from the module, forfeiting future rewards from gauges - Unstake(ctx context.Context, in *MsgUnstake, opts ...grpc.CallOption) (*MsgUnstakeResponse, error) - // Update incentives params - UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) -} - -type msgClient struct { - cc grpc1.ClientConn -} - -func NewMsgClient(cc grpc1.ClientConn) MsgClient { - return &msgClient{cc} -} - -func (c *msgClient) CreateGauge(ctx context.Context, in *MsgCreateGauge, opts ...grpc.CallOption) (*MsgCreateGaugeResponse, error) { - out := new(MsgCreateGaugeResponse) - err := c.cc.Invoke(ctx, "/neutron.incentives.Msg/CreateGauge", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) AddToGauge(ctx context.Context, in *MsgAddToGauge, opts ...grpc.CallOption) (*MsgAddToGaugeResponse, error) { - out := new(MsgAddToGaugeResponse) - err := c.cc.Invoke(ctx, "/neutron.incentives.Msg/AddToGauge", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) Stake(ctx context.Context, in *MsgStake, opts ...grpc.CallOption) (*MsgStakeResponse, error) { - out := new(MsgStakeResponse) - err := c.cc.Invoke(ctx, "/neutron.incentives.Msg/Stake", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) Unstake(ctx context.Context, in *MsgUnstake, opts ...grpc.CallOption) (*MsgUnstakeResponse, error) { - out := new(MsgUnstakeResponse) - err := c.cc.Invoke(ctx, "/neutron.incentives.Msg/Unstake", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { - out := new(MsgUpdateParamsResponse) - err := c.cc.Invoke(ctx, "/neutron.incentives.Msg/UpdateParams", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MsgServer is the server API for Msg service. -type MsgServer interface { - // Create an incentive program - CreateGauge(context.Context, *MsgCreateGauge) (*MsgCreateGaugeResponse, error) - // Add rewards to an existing incentives program - AddToGauge(context.Context, *MsgAddToGauge) (*MsgAddToGaugeResponse, error) - // Deposit LP tokens to the module, qualifying for rewards from gauges - Stake(context.Context, *MsgStake) (*MsgStakeResponse, error) - // Withdraw LP tokens from the module, forfeiting future rewards from gauges - Unstake(context.Context, *MsgUnstake) (*MsgUnstakeResponse, error) - // Update incentives params - UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) -} - -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} - -func (*UnimplementedMsgServer) CreateGauge(ctx context.Context, req *MsgCreateGauge) (*MsgCreateGaugeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateGauge not implemented") -} -func (*UnimplementedMsgServer) AddToGauge(ctx context.Context, req *MsgAddToGauge) (*MsgAddToGaugeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AddToGauge not implemented") -} -func (*UnimplementedMsgServer) Stake(ctx context.Context, req *MsgStake) (*MsgStakeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Stake not implemented") -} -func (*UnimplementedMsgServer) Unstake(ctx context.Context, req *MsgUnstake) (*MsgUnstakeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Unstake not implemented") -} -func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") -} - -func RegisterMsgServer(s grpc1.Server, srv MsgServer) { - s.RegisterService(&_Msg_serviceDesc, srv) -} - -func _Msg_CreateGauge_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgCreateGauge) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).CreateGauge(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/neutron.incentives.Msg/CreateGauge", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).CreateGauge(ctx, req.(*MsgCreateGauge)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_AddToGauge_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgAddToGauge) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).AddToGauge(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/neutron.incentives.Msg/AddToGauge", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).AddToGauge(ctx, req.(*MsgAddToGauge)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_Stake_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgStake) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).Stake(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/neutron.incentives.Msg/Stake", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).Stake(ctx, req.(*MsgStake)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_Unstake_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUnstake) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).Unstake(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/neutron.incentives.Msg/Unstake", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).Unstake(ctx, req.(*MsgUnstake)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateParams) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateParams(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/neutron.incentives.Msg/UpdateParams", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) - } - return interceptor(ctx, in, info, handler) -} - -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "neutron.incentives.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "CreateGauge", - Handler: _Msg_CreateGauge_Handler, - }, - { - MethodName: "AddToGauge", - Handler: _Msg_AddToGauge_Handler, - }, - { - MethodName: "Stake", - Handler: _Msg_Stake_Handler, - }, - { - MethodName: "Unstake", - Handler: _Msg_Unstake_Handler, - }, - { - MethodName: "UpdateParams", - Handler: _Msg_UpdateParams_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "neutron/incentives/tx.proto", -} - -func (m *MsgCreateGauge) 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 *MsgCreateGauge) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgCreateGauge) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.PricingTick != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.PricingTick)) - i-- - dAtA[i] = 0x38 - } - if m.NumEpochsPaidOver != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.NumEpochsPaidOver)) - i-- - dAtA[i] = 0x30 - } - n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime):]) - if err1 != nil { - return 0, err1 - } - i -= n1 - i = encodeVarintTx(dAtA, i, uint64(n1)) - i-- - dAtA[i] = 0x2a - if len(m.Coins) > 0 { - for iNdEx := len(m.Coins) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Coins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - { - size, err := m.DistributeTo.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.Owner) > 0 { - i -= len(m.Owner) - copy(dAtA[i:], m.Owner) - i = encodeVarintTx(dAtA, i, uint64(len(m.Owner))) - i-- - dAtA[i] = 0x12 - } - if m.IsPerpetual { - i-- - if m.IsPerpetual { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *MsgCreateGaugeResponse) 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 *MsgCreateGaugeResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgCreateGaugeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgAddToGauge) 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 *MsgAddToGauge) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgAddToGauge) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Rewards) > 0 { - for iNdEx := len(m.Rewards) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Rewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if m.GaugeId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.GaugeId)) - i-- - dAtA[i] = 0x10 - } - if len(m.Owner) > 0 { - i -= len(m.Owner) - copy(dAtA[i:], m.Owner) - i = encodeVarintTx(dAtA, i, uint64(len(m.Owner))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgAddToGaugeResponse) 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 *MsgAddToGaugeResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgAddToGaugeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgStake) 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 *MsgStake) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgStake) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Coins) > 0 { - for iNdEx := len(m.Coins) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Coins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.Owner) > 0 { - i -= len(m.Owner) - copy(dAtA[i:], m.Owner) - i = encodeVarintTx(dAtA, i, uint64(len(m.Owner))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgStakeResponse) 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 *MsgStakeResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgStakeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.ID != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.ID)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *MsgUnstake) 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 *MsgUnstake) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUnstake) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Unstakes) > 0 { - for iNdEx := len(m.Unstakes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Unstakes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.Owner) > 0 { - i -= len(m.Owner) - copy(dAtA[i:], m.Owner) - i = encodeVarintTx(dAtA, i, uint64(len(m.Owner))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUnstake_UnstakeDescriptor) 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 *MsgUnstake_UnstakeDescriptor) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUnstake_UnstakeDescriptor) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Coins) > 0 { - for iNdEx := len(m.Coins) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Coins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if m.ID != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.ID)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *MsgUnstakeResponse) 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 *MsgUnstakeResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUnstakeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParams) 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 = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateParamsResponse) 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 *MsgCreateGauge) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.IsPerpetual { - n += 2 - } - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.DistributeTo.Size() - n += 1 + l + sovTx(uint64(l)) - if len(m.Coins) > 0 { - for _, e := range m.Coins { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime) - n += 1 + l + sovTx(uint64(l)) - if m.NumEpochsPaidOver != 0 { - n += 1 + sovTx(uint64(m.NumEpochsPaidOver)) - } - if m.PricingTick != 0 { - n += 1 + sovTx(uint64(m.PricingTick)) - } - return n -} - -func (m *MsgCreateGaugeResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgAddToGauge) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.GaugeId != 0 { - n += 1 + sovTx(uint64(m.GaugeId)) - } - if len(m.Rewards) > 0 { - for _, e := range m.Rewards { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - return n -} - -func (m *MsgAddToGaugeResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgStake) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if len(m.Coins) > 0 { - for _, e := range m.Coins { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - return n -} - -func (m *MsgStakeResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ID != 0 { - n += 1 + sovTx(uint64(m.ID)) - } - return n -} - -func (m *MsgUnstake) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if len(m.Unstakes) > 0 { - for _, e := range m.Unstakes { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - return n -} - -func (m *MsgUnstake_UnstakeDescriptor) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ID != 0 { - n += 1 + sovTx(uint64(m.ID)) - } - if len(m.Coins) > 0 { - for _, e := range m.Coins { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - return n -} - -func (m *MsgUnstakeResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgUpdateParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Params.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgUpdateParamsResponse) 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 *MsgCreateGauge) 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: MsgCreateGauge: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateGauge: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsPerpetual", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.IsPerpetual = bool(v != 0) - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 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.Owner = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DistributeTo", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.DistributeTo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Coins", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Coins = append(m.Coins, types.Coin{}) - if err := m.Coins[len(m.Coins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NumEpochsPaidOver", wireType) - } - m.NumEpochsPaidOver = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.NumEpochsPaidOver |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PricingTick", wireType) - } - m.PricingTick = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PricingTick |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *MsgCreateGaugeResponse) 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: MsgCreateGaugeResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateGaugeResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgAddToGauge) 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: MsgAddToGauge: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAddToGauge: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 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.Owner = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GaugeId", wireType) - } - m.GaugeId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.GaugeId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Rewards", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Rewards = append(m.Rewards, types.Coin{}) - if err := m.Rewards[len(m.Rewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgAddToGaugeResponse) 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: MsgAddToGaugeResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAddToGaugeResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgStake) 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: MsgStake: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgStake: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 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.Owner = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Coins", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Coins = append(m.Coins, types.Coin{}) - if err := m.Coins[len(m.Coins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgStakeResponse) 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: MsgStakeResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgStakeResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) - } - m.ID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ID |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *MsgUnstake) 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: MsgUnstake: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUnstake: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 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.Owner = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Unstakes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Unstakes = append(m.Unstakes, &MsgUnstake_UnstakeDescriptor{}) - if err := m.Unstakes[len(m.Unstakes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUnstake_UnstakeDescriptor) 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: UnstakeDescriptor: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: UnstakeDescriptor: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) - } - m.ID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ID |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Coins", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Coins = append(m.Coins, types.Coin{}) - if err := m.Coins[len(m.Coins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUnstakeResponse) 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: MsgUnstakeResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUnstakeResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpdateParams) 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: MsgUpdateParams: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Authority = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.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 *MsgUpdateParamsResponse) 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: MsgUpdateParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: 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") -)