diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2463aeb5ee4..ff8098cf98d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,7 +22,7 @@ jobs: - uses: golangci/golangci-lint-action@v2 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.39 + version: v1.45 args: --timeout 10m github-token: ${{ secrets.github_token }} if: "env.GIT_DIFF != ''" \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index eb8466ddc67..803a5d32c83 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,22 +5,95 @@ run: linters: disable-all: true + # Enable specific linter + # https://golangci-lint.run/usage/linters/#enabled-by-default-linters enable: + - asciicheck + - bidichk + - bodyclose + - contextcheck + # - cyclop +# - deadcode <- re-enable in another pr + - depguard + # - dogsled <- disabled because we would like to participate in the iditerod + # - dupl <- really just catches cli stub text + - durationcheck - errcheck + - errname +# - errorlint <- later +# - exhaustive <- too picky + # - exhaustivestruct <- disabled because we don't want to use every element of every struct + - exportloopref + # - forbidigo <- forbids fmt.Print* by default + - forcetypeassert + # - funlen <- some of our functions are longer than this by necessity + # - gci <- questionable utility + # - gochecknoglobals <- disabled because we want some globals + # - gochecknoinits <- disabled because we want to use init() + # - gocognit <- disabled for same reason as gocyclo + - goconst + # - gocritic <- re enable later to catch capitalized local variables + # - gocyclo <- disabled because it won't work with how we cosmos + # - godot + # - godox <- detects TODO/BUG/FIXME and we may wantnthis later but isn't appropriate now + # - goerr113 <- disabled due to lack of comprehension - gofmt - # - goimports - # - golint - - maligned + # - gofumpt + - goheader + - goimports + # - gomoddirectives <- disables replaces + - gomodguard + - goprintffuncname +# - gosec <- triggers too much for this round and should be re-enabled later +# - gosimple <- later + - govet + # - ifshort <- seems to be of questionable value + - importas + - ineffassign + # - ireturn <- disabled because we want to return interfaces + # - lll <- disabled as it is a bit much. Maybe we have a desired limit? + - makezero + - misspell + - nakedret +# - nestif <- ? + - nilerr + - nilnil + # - nlreturn <- disabled as it doesn't auto-fix something simple and doesn't add anything useful + - noctx + # - nolintlint <- disabled because we use nolint in some places + - paralleltest + # - prealloc <- disabled because it makes simple code complicated +# - predeclared <- later + - promlinter +# - revive <- temporarily disabled while jacob figures out how to make poolId not trigger it. + - rowserrcheck + - sqlclosecheck +# - staticcheck <- later +# - structcheck <- later +# - stylecheck <- enable later, atriggers on underscores in variable names and on poolId + # - tagliatelle <- disabled for defying cosmos idiom + - tenv + - testpackage +# - thelper <- later + - tparallel + - typecheck + - unconvert +# - unparam <- looks for unused parameters (enable later) +# - unused <- looks for unused variables (enable later) +# - varcheck <- later + # - varnamelen <- disabled because defies idiom + # - wastedassign + - whitespace +# - wrapcheck +# - wsl issues: exclude-rules: - path: bench_test\.go linters: - errcheck + - path: client/docs + linters: + - all max-issues-per-linter: 10000 max-same-issues: 10000 - -linters-settings: - maligned: - # print struct with more effective memory layout or not, false by default - suggest-new: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 35f04a41b0d..98321c37384 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#1095](https://github.com/osmosis-labs/osmosis/pull/1095) Fix authz being unable to use lockup & superfluid types. * [#1105](https://github.com/osmosis-labs/osmosis/pull/1105) Add GitHub Actions to automatically push the osmosis Docker image * [#1114](https://github.com/osmosis-labs/osmosis/pull/1114) Improve CI: remove duplicate runs of test worflow +* [#1127](https://github.com/osmosis-labs/osmosis/pull/1127) Stricter Linting: bump golangci-lint version and enable additional linters. ### SDK fork updates diff --git a/Makefile b/Makefile index f57232bd9b0..1257f17eb08 100644 --- a/Makefile +++ b/Makefile @@ -231,7 +231,7 @@ benchmark: ############################################################################### lint: - golangci-lint run --disable-all -E errcheck + golangci-lint run find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s format: diff --git a/app/app.go b/app/app.go index 965094323e4..d3221b1c307 100644 --- a/app/app.go +++ b/app/app.go @@ -1,7 +1,7 @@ package app import ( - // Imports from the Go Standard Library + // Imports from the Go Standard Library. "fmt" "io" "net/http" @@ -9,16 +9,16 @@ import ( "path/filepath" "strings" - // HTTP Router + // HTTP Router. "github.com/gorilla/mux" - // Used to serve OpenAPI information + // Used to serve OpenAPI information. "github.com/rakyll/statik/fs" - // A CLI helper + // A CLI helper. "github.com/spf13/cast" - // Imports from Tendermint, Osmosis' consensus protocol + // Imports from Tendermint, Osmosis' consensus protocol. abci "github.com/tendermint/tendermint/abci/types" tmjson "github.com/tendermint/tendermint/libs/json" "github.com/tendermint/tendermint/libs/log" @@ -26,7 +26,7 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" - // Utilities from the Cosmos-SDK other than Cosmos modules + // Utilities from the Cosmos-SDK other than Cosmos modules. "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" @@ -51,7 +51,7 @@ import ( authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" - // Capability: allows developers to atomically define what a module can and cannot do + // Capability: allows developers to atomically define what a module can and cannot do. capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" // Crisis: Halting the blockchain under certain circumstances (e.g. if an invariant is broken). @@ -59,28 +59,28 @@ import ( // Evidence handling for double signing, misbehaviour, etc. - // Params: Parameters that are always available + // Params: Parameters that are always available. paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" // Upgrade: Software upgrades handling and coordination. upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - // IBC Transfer: Defines the "transfer" IBC port + // IBC Transfer: Defines the "transfer" IBC port. transfer "github.com/cosmos/ibc-go/v2/modules/apps/transfer" - // Osmosis application prarmeters + // Osmosis application prarmeters. appparams "github.com/osmosis-labs/osmosis/v7/app/params" - // Upgrades from earlier versions of Osmosis + // Upgrades from earlier versions of Osmosis. v4 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v4" v5 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v5" v7 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v7" _ "github.com/osmosis-labs/osmosis/v7/client/docs/statik" - // Superfluid: Allows users to stake gamm (bonded liquidity) + // Superfluid: Allows users to stake gamm (bonded liquidity). superfluidtypes "github.com/osmosis-labs/osmosis/v7/x/superfluid/types" - // Wasm: Allows Osmosis to interact with web assembly smart contracts + // Wasm: Allows Osmosis to interact with web assembly smart contracts. "github.com/CosmWasm/wasmd/x/wasm" ) @@ -95,7 +95,7 @@ var ( // https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34 EnableSpecificWasmProposals = "" - // use this for clarity in argument list + // use this for clarity in argument list. EmptyWasmOpts []wasm.Option ) @@ -117,7 +117,7 @@ func GetWasmEnabledProposals() []wasm.ProposalType { } var ( - // DefaultNodeHome default home directories for the application daemon + // DefaultNodeHome default home directories for the application daemon. DefaultNodeHome string // ModuleBasics defines the module BasicManager is in charge of setting up basic, @@ -125,10 +125,10 @@ var ( // and genesis verification. ModuleBasics = module.NewBasicManager(appModuleBasics...) - // module account permissions + // module account permissions. maccPerms = moduleAaccountPermissions - // module accounts that are allowed to receive tokens + // module accounts that are allowed to receive tokens. allowedReceivingModAcc = map[string]bool{} ) @@ -188,7 +188,6 @@ func NewOsmosisApp( wasmOpts []wasm.Option, baseAppOptions ...func(*baseapp.BaseApp), ) *OsmosisApp { - appCodec := encodingConfig.Marshaler cdc := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry @@ -235,7 +234,7 @@ func NewOsmosisApp( // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment // we prefer to be more strict in what arguments the modules expect. - var skipGenesisInvariants = cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) + skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) // NOTE: All module / keeper changes should happen prior to this module.NewManager line being called. // However in the event any changes do need to happen after this call, ensure that that keeper @@ -327,27 +326,27 @@ func NewOsmosisApp( // MakeCodecs constructs the *std.Codec and *codec.LegacyAmino instances used by // simapp. It is useful for tests and clients who do not want to construct the -// full simapp +// full simapp. func MakeCodecs() (codec.Codec, *codec.LegacyAmino) { config := MakeEncodingConfig() return config.Marshaler, config.Amino } -// Name returns the name of the App +// Name returns the name of the App. func (app *OsmosisApp) Name() string { return app.BaseApp.Name() } -// BeginBlocker application updates every begin block +// BeginBlocker application updates every begin block. func (app *OsmosisApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { BeginBlockForks(ctx, app) return app.mm.BeginBlock(ctx, req) } -// EndBlocker application updates every end block +// EndBlocker application updates every end block. func (app *OsmosisApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { return app.mm.EndBlock(ctx, req) } -// InitChainer application update at chain initialization +// InitChainer application update at chain initialization. func (app *OsmosisApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { var genesisState GenesisState if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil { @@ -359,7 +358,7 @@ func (app *OsmosisApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) a return app.mm.InitGenesis(ctx, app.appCodec, genesisState) } -// LoadHeight loads a particular height +// LoadHeight loads a particular height. func (app *OsmosisApp) LoadHeight(height int64) error { return app.LoadVersion(height) } @@ -380,7 +379,7 @@ func (app *OsmosisApp) AppCodec() codec.Codec { return app.appCodec } -// InterfaceRegistry returns Osmosis' InterfaceRegistry +// InterfaceRegistry returns Osmosis' InterfaceRegistry. func (app *OsmosisApp) InterfaceRegistry() types.InterfaceRegistry { return app.interfaceRegistry } @@ -414,7 +413,7 @@ func (app *OsmosisApp) GetSubspace(moduleName string) paramstypes.Subspace { return subspace } -// SimulationManager implements the SimulationApp interface +// SimulationManager implements the SimulationApp interface. func (app *OsmosisApp) SimulationManager() *module.SimulationManager { return app.sm } @@ -495,7 +494,7 @@ func (app *OsmosisApp) setupUpgradeHandlers() { app.AccountKeeper)) } -// RegisterSwaggerAPI registers swagger route with API Server +// RegisterSwaggerAPI registers swagger route with API Server. func RegisterSwaggerAPI(ctx client.Context, rtr *mux.Router) { statikFS, err := fs.New() if err != nil { @@ -507,7 +506,7 @@ func RegisterSwaggerAPI(ctx client.Context, rtr *mux.Router) { rtr.PathPrefix("/swagger/").Handler(staticServer) } -// GetMaccPerms returns a copy of the module account permissions +// GetMaccPerms returns a copy of the module account permissions. func GetMaccPerms() map[string][]string { dupMaccPerms := make(map[string][]string) for k, v := range maccPerms { diff --git a/app/apptesting/test_suite.go b/app/apptesting/test_suite.go index 176ecb3dd17..3d299d7966f 100644 --- a/app/apptesting/test_suite.go +++ b/app/apptesting/test_suite.go @@ -66,7 +66,7 @@ func (keeperTestHelper *KeeperTestHelper) SetupValidator(bondStatus stakingtypes } func (keeperTestHelper *KeeperTestHelper) BeginNewBlock(executeNextEpoch bool) { - valAddr := []byte(":^) at this distribution workaround") + valAddr := []byte(":^) at this distribution workaround") //nolint validators := keeperTestHelper.App.StakingKeeper.GetAllValidators(keeperTestHelper.Ctx) if len(validators) >= 1 { valAddrFancy, err := validators[0].GetConsAddr() @@ -91,9 +91,11 @@ func (keeperTestHelper *KeeperTestHelper) BeginNewBlock(executeNextEpoch bool) { newCtx := keeperTestHelper.Ctx.WithBlockTime(newBlockTime).WithBlockHeight(keeperTestHelper.Ctx.BlockHeight() + 1) keeperTestHelper.Ctx = newCtx lastCommitInfo := abci.LastCommitInfo{ - Votes: []abci.VoteInfo{{ - Validator: abci.Validator{Address: valAddr, Power: 1000}, - SignedLastBlock: true}, + Votes: []abci.VoteInfo{ + { + Validator: abci.Validator{Address: valAddr, Power: 1000}, + SignedLastBlock: true, + }, }, } reqBeginBlock := abci.RequestBeginBlock{Header: header, LastCommitInfo: lastCommitInfo} @@ -129,10 +131,9 @@ func (keeperTestHelper *KeeperTestHelper) SetupGammPoolsWithBondDenomMultiplier( }) bondDenom := keeperTestHelper.App.StakingKeeper.BondDenom(keeperTestHelper.Ctx) - //TODO: use sdk crypto instead of tendermint to generate address + // TODO: use sdk crypto instead of tendermint to generate address acc1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) - //fund account with pool creation fee poolCreationFee := keeperTestHelper.App.GAMMKeeper.GetParams(keeperTestHelper.Ctx) err := simapp.FundAccount(keeperTestHelper.App.BankKeeper, keeperTestHelper.Ctx, acc1, poolCreationFee.PoolCreationFee) keeperTestHelper.Require().NoError(err) @@ -180,7 +181,7 @@ func (keeperTestHelper *KeeperTestHelper) SetupGammPoolsWithBondDenomMultiplier( } // SwapAndSetSpotPrice runs a swap to set Spot price of a pool using arbitrary values -// returns spot price after the arbitrary swap +// returns spot price after the arbitrary swap. func (keeperTestHelper *KeeperTestHelper) SwapAndSetSpotPrice(poolId uint64, fromAsset sdk.Coin, toAsset sdk.Coin) sdk.Dec { // create a dummy account acc1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) diff --git a/app/encoding.go b/app/encoding.go index c106d30a0c7..67057957882 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -5,7 +5,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/app/params" ) -// MakeEncodingConfig creates an EncodingConfig for testing +// MakeEncodingConfig creates an EncodingConfig for testing. func MakeEncodingConfig() params.EncodingConfig { encodingConfig := params.MakeEncodingConfig() std.RegisterLegacyAminoCodec(encodingConfig.Amino) diff --git a/app/forks.go b/app/forks.go index 136afbed8f0..632d0de4228 100644 --- a/app/forks.go +++ b/app/forks.go @@ -6,7 +6,7 @@ import ( v6 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v6" ) -// BeginBlockForks is intended to be ran in +// BeginBlockForks is intended to be ran in. func BeginBlockForks(ctx sdk.Context, app *OsmosisApp) { switch ctx.BlockHeight() { case v3.UpgradeHeight: diff --git a/app/keepers.go b/app/keepers.go index 3f539d7e4c7..8fcd2edea9d 100644 --- a/app/keepers.go +++ b/app/keepers.go @@ -1,7 +1,7 @@ package app import ( - // Utilities from the Cosmos-SDK other than Cosmos modules + // Utilities from the Cosmos-SDK other than Cosmos modules. "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -17,11 +17,11 @@ import ( // Authz: Authorization for accounts to perform actions on behalf of other accounts. authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" - // Bank: allows users to transfer tokens + // Bank: allows users to transfer tokens. bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - // Capability: allows developers to atomically define what a module can and cannot do + // Capability: allows developers to atomically define what a module can and cannot do. capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" @@ -38,17 +38,17 @@ import ( evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - // Governance: Allows stakeholders to make decisions concering a Cosmos-SDK blockchain's economy and development + // Governance: Allows stakeholders to make decisions concering a Cosmos-SDK blockchain's economy and development. govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" - // Params: Parameters that are always available + // Params: Parameters that are always available. "github.com/cosmos/cosmos-sdk/x/params" paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - // Slashing: + // Slashing:. slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" @@ -61,64 +61,64 @@ import ( upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - // IBC Transfer: Defines the "transfer" IBC port + // IBC Transfer: Defines the "transfer" IBC port. transfer "github.com/cosmos/ibc-go/v2/modules/apps/transfer" ibctransferkeeper "github.com/cosmos/ibc-go/v2/modules/apps/transfer/keeper" ibctransfertypes "github.com/cosmos/ibc-go/v2/modules/apps/transfer/types" ibcclienttypes "github.com/cosmos/ibc-go/v2/modules/core/02-client/types" porttypes "github.com/cosmos/ibc-go/v2/modules/core/05-port/types" - // IBC: Inter-blockchain communication + // IBC: Inter-blockchain communication. ibcclient "github.com/cosmos/ibc-go/v2/modules/core/02-client" ibchost "github.com/cosmos/ibc-go/v2/modules/core/24-host" ibckeeper "github.com/cosmos/ibc-go/v2/modules/core/keeper" - // Upgrades from earlier versions of Osmosis + // Upgrades from earlier versions of Osmosis. _ "github.com/osmosis-labs/osmosis/v7/client/docs/statik" - // Modules that live in the Osmosis repository and are specific to Osmosis + // Modules that live in the Osmosis repository and are specific to Osmosis. claimkeeper "github.com/osmosis-labs/osmosis/v7/x/claim/keeper" claimtypes "github.com/osmosis-labs/osmosis/v7/x/claim/types" "github.com/osmosis-labs/osmosis/v7/x/superfluid" "github.com/osmosis-labs/osmosis/v7/x/txfees" - // Epochs: gives Osmosis a sense of "clock time" so that events can be based on days instead of "number of blocks" + // Epochs: gives Osmosis a sense of "clock time" so that events can be based on days instead of "number of blocks". epochskeeper "github.com/osmosis-labs/osmosis/v7/x/epochs/keeper" epochstypes "github.com/osmosis-labs/osmosis/v7/x/epochs/types" - // Generalized Automated Market Maker + // Generalized Automated Market Maker. gammkeeper "github.com/osmosis-labs/osmosis/v7/x/gamm/keeper" gammtypes "github.com/osmosis-labs/osmosis/v7/x/gamm/types" - // Incentives: Allows Osmosis and foriegn chain communities to incentivize users to provide liquidity + // Incentives: Allows Osmosis and foreign chain communities to incentivize users to provide liquidity. incentiveskeeper "github.com/osmosis-labs/osmosis/v7/x/incentives/keeper" incentivestypes "github.com/osmosis-labs/osmosis/v7/x/incentives/types" - // Lockup: allows tokens to be locked (made non-transferrable) + // Lockup: allows tokens to be locked (made non-transferrable). lockupkeeper "github.com/osmosis-labs/osmosis/v7/x/lockup/keeper" lockuptypes "github.com/osmosis-labs/osmosis/v7/x/lockup/types" - // Mint: Our modified version of github.com/cosmos/cosmos-sdk/x/mint + // Mint: Our modified version of github.com/cosmos/cosmos-sdk/x/mint. mintkeeper "github.com/osmosis-labs/osmosis/v7/x/mint/keeper" minttypes "github.com/osmosis-labs/osmosis/v7/x/mint/types" - // Pool incentives: + // Pool incentives:. poolincentives "github.com/osmosis-labs/osmosis/v7/x/pool-incentives" poolincentiveskeeper "github.com/osmosis-labs/osmosis/v7/x/pool-incentives/keeper" poolincentivestypes "github.com/osmosis-labs/osmosis/v7/x/pool-incentives/types" - // Superfluid: Allows users to stake gamm (bonded liquidity) + // Superfluid: Allows users to stake gamm (bonded liquidity). superfluidkeeper "github.com/osmosis-labs/osmosis/v7/x/superfluid/keeper" superfluidtypes "github.com/osmosis-labs/osmosis/v7/x/superfluid/types" - // Txfees: Allows Osmosis to charge transaction fees without harming IBC user experience + // Txfees: Allows Osmosis to charge transaction fees without harming IBC user experience. txfeeskeeper "github.com/osmosis-labs/osmosis/v7/x/txfees/keeper" txfeestypes "github.com/osmosis-labs/osmosis/v7/x/txfees/types" - // Wasm: Allows Osmosis to interact with web assembly smart contracts + // Wasm: Allows Osmosis to interact with web assembly smart contracts. "github.com/CosmWasm/wasmd/x/wasm" - // Modules related to bech32-ibc, which allows new ibc funcationality based on the bech32 prefix of addresses + // Modules related to bech32-ibc, which allows new ibc funcationality based on the bech32 prefix of addresses. "github.com/osmosis-labs/bech32-ibc/x/bech32ibc" bech32ibckeeper "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/keeper" bech32ibctypes "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/types" @@ -205,7 +205,7 @@ func (app *OsmosisApp) InitSpecialKeepers( app.UpgradeKeeper = &upgradeKeeper } -// Note: I put x/wasm here as I need to write it up to these other ones +// Note: I put x/wasm here as I need to write it up to these other ones. func (app *OsmosisApp) InitNormalKeepers( wasmDir string, wasmConfig wasm.Config, @@ -479,7 +479,7 @@ func (app *OsmosisApp) SetupHooks() { ) } -// initParamsKeeper init params keeper and its subspaces +// initParamsKeeper init params keeper and its subspaces. func (app *OsmosisApp) initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper { paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) diff --git a/app/modules.go b/app/modules.go index dca13f8c79c..c6fca8b56d8 100644 --- a/app/modules.go +++ b/app/modules.go @@ -1,7 +1,7 @@ package app import ( - // Utilities from the Cosmos-SDK other than Cosmos modules + // Utilities from the Cosmos-SDK other than Cosmos modules. "github.com/cosmos/cosmos-sdk/types/module" // Cosmos-SDK Modules @@ -13,7 +13,7 @@ import ( authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - // Vesting: Allows the lock and periodic release of tokens + // Vesting: Allows the lock and periodic release of tokens. "github.com/cosmos/cosmos-sdk/x/auth/vesting" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" @@ -21,11 +21,11 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" - // Bank: allows users to transfer tokens + // Bank: allows users to transfer tokens. "github.com/cosmos/cosmos-sdk/x/bank" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - // Capability: allows developers to atomically define what a module can and cannot do + // Capability: allows developers to atomically define what a module can and cannot do. "github.com/cosmos/cosmos-sdk/x/capability" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" @@ -42,20 +42,20 @@ import ( "github.com/cosmos/cosmos-sdk/x/evidence" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - // Genesis Utilities: Used for evertything to do with the very first block of a chain + // Genesis Utilities: Used for evertything to do with the very first block of a chain. "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" - // Governance: Allows stakeholders to make decisions concering a Cosmos-SDK blockchain's economy and development + // Governance: Allows stakeholders to make decisions concering a Cosmos-SDK blockchain's economy and development. "github.com/cosmos/cosmos-sdk/x/gov" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - // Params: Parameters that are always available + // Params: Parameters that are always available. "github.com/cosmos/cosmos-sdk/x/params" paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - // Slashing: + // Slashing:. "github.com/cosmos/cosmos-sdk/x/slashing" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" @@ -68,51 +68,51 @@ import ( upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - // IBC Transfer: Defines the "transfer" IBC port + // IBC Transfer: Defines the "transfer" IBC port. transfer "github.com/cosmos/ibc-go/v2/modules/apps/transfer" ibctransfertypes "github.com/cosmos/ibc-go/v2/modules/apps/transfer/types" - // IBC: Inter-blockchain communication + // IBC: Inter-blockchain communication. ibc "github.com/cosmos/ibc-go/v2/modules/core" ibcclientclient "github.com/cosmos/ibc-go/v2/modules/core/02-client/client" ibchost "github.com/cosmos/ibc-go/v2/modules/core/24-host" - // Osmosis application prarmeters + // Osmosis application prarmeters. appparams "github.com/osmosis-labs/osmosis/v7/app/params" - // Upgrades from earlier versions of Osmosis + // Upgrades from earlier versions of Osmosis. _ "github.com/osmosis-labs/osmosis/v7/client/docs/statik" - // Modules that live in the Osmosis repository and are specific to Osmosis + // Modules that live in the Osmosis repository and are specific to Osmosis. "github.com/osmosis-labs/osmosis/v7/x/claim" claimtypes "github.com/osmosis-labs/osmosis/v7/x/claim/types" - // Epochs: gives Osmosis a sense of "clock time" so that events can be based on days instead of "number of blocks" + // Epochs: gives Osmosis a sense of "clock time" so that events can be based on days instead of "number of blocks". "github.com/osmosis-labs/osmosis/v7/x/epochs" epochstypes "github.com/osmosis-labs/osmosis/v7/x/epochs/types" - // Generalized Automated Market Maker + // Generalized Automated Market Maker. "github.com/osmosis-labs/osmosis/v7/x/gamm" gammtypes "github.com/osmosis-labs/osmosis/v7/x/gamm/types" - // Incentives: Allows Osmosis and foriegn chain communities to incentivize users to provide liquidity + // Incentives: Allows Osmosis and foreign chain communities to incentivize users to provide liquidity. "github.com/osmosis-labs/osmosis/v7/x/incentives" incentivestypes "github.com/osmosis-labs/osmosis/v7/x/incentives/types" - // Lockup: allows tokens to be locked (made non-transferrable) + // Lockup: allows tokens to be locked (made non-transferrable). "github.com/osmosis-labs/osmosis/v7/x/lockup" lockuptypes "github.com/osmosis-labs/osmosis/v7/x/lockup/types" - // Mint: Our modified version of github.com/cosmos/cosmos-sdk/x/mint + // Mint: Our modified version of github.com/cosmos/cosmos-sdk/x/mint. "github.com/osmosis-labs/osmosis/v7/x/mint" minttypes "github.com/osmosis-labs/osmosis/v7/x/mint/types" - // Pool incentives: + // Pool incentives:. poolincentives "github.com/osmosis-labs/osmosis/v7/x/pool-incentives" poolincentivesclient "github.com/osmosis-labs/osmosis/v7/x/pool-incentives/client" poolincentivestypes "github.com/osmosis-labs/osmosis/v7/x/pool-incentives/types" - // Superfluid: Allows users to stake gamm (bonded liquidity) + // Superfluid: Allows users to stake gamm (bonded liquidity). superfluid "github.com/osmosis-labs/osmosis/v7/x/superfluid" superfluidclient "github.com/osmosis-labs/osmosis/v7/x/superfluid/client" superfluidtypes "github.com/osmosis-labs/osmosis/v7/x/superfluid/types" @@ -121,11 +121,11 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/txfees" txfeestypes "github.com/osmosis-labs/osmosis/v7/x/txfees/types" - // Wasm: Allows Osmosis to interact with web assembly smart contracts + // Wasm: Allows Osmosis to interact with web assembly smart contracts. "github.com/CosmWasm/wasmd/x/wasm" wasmclient "github.com/CosmWasm/wasmd/x/wasm/client" - // Modules related to bech32-ibc, which allows new ibc funcationality based on the bech32 prefix of addresses + // Modules related to bech32-ibc, which allows new ibc funcationality based on the bech32 prefix of addresses. "github.com/osmosis-labs/bech32-ibc/x/bech32ibc" bech32ibctypes "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/types" "github.com/osmosis-labs/bech32-ibc/x/bech32ics20" @@ -169,7 +169,7 @@ var appModuleBasics = []module.AppModuleBasic{ wasm.AppModuleBasic{}, } -// module account permissions +// module account permissions. var moduleAaccountPermissions = map[string][]string{ authtypes.FeeCollectorName: nil, distrtypes.ModuleName: nil, @@ -189,7 +189,7 @@ var moduleAaccountPermissions = map[string][]string{ wasm.ModuleName: {authtypes.Burner}, } -// appModules return modules to initlize module manager +// appModules return modules to initlize module manager. func appModules(app *OsmosisApp, encodingConfig appparams.EncodingConfig, skipGenesisInvariants bool) []module.AppModule { appCodec := encodingConfig.Marshaler @@ -276,7 +276,7 @@ var orderEndBlockers = []string{ wasm.ModuleName, } -// modulesOrderInitGenesis returns module names in order for init genesis calls +// modulesOrderInitGenesis returns module names in order for init genesis calls. var modulesOrderInitGenesis = []string{ capabilitytypes.ModuleName, authtypes.ModuleName, @@ -308,7 +308,7 @@ var modulesOrderInitGenesis = []string{ wasm.ModuleName, } -// simulationModules returns modules for simulation manager +// simulationModules returns modules for simulation manager. func simulationModules(app *OsmosisApp, encodingConfig appparams.EncodingConfig, skipGenesisInvariants bool) []module.AppModuleSimulation { appCodec := encodingConfig.Marshaler diff --git a/app/params/config.go b/app/params/config.go index 4062770bcd6..69e56315978 100644 --- a/app/params/config.go +++ b/app/params/config.go @@ -13,20 +13,20 @@ const ( DefaultBondDenom = BaseCoinUnit - // Bech32PrefixAccAddr defines the Bech32 prefix of an account's address + // Bech32PrefixAccAddr defines the Bech32 prefix of an account's address. Bech32PrefixAccAddr = "osmo" ) var ( - // Bech32PrefixAccPub defines the Bech32 prefix of an account's public key + // Bech32PrefixAccPub defines the Bech32 prefix of an account's public key. Bech32PrefixAccPub = Bech32PrefixAccAddr + "pub" - // Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address + // Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address. Bech32PrefixValAddr = Bech32PrefixAccAddr + "valoper" - // Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key + // Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key. Bech32PrefixValPub = Bech32PrefixAccAddr + "valoperpub" - // Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address + // Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address. Bech32PrefixConsAddr = Bech32PrefixAccAddr + "valcons" - // Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key + // Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key. Bech32PrefixConsPub = Bech32PrefixAccAddr + "valconspub" ) diff --git a/app/test_helpers.go b/app/test_helpers.go index a9736e10a5a..6456afb7984 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -11,7 +11,7 @@ import ( dbm "github.com/tendermint/tm-db" ) -// Setup initializes a new OsmosisApp +// Setup initializes a new OsmosisApp. func Setup(isCheckTx bool) *OsmosisApp { db := dbm.NewMemDB() app := NewOsmosisApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, MakeEncodingConfig(), simapp.EmptyAppOptions{}, GetWasmEnabledProposals(), EmptyWasmOpts) @@ -35,7 +35,7 @@ func Setup(isCheckTx bool) *OsmosisApp { } // SetupTestingAppWithLevelDb initializes a new OsmosisApp intended for testing, -// with LevelDB as a db +// with LevelDB as a db. func SetupTestingAppWithLevelDb(isCheckTx bool) (app *OsmosisApp, cleanupFn func()) { dir := "osmosis_testing" db, err := sdk.NewLevelDB("osmosis_leveldb_testing", dir) @@ -67,5 +67,5 @@ func SetupTestingAppWithLevelDb(isCheckTx bool) (app *OsmosisApp, cleanupFn func } } - return + return app, cleanupFn } diff --git a/app/upgrades/v3/constants.go b/app/upgrades/v3/constants.go index 8a0e9c62217..e2fd4db52ef 100644 --- a/app/upgrades/v3/constants.go +++ b/app/upgrades/v3/constants.go @@ -1,4 +1,6 @@ package v3 -const UpgradeName = "v3" -const UpgradeHeight = 712000 +const ( + UpgradeName = "v3" + UpgradeHeight = 712000 +) diff --git a/app/upgrades/v3/forks.go b/app/upgrades/v3/forks.go index a22955ac55f..e10584dbe31 100644 --- a/app/upgrades/v3/forks.go +++ b/app/upgrades/v3/forks.go @@ -15,9 +15,9 @@ func RunForkLogic(ctx sdk.Context, gov *govkeeper.Keeper, staking *stakingkeeper } // Fixes an error where minimum deposit was set to "500 osmo" -// This denom does not exist, which makes it impossible for a proposal to go to a vote +// This denom does not exist, which makes it impossible for a proposal to go to a vote. func FixMinDepositDenom(ctx sdk.Context, gov *govkeeper.Keeper) { - var params = gov.GetDepositParams(ctx) + params := gov.GetDepositParams(ctx) params.MinDeposit = sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(500000000))) gov.SetDepositParams(ctx, params) } diff --git a/app/upgrades/v4/prop12.go b/app/upgrades/v4/prop12.go index 6d5eec4f53e..a7127f1d000 100644 --- a/app/upgrades/v4/prop12.go +++ b/app/upgrades/v4/prop12.go @@ -13,7 +13,7 @@ import ( func Prop12(ctx sdk.Context, bank bankkeeper.Keeper, distr *distrkeeper.Keeper) { payments := GetProp12Payments() - var total = int64(0) + total := int64(0) for _, payment := range payments { addr, err := sdk.AccAddressFromBech32(payment[0]) @@ -31,9 +31,7 @@ func Prop12(ctx sdk.Context, bank bankkeeper.Keeper, distr *distrkeeper.Keeper) total += amount } - //deduct from the feePool tracker feePool := distr.GetFeePool(ctx) feePool.CommunityPool = feePool.CommunityPool.Sub(sdk.NewDecCoins(sdk.NewInt64DecCoin("uosmo", total))) distr.SetFeePool(ctx, feePool) - } diff --git a/app/upgrades/v4/upgrades.go b/app/upgrades/v4/upgrades.go index 42bd913b96a..51830bb1a3d 100644 --- a/app/upgrades/v4/upgrades.go +++ b/app/upgrades/v4/upgrades.go @@ -15,7 +15,8 @@ import ( func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator, bank bankkeeper.Keeper, distr *distrkeeper.Keeper, - gamm *gammkeeper.Keeper) upgradetypes.UpgradeHandler { + gamm *gammkeeper.Keeper, +) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, _plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { // // Upgrade all of the lock storages // locks, err := app.LockupKeeper.GetLegacyPeriodLocks(ctx) diff --git a/app/upgrades/v5/upgrades.go b/app/upgrades/v5/upgrades.go index e6ea3fda904..895f584f429 100644 --- a/app/upgrades/v5/upgrades.go +++ b/app/upgrades/v5/upgrades.go @@ -24,7 +24,8 @@ func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator, ibcConnections *connectionkeeper.Keeper, txFeesKeeper *txfeeskeeper.Keeper, gamm *gammkeeper.Keeper, - staking *stakingkeeper.Keeper) upgradetypes.UpgradeHandler { + staking *stakingkeeper.Keeper, +) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { // Set IBC updates from {inside SDK} to v1 // https://github.com/cosmos/ibc-go/blob/main/docs/migrations/ibc-migration-043.md#in-place-store-migrations diff --git a/app/upgrades/v5/whitelist_feetokens.go b/app/upgrades/v5/whitelist_feetokens.go index 3141a66709b..c979fc4cd30 100644 --- a/app/upgrades/v5/whitelist_feetokens.go +++ b/app/upgrades/v5/whitelist_feetokens.go @@ -13,6 +13,8 @@ import ( // Every asset with a liquid osmo pairing pool on Osmosis, as of 12/01/21 // Notably, Tick is not on this list because the osmo pool has $76 of liquidity. // Cheq'd and KRT are also not on this, due to neither having osmo pairings. +// We nolint because these are strings of whitelisted ibc denoms. +//nolint:gosec var feetoken_whitelist_data = ` ion,uion,2 atom,ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2,1 diff --git a/app/upgrades/v6/constants.go b/app/upgrades/v6/constants.go index 57b8681e912..2e0d7e3ce52 100644 --- a/app/upgrades/v6/constants.go +++ b/app/upgrades/v6/constants.go @@ -1,4 +1,6 @@ package v6 -const UpgradeName = "v6" -const UpgradeHeight = 2464000 +const ( + UpgradeName = "v6" + UpgradeHeight = 2464000 +) diff --git a/cmd/osmosisd/cmd/balances_from_state_export.go b/cmd/osmosisd/cmd/balances_from_state_export.go index eaa393b5ae9..d4eff870946 100644 --- a/cmd/osmosisd/cmd/balances_from_state_export.go +++ b/cmd/osmosisd/cmd/balances_from_state_export.go @@ -79,12 +79,12 @@ func underlyingCoins(originCoins sdk.Coins, pools map[string]gammtypes.PoolI) sd } // pools is a map from LP share string -> pool. -// TODO: Make a separate type for this +// TODO: Make a separate type for this. func underlyingCoinsForSelectPools( originCoins sdk.Coins, pools map[string]gammtypes.PoolI, - selectPoolIDs []uint64) map[uint64]sdk.Coins { - + selectPoolIDs []uint64, +) map[uint64]sdk.Coins { balancesByPool := make(map[uint64]sdk.Coins) for _, coin := range originCoins { @@ -140,7 +140,8 @@ func getGenStateFromPath(genesisFilePath string) (map[string]json.RawMessage, er return genState, nil } -// ExportAirdropSnapshotCmd generates a snapshot.json from a provided exported genesis.json +// ExportAirdropSnapshotCmd generates a snapshot.json from a provided exported genesis.json. +//nolint:ineffassign // because of accounts = authtypes.SanitizeGenesisAccounts(accounts) func ExportDeriveBalancesCmd() *cobra.Command { cmd := &cobra.Command{ Use: "export-derive-balances [input-genesis-file] [output-snapshot-json]", @@ -177,7 +178,7 @@ Example: } authGenesis := authtypes.GenesisState{} - clientCtx.JSONCodec.MustUnmarshalJSON(genState["auth"], &authGenesis) + clientCtx.Codec.MustUnmarshalJSON(genState["auth"], &authGenesis) accounts, err := authtypes.UnpackAccounts(authGenesis.Accounts) if err != nil { panic(err) @@ -188,7 +189,7 @@ Example: snapshotAccs := make(map[string]DerivedAccount) bankGenesis := banktypes.GenesisState{} - clientCtx.JSONCodec.MustUnmarshalJSON(genState["bank"], &bankGenesis) + clientCtx.Codec.MustUnmarshalJSON(genState["bank"], &bankGenesis) for _, balance := range bankGenesis.Balances { address := balance.Address acc, ok := snapshotAccs[address] @@ -201,7 +202,7 @@ Example: } stakingGenesis := stakingtypes.GenesisState{} - clientCtx.JSONCodec.MustUnmarshalJSON(genState["staking"], &stakingGenesis) + clientCtx.Codec.MustUnmarshalJSON(genState["staking"], &stakingGenesis) for _, unbonding := range stakingGenesis.UnbondingDelegations { address := unbonding.DelegatorAddress acc, ok := snapshotAccs[address] @@ -242,7 +243,7 @@ Example: } lockupGenesis := lockuptypes.GenesisState{} - clientCtx.JSONCodec.MustUnmarshalJSON(genState["lockup"], &lockupGenesis) + clientCtx.Codec.MustUnmarshalJSON(genState["lockup"], &lockupGenesis) for _, lock := range lockupGenesis.Locks { address := lock.Owner @@ -256,7 +257,7 @@ Example: } claimGenesis := claimtypes.GenesisState{} - clientCtx.JSONCodec.MustUnmarshalJSON(genState["claim"], &claimGenesis) + clientCtx.Codec.MustUnmarshalJSON(genState["claim"], &claimGenesis) for _, record := range claimGenesis.ClaimRecords { address := record.Address @@ -284,7 +285,7 @@ Example: } gammGenesis := gammtypes.GenesisState{} - clientCtx.JSONCodec.MustUnmarshalJSON(genState["gamm"], &gammGenesis) + clientCtx.Codec.MustUnmarshalJSON(genState["gamm"], &gammGenesis) // collect gamm pools pools := make(map[string]gammtypes.PoolI) @@ -328,7 +329,7 @@ Example: return fmt.Errorf("failed to marshal snapshot: %w", err) } - err = ioutil.WriteFile(snapshotOutput, snapshotJSON, 0644) + err = ioutil.WriteFile(snapshotOutput, snapshotJSON, 0o644) return err }, } diff --git a/cmd/osmosisd/cmd/bech32.go b/cmd/osmosisd/cmd/bech32.go index aada0009744..60b76cd445b 100644 --- a/cmd/osmosisd/cmd/bech32.go +++ b/cmd/osmosisd/cmd/bech32.go @@ -8,11 +8,9 @@ import ( "github.com/cosmos/cosmos-sdk/types/bech32" ) -var ( - flagBech32Prefix = "prefix" -) +var flagBech32Prefix = "prefix" -// get cmd to convert any bech32 address to an osmo prefix +// get cmd to convert any bech32 address to an osmo prefix. func ConvertBech32Cmd() *cobra.Command { cmd := &cobra.Command{ Use: "bech32-convert [bech32 string]", @@ -25,7 +23,6 @@ Example: `, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - bech32prefix, err := cmd.Flags().GetString(flagBech32Prefix) if err != nil { return err diff --git a/cmd/osmosisd/cmd/genaccounts.go b/cmd/osmosisd/cmd/genaccounts.go index 53022422b13..4187c274438 100644 --- a/cmd/osmosisd/cmd/genaccounts.go +++ b/cmd/osmosisd/cmd/genaccounts.go @@ -10,7 +10,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" sdk "github.com/cosmos/cosmos-sdk/types" @@ -41,7 +40,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) depCdc := clientCtx.Codec - cdc := depCdc.(codec.Codec) + cdc := depCdc serverCtx := server.GetServerContextFromCmd(cmd) config := serverCtx.Config diff --git a/cmd/osmosisd/cmd/genesis.go b/cmd/osmosisd/cmd/genesis.go index fdf409e3a96..b242e42a8d8 100644 --- a/cmd/osmosisd/cmd/genesis.go +++ b/cmd/osmosisd/cmd/genesis.go @@ -12,7 +12,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/server" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" @@ -35,6 +34,7 @@ import ( poolincentivestypes "github.com/osmosis-labs/osmosis/v7/x/pool-incentives/types" ) +//nolint:ineffassign func PrepareGenesisCmd(defaultNodeHome string, mbm module.BasicManager) *cobra.Command { cmd := &cobra.Command{ Use: "prepare-genesis", @@ -52,7 +52,7 @@ Example: RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) depCdc := clientCtx.Codec - cdc := depCdc.(codec.Codec) + cdc := depCdc serverCtx := server.GetServerContextFromCmd(cmd) config := serverCtx.Config @@ -105,7 +105,7 @@ Example: func PrepareGenesis(clientCtx client.Context, appState map[string]json.RawMessage, genDoc *tmtypes.GenesisDoc, genesisParams GenesisParams, chainID string) (map[string]json.RawMessage, *tmtypes.GenesisDoc, error) { depCdc := clientCtx.Codec - cdc := depCdc.(codec.Codec) + cdc := depCdc // chain params genesis genDoc.GenesisTime = genesisParams.GenesisTime @@ -249,7 +249,7 @@ func MainnetGenesisParams() GenesisParams { genParams.NativeCoinMetadatas = []banktypes.Metadata{ { - Description: fmt.Sprintf("The native token of Osmosis"), + Description: "The native token of Osmosis", DenomUnits: []*banktypes.DenomUnit{ { Denom: appParams.BaseCoinUnit, @@ -527,7 +527,6 @@ func MainnetGenesisParams() GenesisParams { } func TestnetGenesisParams() GenesisParams { - genParams := MainnetGenesisParams() genParams.GenesisTime = time.Now() diff --git a/cmd/osmosisd/cmd/genwasm.go b/cmd/osmosisd/cmd/genwasm.go index 07e4b29fa0b..ee58db9ef3a 100644 --- a/cmd/osmosisd/cmd/genwasm.go +++ b/cmd/osmosisd/cmd/genwasm.go @@ -24,5 +24,4 @@ func AddGenesisWasmMsgCmd(defaultNodeHome string) *cobra.Command { wasmcli.GenesisListCodesCmd(defaultNodeHome, genesisIO), ) return txCmd - } diff --git a/cmd/osmosisd/cmd/init.go b/cmd/osmosisd/cmd/init.go index 8fc5b810f6a..bc6f92d38d7 100644 --- a/cmd/osmosisd/cmd/init.go +++ b/cmd/osmosisd/cmd/init.go @@ -80,8 +80,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { serverCtx := server.GetServerContextFromCmd(cmd) config := serverCtx.Config - //This is a slice of SEED nodes, not peers. They must be configured in seed mode. - //An easy way to run a lightweight seed node is to use tenderseed: github.com/binaryholdings/tenderseed + // An easy way to run a lightweight seed node is to use tenderseed: github.com/binaryholdings/tenderseed seeds := []string{ "21d7539792ee2e0d650b199bf742c56ae0cf499e@162.55.132.230:2000", // Notional @@ -91,9 +90,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { "f515a8599b40f0e84dfad935ba414674ab11a668@osmosis.blockpane.com:26656", // [ block pane ] "6bcdbcfd5d2c6ba58460f10dbcfde58278212833@osmosis.artifact-staking.io:26656", // Artifact Staking } - - //Override default settings in config.toml - config.P2P.Seeds = strings.Join(seeds[:], ",") + config.P2P.Seeds = strings.Join(seeds, ",") config.P2P.MaxNumInboundPeers = 320 config.P2P.MaxNumOutboundPeers = 40 config.Mempool.Size = 10000 diff --git a/cmd/osmosisd/cmd/root.go b/cmd/osmosisd/cmd/root.go index 5c8731bfbae..2e66a144dd4 100644 --- a/cmd/osmosisd/cmd/root.go +++ b/cmd/osmosisd/cmd/root.go @@ -86,7 +86,6 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { // initAppConfig helps to override default appConfig template and configs. // return "", nil if no custom configuration is required for the application. func initAppConfig() (string, interface{}) { - type OsmosisMempoolConfig struct { ArbitrageMinGasPrice string `mapstructure:"arbitrage-min-gas-fee"` } @@ -135,7 +134,6 @@ min-gas-price-for-high-gas-tx = ".0025" } func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { - cfg := sdk.GetConfig() cfg.Seal() @@ -285,8 +283,8 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty func createOsmosisAppAndExport( logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailWhiteList []string, - appOpts servertypes.AppOptions) (servertypes.ExportedApp, error) { - + appOpts servertypes.AppOptions, +) (servertypes.ExportedApp, error) { encCfg := osmosis.MakeEncodingConfig() // Ideally, we would reuse the one created by NewRootCmd. encCfg.Marshaler = codec.NewProtoCodec(encCfg.InterfaceRegistry) var app *osmosis.OsmosisApp diff --git a/cmd/osmosisd/cmd/testnet.go b/cmd/osmosisd/cmd/testnet.go index c75f4eb283c..11ee553cccc 100644 --- a/cmd/osmosisd/cmd/testnet.go +++ b/cmd/osmosisd/cmd/testnet.go @@ -42,7 +42,7 @@ var ( flagStartingIPAddress = "starting-ip-address" ) -// get cmd to initialize all files for tendermint testnet and application +// get cmd to initialize all files for tendermint testnet and application. func testnetCmd(mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator) *cobra.Command { cmd := &cobra.Command{ Use: "testnet", @@ -100,9 +100,9 @@ Example: return cmd } -const nodeDirPerm = 0755 +const nodeDirPerm = 0o755 -// Initialize the testnet +// Initialize the testnet. func InitTestnet( clientCtx client.Context, cmd *cobra.Command, @@ -120,7 +120,6 @@ func InitTestnet( algoStr string, numValidators int, ) error { - nodeIDs := make([]string, numValidators) valPubKeys := make([]cryptotypes.PubKey, numValidators) @@ -273,7 +272,6 @@ func initGenFiles( genAccounts []authtypes.GenesisAccount, genBalances []banktypes.Balance, genFiles []string, numValidators int, ) error { - appGenState := mbm.DefaultGenesis(clientCtx.Codec) // set the accounts in the genesis state @@ -325,7 +323,6 @@ func collectGenFiles( nodeIDs []string, valPubKeys []cryptotypes.PubKey, numValidators int, outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator, ) error { - var appState json.RawMessage genTime := tmtime.Now() @@ -394,12 +391,12 @@ func writeFile(name string, dir string, contents []byte) error { writePath := filepath.Join(dir) file := filepath.Join(writePath, name) - err := tmos.EnsureDir(writePath, 0755) + err := tmos.EnsureDir(writePath, 0o755) if err != nil { return err } - err = tmos.WriteFile(file, contents, 0644) + err = tmos.WriteFile(file, contents, 0o644) if err != nil { return err } diff --git a/cmd/osmosisd/cmd/testnetify/cmd.go b/cmd/osmosisd/cmd/testnetify/cmd.go index d158ba4b88c..97990c49a9a 100644 --- a/cmd/osmosisd/cmd/testnetify/cmd.go +++ b/cmd/osmosisd/cmd/testnetify/cmd.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/cobra" ) -// get cmd to convert any bech32 address to an osmo prefix +// get cmd to convert any bech32 address to an osmo prefix. func StateExportToTestnetGenesis() *cobra.Command { cmd := &cobra.Command{ Use: "testnetify [state_export_path] -p [testnet_params]", @@ -30,7 +30,7 @@ func StateExportToTestnetGenesis() *cobra.Command { return err } var genesis app.GenesisState - err = json.Unmarshal([]byte(file), &genesis) + err = json.Unmarshal(file, &genesis) if err != nil { return err } diff --git a/cmd/osmosisd/cmd/testnetify/find_replace.go b/cmd/osmosisd/cmd/testnetify/find_replace.go index fad757bac9a..69f413dd5b4 100644 --- a/cmd/osmosisd/cmd/testnetify/find_replace.go +++ b/cmd/osmosisd/cmd/testnetify/find_replace.go @@ -12,7 +12,7 @@ func replaceConsAddrHex(genesis app.GenesisState, fromAddr string, replaceAddr s } // TODO: Make it possible to only replace all in certain genesis keys -// no reason to pay for iterating over bank every time :) +// no reason to pay for iterating over bank every time :). func replaceAllInGenesis(genesis app.GenesisState, find string, replace string) { // To help in debugging findBz := []byte(find) diff --git a/cmd/osmosisd/cmd/testnetify/state_export_to_testnet.go b/cmd/osmosisd/cmd/testnetify/state_export_to_testnet.go index 2f61bfdc1a3..be694c629a1 100644 --- a/cmd/osmosisd/cmd/testnetify/state_export_to_testnet.go +++ b/cmd/osmosisd/cmd/testnetify/state_export_to_testnet.go @@ -10,7 +10,7 @@ var ( valConsBech32 = "osmovalcons" ) -// TODO: Add params for min num validators for consensus +// TODO: Add params for min num validators for consensus. type TestnetParams struct { ValidatorConsensusPubkeys []string ValidatorOperatorPubkeys []string @@ -27,6 +27,7 @@ type ValidatorDetails struct { OperatorAddress string } +//nolint:ineffassign func defaultTestnetParams() TestnetParams { /* priv_validator_key.json file { diff --git a/osmomath/math.go b/osmomath/math.go index ed0c2801c8a..f752dd363da 100644 --- a/osmomath/math.go +++ b/osmomath/math.go @@ -7,14 +7,17 @@ import ( ) // Don't EVER change after initializing -// TODO: Analyze choice here +// TODO: Analyze choice here. var powPrecision, _ = sdk.NewDecFromStr("0.00000001") -// Singletons +// Singletons. var zero sdk.Dec = sdk.ZeroDec() -var one_half sdk.Dec = sdk.MustNewDecFromStr("0.5") -var one sdk.Dec = sdk.OneDec() -var two sdk.Dec = sdk.MustNewDecFromStr("2") + +var ( + one_half sdk.Dec = sdk.MustNewDecFromStr("0.5") + one sdk.Dec = sdk.OneDec() + two sdk.Dec = sdk.MustNewDecFromStr("2") +) // Returns the internal "power precision". // All fractional exponentiation in osmosis is expected to be accurate up to @@ -29,7 +32,7 @@ func GetPowPrecision() sdk.Dec { /*********************************************************/ // AbsDifferenceWithSign returns | a - b |, (a - b).sign() -// a is mutated and returned +// a is mutated and returned. func AbsDifferenceWithSign(a, b sdk.Dec) (sdk.Dec, bool) { if a.GTE(b) { return a.SubMut(b), false @@ -45,7 +48,7 @@ func AbsDifferenceWithSign(a, b sdk.Dec) (sdk.Dec, bool) { // Pow computes base^(exp) // However since the exponent is not an integer, we must do an approximation algorithm. // TODO: In the future, lets add some optimized routines for common exponents, e.g. for common wIn / wOut ratios -// Many simple exponents like 2:1 pools +// Many simple exponents like 2:1 pools. func Pow(base sdk.Dec, exp sdk.Dec) sdk.Dec { // Exponentiation of a negative base with an arbitrary real exponent is not closed within the reals. // You can see this by recalling that `i = (-1)^(.5)`. We have to go to complex numbers to define this. @@ -78,7 +81,7 @@ func Pow(base sdk.Dec, exp sdk.Dec) sdk.Dec { } // Contract: 0 < base <= 2 -// 0 < exp < 1 +// 0 < exp < 1. func PowApprox(base sdk.Dec, exp sdk.Dec, precision sdk.Dec) sdk.Dec { if exp.IsZero() { return sdk.ZeroDec() diff --git a/osmoutils/cache_ctx.go b/osmoutils/cache_ctx.go index f2a63eacad9..2d564a6c441 100644 --- a/osmoutils/cache_ctx.go +++ b/osmoutils/cache_ctx.go @@ -16,7 +16,7 @@ func ApplyFuncIfNoError(ctx sdk.Context, f func(ctx sdk.Context) error) (err err defer func() { if recovErr := recover(); recovErr != nil { fmt.Println(recovErr) - err = errors.New("panic occured during execution") + err = errors.New("panic occurred during execution") } }() // makes a new cache context, which all state changes get wrapped inside of. diff --git a/osmoutils/cli_helpers.go b/osmoutils/cli_helpers.go index 1c87c2a2ef4..88b2a25a0dd 100644 --- a/osmoutils/cli_helpers.go +++ b/osmoutils/cli_helpers.go @@ -20,9 +20,9 @@ const ( bitlen = 64 ) -func ParseUint64SliceFromString(s string, seperator string) ([]uint64, error) { +func ParseUint64SliceFromString(s string, separator string) ([]uint64, error) { var parsedInts []uint64 - for _, s := range strings.Split(s, seperator) { + for _, s := range strings.Split(s, separator) { s = strings.TrimSpace(s) parsed, err := strconv.ParseUint(s, base, bitlen) @@ -34,9 +34,9 @@ func ParseUint64SliceFromString(s string, seperator string) ([]uint64, error) { return parsedInts, nil } -func ParseSdkIntFromString(s string, seperator string) ([]sdk.Int, error) { +func ParseSdkIntFromString(s string, separator string) ([]sdk.Int, error) { var parsedInts []sdk.Int - for _, weightStr := range strings.Split(s, seperator) { + for _, weightStr := range strings.Split(s, separator) { weightStr = strings.TrimSpace(weightStr) parsed, err := strconv.ParseUint(weightStr, base, bitlen) diff --git a/simapp/state.go b/simapp/state.go index ebcaede2e42..7f5e1be7868 100644 --- a/simapp/state.go +++ b/simapp/state.go @@ -26,7 +26,6 @@ import ( func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simtypes.AppStateFn { return func(r *rand.Rand, accs []simtypes.Account, config simtypes.Config, ) (appState json.RawMessage, simAccs []simtypes.Account, chainID string, genesisTimestamp time.Time) { - if sdksimapp.FlagGenesisTimeValue == 0 { genesisTimestamp = simtypes.RandTimestamp(r) } else { @@ -136,7 +135,7 @@ func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simty } // AppStateRandomizedFn creates calls each module's GenesisState generator function -// and creates the simulation params +// and creates the simulation params. func AppStateRandomizedFn( simManager *module.SimulationManager, r *rand.Rand, cdc codec.JSONCodec, accs []simtypes.Account, genesisTimestamp time.Time, appParams simtypes.AppParams, diff --git a/store/legacy/v101/tree.go b/store/legacy/v101/tree.go index d9bdccc6241..3946a593005 100644 --- a/store/legacy/v101/tree.go +++ b/store/legacy/v101/tree.go @@ -24,15 +24,14 @@ func migrateBranchValue(oldValueBz []byte) *store.Node { var oldValue Children fmt.Println(string(oldValueBz)) err := json.Unmarshal(oldValueBz, &oldValue) - if err != nil { panic(err) } cs := make([]*store.Child, len(oldValue)) for i, oldChild := range oldValue { - cs[i] = &store.Child{oldChild.Index, oldChild.Acc} + cs[i] = &store.Child{Index: oldChild.Index, Accumulation: oldChild.Acc} } - return &store.Node{cs} + return &store.Node{Children: cs} } func migrateLeafValue(index []byte, oldValueBz []byte) *store.Leaf { diff --git a/store/node.go b/store/node.go index e39214b81f0..79862a6d69a 100644 --- a/store/node.go +++ b/store/node.go @@ -172,7 +172,7 @@ func (ptr *ptr) pull(key []byte) { } node = node.delete(idx) - // For sake of efficienty on our use case, we pull only when a ptr gets + // For sake of efficiently on our use case, we pull only when a ptr gets // empty. // if len(data.Index) >= int(ptr.tree.m/2) { if len(node.Children) > 0 { @@ -218,7 +218,7 @@ func NewNode(cs ...*Child) *Node { // find returns the appropriate position that key should be inserted // if match is true, idx is the exact position for the key -// if match is false, idx is the position where the key should be inserted +// if match is false, idx is the position where the key should be inserted. func (node Node) find(key []byte) (idx int, match bool) { for idx, child := range node.Children { if bytes.Equal(child.Index, key) { diff --git a/store/tree.go b/store/tree.go index c30c45a3415..d5f70720161 100644 --- a/store/tree.go +++ b/store/tree.go @@ -72,7 +72,7 @@ func (t Tree) Clear() { } } -// ptr is pointer to a specific node inside the tree +// ptr is pointer to a specific node inside the tree. type ptr struct { tree Tree level uint16 @@ -236,10 +236,10 @@ func (ptr *ptr) accumulationSplit(key []byte) (left sdk.Int, exact sdk.Int, righ left, exact, right = ptr.tree.ptrGet(ptr.level-1, node.Children[idx].Index).accumulationSplit(key) left = left.Add(NewNode(node.Children[:idx]...).accumulate()) right = right.Add(NewNode(node.Children[idx+1:]...).accumulate()) - return + return left, exact, right } -// TotalAccumulatedValue returns the sum of the weights for all leaves +// TotalAccumulatedValue returns the sum of the weights for all leaves. func (t Tree) TotalAccumulatedValue() sdk.Int { return t.SubsetAccumulation(nil, nil) } @@ -286,7 +286,7 @@ func (ptr *ptr) visualize(depth int, acc sdk.Int) { } } -// DebugVisualize prints the entire tree to stdout +// DebugVisualize prints the entire tree to stdout. func (t Tree) DebugVisualize() { t.root().visualize(0, sdk.Int{}) } diff --git a/v043_temp/address/hash.go b/v043_temp/address/hash.go index 2d302e63e6c..41fda93e4a7 100644 --- a/v043_temp/address/hash.go +++ b/v043_temp/address/hash.go @@ -9,19 +9,18 @@ import ( "github.com/osmosis-labs/osmosis/v7/v043_temp/conv" ) -// Len is the length of base addresses +// Len is the length of base addresses. const Len = sha256.Size type Addressable interface { Address() []byte } -// Hash creates a new address from address type and key +// Hash creates a new address from address type and key. func Hash(typ string, key []byte) []byte { hasher := sha256.New() _, err := hasher.Write(conv.UnsafeStrToBytes(typ)) // the error always nil, it's here only to satisfy the io.Writer interface - // errors.AssertNil(err) // Isn't implemented in 0.42 errors package // Replaced with underlying function content. diff --git a/x/claim/abci.go b/x/claim/abci.go index eee7928c577..a810418ba0f 100644 --- a/x/claim/abci.go +++ b/x/claim/abci.go @@ -7,7 +7,6 @@ import ( // EndBlocker called every block, process inflation, update validator set. func EndBlocker(ctx sdk.Context, k keeper.Keeper) { - params, err := k.GetParams(ctx) if err != nil { panic(err) diff --git a/x/claim/client/cli/query.go b/x/claim/client/cli/query.go index 147816616ac..0a756697245 100644 --- a/x/claim/client/cli/query.go +++ b/x/claim/client/cli/query.go @@ -12,7 +12,7 @@ import ( "github.com/spf13/cobra" ) -// GetQueryCmd returns the cli query commands for this module +// GetQueryCmd returns the cli query commands for this module. func GetQueryCmd(queryRoute string) *cobra.Command { claimQueryCmd := &cobra.Command{ Use: types.ModuleName, @@ -49,7 +49,6 @@ func GetCmdQueryModuleAccountBalance() *cobra.Command { req := &types.QueryModuleAccountBalanceRequest{} res, err := queryClient.ModuleAccountBalance(context.Background(), req) - if err != nil { return err } @@ -79,7 +78,6 @@ func GetCmdQueryParams() *cobra.Command { params := &types.QueryParamsRequest{} res, err := queryClient.Params(context.Background(), params) - if err != nil { return err } diff --git a/x/claim/client/cli/tx.go b/x/claim/client/cli/tx.go index 2810d1414b4..3e212682ec2 100644 --- a/x/claim/client/cli/tx.go +++ b/x/claim/client/cli/tx.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/cobra" ) -// GetTxCmd returns the transaction commands for this module +// GetTxCmd returns the transaction commands for this module. func GetTxCmd() *cobra.Command { claimTxCmd := &cobra.Command{ Use: types.ModuleName, diff --git a/x/claim/client/rest/rest.go b/x/claim/client/rest/rest.go index ab7f0d9f8bb..0d0578681df 100644 --- a/x/claim/client/rest/rest.go +++ b/x/claim/client/rest/rest.go @@ -10,7 +10,7 @@ const ( MethodGet = "GET" ) -// RegisterRoutes registers claim-related REST handlers to a router +// RegisterRoutes registers claim-related REST handlers to a router. func RegisterRoutes(clientCtx client.Context, r *mux.Router) { } diff --git a/x/claim/client/testutil/test_helpers.go b/x/claim/client/testutil/test_helpers.go index 34a3b1ff3db..69777629cfd 100644 --- a/x/claim/client/testutil/test_helpers.go +++ b/x/claim/client/testutil/test_helpers.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// commonArgs is args for CLI test commands +// commonArgs is args for CLI test commands. var commonArgs = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), diff --git a/x/claim/handler.go b/x/claim/handler.go index d57d32808b9..4521d250f8b 100644 --- a/x/claim/handler.go +++ b/x/claim/handler.go @@ -9,14 +9,12 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/claim/types" ) -// NewHandler returns claim module messages +// NewHandler returns claim module messages. func NewHandler(k keeper.Keeper) sdk.Handler { - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) diff --git a/x/claim/keeper/claim.go b/x/claim/keeper/claim.go index bddf03bc9ee..197c4c5c4a9 100644 --- a/x/claim/keeper/claim.go +++ b/x/claim/keeper/claim.go @@ -10,12 +10,12 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/claim/types" ) -// GetModuleAccountBalance gets the airdrop coin balance of module account +// GetModuleAccountBalance gets the airdrop coin balance of module account. func (k Keeper) GetModuleAccountAddress(ctx sdk.Context) sdk.AccAddress { return k.accountKeeper.GetModuleAddress(types.ModuleName) } -// GetModuleAccountBalance gets the airdrop coin balance of module account +// GetModuleAccountBalance gets the airdrop coin balance of module account. func (k Keeper) GetModuleAccountBalance(ctx sdk.Context) sdk.Coin { moduleAccAddr := k.GetModuleAccountAddress(ctx) params, err := k.GetParams(ctx) @@ -25,7 +25,7 @@ func (k Keeper) GetModuleAccountBalance(ctx sdk.Context) sdk.Coin { return k.bankKeeper.GetBalance(ctx, moduleAccAddr, params.ClaimDenom) } -// SetModuleAccountBalance set balance of airdrop module +// SetModuleAccountBalance set balance of airdrop module. func (k Keeper) CreateModuleAccount(ctx sdk.Context, amount sdk.Coin) { moduleAcc := authtypes.NewEmptyModuleAccount(types.ModuleName, authtypes.Minter) k.accountKeeper.SetModuleAccount(ctx, moduleAcc) @@ -44,7 +44,6 @@ func (k Keeper) CreateModuleAccount(ctx sdk.Context, amount sdk.Coin) { if err := k.bankKeeper.MintCoins(ctx, types.ModuleName, mintCoins); err != nil { panic(err) } - } func (k Keeper) EndAirdrop(ctx sdk.Context) error { @@ -65,7 +64,7 @@ func (k Keeper) EndAirdrop(ctx sdk.Context) error { } // ClawbackAirdrop implements prop 32 by clawing back all the OSMO and IONs from airdrop -// recipient accounts with a sequence number of 0 +// recipient accounts with a sequence number of 0. func (k Keeper) ClawbackAirdrop(ctx sdk.Context) error { totalClawback := sdk.NewCoins() for _, bechAddr := range types.AirdropAddrs { @@ -113,7 +112,7 @@ func (k Keeper) ClawbackAirdrop(ctx sdk.Context) error { return nil } -// ClearClaimables clear claimable amounts +// ClearClaimables clear claimable amounts. func (k Keeper) clearInitialClaimables(ctx sdk.Context) { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, []byte(types.ClaimRecordsStorePrefix)) @@ -124,7 +123,7 @@ func (k Keeper) clearInitialClaimables(ctx sdk.Context) { } } -// SetClaimables set claimable amount from balances object +// SetClaimables set claimable amount from balances object. func (k Keeper) SetClaimRecords(ctx sdk.Context, claimRecords []types.ClaimRecord) error { for _, claimRecord := range claimRecords { err := k.SetClaimRecord(ctx, claimRecord) @@ -135,7 +134,7 @@ func (k Keeper) SetClaimRecords(ctx sdk.Context, claimRecords []types.ClaimRecor return nil } -// GetClaimables get claimables for genesis export +// GetClaimables get claimables for genesis export. func (k Keeper) GetClaimRecords(ctx sdk.Context) []types.ClaimRecord { store := ctx.KVStore(k.storeKey) prefixStore := prefix.NewStore(store, []byte(types.ClaimRecordsStorePrefix)) @@ -145,7 +144,6 @@ func (k Keeper) GetClaimRecords(ctx sdk.Context) []types.ClaimRecord { claimRecords := []types.ClaimRecord{} for ; iterator.Valid(); iterator.Next() { - claimRecord := types.ClaimRecord{} err := proto.Unmarshal(iterator.Value(), &claimRecord) @@ -158,7 +156,7 @@ func (k Keeper) GetClaimRecords(ctx sdk.Context) []types.ClaimRecord { return claimRecords } -// GetClaimRecord returns the claim record for a specific address +// GetClaimRecord returns the claim record for a specific address. func (k Keeper) GetClaimRecord(ctx sdk.Context, addr sdk.AccAddress) (types.ClaimRecord, error) { store := ctx.KVStore(k.storeKey) prefixStore := prefix.NewStore(store, []byte(types.ClaimRecordsStorePrefix)) @@ -176,7 +174,7 @@ func (k Keeper) GetClaimRecord(ctx sdk.Context, addr sdk.AccAddress) (types.Clai return claimRecord, nil } -// SetClaimRecord sets a claim record for an address in store +// SetClaimRecord sets a claim record for an address in store. func (k Keeper) SetClaimRecord(ctx sdk.Context, claimRecord types.ClaimRecord) error { store := ctx.KVStore(k.storeKey) prefixStore := prefix.NewStore(store, []byte(types.ClaimRecordsStorePrefix)) @@ -195,7 +193,7 @@ func (k Keeper) SetClaimRecord(ctx sdk.Context, claimRecord types.ClaimRecord) e return nil } -// GetClaimable returns claimable amount for a specific action done by an address +// GetClaimable returns claimable amount for a specific action done by an address. func (k Keeper) GetClaimableAmountForAction(ctx sdk.Context, addr sdk.AccAddress, action types.Action) (sdk.Coins, error) { claimRecord, err := k.GetClaimRecord(ctx, addr) if err != nil { @@ -256,7 +254,7 @@ func (k Keeper) GetClaimableAmountForAction(ctx sdk.Context, addr sdk.AccAddress return claimableCoins, nil } -// GetClaimable returns claimable amount for a specific action done by an address +// GetClaimable returns claimable amount for a specific action done by an address. func (k Keeper) GetUserTotalClaimable(ctx sdk.Context, addr sdk.AccAddress) (sdk.Coins, error) { claimRecord, err := k.GetClaimRecord(ctx, addr) if err != nil { @@ -278,7 +276,7 @@ func (k Keeper) GetUserTotalClaimable(ctx sdk.Context, addr sdk.AccAddress) (sdk return totalClaimable, nil } -// ClaimCoins remove claimable amount entry and transfer it to user's account +// ClaimCoins remove claimable amount entry and transfer it to user's account. func (k Keeper) ClaimCoinsForAction(ctx sdk.Context, addr sdk.AccAddress, action types.Action) (sdk.Coins, error) { claimableAmount, err := k.GetClaimableAmountForAction(ctx, addr, action) if err != nil { @@ -317,7 +315,7 @@ func (k Keeper) ClaimCoinsForAction(ctx sdk.Context, addr sdk.AccAddress, action return claimableAmount, nil } -// FundRemainingsToCommunity fund remainings to the community when airdrop period end +// FundRemainingsToCommunity fund remainings to the community when airdrop period end. func (k Keeper) fundRemainingsToCommunity(ctx sdk.Context) error { moduleAccAddr := k.GetModuleAccountAddress(ctx) amt := k.GetModuleAccountBalance(ctx) diff --git a/x/claim/keeper/grpc_query.go b/x/claim/keeper/grpc_query.go index cc6734439da..151de117dae 100644 --- a/x/claim/keeper/grpc_query.go +++ b/x/claim/keeper/grpc_query.go @@ -30,7 +30,7 @@ func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.Q return &types.QueryParamsResponse{Params: params}, nil } -// Claimable returns claimable amount per user +// Claimable returns claimable amount per user. func (k Keeper) ClaimRecord( goCtx context.Context, req *types.QueryClaimRecordRequest, @@ -50,7 +50,7 @@ func (k Keeper) ClaimRecord( return &types.QueryClaimRecordResponse{ClaimRecord: claimRecord}, err } -// Activities returns activities +// Activities returns activities. func (k Keeper) ClaimableForAction( goCtx context.Context, req *types.QueryClaimableForActionRequest, @@ -72,7 +72,7 @@ func (k Keeper) ClaimableForAction( }, err } -// Activities returns activities +// Activities returns activities. func (k Keeper) TotalClaimable( goCtx context.Context, req *types.QueryTotalClaimableRequest, diff --git a/x/claim/keeper/hooks.go b/x/claim/keeper/hooks.go index e8c8e54c302..5bc99d52d2e 100644 --- a/x/claim/keeper/hooks.go +++ b/x/claim/keeper/hooks.go @@ -38,41 +38,48 @@ func (k Keeper) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, // ________________________________________________________________________________________ -// Hooks wrapper struct for slashing keeper +// Hooks wrapper struct for slashing keeper. type Hooks struct { k Keeper } -var _ gammtypes.GammHooks = Hooks{} -var _ govtypes.GovHooks = Hooks{} -var _ stakingtypes.StakingHooks = Hooks{} +var ( + _ gammtypes.GammHooks = Hooks{} + _ govtypes.GovHooks = Hooks{} + _ stakingtypes.StakingHooks = Hooks{} +) -// Return the wrapper struct +// Return the wrapper struct. func (k Keeper) Hooks() Hooks { return Hooks{k} } -// gov hooks +// gov hooks. func (h Hooks) AfterProposalFailedMinDeposit(ctx sdk.Context, proposalId uint64) { } + func (h Hooks) AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalId uint64) { } -// gamm hooks +// gamm hooks. func (h Hooks) AfterPoolCreated(ctx sdk.Context, sender sdk.AccAddress, poolId uint64) { h.k.AfterAddLiquidity(ctx, sender) } + func (h Hooks) AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, enterCoins sdk.Coins, shareOutAmount sdk.Int) { h.k.AfterAddLiquidity(ctx, sender) } + func (h Hooks) AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, shareInAmount sdk.Int, exitCoins sdk.Coins) { } + func (h Hooks) AfterSwap(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) { h.k.AfterSwap(ctx, sender) } -// governance hooks +// governance hooks. func (h Hooks) AfterProposalSubmission(ctx sdk.Context, proposalID uint64) {} + func (h Hooks) AfterProposalDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) { } @@ -83,28 +90,37 @@ func (h Hooks) AfterProposalVote(ctx sdk.Context, proposalID uint64, voterAddr s func (h Hooks) AfterProposalInactive(ctx sdk.Context, proposalID uint64) {} func (h Hooks) AfterProposalActive(ctx sdk.Context, proposalID uint64) {} -// staking hooks +// staking hooks. func (h Hooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) {} func (h Hooks) BeforeValidatorModified(ctx sdk.Context, valAddr sdk.ValAddress) {} func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) { } + func (h Hooks) AfterValidatorBonded(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) { } + func (h Hooks) AfterValidatorBeginUnbonding(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) { } + func (h Hooks) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) { } + func (h Hooks) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) { } + func (h Hooks) BeforeDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) { } + func (h Hooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) { h.k.AfterDelegationModified(ctx, delAddr, valAddr) } + func (h Hooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, _ int64, _ sdk.Dec, _ sdk.Dec) { } + func (h Hooks) AfterValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, infractionHeight int64, slashFactor sdk.Dec, effectiveSlashFactor sdk.Dec) { } + func (h Hooks) BeforeSlashingUnbondingDelegation(ctx sdk.Context, unbondingDelegation stakingtypes.UnbondingDelegation, infractionHeight int64, slashFactor sdk.Dec) { } diff --git a/x/claim/keeper/keeper.go b/x/claim/keeper/keeper.go index 566baead3d4..f3cd0853669 100644 --- a/x/claim/keeper/keeper.go +++ b/x/claim/keeper/keeper.go @@ -10,7 +10,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/claim/types" ) -// Keeper struct +// Keeper struct. type Keeper struct { cdc codec.Codec storeKey sdk.StoreKey @@ -20,7 +20,7 @@ type Keeper struct { distrKeeper types.DistrKeeper } -// NewKeeper returns keeper +// NewKeeper returns keeper. func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper, dk types.DistrKeeper) *Keeper { return &Keeper{ cdc: cdc, @@ -32,7 +32,7 @@ func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, ak types.AccountKeeper, b } } -// Logger returns logger +// Logger returns logger. func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } diff --git a/x/claim/keeper/params.go b/x/claim/keeper/params.go index 35ac07e7f38..438bed706ba 100644 --- a/x/claim/keeper/params.go +++ b/x/claim/keeper/params.go @@ -5,7 +5,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/claim/types" ) -// GetParams get params +// GetParams get params. func (k Keeper) GetParams(ctx sdk.Context) (types.Params, error) { store := ctx.KVStore(k.storeKey) bz := store.Get([]byte(types.ParamsKey)) @@ -14,7 +14,7 @@ func (k Keeper) GetParams(ctx sdk.Context) (types.Params, error) { return params, err } -// SetParams set params +// SetParams set params. func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { store := ctx.KVStore(k.storeKey) bz, err := k.cdc.MarshalJSON(¶ms) diff --git a/x/claim/keeper/query.go b/x/claim/keeper/query.go index 68897c37757..0b371643a97 100644 --- a/x/claim/keeper/query.go +++ b/x/claim/keeper/query.go @@ -9,7 +9,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" ) -// NewQuerier returns legacy querier endpoint +// NewQuerier returns legacy querier endpoint. func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { var ( diff --git a/x/claim/module.go b/x/claim/module.go index 3d07333c988..412ccf890ad 100644 --- a/x/claim/module.go +++ b/x/claim/module.go @@ -48,7 +48,7 @@ func (AppModuleBasic) Name() string { func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } -// RegisterInterfaces registers the module's interface types +// RegisterInterfaces registers the module's interface types. func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { } diff --git a/x/claim/types/airdropaddrs.go b/x/claim/types/airdropaddrs.go index 859730414e7..2545fac277f 100644 --- a/x/claim/types/airdropaddrs.go +++ b/x/claim/types/airdropaddrs.go @@ -1,7 +1,7 @@ package types // List of addresses that were airdropped either OSMO or IONs -// Generated using `osmosisd get-airdrop-accounts` CLI command +// Generated using `osmosisd get-airdrop-accounts` CLI command. var ( AirdropAddrs = []string{ "osmo1000644etcp4k4awz77kvy3pryplv8ky8py962d", diff --git a/x/claim/types/errors.go b/x/claim/types/errors.go index 98ba2e3617d..11e16b75e51 100644 --- a/x/claim/types/errors.go +++ b/x/claim/types/errors.go @@ -6,7 +6,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -// x/claim module sentinel errors +// x/claim module sentinel errors. var ( ErrIncorrectModuleAccountBalance = sdkerrors.Register(ModuleName, 1100, "claim module account balance != sum of all claim record InitialClaimableAmounts") diff --git a/x/claim/types/events.go b/x/claim/types/events.go index de74ec9d57c..bc1f453e4d0 100644 --- a/x/claim/types/events.go +++ b/x/claim/types/events.go @@ -1,6 +1,6 @@ package types -// claim module event typs +// claim module event typs. const ( EventTypeClaim = "claim" ) diff --git a/x/claim/types/expected_keepers.go b/x/claim/types/expected_keepers.go index 6775f692a14..00ce4bad2ae 100644 --- a/x/claim/types/expected_keepers.go +++ b/x/claim/types/expected_keepers.go @@ -14,7 +14,7 @@ type BankKeeper interface { MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error } -// AccountKeeper defines the expected account keeper used for simulations (noalias) +// AccountKeeper defines the expected account keeper used for simulations (noalias). type AccountKeeper interface { GetModuleAddress(name string) sdk.AccAddress SetModuleAccount(ctx sdk.Context, macc authtypes.ModuleAccountI) @@ -23,12 +23,12 @@ type AccountKeeper interface { GetSequence(sdk.Context, sdk.AccAddress) (uint64, error) } -// DistrKeeper is the keeper of the distribution store +// DistrKeeper is the keeper of the distribution store. type DistrKeeper interface { FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error } -// StakingKeeper expected staking keeper (noalias) +// StakingKeeper expected staking keeper (noalias). type StakingKeeper interface { // BondDenom - Bondable coin denomination BondDenom(sdk.Context) string diff --git a/x/claim/types/genesis.go b/x/claim/types/genesis.go index 059aeb80ea9..ec2a5bd389d 100644 --- a/x/claim/types/genesis.go +++ b/x/claim/types/genesis.go @@ -11,10 +11,10 @@ import ( type Actions []Action -// DefaultIndex is the default capability global index +// DefaultIndex is the default capability global index. const DefaultIndex uint64 = 1 -// DefaultGenesis returns the default Capability genesis state +// DefaultGenesis returns the default Capability genesis state. func DefaultGenesis() *GenesisState { return &GenesisState{ ModuleAccountBalance: sdk.NewCoin(DefaultClaimDenom, sdk.ZeroInt()), diff --git a/x/claim/types/keys.go b/x/claim/types/keys.go index 4f004d371ae..98a5c39749a 100644 --- a/x/claim/types/keys.go +++ b/x/claim/types/keys.go @@ -1,24 +1,24 @@ package types const ( - // ModuleName defines the module name + // ModuleName defines the module name. ModuleName = "claim" - // StoreKey defines the primary module store key + // StoreKey defines the primary module store key. StoreKey = ModuleName - // RouterKey is the message route for slashing + // RouterKey is the message route for slashing. RouterKey = ModuleName - // QuerierRoute defines the module's query routing key + // QuerierRoute defines the module's query routing key. QuerierRoute = ModuleName - // ClaimRecordsStorePrefix defines the store prefix for the claim records + // ClaimRecordsStorePrefix defines the store prefix for the claim records. ClaimRecordsStorePrefix = "claimrecords" - // ParamsKey defines the store key for claim module parameters + // ParamsKey defines the store key for claim module parameters. ParamsKey = "params" - // ActionKey defines the store key to store user accomplished actions + // ActionKey defines the store key to store user accomplished actions. ActionKey = "action" ) diff --git a/x/epochs/abci.go b/x/epochs/abci.go index 87c0f8247fe..48d9048a02e 100644 --- a/x/epochs/abci.go +++ b/x/epochs/abci.go @@ -10,7 +10,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/epochs/types" ) -// BeginBlocker of epochs module +// BeginBlocker of epochs module. func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) k.IterateEpochInfo(ctx, func(index int64, epochInfo types.EpochInfo) (stop bool) { diff --git a/x/epochs/client/cli/cli_test.go b/x/epochs/client/cli/cli_test.go index c7cbae8d04e..1880f0eeb93 100644 --- a/x/epochs/client/cli/cli_test.go +++ b/x/epochs/client/cli/cli_test.go @@ -71,7 +71,7 @@ func (s *IntegrationTestSuite) TestGetCmdCurrentEpoch() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) } }) } @@ -105,7 +105,7 @@ func (s *IntegrationTestSuite) TestGetCmdEpochsInfos() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) } }) } diff --git a/x/epochs/client/cli/query.go b/x/epochs/client/cli/query.go index c3400327998..00b9df9e431 100644 --- a/x/epochs/client/cli/query.go +++ b/x/epochs/client/cli/query.go @@ -11,7 +11,7 @@ import ( "github.com/spf13/cobra" ) -// GetQueryCmd returns the cli query commands for this module +// GetQueryCmd returns the cli query commands for this module. func GetQueryCmd(queryRoute string) *cobra.Command { // Group epochs queries under a subcommand cmd := &cobra.Command{ @@ -30,7 +30,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { return cmd } -// GetCmdEpochsInfos provide running epochInfos +// GetCmdEpochsInfos provide running epochInfos. func GetCmdEpochsInfos() *cobra.Command { cmd := &cobra.Command{ Use: "epoch-infos", @@ -66,7 +66,7 @@ $ %s query epochs epoch-infos return cmd } -// GetCmdCurrentEpoch provides current epoch by specified identifier +// GetCmdCurrentEpoch provides current epoch by specified identifier. func GetCmdCurrentEpoch() *cobra.Command { cmd := &cobra.Command{ Use: "current-epoch", diff --git a/x/epochs/client/cli/tx.go b/x/epochs/client/cli/tx.go index 6f60825089b..cf041d50b9d 100644 --- a/x/epochs/client/cli/tx.go +++ b/x/epochs/client/cli/tx.go @@ -7,11 +7,11 @@ import ( "github.com/cosmos/cosmos-sdk/client" - // "github.com/cosmos/cosmos-sdk/client/flags" + // "github.com/cosmos/cosmos-sdk/client/flags". "github.com/osmosis-labs/osmosis/v7/x/epochs/types" ) -// GetTxCmd returns the transaction commands for this module +// GetTxCmd returns the transaction commands for this module. func GetTxCmd() *cobra.Command { cmd := &cobra.Command{ Use: types.ModuleName, diff --git a/x/epochs/client/rest/rest.go b/x/epochs/client/rest/rest.go index b96cb1af9e5..3b3961e2a01 100644 --- a/x/epochs/client/rest/rest.go +++ b/x/epochs/client/rest/rest.go @@ -10,7 +10,7 @@ const ( MethodGet = "GET" ) -// RegisterRoutes registers epochs-related REST handlers to a router +// RegisterRoutes registers epochs-related REST handlers to a router. func RegisterRoutes(clientCtx client.Context, r *mux.Router) { } diff --git a/x/epochs/handler.go b/x/epochs/handler.go index cd30719707d..f6a83716f9e 100644 --- a/x/epochs/handler.go +++ b/x/epochs/handler.go @@ -9,7 +9,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/epochs/types" ) -// NewHandler returns a handler for epochs module messages +// NewHandler returns a handler for epochs module messages. func NewHandler(k keeper.Keeper) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) diff --git a/x/epochs/keeper/epoch.go b/x/epochs/keeper/epoch.go index 561b4873563..f02659d2eaa 100644 --- a/x/epochs/keeper/epoch.go +++ b/x/epochs/keeper/epoch.go @@ -8,7 +8,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/epochs/types" ) -// GetEpochInfo returns epoch info by identifier +// 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) @@ -23,7 +23,7 @@ func (k Keeper) GetEpochInfo(ctx sdk.Context, identifier string) types.EpochInfo return epoch } -// SetEpochInfo set epoch info +// SetEpochInfo set epoch info. func (k Keeper) SetEpochInfo(ctx sdk.Context, epoch types.EpochInfo) { store := ctx.KVStore(k.storeKey) value, err := proto.Marshal(&epoch) @@ -33,13 +33,13 @@ func (k Keeper) SetEpochInfo(ctx sdk.Context, epoch types.EpochInfo) { store.Set(append(types.KeyPrefixEpoch, []byte(epoch.Identifier)...), value) } -// DeleteEpochInfo delete epoch info +// 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 +// 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) diff --git a/x/epochs/keeper/grpc_query.go b/x/epochs/keeper/grpc_query.go index 4a409380df5..45922d9150b 100644 --- a/x/epochs/keeper/grpc_query.go +++ b/x/epochs/keeper/grpc_query.go @@ -10,7 +10,7 @@ import ( var _ types.QueryServer = Keeper{} -// EpochInfos provide running epochInfos +// EpochInfos provide running epochInfos. func (k Keeper) EpochInfos(c context.Context, _ *types.QueryEpochsInfoRequest) (*types.QueryEpochsInfoResponse, error) { ctx := sdk.UnwrapSDKContext(c) @@ -19,7 +19,7 @@ func (k Keeper) EpochInfos(c context.Context, _ *types.QueryEpochsInfoRequest) ( }, nil } -// CurrentEpoch provides current epoch of specified identifier +// CurrentEpoch provides current epoch of specified identifier. func (k Keeper) CurrentEpoch(c context.Context, req *types.QueryCurrentEpochRequest) (*types.QueryCurrentEpochResponse, error) { ctx := sdk.UnwrapSDKContext(c) diff --git a/x/epochs/keeper/keeper.go b/x/epochs/keeper/keeper.go index 0e130cd01b3..157aa6549ef 100644 --- a/x/epochs/keeper/keeper.go +++ b/x/epochs/keeper/keeper.go @@ -24,7 +24,7 @@ func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey) *Keeper { } } -// Set the gamm hooks +// Set the gamm hooks. func (k *Keeper) SetHooks(eh types.EpochHooks) *Keeper { if k.hooks != nil { panic("cannot set epochs hooks twice") diff --git a/x/epochs/module.go b/x/epochs/module.go index 024a91d485b..b2f8f7de4b4 100644 --- a/x/epochs/module.go +++ b/x/epochs/module.go @@ -57,7 +57,7 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { types.RegisterCodec(cdc) } -// RegisterInterfaces registers the module's interface types +// RegisterInterfaces registers the module's interface types. func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { types.RegisterInterfaces(reg) } @@ -189,7 +189,7 @@ func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { return nil } -// RegisterStoreDecoder registers a decoder for supply module's types +// RegisterStoreDecoder registers a decoder for supply module's types. func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { } diff --git a/x/epochs/simulation/genesis.go b/x/epochs/simulation/genesis.go index f6a2497260f..e371ed8474b 100644 --- a/x/epochs/simulation/genesis.go +++ b/x/epochs/simulation/genesis.go @@ -11,7 +11,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/epochs/types" ) -// RandomizedGenState generates a random GenesisState for mint +// RandomizedGenState generates a random GenesisState for mint. func RandomizedGenState(simState *module.SimulationState) { epochs := []types.EpochInfo{ { diff --git a/x/epochs/types/errors.go b/x/epochs/types/errors.go index 9ba1ba6575f..0c13f2f4ed4 100644 --- a/x/epochs/types/errors.go +++ b/x/epochs/types/errors.go @@ -6,7 +6,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -// x/epochs module sentinel errors +// x/epochs module sentinel errors. var ( ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") ) diff --git a/x/epochs/types/genesis.go b/x/epochs/types/genesis.go index 68895b75f38..56a36a8154c 100644 --- a/x/epochs/types/genesis.go +++ b/x/epochs/types/genesis.go @@ -5,14 +5,14 @@ import ( "time" ) -// DefaultIndex is the default capability global index +// DefaultIndex is the default capability global index. const DefaultIndex uint64 = 1 func NewGenesisState(epochs []EpochInfo) *GenesisState { return &GenesisState{Epochs: epochs} } -// DefaultGenesis returns the default Capability genesis state +// DefaultGenesis returns the default Capability genesis state. func DefaultGenesis() *GenesisState { epochs := []EpochInfo{ { diff --git a/x/epochs/types/hooks.go b/x/epochs/types/hooks.go index b6186a237a3..8d24652aecf 100644 --- a/x/epochs/types/hooks.go +++ b/x/epochs/types/hooks.go @@ -13,21 +13,21 @@ type EpochHooks interface { var _ EpochHooks = MultiEpochHooks{} -// combine multiple gamm hooks, all hook functions are run in array sequence +// 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 +// 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, epochNumber int64) { for i := range h { h[i].AfterEpochEnd(ctx, epochIdentifier, epochNumber) } } -// BeforeEpochStart is called when epoch is going to be started, epochNumber is the number of epoch that is starting +// 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, epochNumber int64) { for i := range h { h[i].BeforeEpochStart(ctx, epochIdentifier, epochNumber) diff --git a/x/epochs/types/keys.go b/x/epochs/types/keys.go index 704135da0ec..cff81a40d75 100644 --- a/x/epochs/types/keys.go +++ b/x/epochs/types/keys.go @@ -1,23 +1,21 @@ package types const ( - // ModuleName defines the module name + // ModuleName defines the module name. ModuleName = "epochs" - // StoreKey defines the primary module store key + // StoreKey defines the primary module store key. StoreKey = ModuleName - // RouterKey is the message route for slashing + // RouterKey is the message route for slashing. RouterKey = ModuleName - // QuerierRoute defines the module's query routing key + // QuerierRoute defines the module's query routing key. QuerierRoute = ModuleName ) -var ( - // KeyPrefixEpoch defines prefix key for storing epochs - KeyPrefixEpoch = []byte{0x01} -) +// KeyPrefixEpoch defines prefix key for storing epochs. +var KeyPrefixEpoch = []byte{0x01} func KeyPrefix(p string) []byte { return []byte(p) diff --git a/x/gamm/client/cli/cli_test.go b/x/gamm/client/cli/cli_test.go index ef9009a274a..271c4ef1f58 100644 --- a/x/gamm/client/cli/cli_test.go +++ b/x/gamm/client/cli/cli_test.go @@ -334,7 +334,7 @@ func (s *IntegrationTestSuite) TestNewCreatePoolCmd() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - err = clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType) + err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType) s.Require().NoError(err, out.String()) txResp := tc.respType.(*sdk.TxResponse) @@ -411,7 +411,7 @@ func (s IntegrationTestSuite) TestNewJoinPoolCmd() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -472,7 +472,7 @@ func (s IntegrationTestSuite) TestNewExitPoolCmd() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -536,7 +536,7 @@ func (s IntegrationTestSuite) TestNewSwapExactAmountOutCmd() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -598,7 +598,7 @@ func (s IntegrationTestSuite) TestNewJoinSwapExternAmountInCmd() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -645,7 +645,7 @@ func (s IntegrationTestSuite) TestNewJoinSwapExternAmountInCmd() { // s.Require().Error(err) // } else { // s.Require().NoError(err, out.String()) -// s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) +// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) // txResp := tc.respType.(*sdk.TxResponse) // s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -708,7 +708,7 @@ func (s IntegrationTestSuite) TestNewJoinSwapExternAmountInCmd() { // s.Require().Error(err) // } else { // s.Require().NoError(err, out.String()) -// s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) +// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) // txResp := tc.respType.(*sdk.TxResponse) // s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -754,7 +754,7 @@ func (s IntegrationTestSuite) TestNewExitSwapShareAmountInCmd() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -793,7 +793,7 @@ func (s *IntegrationTestSuite) TestGetCmdPools() { } else { resp := types.QueryPoolsResponse{} s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &resp), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) s.Require().Greater(len(resp.Pools), 0, out.String()) } @@ -831,7 +831,7 @@ func (s *IntegrationTestSuite) TestGetCmdNumPools() { } else { resp := types.QueryNumPoolsResponse{} s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &resp), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) s.Require().Greater(resp.NumPools, uint64(0), out.String()) } @@ -871,7 +871,7 @@ func (s *IntegrationTestSuite) TestGetCmdPool() { s.Require().NoError(err, out.String()) resp := types.QueryPoolResponse{} - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &resp), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) } }) } @@ -908,7 +908,7 @@ func (s *IntegrationTestSuite) TestGetCmdTotalShares() { } else { resp := types.QueryTotalSharesResponse{} s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &resp), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) } }) } @@ -944,7 +944,7 @@ func (s *IntegrationTestSuite) TestGetCmdTotalLiquidity() { } else { resp := types.QueryTotalLiquidityResponse{} s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &resp), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) } }) } @@ -981,7 +981,7 @@ func (s *IntegrationTestSuite) TestGetCmdSpotPrice() { } else { resp := types.QuerySpotPriceResponse{} s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &resp), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) } }) } @@ -1022,7 +1022,7 @@ func (s *IntegrationTestSuite) TestGetCmdSpotPrice() { // } else { // resp := types.QuerySwapExactAmountInResponse{} // s.Require().NoError(err, out.String()) -// s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &resp), out.String()) +// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) // } // }) // } @@ -1063,7 +1063,7 @@ func (s *IntegrationTestSuite) TestGetCmdSpotPrice() { // } else { // resp := types.QuerySwapExactAmountOutResponse{} // s.Require().NoError(err, out.String()) -// s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &resp), out.String()) +// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) // } // }) // } @@ -1124,7 +1124,7 @@ func (s IntegrationTestSuite) TestNewSwapExactAmountInCmd() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) diff --git a/x/gamm/client/cli/flags.go b/x/gamm/client/cli/flags.go index 2f7284f5e58..f7abe3db117 100644 --- a/x/gamm/client/cli/flags.go +++ b/x/gamm/client/cli/flags.go @@ -5,10 +5,10 @@ import ( ) const ( - // Will be parsed to string + // Will be parsed to string. FlagPoolFile = "pool-file" - // Names of fields in pool json file + // Names of fields in pool json file. PoolFileWeights = "weights" PoolFileInitialDeposit = "initial-deposit" PoolFileSwapFee = "swap-fee" @@ -21,21 +21,21 @@ const ( PoolFileTargetPoolWeights = "target-pool-weights" FlagPoolId = "pool-id" - // Will be parsed to sdk.Int + // Will be parsed to sdk.Int. FlagShareAmountOut = "share-amount-out" - // Will be parsed to []sdk.Coin + // Will be parsed to []sdk.Coin. FlagMaxAmountsIn = "max-amounts-in" - // Will be parsed to sdk.Int + // Will be parsed to sdk.Int. FlagShareAmountIn = "share-amount-in" - // Will be parsed to []sdk.Coin + // Will be parsed to []sdk.Coin. FlagMinAmountsOut = "min-amounts-out" - // Will be parsed to uint64 + // Will be parsed to uint64. FlagSwapRoutePoolIds = "swap-route-pool-ids" - // Will be parsed to []sdk.Coin + // Will be parsed to []sdk.Coin. FlagSwapRouteAmounts = "swap-route-amounts" - // Will be parsed to []string + // Will be parsed to []string. FlagSwapRouteDenoms = "swap-route-denoms" ) diff --git a/x/gamm/client/cli/parse.go b/x/gamm/client/cli/parse.go index 5d02bfc9c43..4726a4e7df5 100644 --- a/x/gamm/client/cli/parse.go +++ b/x/gamm/client/cli/parse.go @@ -16,7 +16,7 @@ type XCreatePoolInputsExceptions struct { Other *string // Other won't raise an error } -// UnmarshalJSON should error if there are fields unexpected +// UnmarshalJSON should error if there are fields unexpected. func (release *createPoolInputs) UnmarshalJSON(data []byte) error { var createPoolE XCreatePoolInputsExceptions dec := json.NewDecoder(bytes.NewReader(data)) diff --git a/x/gamm/client/cli/query.go b/x/gamm/client/cli/query.go index dad88d3114e..aacd23d508d 100644 --- a/x/gamm/client/cli/query.go +++ b/x/gamm/client/cli/query.go @@ -14,7 +14,7 @@ import ( "gopkg.in/yaml.v2" ) -// GetQueryCmd returns the cli query commands for this module +// GetQueryCmd returns the cli query commands for this module. func GetQueryCmd() *cobra.Command { // Group gamm queries under a subcommand cmd := &cobra.Command{ @@ -40,7 +40,7 @@ func GetQueryCmd() *cobra.Command { return cmd } -// GetCmdPool returns pool +// GetCmdPool returns pool. func GetCmdPool() *cobra.Command { cmd := &cobra.Command{ Use: "pool ", @@ -81,7 +81,7 @@ $ %s query gamm pool 1 return cmd } -// TODO: Push this to the SDK +// TODO: Push this to the SDK. func writeOutputBoilerplate(ctx client.Context, out []byte) error { writer := ctx.Output if writer == nil { @@ -103,7 +103,7 @@ func writeOutputBoilerplate(ctx client.Context, out []byte) error { return nil } -// GetCmdPools return pools +// GetCmdPools return pools. func GetCmdPools() *cobra.Command { cmd := &cobra.Command{ Use: "pools", @@ -146,7 +146,7 @@ $ %s query gamm pools return cmd } -// GetCmdNumPools return number of pools available +// GetCmdNumPools return number of pools available. func GetCmdNumPools() *cobra.Command { cmd := &cobra.Command{ Use: "num-pools", @@ -181,7 +181,7 @@ $ %s query gamm num-pools return cmd } -// GetCmdPoolParams return pool params +// GetCmdPoolParams return pool params. func GetCmdPoolParams() *cobra.Command { cmd := &cobra.Command{ Use: "pool-params ", @@ -216,14 +216,12 @@ $ %s query gamm pool-params 1 if clientCtx.OutputFormat == "text" { out, err := yaml.Marshal(res.GetParams()) - if err != nil { return err } return writeOutputBoilerplate(clientCtx, out) } else { out, err := clientCtx.Codec.MarshalJSON(res) - if err != nil { return err } @@ -237,7 +235,7 @@ $ %s query gamm pool-params 1 return cmd } -// GetCmdTotalShares return total share +// GetCmdTotalShares return total share. func GetCmdTotalShares() *cobra.Command { cmd := &cobra.Command{ Use: "total-share ", @@ -279,7 +277,7 @@ $ %s query gamm total-share 1 return cmd } -// GetCmdQueryTotalLiquidity return total liquidity +// GetCmdQueryTotalLiquidity return total liquidity. func GetCmdQueryTotalLiquidity() *cobra.Command { cmd := &cobra.Command{ Use: "total-liquidity", @@ -358,7 +356,7 @@ $ %s query gamm spot-price 1 stake stake2 return cmd } -// GetCmdEstimateSwapExactAmountIn returns estimation of output coin when amount of x token input +// GetCmdEstimateSwapExactAmountIn returns estimation of output coin when amount of x token input. func GetCmdEstimateSwapExactAmountIn() *cobra.Command { cmd := &cobra.Command{ Use: "estimate-swap-exact-amount-in ", @@ -411,7 +409,7 @@ $ %s query gamm estimate-swap-exact-amount-in 1 osm11vmx8jtggpd9u7qr0t8vxclycz85 return cmd } -// GetCmdEstimateSwapExactAmountOut returns estimation of input coin to get exact amount of x token output +// GetCmdEstimateSwapExactAmountOut returns estimation of input coin to get exact amount of x token output. func GetCmdEstimateSwapExactAmountOut() *cobra.Command { cmd := &cobra.Command{ Use: "estimate-swap-exact-amount-out ", diff --git a/x/gamm/client/cli/tx.go b/x/gamm/client/cli/tx.go index a512d1e8ce3..66169169c54 100644 --- a/x/gamm/client/cli/tx.go +++ b/x/gamm/client/cli/tx.go @@ -333,7 +333,6 @@ func NewExitSwapShareAmountIn() *cobra.Command { } func NewBuildCreateBalancerPoolMsg(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSet) (tx.Factory, sdk.Msg, error) { - pool, err := parseCreatePoolFlags(fs) if err != nil { return txf, nil, fmt.Errorf("failed to parse pool: %w", err) @@ -365,7 +364,6 @@ func NewBuildCreateBalancerPoolMsg(clientCtx client.Context, txf tx.Factory, fs var poolAssets []balancer.PoolAsset for i := 0; i < len(poolAssetCoins); i++ { - if poolAssetCoins[i].Denom != deposit[i].Denom { return txf, nil, errors.New("deposit tokens and token weights should have same denom order") } @@ -401,7 +399,6 @@ func NewBuildCreateBalancerPoolMsg(clientCtx client.Context, txf tx.Factory, fs var targetPoolAssets []balancer.PoolAsset for i := 0; i < len(targetPoolAssetCoins); i++ { - if targetPoolAssetCoins[i].Denom != poolAssetCoins[i].Denom { return txf, nil, errors.New("initial pool weights and target pool weights should have same denom order") } diff --git a/x/gamm/client/testutil/test_helpers.go b/x/gamm/client/testutil/test_helpers.go index 4fc6cde9fd7..48ab1d4337b 100644 --- a/x/gamm/client/testutil/test_helpers.go +++ b/x/gamm/client/testutil/test_helpers.go @@ -12,7 +12,7 @@ import ( gammcli "github.com/osmosis-labs/osmosis/v7/x/gamm/client/cli" ) -// commonArgs is args for CLI test commands +// commonArgs is args for CLI test commands. var commonArgs = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), @@ -80,7 +80,7 @@ func MsgJoinPool(clientCtx client.Context, owner fmt.Stringer, poolID uint64, sh return clitestutil.ExecTestCLICmd(clientCtx, gammcli.NewJoinPoolCmd(), args) } -// MsgExitPool broadcast a pool exit message +// MsgExitPool broadcast a pool exit message. func MsgExitPool(clientCtx client.Context, owner fmt.Stringer, poolID uint64, shareAmtIn string, minAmountsOut []string, extraArgs ...string) (testutil.BufferWriter, error) { args := []string{ fmt.Sprintf("--%s=%d", gammcli.FlagPoolId, poolID), diff --git a/x/gamm/keeper/grpc_query.go b/x/gamm/keeper/grpc_query.go index fcd4dfa6e70..a751f9b5d5b 100644 --- a/x/gamm/keeper/grpc_query.go +++ b/x/gamm/keeper/grpc_query.go @@ -20,9 +20,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/gamm/types" ) -var ( - sdkIntMaxValue = sdk.NewInt(0) -) +var sdkIntMaxValue = sdk.NewInt(0) func init() { maxInt := big.NewInt(2) @@ -95,7 +93,6 @@ func (k Keeper) Pools( anys = append(anys, any) return nil }) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } diff --git a/x/gamm/keeper/invariants.go b/x/gamm/keeper/invariants.go index 6aa34977874..a853b151c48 100644 --- a/x/gamm/keeper/invariants.go +++ b/x/gamm/keeper/invariants.go @@ -11,7 +11,7 @@ import ( const poolBalanceInvariantName = "pool-account-balance-equals-expected" -// RegisterInvariants registers all governance invariants +// RegisterInvariants registers all governance invariants. func RegisterInvariants(ir sdk.InvariantRegistry, keeper Keeper, bk types.BankKeeper) { // ir.RegisterRoute(types.ModuleName, poolBalanceInvariantName, PoolAccountInvariant(keeper, bk)) // ir.RegisterRoute(types.ModuleName, "pool-total-weight", PoolTotalWeightInvariant(keeper, bk)) @@ -113,9 +113,7 @@ func genericPow(base, exp sdk.Dec) sdk.Dec { // return product // } -var ( - errorMargin, _ = sdk.NewDecFromStr("0.0001") // 0.01% -) +var errorMargin, _ = sdk.NewDecFromStr("0.0001") // 0.01% // PoolProductContantInvariant chekcs that the pool constant invariant V where // V = product([asset_balance_n^asset_weight_n]) holds. diff --git a/x/gamm/keeper/keeper.go b/x/gamm/keeper/keeper.go index a7e15bff2f9..1722e21595f 100644 --- a/x/gamm/keeper/keeper.go +++ b/x/gamm/keeper/keeper.go @@ -2,6 +2,7 @@ package keeper import ( "fmt" + "strconv" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -59,7 +60,44 @@ func NewKeeper(cdc codec.BinaryCodec, storeKey sdk.StoreKey, paramSpace paramtyp } } -// Set the gamm hooks +func (k *Keeper) createSwapEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.TypeEvtTokenSwapped, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), + sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), + sdk.NewAttribute(types.AttributeKeyTokensIn, input.String()), + sdk.NewAttribute(types.AttributeKeyTokensOut, output.String()), + ), + }) +} + +func (k *Keeper) createAddLiquidityEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, liquidity sdk.Coins) { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.TypeEvtPoolJoined, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), + sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), + sdk.NewAttribute(types.AttributeKeyTokensIn, liquidity.String()), + ), + }) +} + +func (k *Keeper) createRemoveLiquidityEvent(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, liquidity sdk.Coins) { + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.TypeEvtPoolExited, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), + sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(poolId, 10)), + sdk.NewAttribute(types.AttributeKeyTokensOut, liquidity.String()), + ), + }) +} + +// Set the gamm hooks. func (k *Keeper) SetHooks(gh types.GammHooks) *Keeper { if k.hooks != nil { panic("cannot set gamm hooks twice") diff --git a/x/gamm/keeper/msg_server.go b/x/gamm/keeper/msg_server.go index 0ea347c1cf2..21d781f2c13 100644 --- a/x/gamm/keeper/msg_server.go +++ b/x/gamm/keeper/msg_server.go @@ -26,8 +26,10 @@ func NewBalancerMsgServerImpl(keeper *Keeper) balancer.MsgServer { } } -var _ types.MsgServer = msgServer{} -var _ balancer.MsgServer = msgServer{} +var ( + _ types.MsgServer = msgServer{} + _ balancer.MsgServer = msgServer{} +) func (server msgServer) CreateBalancerPool(goCtx context.Context, msg *balancer.MsgCreateBalancerPool) (*balancer.MsgCreateBalancerPoolResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -122,7 +124,6 @@ func (server msgServer) SwapExactAmountIn(goCtx context.Context, msg *types.MsgS } tokenOutAmount, err := server.keeper.MultihopSwapExactAmountIn(ctx, sender, msg.Routes, msg.TokenIn, msg.TokenOutMinAmount) - if err != nil { return nil, err } diff --git a/x/gamm/keeper/multihop.go b/x/gamm/keeper/multihop.go index bdfcccf5311..11f692555e6 100644 --- a/x/gamm/keeper/multihop.go +++ b/x/gamm/keeper/multihop.go @@ -8,7 +8,7 @@ import ( // MultihopSwapExactAmountIn defines the input denom and input amount for the first pool, // the output of the first pool is chained as the input for the next routed pool -// transaction succeeds when final amount out is greater than tokenOutMinAmount defined +// transaction succeeds when final amount out is greater than tokenOutMinAmount defined. func (k Keeper) MultihopSwapExactAmountIn( ctx sdk.Context, sender sdk.AccAddress, @@ -65,10 +65,10 @@ func (k Keeper) MultihopSwapExactAmountOut( } } - return + return tokenInAmount, nil } -// TODO: Document this function +// TODO: Document this function. func (k Keeper) createMultihopExpectedSwapOuts(ctx sdk.Context, routes []types.SwapAmountOutRoute, tokenOut sdk.Coin) ([]sdk.Int, error) { insExpected := make([]sdk.Int, len(routes)) for i := len(routes) - 1; i >= 0; i-- { diff --git a/x/gamm/keeper/params.go b/x/gamm/keeper/params.go index f2ff63b3d9c..6353bcadaff 100644 --- a/x/gamm/keeper/params.go +++ b/x/gamm/keeper/params.go @@ -5,13 +5,13 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/gamm/types" ) -// GetParams returns the total set params +// GetParams returns the total set params. func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { k.paramSpace.GetParamSet(ctx, ¶ms) return params } -// SetParams sets the total set of params +// SetParams sets the total set of params. func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { k.paramSpace.SetParamSet(ctx, ¶ms) } diff --git a/x/gamm/keeper/pool.go b/x/gamm/keeper/pool.go index 037eff11013..a7bb712cc06 100644 --- a/x/gamm/keeper/pool.go +++ b/x/gamm/keeper/pool.go @@ -23,7 +23,6 @@ func (k Keeper) UnmarshalPool(bz []byte) (types.PoolI, error) { } func (k Keeper) GetPool(ctx sdk.Context, poolId uint64) (types.PoolI, error) { - store := ctx.KVStore(k.storeKey) poolKey := types.GetKeyPrefixPools(poolId) if !store.Has(poolKey) { @@ -228,14 +227,14 @@ func (k Keeper) newBalancerPool(ctx sdk.Context, balancerPoolParams balancer.Poo return &pool, nil } -// SetNextPoolNumber sets next pool number +// SetNextPoolNumber sets next pool number. func (k Keeper) SetNextPoolNumber(ctx sdk.Context, poolNumber uint64) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(&gogotypes.UInt64Value{Value: poolNumber}) store.Set(types.KeyNextGlobalPoolNumber, bz) } -// GetNextPoolNumberAndIncrement returns the next pool number, and increments the corresponding state entry +// GetNextPoolNumberAndIncrement returns the next pool number, and increments the corresponding state entry. func (k Keeper) GetNextPoolNumberAndIncrement(ctx sdk.Context) uint64 { var poolNumber uint64 store := ctx.KVStore(k.storeKey) diff --git a/x/gamm/keeper/pool_service.go b/x/gamm/keeper/pool_service.go index 6f12f43db82..28daa280917 100644 --- a/x/gamm/keeper/pool_service.go +++ b/x/gamm/keeper/pool_service.go @@ -19,7 +19,8 @@ func (k Keeper) CalculateSpotPrice( ctx sdk.Context, poolID uint64, baseAssetDenom string, - quoteAssetDenom string) (sdk.Dec, error) { + quoteAssetDenom string, +) (sdk.Dec, error) { pool, err := k.GetPool(ctx, poolID) if err != nil { return sdk.Dec{}, err @@ -220,6 +221,7 @@ func (k Keeper) JoinSwapExactAmountIn( return shareOutAmount, nil } +//nolint:deadcode,govet // looks like we have known dead code beneath "panic" func (k Keeper) JoinSwapShareAmountOut( ctx sdk.Context, sender sdk.AccAddress, @@ -233,8 +235,10 @@ func (k Keeper) JoinSwapShareAmountOut( return sdk.Int{}, err } - panic("implement") + panic("implement") // I moved this past return, it caused everything beneath it to be dead code + tokenInAmount = sdk.ZeroInt() + // normalizedWeight := PoolAsset.Weight.ToDec().Quo(pool.GetTotalWeight().ToDec()) // tokenInAmount = calcSingleInGivenPoolOut( // PoolAsset.Token.Amount.ToDec(), diff --git a/x/gamm/module.go b/x/gamm/module.go index b454a1f2838..c350e82387e 100644 --- a/x/gamm/module.go +++ b/x/gamm/module.go @@ -61,7 +61,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod } //--------------------------------------- -// Interfaces +// Interfaces. func (b AppModuleBasic) RegisterRESTRoutes(ctx client.Context, r *mux.Router) { rest.RegisterHandlers(ctx, r) } @@ -102,7 +102,8 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { } func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, - accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper) AppModule { + accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, +) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, @@ -160,7 +161,7 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val // AppModuleSimulation functions // GenerateGenesisState creates a randomized GenState of the gamm module. -// However, at launch the gamm module has no state, hence this is a no-op +// However, at launch the gamm module has no state, hence this is a no-op. func (AppModule) GenerateGenesisState(simState *module.SimulationState) { // simulation.RandomizedGenState(simState) } @@ -177,9 +178,8 @@ func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { // return simulation.ParamChanges(r) } -// RegisterStoreDecoder registers a decoder for supply module's types +// RegisterStoreDecoder registers a decoder for supply module's types. func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { - return } // WeightedOperations returns all the simulation operations with their respective weights. diff --git a/x/gamm/pool-models/balancer/amm.go b/x/gamm/pool-models/balancer/amm.go index 1950607c746..d31b8531ff9 100644 --- a/x/gamm/pool-models/balancer/amm.go +++ b/x/gamm/pool-models/balancer/amm.go @@ -16,7 +16,7 @@ import ( // balanceYDelta is positive when the balance liquidity decreases. // balanceYDelta is negative when the balance liquidity increases. // -// panics if tokenWeightUnknown is 0 +// panics if tokenWeightUnknown is 0. func solveConstantFunctionInvariant( tokenBalanceFixedBefore, tokenBalanceFixedAfter, @@ -38,10 +38,11 @@ func solveConstantFunctionInvariant( } // CalcOutAmtGivenIn calculates token to be swapped out given -// the provided amount, fee deducted, using solveConstantFunctionInvariant +// the provided amount, fee deducted, using solveConstantFunctionInvariant. func (p Pool) CalcOutAmtGivenIn( ctx sdk.Context, tokensIn sdk.Coins, tokenOutDenom string, swapFee sdk.Dec) ( - tokenOut sdk.DecCoin, err error) { + tokenOut sdk.DecCoin, err error, +) { tokenIn, poolAssetIn, poolAssetOut, err := p.parsePoolAssets(tokensIn, tokenOutDenom) if err != nil { return sdk.DecCoin{}, err @@ -61,10 +62,11 @@ func (p Pool) CalcOutAmtGivenIn( } // calcInAmtGivenOut calculates token to be provided, fee added, -// given the swapped out amount, using solveConstantFunctionInvariant +// given the swapped out amount, using solveConstantFunctionInvariant. func (p Pool) CalcInAmtGivenOut( ctx sdk.Context, tokensOut sdk.Coins, tokenInDenom string, swapFee sdk.Dec) ( - tokenIn sdk.DecCoin, err error) { + tokenIn sdk.DecCoin, err error, +) { tokenOut, poolAssetOut, poolAssetIn, err := p.parsePoolAssets(tokensOut, tokenInDenom) if err != nil { return sdk.DecCoin{}, err @@ -86,7 +88,7 @@ func (p Pool) CalcInAmtGivenOut( return sdk.NewDecCoinFromDec(tokenInDenom, tokenAmountInBeforeFee), nil } -// ApplySwap +// ApplySwap. func (p *Pool) ApplySwap(ctx sdk.Context, tokensIn sdk.Coins, tokensOut sdk.Coins) error { // Also ensures that len(tokensIn) = 1 = len(tokensOut) inPoolAsset, outPoolAsset, err := p.parsePoolAssetsCoins(tokensIn, tokensOut) @@ -124,7 +126,7 @@ func (p Pool) SpotPrice(ctx sdk.Context, baseAsset, quoteAsset string) (sdk.Dec, } // balancer notation: pAo - poolshares amount out, given single asset in -// the second argument requires the tokenWeightIn / total token weight +// the second argument requires the tokenWeightIn / total token weight. func calcPoolOutGivenSingleIn( tokenBalanceIn, normalizedTokenWeightIn, @@ -157,7 +159,7 @@ func calcPoolOutGivenSingleIn( return poolAmountOut } -// calcPoolOutGivenSingleIn - balance pAo +// calcPoolOutGivenSingleIn - balance pAo. func (p *Pool) singleAssetJoin(tokenIn sdk.Coin, swapFee sdk.Dec) (numShares sdk.Int, err error) { tokenInPoolAsset, err := p.GetPoolAsset(tokenIn.Denom) if err != nil { diff --git a/x/gamm/pool-models/balancer/balancer_pool.go b/x/gamm/pool-models/balancer/balancer_pool.go index 3111b6b9136..dd84136ddc5 100644 --- a/x/gamm/pool-models/balancer/balancer_pool.go +++ b/x/gamm/pool-models/balancer/balancer_pool.go @@ -453,7 +453,6 @@ func (pa Pool) NumAssets() int { } func (pa Pool) IsActive(curBlockTime time.Time) bool { - // Add frozen pool checking, etc... return true diff --git a/x/gamm/pool-models/balancer/msgs.go b/x/gamm/pool-models/balancer/msgs.go index b5921dd9cfd..95640a5c1e7 100644 --- a/x/gamm/pool-models/balancer/msgs.go +++ b/x/gamm/pool-models/balancer/msgs.go @@ -16,7 +16,6 @@ var _ sdk.Msg = &MsgCreateBalancerPool{} func (msg MsgCreateBalancerPool) Route() string { return types.RouterKey } func (msg MsgCreateBalancerPool) Type() string { return TypeMsgCreateBalancerPool } func (msg MsgCreateBalancerPool) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) @@ -39,9 +38,11 @@ func (msg MsgCreateBalancerPool) ValidateBasic() error { return nil } + func (msg MsgCreateBalancerPool) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } + func (msg MsgCreateBalancerPool) GetSigners() []sdk.AccAddress { sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { diff --git a/x/gamm/pool-models/balancer/pool_asset.go b/x/gamm/pool-models/balancer/pool_asset.go index 40ebc3b99f9..22eddf5e740 100644 --- a/x/gamm/pool-models/balancer/pool_asset.go +++ b/x/gamm/pool-models/balancer/pool_asset.go @@ -66,7 +66,7 @@ func SortPoolAssetsOutOfPlaceByDenom(assets []PoolAsset) []PoolAsset { return assets_copy } -// SortPoolAssetsByDenom sorts pool assets in place, by weight +// SortPoolAssetsByDenom sorts pool assets in place, by weight. func SortPoolAssetsByDenom(assets []PoolAsset) { sort.Slice(assets, func(i, j int) bool { PoolAssetA := assets[i] @@ -100,7 +100,7 @@ func ValidateUserSpecifiedPoolAssets(assets []PoolAsset) error { return nil } -// PoolAssetsCoins returns all the coins corresponding to a slice of pool assets +// PoolAssetsCoins returns all the coins corresponding to a slice of pool assets. func PoolAssetsCoins(assets []PoolAsset) sdk.Coins { coins := sdk.Coins{} for _, asset := range assets { diff --git a/x/gamm/simulation/operations.go b/x/gamm/simulation/operations.go index 6dbbbb01a13..c6b98189dad 100644 --- a/x/gamm/simulation/operations.go +++ b/x/gamm/simulation/operations.go @@ -1,3 +1,4 @@ +//nolint:gosec // nolint because this file contains strings for testing package simulation import ( @@ -18,7 +19,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/gamm/types" ) -// Simulation operation weights constants +// Simulation operation weights constants. const ( OpWeightMsgCreatePool = "op_weight_create_pool" OpWeightMsgSwapExactAmountIn = "op_weight_swap_exact_amount_in" @@ -41,7 +42,7 @@ const ( DefaultWeightMsgExitSwapShareAmountIn int = 10 ) -// WeightedOperations returns all the operations from the module with their respective weights +// WeightedOperations returns all the operations from the module with their respective weights. func WeightedOperations( appParams simtypes.AppParams, cdc codec.JSONCodec, ak stakingTypes.AccountKeeper, bk stakingTypes.BankKeeper, k keeper.Keeper, @@ -129,7 +130,7 @@ func Max(x, y int) int { return y } -// SimulateMsgCreateBalancerPool generates a MsgCreatePool with random values +// SimulateMsgCreateBalancerPool generates a MsgCreatePool with random values. func SimulateMsgCreateBalancerPool(ak stakingTypes.AccountKeeper, bk stakingTypes.BankKeeper, k keeper.Keeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, diff --git a/x/gamm/types/codec.go b/x/gamm/types/codec.go index 62c81844bb7..c0d961f54a6 100644 --- a/x/gamm/types/codec.go +++ b/x/gamm/types/codec.go @@ -22,7 +22,6 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { } func RegisterInterfaces(registry types.InterfaceRegistry) { - registry.RegisterInterface( "osmosis.gamm.v1beta1.PoolI", (*PoolI)(nil), diff --git a/x/gamm/types/constants.go b/x/gamm/types/constants.go index f5ffe1bc496..ca4d4acc727 100644 --- a/x/gamm/types/constants.go +++ b/x/gamm/types/constants.go @@ -12,9 +12,9 @@ const ( ) var ( - // OneShare represents the amount of subshares in a single pool share + // OneShare represents the amount of subshares in a single pool share. OneShare = sdk.NewIntWithDecimal(1, OneShareExponent) - // InitPoolSharesSupply is the amount of new shares to initialize a pool with + // InitPoolSharesSupply is the amount of new shares to initialize a pool with. InitPoolSharesSupply = OneShare.MulRaw(100) ) diff --git a/x/gamm/types/errors.go b/x/gamm/types/errors.go index 26e01e8ad8e..9a7d64d0a04 100644 --- a/x/gamm/types/errors.go +++ b/x/gamm/types/errors.go @@ -2,7 +2,7 @@ package types import sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -// x/gamm module sentinel errors +// x/gamm module sentinel errors. var ( ErrPoolNotFound = sdkerrors.Register(ModuleName, 1, "pool not found") ErrPoolAlreadyExist = sdkerrors.Register(ModuleName, 2, "pool already exist") diff --git a/x/gamm/types/expected_keepers.go b/x/gamm/types/expected_keepers.go index ee18d78bcd7..e69a5da4c9f 100644 --- a/x/gamm/types/expected_keepers.go +++ b/x/gamm/types/expected_keepers.go @@ -57,7 +57,7 @@ type BankKeeper interface { IterateAllBalances(ctx sdk.Context, callback func(addr sdk.AccAddress, coin sdk.Coin) (stop bool)) } -// DistrKeeper defines the contract needed to be fulfilled for distribution keeper +// DistrKeeper defines the contract needed to be fulfilled for distribution keeper. type DistrKeeper interface { FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error } diff --git a/x/gamm/types/genesis.go b/x/gamm/types/genesis.go index 47b2102730e..2e6539ee605 100644 --- a/x/gamm/types/genesis.go +++ b/x/gamm/types/genesis.go @@ -4,7 +4,7 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" ) -// DefaultGenesis creates a default GenesisState object +// DefaultGenesis creates a default GenesisState object. func DefaultGenesis() *GenesisState { return &GenesisState{ Pools: []*codectypes.Any{}, diff --git a/x/gamm/types/hooks.go b/x/gamm/types/hooks.go index de9e7d87f81..20969d75245 100644 --- a/x/gamm/types/hooks.go +++ b/x/gamm/types/hooks.go @@ -15,10 +15,10 @@ type GammHooks interface { var _ GammHooks = MultiGammHooks{} -// combine multiple gamm hooks, all hook functions are run in array sequence +// combine multiple gamm hooks, all hook functions are run in array sequence. type MultiGammHooks []GammHooks -// Creates hooks for the Gamm Module +// Creates hooks for the Gamm Module. func NewMultiGammHooks(hooks ...GammHooks) MultiGammHooks { return hooks } diff --git a/x/gamm/types/key.go b/x/gamm/types/key.go index 08a693add47..ce03c67073e 100644 --- a/x/gamm/types/key.go +++ b/x/gamm/types/key.go @@ -19,11 +19,11 @@ const ( ) var ( - // KeyNextGlobalPoolNumber defines key to store the next Pool ID to be used + // KeyNextGlobalPoolNumber defines key to store the next Pool ID to be used. KeyNextGlobalPoolNumber = []byte{0x01} - // KeyPrefixPools defines prefix to store pools + // KeyPrefixPools defines prefix to store pools. KeyPrefixPools = []byte{0x02} - // KeyTotalLiquidity defines key to store total liquidity + // KeyTotalLiquidity defines key to store total liquidity. KeyTotalLiquidity = []byte{0x03} ) diff --git a/x/gamm/types/msg_lp.go b/x/gamm/types/msg_lp.go index f661e48cfb7..65b000f840a 100644 --- a/x/gamm/types/msg_lp.go +++ b/x/gamm/types/msg_lp.go @@ -13,20 +13,26 @@ type LiquidityChangeMsg interface { LiquidityChangeType() LiquidityChangeType } -var _ LiquidityChangeMsg = MsgExitPool{} -var _ LiquidityChangeMsg = MsgExitSwapShareAmountIn{} -var _ LiquidityChangeMsg = MsgExitSwapExternAmountOut{} +var ( + _ LiquidityChangeMsg = MsgExitPool{} + _ LiquidityChangeMsg = MsgExitSwapShareAmountIn{} + _ LiquidityChangeMsg = MsgExitSwapExternAmountOut{} +) -var _ LiquidityChangeMsg = MsgJoinPool{} -var _ LiquidityChangeMsg = MsgJoinSwapExternAmountIn{} -var _ LiquidityChangeMsg = MsgJoinSwapShareAmountOut{} +var ( + _ LiquidityChangeMsg = MsgJoinPool{} + _ LiquidityChangeMsg = MsgJoinSwapExternAmountIn{} + _ LiquidityChangeMsg = MsgJoinSwapShareAmountOut{} +) func (msg MsgExitPool) LiquidityChangeType() LiquidityChangeType { return RemoveLiquidity } + func (msg MsgExitSwapShareAmountIn) LiquidityChangeType() LiquidityChangeType { return RemoveLiquidity } + func (msg MsgExitSwapExternAmountOut) LiquidityChangeType() LiquidityChangeType { return RemoveLiquidity } @@ -34,9 +40,11 @@ func (msg MsgExitSwapExternAmountOut) LiquidityChangeType() LiquidityChangeType func (msg MsgJoinPool) LiquidityChangeType() LiquidityChangeType { return AddLiquidity } + func (msg MsgJoinSwapExternAmountIn) LiquidityChangeType() LiquidityChangeType { return AddLiquidity } + func (msg MsgJoinSwapShareAmountOut) LiquidityChangeType() LiquidityChangeType { return AddLiquidity } diff --git a/x/gamm/types/msg_swap.go b/x/gamm/types/msg_swap.go index 61e15b8241a..38d2090740a 100644 --- a/x/gamm/types/msg_swap.go +++ b/x/gamm/types/msg_swap.go @@ -7,15 +7,19 @@ type SwapMsgRoute interface { TokenDenomsOnPath() []string } -var _ SwapMsgRoute = MsgSwapExactAmountOut{} -var _ SwapMsgRoute = MsgSwapExactAmountIn{} +var ( + _ SwapMsgRoute = MsgSwapExactAmountOut{} + _ SwapMsgRoute = MsgSwapExactAmountIn{} +) func (msg MsgSwapExactAmountOut) TokenInDenom() string { return msg.Routes[0].GetTokenInDenom() } + func (msg MsgSwapExactAmountOut) TokenOutDenom() string { return msg.TokenOut.Denom } + func (msg MsgSwapExactAmountOut) TokenDenomsOnPath() []string { denoms := make([]string, 0, len(msg.Routes)+1) for i := 0; i < len(msg.Routes); i++ { @@ -28,10 +32,12 @@ func (msg MsgSwapExactAmountOut) TokenDenomsOnPath() []string { func (msg MsgSwapExactAmountIn) TokenInDenom() string { return msg.TokenIn.Denom } + func (msg MsgSwapExactAmountIn) TokenOutDenom() string { lastRouteIndex := len(msg.Routes) - 1 return msg.Routes[lastRouteIndex].GetTokenOutDenom() } + func (msg MsgSwapExactAmountIn) TokenDenomsOnPath() []string { denoms := make([]string, 0, len(msg.Routes)+1) denoms = append(denoms, msg.TokenInDenom()) diff --git a/x/gamm/types/msgs.go b/x/gamm/types/msgs.go index c8f0a6bb800..3e99d40c792 100644 --- a/x/gamm/types/msgs.go +++ b/x/gamm/types/msgs.go @@ -9,7 +9,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -// constants +// constants. const ( TypeMsgSwapExactAmountIn = "swap_exact_amount_in" TypeMsgSwapExactAmountOut = "swap_exact_amount_out" @@ -87,9 +87,11 @@ func (msg MsgSwapExactAmountIn) ValidateBasic() error { return nil } + func (msg MsgSwapExactAmountIn) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } + func (msg MsgSwapExactAmountIn) GetSigners() []sdk.AccAddress { sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { @@ -104,7 +106,6 @@ func (msg MsgSwapExactAmountOut) Route() string { return RouterKey } func (msg MsgSwapExactAmountOut) Type() string { return TypeMsgSwapExactAmountOut } func (msg MsgSwapExactAmountOut) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) } @@ -124,9 +125,11 @@ func (msg MsgSwapExactAmountOut) ValidateBasic() error { return nil } + func (msg MsgSwapExactAmountOut) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } + func (msg MsgSwapExactAmountOut) GetSigners() []sdk.AccAddress { sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { @@ -156,9 +159,11 @@ func (msg MsgJoinPool) ValidateBasic() error { return nil } + func (msg MsgJoinPool) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } + func (msg MsgJoinPool) GetSigners() []sdk.AccAddress { sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { @@ -188,9 +193,11 @@ func (msg MsgExitPool) ValidateBasic() error { return nil } + func (msg MsgExitPool) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } + func (msg MsgExitPool) GetSigners() []sdk.AccAddress { sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { @@ -219,9 +226,11 @@ func (msg MsgJoinSwapExternAmountIn) ValidateBasic() error { return nil } + func (msg MsgJoinSwapExternAmountIn) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } + func (msg MsgJoinSwapExternAmountIn) GetSigners() []sdk.AccAddress { sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { @@ -255,9 +264,11 @@ func (msg MsgJoinSwapShareAmountOut) ValidateBasic() error { return nil } + func (msg MsgJoinSwapShareAmountOut) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } + func (msg MsgJoinSwapShareAmountOut) GetSigners() []sdk.AccAddress { sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { @@ -286,9 +297,11 @@ func (msg MsgExitSwapExternAmountOut) ValidateBasic() error { return nil } + func (msg MsgExitSwapExternAmountOut) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } + func (msg MsgExitSwapExternAmountOut) GetSigners() []sdk.AccAddress { sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { @@ -322,9 +335,11 @@ func (msg MsgExitSwapShareAmountIn) ValidateBasic() error { return nil } + func (msg MsgExitSwapShareAmountIn) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } + func (msg MsgExitSwapShareAmountIn) GetSigners() []sdk.AccAddress { sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { diff --git a/x/gamm/types/params.go b/x/gamm/types/params.go index 4780a63f113..08fe91ff87f 100644 --- a/x/gamm/types/params.go +++ b/x/gamm/types/params.go @@ -8,7 +8,7 @@ import ( appparams "github.com/osmosis-labs/osmosis/v7/app/params" ) -// Parameter store keys +// Parameter store keys. var ( KeyPoolCreationFee = []byte("PoolCreationFee") ) @@ -24,24 +24,23 @@ func NewParams(poolCreationFee sdk.Coins) Params { } } -// default gamm module parameters +// default gamm module parameters. func DefaultParams() Params { return Params{ PoolCreationFee: sdk.Coins{sdk.NewInt64Coin(appparams.BaseCoinUnit, 1000_000_000)}, // 1000 OSMO } } -// validate params +// validate params. func (p Params) Validate() error { if err := validatePoolCreationFee(p.PoolCreationFee); err != nil { return err } return nil - } -// Implements params.ParamSet +// Implements params.ParamSet. func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyPoolCreationFee, &p.PoolCreationFee, validatePoolCreationFee), diff --git a/x/incentives/client/cli/cli_test.go b/x/incentives/client/cli/cli_test.go index 9dd080ca0a8..752dc1ce416 100644 --- a/x/incentives/client/cli/cli_test.go +++ b/x/incentives/client/cli/cli_test.go @@ -64,7 +64,7 @@ func (s *IntegrationTestSuite) TestGetCmdGauges() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) } }) } @@ -98,7 +98,7 @@ func (s *IntegrationTestSuite) TestGetCmdToDistributeCoins() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) } }) } @@ -132,7 +132,7 @@ func (s *IntegrationTestSuite) TestGetCmdDistributedCoins() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) } }) } @@ -166,7 +166,7 @@ func (s *IntegrationTestSuite) TestGetCmdGaugeByID() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) } }) } @@ -200,7 +200,7 @@ func (s *IntegrationTestSuite) TestGetCmdActiveGauges() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) } }) } @@ -234,7 +234,7 @@ func (s *IntegrationTestSuite) TestGetCmdActiveGaugesPerDenom() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) } }) } @@ -268,7 +268,7 @@ func (s *IntegrationTestSuite) TestGetCmdUpcomingGauges() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) } }) } @@ -326,7 +326,7 @@ func (s *IntegrationTestSuite) TestGetCmdRewardsEst() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) } }) } diff --git a/x/incentives/client/cli/flags.go b/x/incentives/client/cli/flags.go index 8c46f16b079..11801813f28 100644 --- a/x/incentives/client/cli/flags.go +++ b/x/incentives/client/cli/flags.go @@ -6,7 +6,7 @@ import ( flag "github.com/spf13/pflag" ) -// flags for lockup module tx commands +// flags for lockup module tx commands. const ( FlagDuration = "duration" FlagStartTime = "start-time" @@ -19,7 +19,7 @@ const ( FlagEndEpoch = "end-epoch" ) -// FlagSetCreateGauge returns flags for creating gauge +// FlagSetCreateGauge returns flags for creating gauge. func FlagSetCreateGauge() *flag.FlagSet { fs := flag.NewFlagSet("", flag.ContinueOnError) diff --git a/x/incentives/client/cli/query.go b/x/incentives/client/cli/query.go index 7571eb835bb..4231bcc3abb 100644 --- a/x/incentives/client/cli/query.go +++ b/x/incentives/client/cli/query.go @@ -12,7 +12,7 @@ import ( "github.com/spf13/cobra" ) -// GetQueryCmd returns the cli query commands for this module +// GetQueryCmd returns the cli query commands for this module. func GetQueryCmd(queryRoute string) *cobra.Command { // Group incentives queries under a subcommand cmd := &cobra.Command{ @@ -37,7 +37,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { return cmd } -// GetCmdGauges returns full available gauges +// GetCmdGauges returns full available gauges. func GetCmdGauges() *cobra.Command { cmd := &cobra.Command{ Use: "gauges", @@ -81,7 +81,7 @@ $ %s query incentives gauges return cmd } -// GetCmdToDistributeCoins returns coins that is going to be distributed +// GetCmdToDistributeCoins returns coins that is going to be distributed. func GetCmdToDistributeCoins() *cobra.Command { cmd := &cobra.Command{ Use: "to-distribute-coins", @@ -117,7 +117,7 @@ $ %s query incentives to-distribute-coins return cmd } -// GetCmdDistributedCoins returns coins that are distributed so far +// GetCmdDistributedCoins returns coins that are distributed so far. func GetCmdDistributedCoins() *cobra.Command { cmd := &cobra.Command{ Use: "distributed-coins", @@ -153,7 +153,7 @@ $ %s query incentives distributed-coins return cmd } -// GetCmdGaugeByID returns Gauge by id +// GetCmdGaugeByID returns Gauge by id. func GetCmdGaugeByID() *cobra.Command { cmd := &cobra.Command{ Use: "gauge-by-id [id]", @@ -194,7 +194,7 @@ $ %s query incentives gauge-by-id 1 return cmd } -// GetCmdActiveGauges returns active gauges +// GetCmdActiveGauges returns active gauges. func GetCmdActiveGauges() *cobra.Command { cmd := &cobra.Command{ Use: "active-gauges", @@ -235,7 +235,7 @@ $ %s query incentives active-gauges return cmd } -// GetCmdActiveGaugesPerDenom returns active gauges for specified denom +// GetCmdActiveGaugesPerDenom returns active gauges for specified denom. func GetCmdActiveGaugesPerDenom() *cobra.Command { cmd := &cobra.Command{ Use: "active-gauges-per-denom [denom]", @@ -276,7 +276,7 @@ $ %s query incentives active-gauges-per-denom [denom] return cmd } -// GetCmdUpcomingGauges returns scheduled gauges +// GetCmdUpcomingGauges returns scheduled gauges. func GetCmdUpcomingGauges() *cobra.Command { cmd := &cobra.Command{ Use: "upcoming-gauges", @@ -317,7 +317,7 @@ $ %s query incentives upcoming-gauges return cmd } -// GetCmdRewardsEst returns rewards estimation +// GetCmdRewardsEst returns rewards estimation. func GetCmdRewardsEst() *cobra.Command { cmd := &cobra.Command{ Use: "rewards-estimation", diff --git a/x/incentives/client/cli/tx.go b/x/incentives/client/cli/tx.go index da9e0cef238..bad6068c6ee 100644 --- a/x/incentives/client/cli/tx.go +++ b/x/incentives/client/cli/tx.go @@ -15,7 +15,7 @@ import ( "github.com/spf13/cobra" ) -// GetTxCmd returns the transaction commands for this module +// GetTxCmd returns the transaction commands for this module. func GetTxCmd() *cobra.Command { cmd := &cobra.Command{ Use: types.ModuleName, @@ -33,7 +33,7 @@ func GetTxCmd() *cobra.Command { return cmd } -// NewCreateGaugeCmd broadcast MsgCreateGauge +// NewCreateGaugeCmd broadcast MsgCreateGauge. func NewCreateGaugeCmd() *cobra.Command { cmd := &cobra.Command{ Use: "create-gauge [lockup_denom] [reward] [flags]", @@ -53,7 +53,7 @@ func NewCreateGaugeCmd() *cobra.Command { return err } - startTime := time.Time{} + var startTime time.Time timeStr, err := cmd.Flags().GetString(FlagStartTime) if err != nil { return err @@ -112,7 +112,7 @@ func NewCreateGaugeCmd() *cobra.Command { return cmd } -// NewAddToGaugeCmd broadcast MsgAddToGauge +// NewAddToGaugeCmd broadcast MsgAddToGauge. func NewAddToGaugeCmd() *cobra.Command { cmd := &cobra.Command{ Use: "add-to-gauge [gauge_id] [rewards] [flags]", diff --git a/x/incentives/client/rest/rest.go b/x/incentives/client/rest/rest.go index e9e6af25a8c..0e11ebbb853 100644 --- a/x/incentives/client/rest/rest.go +++ b/x/incentives/client/rest/rest.go @@ -10,7 +10,7 @@ const ( MethodGet = "GET" ) -// RegisterRoutes registers incentives-related REST handlers to a router +// RegisterRoutes registers incentives-related REST handlers to a router. func RegisterRoutes(clientCtx client.Context, r *mux.Router) { } diff --git a/x/incentives/handler.go b/x/incentives/handler.go index 2f2b38c94c6..33a27f15bfc 100644 --- a/x/incentives/handler.go +++ b/x/incentives/handler.go @@ -9,7 +9,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/incentives/types" ) -// NewHandler returns msg handler for this module +// NewHandler returns msg handler for this module. func NewHandler(k *keeper.Keeper) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) diff --git a/x/incentives/keeper/distribute.go b/x/incentives/keeper/distribute.go index 973038cad7d..fd9ab4e4bb2 100644 --- a/x/incentives/keeper/distribute.go +++ b/x/incentives/keeper/distribute.go @@ -33,7 +33,7 @@ func (k Keeper) getDistributedCoinsFromIterator(ctx sdk.Context, iterator db.Ite return k.getDistributedCoinsFromGauges(k.getGaugesFromIterator(ctx, iterator)) } -// BeginDistribution is a utility to begin distribution for a specific gauge +// BeginDistribution is a utility to begin distribution for a specific gauge. func (k Keeper) BeginDistribution(ctx sdk.Context, gauge types.Gauge) error { // validation for current time and distribution start time if ctx.BlockTime().Before(gauge.StartTime) { @@ -50,7 +50,7 @@ func (k Keeper) BeginDistribution(ctx sdk.Context, gauge types.Gauge) error { return nil } -// FinishDistribution is a utility to finish distribution for a specific gauge +// FinishDistribution is a utility to finish distribution for a specific gauge. func (k Keeper) FinishDistribution(ctx sdk.Context, gauge types.Gauge) error { timeKey := getTimeKey(gauge.StartTime) if err := k.deleteGaugeRefByKey(ctx, combineKeys(types.KeyPrefixActiveGauges, timeKey), gauge.Id); err != nil { @@ -66,7 +66,7 @@ func (k Keeper) FinishDistribution(ctx sdk.Context, gauge types.Gauge) error { return nil } -// GetLocksToDistribution get locks that are associated to a condition +// GetLocksToDistribution get locks that are associated to a condition. func (k Keeper) GetLocksToDistribution(ctx sdk.Context, distrTo lockuptypes.QueryCondition) []lockuptypes.PeriodLock { switch distrTo.LockQueryType { case lockuptypes.ByDuration: @@ -79,7 +79,7 @@ func (k Keeper) GetLocksToDistribution(ctx sdk.Context, distrTo lockuptypes.Quer } // getLocksToDistributionWithMaxDuration get locks that are associated to a condition -// and if its by duration, then use the min Duration +// and if its by duration, then use the min Duration. func (k Keeper) getLocksToDistributionWithMaxDuration(ctx sdk.Context, distrTo lockuptypes.QueryCondition, minDuration time.Duration) []lockuptypes.PeriodLock { switch distrTo.LockQueryType { case lockuptypes.ByDuration: @@ -156,7 +156,7 @@ func (k Keeper) FilteredLocksDistributionEst(ctx sdk.Context, gauge types.Gauge, } // distributionInfo stores all of the information for pent up sends for rewards distributions. -// This enables us to lower the number of events and calls to back +// This enables us to lower the number of events and calls to back. type distributionInfo struct { nextID int lockOwnerAddrToID map[string]int @@ -222,9 +222,10 @@ func (k Keeper) doDistributionSends(ctx sdk.Context, distrs *distributionInfo) e // distributeSyntheticInternal runs the distribution logic for a synthetic rewards distribution gauge, and adds the sends to // the distrInfo computed. It also updates the gauge for the distribution. // locks is expected to be the correct set of lock recipients for this gauge. -// TODO: Make this code have way more re-use with distribute internal (post-v7) +// TODO: Make this code have way more re-use with distribute internal (post-v7). func (k Keeper) distributeSyntheticInternal( - ctx sdk.Context, gauge types.Gauge, locks []lockuptypes.PeriodLock, distrInfo *distributionInfo) (sdk.Coins, error) { + ctx sdk.Context, gauge types.Gauge, locks []lockuptypes.PeriodLock, distrInfo *distributionInfo, +) (sdk.Coins, error) { totalDistrCoins := sdk.NewCoins() denom := gauge.DistributeTo.Denom @@ -289,7 +290,8 @@ func (k Keeper) distributeSyntheticInternal( // the distrInfo computed. It also updates the gauge for the distribution. // locks is expected to be the correct set of lock recipients for this gauge. func (k Keeper) distributeInternal( - ctx sdk.Context, gauge types.Gauge, locks []lockuptypes.PeriodLock, distrInfo *distributionInfo) (sdk.Coins, error) { + ctx sdk.Context, gauge types.Gauge, locks []lockuptypes.PeriodLock, distrInfo *distributionInfo, +) (sdk.Coins, error) { totalDistrCoins := sdk.NewCoins() denom := gauge.DistributeTo.Denom lockSum := lockuptypes.SumLocksByDenom(locks, denom) @@ -361,7 +363,7 @@ func (k Keeper) getDistributeToBaseLocks(ctx sdk.Context, gauge types.Gauge, cac return FilterLocksByMinDuration(allLocks, gauge.DistributeTo.Duration) } -// Distribute coins from gauge according to its conditions +// Distribute coins from gauge according to its conditions. func (k Keeper) Distribute(ctx sdk.Context, gauges []types.Gauge) (sdk.Coins, error) { distrInfo := newDistributionInfo() @@ -406,14 +408,14 @@ func (k Keeper) checkFinishDistribution(ctx sdk.Context, gauges []types.Gauge) { } } -// GetModuleToDistributeCoins returns sum of to distribute coins for all of the module +// GetModuleToDistributeCoins returns sum of to distribute coins for all of the module. func (k Keeper) GetModuleToDistributeCoins(ctx sdk.Context) sdk.Coins { activeGaugesDistr := k.getToDistributeCoinsFromIterator(ctx, k.ActiveGaugesIterator(ctx)) upcomingGaugesDistr := k.getToDistributeCoinsFromIterator(ctx, k.UpcomingGaugesIteratorAfterTime(ctx, ctx.BlockTime())) return activeGaugesDistr.Add(upcomingGaugesDistr...) } -// GetModuleDistributedCoins returns sum of distributed coins so far +// GetModuleDistributedCoins returns sum of distributed coins so far. func (k Keeper) GetModuleDistributedCoins(ctx sdk.Context) sdk.Coins { activeGaugesDistr := k.getDistributedCoinsFromIterator(ctx, k.ActiveGaugesIterator(ctx)) finishedGaugesDistr := k.getDistributedCoinsFromIterator(ctx, k.FinishedGaugesIterator(ctx)) diff --git a/x/incentives/keeper/gauge.go b/x/incentives/keeper/gauge.go index 4342fed2e32..2119bd86bd8 100644 --- a/x/incentives/keeper/gauge.go +++ b/x/incentives/keeper/gauge.go @@ -35,7 +35,7 @@ func (k Keeper) getGaugesFromIterator(ctx sdk.Context, iterator db.Iterator) []t return gauges } -// Compute the total amount of coins in all the gauges +// Compute the total amount of coins in all the gauges. func (k Keeper) getCoinsFromGauges(gauges []types.Gauge) sdk.Coins { coins := sdk.Coins{} for _, gauge := range gauges { @@ -48,7 +48,7 @@ func (k Keeper) getCoinsFromIterator(ctx sdk.Context, iterator db.Iterator) sdk. return k.getCoinsFromGauges(k.getGaugesFromIterator(ctx, iterator)) } -// setGauge set the gauge inside store +// 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) @@ -59,7 +59,7 @@ func (k Keeper) setGauge(ctx sdk.Context, gauge *types.Gauge) error { return nil } -// CreateGaugeRefKeys adds gauge references as needed. Used to consolidate codepaths for InitGenesis and CreateGauge +// CreateGaugeRefKeys adds gauge references as needed. Used to consolidate codepaths for InitGenesis and CreateGauge. func (k Keeper) CreateGaugeRefKeys(ctx sdk.Context, gauge *types.Gauge, combinedKeys []byte, activeOrUpcomingGauge bool) error { if err := k.addGaugeRefByKey(ctx, combinedKeys, gauge.Id); err != nil { return err @@ -94,9 +94,8 @@ func (k Keeper) SetGaugeWithRefKey(ctx sdk.Context, gauge *types.Gauge) error { } } -// CreateGauge create a gauge and send coins to the gauge +// CreateGauge create a gauge and send coins to the gauge. func (k Keeper) CreateGauge(ctx sdk.Context, isPerpetual bool, owner sdk.AccAddress, coins sdk.Coins, distrTo lockuptypes.QueryCondition, startTime time.Time, numEpochsPaidOver uint64) (uint64, error) { - // Ensure that this gauge's duration is one of the allowed durations on chain durations := k.GetLockableDurations(ctx) if distrTo.LockQueryType == lockuptypes.ByDuration { @@ -148,7 +147,7 @@ func (k Keeper) CreateGauge(ctx sdk.Context, isPerpetual bool, owner sdk.AccAddr return gauge.Id, nil } -// AddToGauge add coins to gauge +// AddToGauge add 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 { @@ -167,7 +166,7 @@ func (k Keeper) AddToGaugeRewards(ctx sdk.Context, owner sdk.AccAddress, coins s return nil } -// GetGaugeByID Returns gauge from gauge ID +// 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) @@ -182,7 +181,7 @@ func (k Keeper) GetGaugeByID(ctx sdk.Context, gaugeID uint64) (*types.Gauge, err return &gauge, nil } -// GetGaugeFromIDs returns gauges from gauge ids reference +// GetGaugeFromIDs returns gauges from gauge ids reference. func (k Keeper) GetGaugeFromIDs(ctx sdk.Context, gaugeIDs []uint64) ([]types.Gauge, error) { gauges := []types.Gauge{} for _, gaugeID := range gaugeIDs { @@ -195,7 +194,7 @@ func (k Keeper) GetGaugeFromIDs(ctx sdk.Context, gaugeIDs []uint64) ([]types.Gau return gauges, nil } -// GetGauges returns gauges both upcoming and active +// GetGauges returns gauges both upcoming and active. func (k Keeper) GetGauges(ctx sdk.Context) []types.Gauge { return k.getGaugesFromIterator(ctx, k.GaugesIterator(ctx)) } @@ -204,17 +203,17 @@ func (k Keeper) GetNotFinishedGauges(ctx sdk.Context) []types.Gauge { return append(k.GetActiveGauges(ctx), k.GetUpcomingGauges(ctx)...) } -// GetActiveGauges returns active gauges +// GetActiveGauges returns active gauges. func (k Keeper) GetActiveGauges(ctx sdk.Context) []types.Gauge { return k.getGaugesFromIterator(ctx, k.ActiveGaugesIterator(ctx)) } -// GetUpcomingGauges returns scheduled gauges +// GetUpcomingGauges returns scheduled gauges. func (k Keeper) GetUpcomingGauges(ctx sdk.Context) []types.Gauge { return k.getGaugesFromIterator(ctx, k.UpcomingGaugesIterator(ctx)) } -// GetFinishedGauges returns finished gauges +// GetFinishedGauges returns finished gauges. func (k Keeper) GetFinishedGauges(ctx sdk.Context) []types.Gauge { return k.getGaugesFromIterator(ctx, k.FinishedGaugesIterator(ctx)) } @@ -264,7 +263,6 @@ func (k Keeper) GetRewardsEst(ctx sdk.Context, addr sdk.AccAddress, locks []lock } for epoch := distrBeginEpoch; epoch <= endEpoch; epoch++ { - newGauge, distrCoins, err := k.FilteredLocksDistributionEst(cacheCtx, gauge, locks) if err != nil { continue diff --git a/x/incentives/keeper/grpc_query.go b/x/incentives/keeper/grpc_query.go index acc66b2258d..97bedbf9649 100644 --- a/x/incentives/keeper/grpc_query.go +++ b/x/incentives/keeper/grpc_query.go @@ -17,19 +17,19 @@ import ( var _ types.QueryServer = Keeper{} -// ModuleToDistributeCoins returns coins that is going to be distributed +// ModuleToDistributeCoins returns coins that is going to be distributed. func (k Keeper) ModuleToDistributeCoins(goCtx context.Context, req *types.ModuleToDistributeCoinsRequest) (*types.ModuleToDistributeCoinsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) return &types.ModuleToDistributeCoinsResponse{Coins: k.GetModuleToDistributeCoins(ctx)}, nil } -// ModuleDistributedCoins returns coins that are distributed by module so far +// ModuleDistributedCoins returns coins that are distributed by module so far. func (k Keeper) ModuleDistributedCoins(goCtx context.Context, req *types.ModuleDistributedCoinsRequest) (*types.ModuleDistributedCoinsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) return &types.ModuleDistributedCoinsResponse{Coins: k.GetModuleDistributedCoins(ctx)}, nil } -// GaugeByID returns Gauge by id +// GaugeByID returns Gauge by id. func (k Keeper) GaugeByID(goCtx context.Context, req *types.GaugeByIDRequest) (*types.GaugeByIDResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) gauge, err := k.GetGaugeByID(ctx, req.Id) @@ -39,7 +39,7 @@ func (k Keeper) GaugeByID(goCtx context.Context, req *types.GaugeByIDRequest) (* return &types.GaugeByIDResponse{Gauge: gauge}, nil } -// Gauges returns gauges both upcoming and active +// Gauges returns gauges both upcoming and active. func (k Keeper) Gauges(goCtx context.Context, req *types.GaugesRequest) (*types.GaugesResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) gauges := []types.Gauge{} @@ -55,7 +55,6 @@ func (k Keeper) Gauges(goCtx context.Context, req *types.GaugesRequest) (*types. return true, nil }) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -63,7 +62,7 @@ func (k Keeper) Gauges(goCtx context.Context, req *types.GaugesRequest) (*types. return &types.GaugesResponse{Data: gauges, Pagination: pageRes}, nil } -// ActiveGauges returns active gauges +// ActiveGauges returns active gauges. func (k Keeper) ActiveGauges(goCtx context.Context, req *types.ActiveGaugesRequest) (*types.ActiveGaugesResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) gauges := []types.Gauge{} @@ -79,7 +78,6 @@ func (k Keeper) ActiveGauges(goCtx context.Context, req *types.ActiveGaugesReque return true, nil }) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -87,7 +85,7 @@ func (k Keeper) ActiveGauges(goCtx context.Context, req *types.ActiveGaugesReque return &types.ActiveGaugesResponse{Data: gauges, Pagination: pageRes}, nil } -// ActiveGaugesPerDenom returns active gauges for the specified denom +// ActiveGaugesPerDenom returns active gauges for the specified denom. func (k Keeper) ActiveGaugesPerDenom(goCtx context.Context, req *types.ActiveGaugesPerDenomRequest) (*types.ActiveGaugesPerDenomResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) gauges := []types.Gauge{} @@ -103,7 +101,6 @@ func (k Keeper) ActiveGaugesPerDenom(goCtx context.Context, req *types.ActiveGau } return true, nil }) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -111,7 +108,7 @@ func (k Keeper) ActiveGaugesPerDenom(goCtx context.Context, req *types.ActiveGau return &types.ActiveGaugesPerDenomResponse{Data: gauges, Pagination: pageRes}, nil } -// UpcomingGauges returns scheduled gauges +// UpcomingGauges returns scheduled gauges. func (k Keeper) UpcomingGauges(goCtx context.Context, req *types.UpcomingGaugesRequest) (*types.UpcomingGaugesResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) gauges := []types.Gauge{} @@ -127,7 +124,6 @@ func (k Keeper) UpcomingGauges(goCtx context.Context, req *types.UpcomingGaugesR return true, nil }) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -135,7 +131,7 @@ func (k Keeper) UpcomingGauges(goCtx context.Context, req *types.UpcomingGaugesR return &types.UpcomingGaugesResponse{Data: gauges, Pagination: pageRes}, nil } -// RewardsEst returns rewards estimation at a future specific time +// RewardsEst returns rewards estimation at a future specific time. func (k Keeper) RewardsEst(goCtx context.Context, req *types.RewardsEstRequest) (*types.RewardsEstResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) diff := req.EndEpoch - k.GetEpochInfo(ctx).CurrentEpoch @@ -163,7 +159,7 @@ func (k Keeper) LockableDurations(ctx context.Context, _ *types.QueryLockableDur return &types.QueryLockableDurationsResponse{LockableDurations: k.GetLockableDurations(sdkCtx)}, nil } -// getGaugeFromIDJsonBytes returns gauges from gauge id json bytes +// getGaugeFromIDJsonBytes returns gauges from gauge id json bytes. func (k Keeper) getGaugeFromIDJsonBytes(ctx sdk.Context, refValue []byte) ([]types.Gauge, error) { gauges := []types.Gauge{} gaugeIDs := []uint64{} diff --git a/x/incentives/keeper/hooks.go b/x/incentives/keeper/hooks.go index 0659bfea5dd..d2f8da30ae5 100644 --- a/x/incentives/keeper/hooks.go +++ b/x/incentives/keeper/hooks.go @@ -46,19 +46,19 @@ func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumb // ___________________________________________________________________________________________________ -// Hooks wrapper struct for incentives keeper +// Hooks wrapper struct for incentives keeper. type Hooks struct { k Keeper } var _ epochstypes.EpochHooks = Hooks{} -// Return the wrapper struct +// Return the wrapper struct. func (k Keeper) Hooks() Hooks { return Hooks{k} } -// epochs hooks +// epochs hooks. func (h Hooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) { h.k.BeforeEpochStart(ctx, epochIdentifier, epochNumber) } diff --git a/x/incentives/keeper/iterator.go b/x/incentives/keeper/iterator.go index f96e758db81..383dec9f52b 100644 --- a/x/incentives/keeper/iterator.go +++ b/x/incentives/keeper/iterator.go @@ -9,7 +9,7 @@ import ( lockuptypes "github.com/osmosis-labs/osmosis/v7/x/lockup/types" ) -// Returns an iterator over all gauges in the {prefix} space of state, that begin distributing rewards after a specific time +// Returns an iterator over all gauges in the {prefix} space of state, that begin distributing rewards after a specific time. func (k Keeper) iteratorAfterTime(ctx sdk.Context, prefix []byte, time time.Time) sdk.Iterator { store := ctx.KVStore(k.storeKey) timeKey := getTimeKey(time) @@ -29,32 +29,32 @@ func (k Keeper) iterator(ctx sdk.Context, prefix []byte) sdk.Iterator { return sdk.KVStorePrefixIterator(store, prefix) } -// UpcomingGaugesIteratorAfterTime returns the iterator to get upcoming gauges that start distribution after specific time +// UpcomingGaugesIteratorAfterTime returns the iterator to get upcoming gauges that start distribution after specific time. func (k Keeper) UpcomingGaugesIteratorAfterTime(ctx sdk.Context, time time.Time) sdk.Iterator { return k.iteratorAfterTime(ctx, types.KeyPrefixUpcomingGauges, time) } -// UpcomingGaugesIteratorBeforeTime returns the iterator to get upcoming gauges that already started distribution before specific time +// UpcomingGaugesIteratorBeforeTime returns the iterator to get upcoming gauges that already started distribution before specific time. func (k Keeper) UpcomingGaugesIteratorBeforeTime(ctx sdk.Context, time time.Time) sdk.Iterator { return k.iteratorBeforeTime(ctx, types.KeyPrefixUpcomingGauges, time) } -// GaugesIterator returns iterator for all gauges +// GaugesIterator returns iterator for all gauges. func (k Keeper) GaugesIterator(ctx sdk.Context) sdk.Iterator { return k.iterator(ctx, types.KeyPrefixGauges) } -// UpcomingGaugesIterator returns iterator for upcoming gauges +// UpcomingGaugesIterator returns iterator for upcoming gauges. func (k Keeper) UpcomingGaugesIterator(ctx sdk.Context) sdk.Iterator { return k.iterator(ctx, types.KeyPrefixUpcomingGauges) } -// ActiveGaugesIterator returns iterator for active gauges +// ActiveGaugesIterator returns iterator for active gauges. func (k Keeper) ActiveGaugesIterator(ctx sdk.Context) sdk.Iterator { return k.iterator(ctx, types.KeyPrefixActiveGauges) } -// FinishedGaugesIterator returns iterator for finished gauges +// FinishedGaugesIterator returns iterator for finished gauges. func (k Keeper) FinishedGaugesIterator(ctx sdk.Context) sdk.Iterator { return k.iterator(ctx, types.KeyPrefixFinishedGauges) } diff --git a/x/incentives/keeper/keeper.go b/x/incentives/keeper/keeper.go index 132c894ebd5..d90eac3f59a 100644 --- a/x/incentives/keeper/keeper.go +++ b/x/incentives/keeper/keeper.go @@ -36,7 +36,7 @@ func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, paramSpace paramtypes.Sub } } -// Set the gamm hooks +// Set the gamm hooks. func (k *Keeper) SetHooks(ih types.IncentiveHooks) *Keeper { if k.hooks != nil { panic("cannot set incentive hooks twice") diff --git a/x/incentives/keeper/msg_server.go b/x/incentives/keeper/msg_server.go index 369a2c0f59b..16ff28e8876 100644 --- a/x/incentives/keeper/msg_server.go +++ b/x/incentives/keeper/msg_server.go @@ -13,7 +13,7 @@ type msgServer struct { keeper *Keeper } -// NewMsgServerImpl returns an instance of MsgServer +// NewMsgServerImpl returns an instance of MsgServer. func NewMsgServerImpl(keeper *Keeper) types.MsgServer { return &msgServer{ keeper: keeper, diff --git a/x/incentives/keeper/params.go b/x/incentives/keeper/params.go index b69a95449bb..d3e82b1dc50 100644 --- a/x/incentives/keeper/params.go +++ b/x/incentives/keeper/params.go @@ -5,13 +5,13 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/incentives/types" ) -// GetParams returns the total set params +// GetParams returns the total set params. func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { k.paramSpace.GetParamSet(ctx, ¶ms) return params } -// SetParams sets the total set of params +// SetParams sets the total set of params. func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { k.paramSpace.SetParamSet(ctx, ¶ms) } diff --git a/x/incentives/keeper/store.go b/x/incentives/keeper/store.go index 95707e3d93d..31004be9bad 100644 --- a/x/incentives/keeper/store.go +++ b/x/incentives/keeper/store.go @@ -8,7 +8,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/incentives/types" ) -// GetLastGaugeID returns ID used last time +// GetLastGaugeID returns ID used last time. func (k Keeper) GetLastGaugeID(ctx sdk.Context) uint64 { store := ctx.KVStore(k.storeKey) @@ -20,13 +20,13 @@ func (k Keeper) GetLastGaugeID(ctx sdk.Context) uint64 { return sdk.BigEndianToUint64(bz) } -// SetLastGaugeID save ID used by last gauge +// SetLastGaugeID save ID used by last gauge. func (k Keeper) SetLastGaugeID(ctx sdk.Context, ID uint64) { store := ctx.KVStore(k.storeKey) store.Set(types.KeyLastGaugeID, sdk.Uint64ToBigEndian(ID)) } -// gaugeStoreKey returns action store key from ID +// gaugeStoreKey returns action store key from ID. func gaugeStoreKey(ID uint64) []byte { return combineKeys(types.KeyPrefixPeriodGauge, sdk.Uint64ToBigEndian(ID)) } @@ -35,7 +35,7 @@ func gaugeDenomStoreKey(denom string) []byte { return combineKeys(types.KeyPrefixGaugesByDenom, []byte(denom)) } -// getGaugeRefs get gauge IDs specified on the provided key +// getGaugeRefs get gauge IDs specified on the provided key. func (k Keeper) getGaugeRefs(ctx sdk.Context, key []byte) []uint64 { store := ctx.KVStore(k.storeKey) gaugeIDs := []uint64{} @@ -49,7 +49,7 @@ func (k Keeper) getGaugeRefs(ctx sdk.Context, key []byte) []uint64 { return gaugeIDs } -// addGaugeRefByKey append gauge ID into an array associated to provided key +// addGaugeRefByKey append gauge ID into an array associated to provided key. func (k Keeper) addGaugeRefByKey(ctx sdk.Context, key []byte, gaugeID uint64) error { store := ctx.KVStore(k.storeKey) gaugeIDs := k.getGaugeRefs(ctx, key) @@ -65,7 +65,7 @@ func (k Keeper) addGaugeRefByKey(ctx sdk.Context, key []byte, gaugeID uint64) er return nil } -// deleteGaugeRefByKey removes gauge ID from an array associated to provided key +// deleteGaugeRefByKey removes gauge ID from an array associated to provided key. func (k Keeper) deleteGaugeRefByKey(ctx sdk.Context, key []byte, gaugeID uint64) error { store := ctx.KVStore(k.storeKey) gaugeIDs := k.getGaugeRefs(ctx, key) @@ -85,17 +85,17 @@ func (k Keeper) deleteGaugeRefByKey(ctx sdk.Context, key []byte, gaugeID uint64) return nil } -// getAllGaugeIDsByDenom returns all active gauge-IDs associated with lockups of denomination `denom` +// getAllGaugeIDsByDenom returns all active gauge-IDs associated with lockups of denomination `denom`. func (k Keeper) getAllGaugeIDsByDenom(ctx sdk.Context, denom string) []uint64 { return k.getGaugeRefs(ctx, gaugeDenomStoreKey(denom)) } -// deleteGaugeIDForDenom deletes ID from the list of gauge ID's associated with denomination `denom` +// deleteGaugeIDForDenom deletes ID from the list of gauge ID's associated with denomination `denom`. func (k Keeper) deleteGaugeIDForDenom(ctx sdk.Context, ID uint64, denom string) error { return k.deleteGaugeRefByKey(ctx, gaugeDenomStoreKey(denom), ID) } -// addGaugeIDForDenom adds ID to the list of gauge ID's associated with denomination `denom` +// addGaugeIDForDenom adds ID to the list of gauge ID's associated with denomination `denom`. func (k Keeper) addGaugeIDForDenom(ctx sdk.Context, ID uint64, denom string) error { return k.addGaugeRefByKey(ctx, gaugeDenomStoreKey(denom), ID) } diff --git a/x/incentives/keeper/utils.go b/x/incentives/keeper/utils.go index 097d589fcaa..edbb34e7dc3 100644 --- a/x/incentives/keeper/utils.go +++ b/x/incentives/keeper/utils.go @@ -25,7 +25,7 @@ func removeValue(IDs []uint64, ID uint64) ([]uint64, int) { return IDs[:len(IDs)-1], index } -// getTimeKey returns the key used for getting a set of gauges +// getTimeKey returns the key used for getting a set of gauges. func getTimeKey(timestamp time.Time) []byte { timeBz := sdk.FormatTimeBytes(timestamp) timeBzL := len(timeBz) @@ -44,7 +44,7 @@ func getTimeKey(timestamp time.Time) []byte { return bz } -// combineKeys combine bytes array into a single bytes +// combineKeys combine bytes array into a single bytes. func combineKeys(keys ...[]byte) []byte { combined := []byte{} for i, key := range keys { diff --git a/x/incentives/module.go b/x/incentives/module.go index c5f13c578ac..61cd8dcff16 100644 --- a/x/incentives/module.go +++ b/x/incentives/module.go @@ -57,7 +57,7 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { types.RegisterCodec(cdc) } -// RegisterInterfaces registers the module's interface types +// RegisterInterfaces registers the module's interface types. func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { types.RegisterInterfaces(reg) } @@ -200,7 +200,7 @@ func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { return nil // TODO } -// RegisterStoreDecoder registers a decoder for supply module's types +// RegisterStoreDecoder registers a decoder for supply module's types. func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { // TODO } diff --git a/x/incentives/simulation/genesis.go b/x/incentives/simulation/genesis.go index 1acc0f350f4..19284e0f685 100644 --- a/x/incentives/simulation/genesis.go +++ b/x/incentives/simulation/genesis.go @@ -13,12 +13,12 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/incentives/types" ) -// Simulation parameter constants +// Simulation parameter constants. const ( ParamsDistrEpochIdentifier = "distr_epoch_identifier" ) -// RandomizedGenState generates a random GenesisState for gov +// RandomizedGenState generates a random GenesisState for gov. func RandomizedGenState(simState *module.SimulationState) { // Parameter for how often rewards get distributed var distrEpochIdentifier string diff --git a/x/incentives/simulation/operations.go b/x/incentives/simulation/operations.go index 3c378045c3d..54a61a88ca0 100644 --- a/x/incentives/simulation/operations.go +++ b/x/incentives/simulation/operations.go @@ -18,7 +18,7 @@ import ( lockuptypes "github.com/osmosis-labs/osmosis/v7/x/lockup/types" ) -// Simulation operation weights constants +// Simulation operation weights constants. const ( DefaultWeightMsgCreateGauge int = 10 DefaultWeightMsgAddToGauge int = 10 @@ -26,7 +26,7 @@ const ( OpWeightMsgAddToGauge = "op_weight_msg_add_to_gauge" ) -// WeightedOperations returns all the operations from the module with their respective weights +// WeightedOperations returns all the operations from the module with their respective weights. func WeightedOperations( appParams simtypes.AppParams, cdc codec.JSONCodec, ak stakingTypes.AccountKeeper, bk stakingTypes.BankKeeper, ek types.EpochKeeper, k keeper.Keeper, @@ -107,7 +107,7 @@ func Max(x, y int) int { return y } -// SimulateMsgCreateGauge generates a MsgCreateGauge with random values +// SimulateMsgCreateGauge generates a MsgCreateGauge with random values. func SimulateMsgCreateGauge(ak stakingTypes.AccountKeeper, bk stakingTypes.BankKeeper, ek types.EpochKeeper, k keeper.Keeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, diff --git a/x/incentives/simulation/params.go b/x/incentives/simulation/params.go index 7c4f66c5234..2a79a62a201 100644 --- a/x/incentives/simulation/params.go +++ b/x/incentives/simulation/params.go @@ -15,14 +15,12 @@ const ( keyDistrEpochIdentifier = "DistrEpochIdentifier" ) -var ( - // TODO: remove hardcoded params - // refer x/epochs/simulation/genesis.go - epochIdentifiers = []string{"day", "hour"} -) +// TODO: remove hardcoded params +// refer x/epochs/simulation/genesis.go. +var epochIdentifiers = []string{"day", "hour"} // ParamChanges defines the parameters that can be modified by param change proposals -// on the simulation +// on the simulation. func ParamChanges(r *rand.Rand) []simtypes.ParamChange { return []simtypes.ParamChange{ simulation.NewSimParamChange(types.ModuleName, keyDistrEpochIdentifier, diff --git a/x/incentives/types/events.go b/x/incentives/types/events.go index da78b14cd79..9c15cd7baa7 100644 --- a/x/incentives/types/events.go +++ b/x/incentives/types/events.go @@ -1,6 +1,6 @@ package types -// event types +// event types. const ( TypeEvtCreateGauge = "create_gauge" TypeEvtAddToGauge = "add_to_gauge" diff --git a/x/incentives/types/expected_keepers.go b/x/incentives/types/expected_keepers.go index e172284eab4..661edb05607 100644 --- a/x/incentives/types/expected_keepers.go +++ b/x/incentives/types/expected_keepers.go @@ -21,7 +21,7 @@ type BankKeeper interface { SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error } -// LockupKeeper defines the expected interface needed to retrieve locks +// LockupKeeper defines the expected interface needed to retrieve locks. type LockupKeeper interface { GetSyntheticLockup(ctx sdk.Context, lockID uint64, suffix string) (*lockuptypes.SyntheticLock, error) GetLocksPastTimeDenom(ctx sdk.Context, denom string, timestamp time.Time) []lockuptypes.PeriodLock diff --git a/x/incentives/types/genesis.go b/x/incentives/types/genesis.go index bfcd5250d21..afa224997ac 100644 --- a/x/incentives/types/genesis.go +++ b/x/incentives/types/genesis.go @@ -8,10 +8,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec" ) -// DefaultIndex is the default capability global index +// DefaultIndex is the default capability global index. const DefaultIndex uint64 = 1 -// DefaultGenesis returns the default Capability genesis state +// DefaultGenesis returns the default Capability genesis state. func DefaultGenesis() *GenesisState { return &GenesisState{ Params: Params{ diff --git a/x/incentives/types/hooks.go b/x/incentives/types/hooks.go index 8eb0d396c18..08c81719b4e 100644 --- a/x/incentives/types/hooks.go +++ b/x/incentives/types/hooks.go @@ -12,7 +12,7 @@ type IncentiveHooks interface { var _ IncentiveHooks = MultiIncentiveHooks{} -// combine multiple incentive hooks, all hook functions are run in array sequence +// combine multiple incentive hooks, all hook functions are run in array sequence. type MultiIncentiveHooks []IncentiveHooks func NewMultiIncentiveHooks(hooks ...IncentiveHooks) MultiIncentiveHooks { diff --git a/x/incentives/types/keys.go b/x/incentives/types/keys.go index 98925484148..c486adac413 100644 --- a/x/incentives/types/keys.go +++ b/x/incentives/types/keys.go @@ -1,49 +1,49 @@ package types var ( - // ModuleName defines the module name + // ModuleName defines the module name. ModuleName = "incentives" - // StoreKey defines the primary module store key + // StoreKey defines the primary module store key. StoreKey = ModuleName - // RouterKey is the message route for slashing + // RouterKey is the message route for slashing. RouterKey = ModuleName - // QuerierRoute defines the module's query routing key + // QuerierRoute defines the module's query routing key. QuerierRoute = ModuleName - // MemStoreKey defines the in-memory store key + // MemStoreKey defines the in-memory store key. MemStoreKey = "mem_capability" - // KeyPrefixTimestamp defines prefix key for timestamp iterator key + // KeyPrefixTimestamp defines prefix key for timestamp iterator key. KeyPrefixTimestamp = []byte{0x01} - // KeyLastGaugeID defines key for setting last gauge ID + // KeyLastGaugeID defines key for setting last gauge ID. KeyLastGaugeID = []byte{0x02} - // KeyPrefixPeriodGauge defines prefix key for storing gauges + // KeyPrefixPeriodGauge defines prefix key for storing gauges. KeyPrefixPeriodGauge = []byte{0x03} - // KeyPrefixGauges defines prefix key for storing reference key for all gauges + // KeyPrefixGauges defines prefix key for storing reference key for all gauges. KeyPrefixGauges = []byte{0x04} - // KeyPrefixUpcomingGauges defines prefix key for storing reference key for upcoming gauges + // KeyPrefixUpcomingGauges defines prefix key for storing reference key for upcoming gauges. KeyPrefixUpcomingGauges = []byte{0x04, 0x00} - // KeyPrefixActiveGauges defines prefix key for storing reference key for active gauges + // KeyPrefixActiveGauges defines prefix key for storing reference key for active gauges. KeyPrefixActiveGauges = []byte{0x04, 0x01} - // KeyPrefixFinishedGauges defines prefix key for storing reference key for finished gauges + // KeyPrefixFinishedGauges defines prefix key for storing reference key for finished gauges. KeyPrefixFinishedGauges = []byte{0x04, 0x02} - // KeyPrefixGaugesByDenom defines prefix key for storing indexes of gauge IDs by denomination + // KeyPrefixGaugesByDenom defines prefix key for storing indexes of gauge IDs by denomination. KeyPrefixGaugesByDenom = []byte{0x05} - // KeyIndexSeparator defines key for merging bytes + // KeyIndexSeparator defines key for merging bytes. KeyIndexSeparator = []byte{0x07} - // LockableDurationsKey defines key for storing valid durations for giving incentives + // LockableDurationsKey defines key for storing valid durations for giving incentives. LockableDurationsKey = []byte("lockable_durations") ) diff --git a/x/incentives/types/msgs.go b/x/incentives/types/msgs.go index 020601f2580..0a6d6cee771 100644 --- a/x/incentives/types/msgs.go +++ b/x/incentives/types/msgs.go @@ -8,7 +8,7 @@ import ( lockuptypes "github.com/osmosis-labs/osmosis/v7/x/lockup/types" ) -// constants +// constants. const ( TypeMsgCreateGauge = "create_gauge" TypeMsgAddToGauge = "add_to_gauge" @@ -16,7 +16,7 @@ const ( var _ sdk.Msg = &MsgCreateGauge{} -// NewMsgCreateGauge creates a message to create a gauge +// NewMsgCreateGauge creates a message to create a gauge. func NewMsgCreateGauge(isPerpetual bool, owner sdk.AccAddress, distributeTo lockuptypes.QueryCondition, coins sdk.Coins, startTime time.Time, numEpochsPaidOver uint64) *MsgCreateGauge { return &MsgCreateGauge{ IsPerpetual: isPerpetual, @@ -56,9 +56,11 @@ func (m MsgCreateGauge) ValidateBasic() error { return nil } + func (m MsgCreateGauge) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } + func (m MsgCreateGauge) GetSigners() []sdk.AccAddress { owner, _ := sdk.AccAddressFromBech32(m.Owner) return []sdk.AccAddress{owner} @@ -66,7 +68,7 @@ func (m MsgCreateGauge) GetSigners() []sdk.AccAddress { var _ sdk.Msg = &MsgAddToGauge{} -// NewMsgCreateGauge creates a message to create a gauge +// NewMsgCreateGauge creates a message to create a gauge. func NewMsgAddToGauge(owner sdk.AccAddress, gaugeId uint64, rewards sdk.Coins) *MsgAddToGauge { return &MsgAddToGauge{ Owner: owner.String(), @@ -87,9 +89,11 @@ func (m MsgAddToGauge) ValidateBasic() error { return nil } + func (m MsgAddToGauge) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } + func (m MsgAddToGauge) GetSigners() []sdk.AccAddress { owner, _ := sdk.AccAddressFromBech32(m.Owner) return []sdk.AccAddress{owner} diff --git a/x/incentives/types/params.go b/x/incentives/types/params.go index 1064b1a4b3e..d88ff742bc8 100644 --- a/x/incentives/types/params.go +++ b/x/incentives/types/params.go @@ -5,7 +5,7 @@ import ( epochtypes "github.com/osmosis-labs/osmosis/v7/x/epochs/types" ) -// Parameter store keys +// Parameter store keys. var ( KeyDistrEpochIdentifier = []byte("DistrEpochIdentifier") ) @@ -21,14 +21,14 @@ func NewParams(distrEpochIdentifier string) Params { } } -// default minting module parameters +// default minting module parameters. func DefaultParams() Params { return Params{ DistrEpochIdentifier: "week", } } -// validate params +// validate params. func (p Params) Validate() error { if err := epochtypes.ValidateEpochIdentifierInterface(p.DistrEpochIdentifier); err != nil { return err @@ -36,7 +36,7 @@ func (p Params) Validate() error { return nil } -// Implements params.ParamSet +// Implements params.ParamSet. func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyDistrEpochIdentifier, &p.DistrEpochIdentifier, epochtypes.ValidateEpochIdentifierInterface), diff --git a/x/lockup/abci.go b/x/lockup/abci.go index 5125d56353d..3448b65a6e3 100644 --- a/x/lockup/abci.go +++ b/x/lockup/abci.go @@ -7,11 +7,11 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/lockup/keeper" ) -// BeginBlocker is called on every block +// BeginBlocker is called on every block. func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper) { } -// Called every block to automatically unlock matured locks +// Called every block to automatically unlock matured locks. func EndBlocker(ctx sdk.Context, k keeper.Keeper) []abci.ValidatorUpdate { // disable automatic withdraw before specific block height // it is actually for testing with legacy diff --git a/x/lockup/client/cli/cli_test.go b/x/lockup/client/cli/cli_test.go index be406156770..b9f87c57c86 100644 --- a/x/lockup/client/cli/cli_test.go +++ b/x/lockup/client/cli/cli_test.go @@ -129,7 +129,7 @@ func (s *IntegrationTestSuite) TestNewLockTokensCmd() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -196,7 +196,7 @@ func (s *IntegrationTestSuite) TestBeginUnlockingCmd() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -232,7 +232,7 @@ func (s *IntegrationTestSuite) TestNewBeginUnlockPeriodLockCmd() { sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(200))), "1s") s.Require().NoError(err) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) // This is a hardcoded path in the events to get the lockID // this is incredibly brittle... // fmt.Println(txResp.Logs[0]) @@ -274,7 +274,7 @@ func (s *IntegrationTestSuite) TestNewBeginUnlockPeriodLockCmd() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) txResp := tc.respType.(*sdk.TxResponse) s.Require().Equal(tc.expectedCode, txResp.Code, out.String()) @@ -312,7 +312,7 @@ func (s *IntegrationTestSuite) TestCmdAccountUnlockableCoins() { s.Require().NoError(err) var result types.AccountUnlockableCoinsResponse - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &result)) s.Require().Equal(tc.coins.String(), result.Coins.String()) }) } @@ -347,7 +347,7 @@ func (s *IntegrationTestSuite) TestCmdAccountUnlockingCoins() { s.Require().NoError(err) var result types.AccountUnlockingCoinsResponse - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &result)) s.Require().Equal(tc.coins.String(), result.Coins.String()) }) } @@ -381,7 +381,7 @@ func (s IntegrationTestSuite) TestCmdModuleBalance() { s.Require().NoError(err) var result types.ModuleBalanceResponse - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &result)) s.Require().Equal(tc.coins.String(), result.Coins.String()) }) } @@ -415,7 +415,7 @@ func (s IntegrationTestSuite) TestCmdModuleLockedAmount() { s.Require().NoError(err) var result types.ModuleLockedAmountResponse - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &result)) s.Require().Equal(tc.coins.String(), result.Coins.String()) }) } @@ -450,7 +450,7 @@ func (s IntegrationTestSuite) TestCmdAccountLockedCoins() { s.Require().NoError(err) var result types.ModuleLockedAmountResponse - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &result)) s.Require().Equal(tc.coins.String(), result.Coins.String()) }) } @@ -485,7 +485,7 @@ func (s IntegrationTestSuite) TestCmdAccountLockedPastTime() { s.Require().NoError(err) var result types.AccountLockedPastTimeResponse - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &result)) s.Require().Len(result.Locks, 1) }) } @@ -520,7 +520,7 @@ func (s IntegrationTestSuite) TestCmdAccountLockedPastTimeNotUnlockingOnly() { s.Require().NoError(err) var result types.AccountLockedPastTimeNotUnlockingOnlyResponse - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &result)) s.Require().Len(result.Locks, 0) }) } @@ -555,7 +555,7 @@ func (s IntegrationTestSuite) TestCmdAccountUnlockedBeforeTime() { s.Require().NoError(err) var result types.AccountUnlockedBeforeTimeResponse - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &result)) s.Require().Len(result.Locks, 0) }) } @@ -591,7 +591,7 @@ func (s IntegrationTestSuite) TestCmdAccountLockedPastTimeDenom() { s.Require().NoError(err) var result types.AccountLockedPastTimeDenomResponse - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &result)) s.Require().Len(result.Locks, 1) }) } @@ -624,7 +624,7 @@ func (s IntegrationTestSuite) TestCmdLockedByID() { s.Require().NoError(err) var result types.LockedResponse - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &result)) s.Require().Equal(result.Lock.ID, uint64(1)) }) } @@ -658,7 +658,7 @@ func (s IntegrationTestSuite) TestCmdAccountLockedLongerDuration() { s.Require().NoError(err) var result types.AccountLockedLongerDurationResponse - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &result)) s.Require().Len(result.Locks, 1) }) } @@ -692,7 +692,7 @@ func (s IntegrationTestSuite) TestCmdAccountLockedLongerDurationNotUnlockingOnly s.Require().NoError(err) var result types.AccountLockedLongerDurationNotUnlockingOnlyResponse - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &result)) s.Require().Len(result.Locks, 0) }) } @@ -727,7 +727,7 @@ func (s IntegrationTestSuite) TestCmdAccountLockedLongerDurationDenom() { s.Require().NoError(err) var result types.AccountLockedLongerDurationDenomResponse - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &result)) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &result)) s.Require().Len(result.Locks, 1) }) } diff --git a/x/lockup/client/cli/flags.go b/x/lockup/client/cli/flags.go index 058c043840e..dbe3218f773 100644 --- a/x/lockup/client/cli/flags.go +++ b/x/lockup/client/cli/flags.go @@ -4,14 +4,14 @@ import ( flag "github.com/spf13/pflag" ) -// flags for lockup module tx commands +// flags for lockup module tx commands. const ( FlagDuration = "duration" FlagMinDuration = "min-duration" FlagAmount = "amount" ) -// FlagSetLockTokens returns flags for LockTokens msg builder +// FlagSetLockTokens returns flags for LockTokens msg builder. func FlagSetLockTokens() *flag.FlagSet { fs := flag.NewFlagSet("", flag.ContinueOnError) diff --git a/x/lockup/client/cli/query.go b/x/lockup/client/cli/query.go index 6c789e12801..7100d4670b6 100644 --- a/x/lockup/client/cli/query.go +++ b/x/lockup/client/cli/query.go @@ -19,7 +19,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/lockup/types" ) -// GetQueryCmd returns the cli query commands for this module +// GetQueryCmd returns the cli query commands for this module. func GetQueryCmd(queryRoute string) *cobra.Command { // Group lockup queries under a subcommand cmd := &cobra.Command{ @@ -52,7 +52,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { return cmd } -// GetCmdModuleBalance returns full balance of the module +// GetCmdModuleBalance returns full balance of the module. func GetCmdModuleBalance() *cobra.Command { cmd := &cobra.Command{ Use: "module-balance", @@ -88,7 +88,7 @@ $ %s query lockup module-balance return cmd } -// GetCmdModuleLockedAmount returns locked balance of the module +// GetCmdModuleLockedAmount returns locked balance of the module. func GetCmdModuleLockedAmount() *cobra.Command { cmd := &cobra.Command{ Use: "module-locked-amount", @@ -124,7 +124,7 @@ $ %s query lockup module-locked-amount return cmd } -// GetCmdAccountUnlockableCoins returns unlockable coins which are not withdrawn yet +// GetCmdAccountUnlockableCoins returns unlockable coins which are not withdrawn yet. func GetCmdAccountUnlockableCoins() *cobra.Command { cmd := &cobra.Command{ Use: "account-unlockable-coins
", @@ -161,7 +161,7 @@ $ %s query lockup account-unlockable-coins
return cmd } -// GetCmdAccountUnlockingCoins returns unlocking coins +// GetCmdAccountUnlockingCoins returns unlocking coins. func GetCmdAccountUnlockingCoins() *cobra.Command { cmd := &cobra.Command{ Use: "account-unlocking-coins
", @@ -198,7 +198,7 @@ $ %s query lockup account-unlocking-coins
return cmd } -// GetCmdAccountLockedCoins returns locked coins that can't be withdrawn +// GetCmdAccountLockedCoins returns locked coins that can't be withdrawn. func GetCmdAccountLockedCoins() *cobra.Command { cmd := &cobra.Command{ Use: "account-locked-coins
", @@ -235,16 +235,16 @@ $ %s query lockup account-locked-coins
return cmd } -// GetCmdAccountLockedPastTime returns locked records of an account with unlock time beyond timestamp +// GetCmdAccountLockedPastTime returns locked records of an account with unlock time beyond timestamp. func GetCmdAccountLockedPastTime() *cobra.Command { cmd := &cobra.Command{ - Use: "account-locked-pasttime
", + Use: "account-locked-pastime
", Short: "Query locked records of an account with unlock time beyond timestamp", Long: strings.TrimSpace( fmt.Sprintf(`Query locked records of an account with unlock time beyond timestamp. Example: -$ %s query lockup account-locked-pasttime
+$ %s query lockup account-locked-pastime
`, version.AppName, ), @@ -278,16 +278,16 @@ $ %s query lockup account-locked-pasttime
return cmd } -// GetCmdAccountLockedPastTimeNotUnlockingOnly returns locked records of an account with unlock time beyond timestamp within not unlocking queue +// GetCmdAccountLockedPastTimeNotUnlockingOnly returns locked records of an account with unlock time beyond timestamp within not unlocking queue. func GetCmdAccountLockedPastTimeNotUnlockingOnly() *cobra.Command { cmd := &cobra.Command{ - Use: "account-locked-pasttime-not-unlocking
", + Use: "account-locked-pastime-not-unlocking
", Short: "Query locked records of an account with unlock time beyond timestamp within not unlocking queue", Long: strings.TrimSpace( fmt.Sprintf(`Query locked records of an account with unlock time beyond timestamp within not unlocking queue. Example: -$ %s query lockup account-locked-pasttime-not-unlocking
+$ %s query lockup account-locked-pastime-not-unlocking
`, version.AppName, ), @@ -321,7 +321,7 @@ $ %s query lockup account-locked-pasttime-not-unlocking
return cmd } -// GetCmdAccountUnlockedBeforeTime returns unlocked records with unlock time before timestamp +// GetCmdAccountUnlockedBeforeTime returns unlocked records with unlock time before timestamp. func GetCmdAccountUnlockedBeforeTime() *cobra.Command { cmd := &cobra.Command{ Use: "account-locked-beforetime
", @@ -330,7 +330,7 @@ func GetCmdAccountUnlockedBeforeTime() *cobra.Command { fmt.Sprintf(`Query account's the total unlocked records with unlock time before timestamp. Example: -$ %s query lockup account-locked-pasttime
+$ %s query lockup account-locked-pastime
`, version.AppName, ), @@ -364,16 +364,16 @@ $ %s query lockup account-locked-pasttime
return cmd } -// GetCmdAccountLockedPastTimeDenom returns lock records by address, timestamp, denom +// GetCmdAccountLockedPastTimeDenom returns lock records by address, timestamp, denom. func GetCmdAccountLockedPastTimeDenom() *cobra.Command { cmd := &cobra.Command{ - Use: "account-locked-pasttime-denom
", + Use: "account-locked-pastime-denom
", Short: "Query account's lock records by address, timestamp, denom", Long: strings.TrimSpace( fmt.Sprintf(`Query account's lock records by address, timestamp, denom. Example: -$ %s query lockup account-locked-pasttime-denom
+$ %s query lockup account-locked-pastime-denom
`, version.AppName, ), @@ -409,7 +409,7 @@ $ %s query lockup account-locked-pasttime-denom
return cmd } -// GetCmdLockedByID returns lock record by id +// GetCmdLockedByID returns lock record by id. func GetCmdLockedByID() *cobra.Command { cmd := &cobra.Command{ Use: "lock-by-id ", @@ -451,7 +451,7 @@ $ %s query lockup lock-by-id return cmd } -// GetCmdSyntheticLockupsByLockupID returns synthetic lockups by lockup id +// GetCmdSyntheticLockupsByLockupID returns synthetic lockups by lockup id. func GetCmdSyntheticLockupsByLockupID() *cobra.Command { cmd := &cobra.Command{ Use: "synthetic-lockups-by-lock-id ", @@ -493,7 +493,7 @@ $ %s query lockup synthetic-lockups-by-lock-id return cmd } -// GetCmdAccountLockedLongerDuration returns account locked records with longer duration +// GetCmdAccountLockedLongerDuration returns account locked records with longer duration. func GetCmdAccountLockedLongerDuration() *cobra.Command { cmd := &cobra.Command{ Use: "account-locked-longer-duration
", @@ -535,7 +535,7 @@ $ %s query lockup account-locked-longer-duration
return cmd } -// GetCmdAccountLockedLongerDurationNotUnlockingOnly returns account locked records with longer duration from unlocking only queue +// GetCmdAccountLockedLongerDurationNotUnlockingOnly returns account locked records with longer duration from unlocking only queue. func GetCmdAccountLockedLongerDurationNotUnlockingOnly() *cobra.Command { cmd := &cobra.Command{ Use: "account-locked-longer-duration-not-unlocking
", @@ -577,7 +577,7 @@ $ %s query lockup account-locked-longer-duration-not-unlocking
", @@ -586,7 +586,7 @@ func GetCmdAccountLockedLongerDurationDenom() *cobra.Command { fmt.Sprintf(`Query account's locked records for a denom with longer duration. Example: -$ %s query lockup account-locked-pasttime
+$ %s query lockup account-locked-pastime
`, version.AppName, ), @@ -621,7 +621,7 @@ $ %s query lockup account-locked-pasttime
return cmd } -// GetCmdTotalBondedByDenom returns total amount of locked asset +// GetCmdTotalBondedByDenom returns total amount of locked asset. func GetCmdTotalLockedByDenom() *cobra.Command { cmd := &cobra.Command{ Use: "total-locked-of-denom ", @@ -669,7 +669,7 @@ $ %s query lockup total-locked-of-denom return cmd } -// GetCmdOutputLocksJson outputs all locks into a file called lock_export.json +// GetCmdOutputLocksJson outputs all locks into a file called lock_export.json. func GetCmdOutputLocksJson() *cobra.Command { cmd := &cobra.Command{ Use: "output-all-locks ", @@ -737,7 +737,7 @@ $ %s query lockup output-all-locks if err != nil { return err } - err = ioutil.WriteFile("lock_export.json", []byte(bz), 0777) + err = ioutil.WriteFile("lock_export.json", bz, 0o777) if err != nil { return err } diff --git a/x/lockup/client/cli/tx.go b/x/lockup/client/cli/tx.go index f0b6f6838db..603f2aa3ea9 100644 --- a/x/lockup/client/cli/tx.go +++ b/x/lockup/client/cli/tx.go @@ -14,7 +14,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/lockup/types" ) -// GetTxCmd returns the transaction commands for this module +// GetTxCmd returns the transaction commands for this module. func GetTxCmd() *cobra.Command { cmd := &cobra.Command{ Use: types.ModuleName, @@ -33,7 +33,7 @@ func GetTxCmd() *cobra.Command { return cmd } -// NewLockTokensCmd lock tokens into lockup pool from user's account +// NewLockTokensCmd lock tokens into lockup pool from user's account. func NewLockTokensCmd() *cobra.Command { cmd := &cobra.Command{ Use: "lock-tokens [tokens]", @@ -80,7 +80,7 @@ func NewLockTokensCmd() *cobra.Command { return cmd } -// NewBeginUnlockingCmd unlock all unlockable tokens from user's account +// NewBeginUnlockingCmd unlock all unlockable tokens from user's account. func NewBeginUnlockingCmd() *cobra.Command { cmd := &cobra.Command{ Use: "begin-unlock-tokens", @@ -106,7 +106,7 @@ func NewBeginUnlockingCmd() *cobra.Command { return cmd } -// NewBeginUnlockByIDCmd unlock individual period lock by ID +// NewBeginUnlockByIDCmd unlock individual period lock by ID. func NewBeginUnlockByIDCmd() *cobra.Command { cmd := &cobra.Command{ Use: "begin-unlock-by-id [id]", diff --git a/x/lockup/client/rest/query.go b/x/lockup/client/rest/query.go index a87987efe0d..c7eaeb958d1 100644 --- a/x/lockup/client/rest/query.go +++ b/x/lockup/client/rest/query.go @@ -283,7 +283,6 @@ func queryAccountLockedLongerDurationFn(clientCtx client.Context) http.HandlerFu func queryAccountLockedLongerDurationDenomFn(clientCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) strOwnerAddress := vars[RestOwnerAddress] owner, err := sdk.AccAddressFromBech32(strOwnerAddress) diff --git a/x/lockup/client/rest/rest.go b/x/lockup/client/rest/rest.go index 28af3f62afd..60a4faee74d 100644 --- a/x/lockup/client/rest/rest.go +++ b/x/lockup/client/rest/rest.go @@ -19,14 +19,14 @@ const ( RestDuration = "duration" ) -// RegisterRoutes register query and tx rest routes +// RegisterRoutes register query and tx rest routes. func RegisterRoutes(clientCtx client.Context, rtr *mux.Router) { r := clientrest.WithHTTPDeprecationHeaders(rtr) registerQueryRoutes(clientCtx, r) registerTxHandlers(clientCtx, r) } -// LockTokensReq defines the properties of a MsgLockTokens request +// LockTokensReq defines the properties of a MsgLockTokens request. type LockTokensReq struct { BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` Owner sdk.AccAddress `json:"owner,omitempty" yaml:"owner"` diff --git a/x/lockup/client/testutil/test_helpers.go b/x/lockup/client/testutil/test_helpers.go index 7b27ca6b8ff..174a29c44cc 100644 --- a/x/lockup/client/testutil/test_helpers.go +++ b/x/lockup/client/testutil/test_helpers.go @@ -11,7 +11,7 @@ import ( lockupcli "github.com/osmosis-labs/osmosis/v7/x/lockup/client/cli" ) -// commonArgs is args for CLI test commands +// commonArgs is args for CLI test commands. var commonArgs = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), @@ -20,7 +20,6 @@ var commonArgs = []string{ // MsgLockTokens creates a lock tokens message. func MsgLockTokens(clientCtx client.Context, owner fmt.Stringer, amount fmt.Stringer, duration string, extraArgs ...string) (testutil.BufferWriter, error) { - args := []string{ amount.String(), fmt.Sprintf("--%s=%s", lockupcli.FlagDuration, duration), @@ -31,9 +30,8 @@ func MsgLockTokens(clientCtx client.Context, owner fmt.Stringer, amount fmt.Stri return clitestutil.ExecTestCLICmd(clientCtx, lockupcli.NewLockTokensCmd(), args) } -// MsgBeginUnlocking creates a begin unlock tokens message +// MsgBeginUnlocking creates a begin unlock tokens message. func MsgBeginUnlocking(clientCtx client.Context, owner fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) { - args := []string{ fmt.Sprintf("--%s=%s", flags.FlagFrom, owner.String()), fmt.Sprintf("--%s=%d", flags.FlagGas, 500000), diff --git a/x/lockup/keeper/admin_keeper.go b/x/lockup/keeper/admin_keeper.go index 5880d992637..f663307bd41 100644 --- a/x/lockup/keeper/admin_keeper.go +++ b/x/lockup/keeper/admin_keeper.go @@ -6,7 +6,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/lockup/types" ) -// Relock unlock previous lockID and create a new lock with newCoins with same duration and endtime +// Relock unlock previous lockID and create a new lock with newCoins with same duration and endtime. func (ak AdminKeeper) Relock(ctx sdk.Context, lockID uint64, newCoins sdk.Coins) error { lock, err := ak.GetLockByID(ctx, lockID) if err != nil { @@ -41,7 +41,7 @@ func (ak AdminKeeper) Relock(ctx sdk.Context, lockID uint64, newCoins sdk.Coins) return nil } -// BreakLock unlock a lockID without considering time with admin priviledge +// BreakLock unlock a lockID without considering time with admin privilege. func (ak AdminKeeper) BreakLock(ctx sdk.Context, lockID uint64) error { lock, err := ak.GetLockByID(ctx, lockID) if err != nil { diff --git a/x/lockup/keeper/grpc_query.go b/x/lockup/keeper/grpc_query.go index b67008a66c8..7bcac34c20a 100644 --- a/x/lockup/keeper/grpc_query.go +++ b/x/lockup/keeper/grpc_query.go @@ -10,19 +10,19 @@ import ( var _ types.QueryServer = Keeper{} -// ModuleBalance Return full balance of the module +// ModuleBalance Return full balance of the module. func (k Keeper) ModuleBalance(goCtx context.Context, req *types.ModuleBalanceRequest) (*types.ModuleBalanceResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) return &types.ModuleBalanceResponse{Coins: k.GetModuleBalance(ctx)}, nil } -// ModuleLockedAmount Returns locked balance of the module +// ModuleLockedAmount Returns locked balance of the module. func (k Keeper) ModuleLockedAmount(goCtx context.Context, req *types.ModuleLockedAmountRequest) (*types.ModuleLockedAmountResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) return &types.ModuleLockedAmountResponse{Coins: k.GetModuleLockedCoins(ctx)}, nil } -// AccountUnlockableCoins returns unlockable coins which are not withdrawn yet +// AccountUnlockableCoins returns unlockable coins which are not withdrawn yet. func (k Keeper) AccountUnlockableCoins(goCtx context.Context, req *types.AccountUnlockableCoinsRequest) (*types.AccountUnlockableCoinsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) owner, err := sdk.AccAddressFromBech32(req.Owner) @@ -34,7 +34,7 @@ func (k Keeper) AccountUnlockableCoins(goCtx context.Context, req *types.Account return &types.AccountUnlockableCoinsResponse{Coins: k.GetAccountUnlockableCoins(ctx, owner)}, nil } -// AccountUnlockingCoins returns whole unlocking coins +// AccountUnlockingCoins returns whole unlocking coins. func (k Keeper) AccountUnlockingCoins(goCtx context.Context, req *types.AccountUnlockingCoinsRequest) (*types.AccountUnlockingCoinsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) owner, err := sdk.AccAddressFromBech32(req.Owner) @@ -46,7 +46,7 @@ func (k Keeper) AccountUnlockingCoins(goCtx context.Context, req *types.AccountU return &types.AccountUnlockingCoinsResponse{Coins: k.GetAccountUnlockingCoins(ctx, owner)}, nil } -// AccountLockedCoins Returns a locked coins that can't be withdrawn +// AccountLockedCoins Returns a locked coins that can't be withdrawn. func (k Keeper) AccountLockedCoins(goCtx context.Context, req *types.AccountLockedCoinsRequest) (*types.AccountLockedCoinsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) owner, err := sdk.AccAddressFromBech32(req.Owner) @@ -58,7 +58,7 @@ func (k Keeper) AccountLockedCoins(goCtx context.Context, req *types.AccountLock return &types.AccountLockedCoinsResponse{Coins: k.GetAccountLockedCoins(ctx, owner)}, nil } -// AccountLockedPastTime Returns the total locks of an account whose unlock time is beyond timestamp +// AccountLockedPastTime Returns the total locks of an account whose unlock time is beyond timestamp. func (k Keeper) AccountLockedPastTime(goCtx context.Context, req *types.AccountLockedPastTimeRequest) (*types.AccountLockedPastTimeResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) owner, err := sdk.AccAddressFromBech32(req.Owner) @@ -70,7 +70,7 @@ func (k Keeper) AccountLockedPastTime(goCtx context.Context, req *types.AccountL return &types.AccountLockedPastTimeResponse{Locks: k.GetAccountLockedPastTime(ctx, owner, req.Timestamp)}, nil } -// AccountUnlockedBeforeTime Returns the total unlocks of an account whose unlock time is before timestamp +// AccountUnlockedBeforeTime Returns the total unlocks of an account whose unlock time is before timestamp. func (k Keeper) AccountUnlockedBeforeTime(goCtx context.Context, req *types.AccountUnlockedBeforeTimeRequest) (*types.AccountUnlockedBeforeTimeResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) owner, err := sdk.AccAddressFromBech32(req.Owner) @@ -83,7 +83,7 @@ func (k Keeper) AccountUnlockedBeforeTime(goCtx context.Context, req *types.Acco return &types.AccountUnlockedBeforeTimeResponse{Locks: k.GetAccountUnlockedBeforeTime(ctx, owner, req.Timestamp)}, nil } -// AccountLockedPastTimeDenom is equal to GetAccountLockedPastTime but denom specific +// AccountLockedPastTimeDenom is equal to GetAccountLockedPastTime but denom specific. func (k Keeper) AccountLockedPastTimeDenom(goCtx context.Context, req *types.AccountLockedPastTimeDenomRequest) (*types.AccountLockedPastTimeDenomResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) owner, err := sdk.AccAddressFromBech32(req.Owner) @@ -95,21 +95,21 @@ func (k Keeper) AccountLockedPastTimeDenom(goCtx context.Context, req *types.Acc return &types.AccountLockedPastTimeDenomResponse{Locks: k.GetAccountLockedPastTimeDenom(ctx, owner, req.Denom, req.Timestamp)}, nil } -// LockedByID Returns lock by lock ID +// LockedByID Returns lock by lock ID. func (k Keeper) LockedByID(goCtx context.Context, req *types.LockedRequest) (*types.LockedResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) lock, err := k.GetLockByID(ctx, req.LockId) return &types.LockedResponse{Lock: lock}, err } -// SyntheticLockupsByLockupID returns synthetic lockups by native lockup id +// SyntheticLockupsByLockupID returns synthetic lockups by native lockup id. func (k Keeper) SyntheticLockupsByLockupID(goCtx context.Context, req *types.SyntheticLockupsByLockupIDRequest) (*types.SyntheticLockupsByLockupIDResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) synthLocks := k.GetAllSyntheticLockupsByLockup(ctx, req.LockId) return &types.SyntheticLockupsByLockupIDResponse{SyntheticLocks: synthLocks}, nil } -// AccountLockedLongerDuration Returns account locked with duration longer than specified +// AccountLockedLongerDuration Returns account locked with duration longer than specified. func (k Keeper) AccountLockedLongerDuration(goCtx context.Context, req *types.AccountLockedLongerDurationRequest) (*types.AccountLockedLongerDurationResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) owner, err := sdk.AccAddressFromBech32(req.Owner) @@ -122,7 +122,7 @@ func (k Keeper) AccountLockedLongerDuration(goCtx context.Context, req *types.Ac return &types.AccountLockedLongerDurationResponse{Locks: locks}, nil } -// AccountLockedLongerDurationDenom Returns account locked with duration longer than specified with specific denom +// AccountLockedLongerDurationDenom Returns account locked with duration longer than specified with specific denom. func (k Keeper) AccountLockedLongerDurationDenom(goCtx context.Context, req *types.AccountLockedLongerDurationDenomRequest) (*types.AccountLockedLongerDurationDenomResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) owner, err := sdk.AccAddressFromBech32(req.Owner) @@ -135,7 +135,7 @@ func (k Keeper) AccountLockedLongerDurationDenom(goCtx context.Context, req *typ return &types.AccountLockedLongerDurationDenomResponse{Locks: locks}, nil } -// AccountLockedPastTimeNotUnlockingOnly Returns locked records of an account with unlock time beyond timestamp excluding tokens started unlocking +// AccountLockedPastTimeNotUnlockingOnly Returns locked records of an account with unlock time beyond timestamp excluding tokens started unlocking. func (k Keeper) AccountLockedPastTimeNotUnlockingOnly(goCtx context.Context, req *types.AccountLockedPastTimeNotUnlockingOnlyRequest) (*types.AccountLockedPastTimeNotUnlockingOnlyResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) owner, err := sdk.AccAddressFromBech32(req.Owner) @@ -147,7 +147,7 @@ func (k Keeper) AccountLockedPastTimeNotUnlockingOnly(goCtx context.Context, req return &types.AccountLockedPastTimeNotUnlockingOnlyResponse{Locks: k.GetAccountLockedPastTimeNotUnlockingOnly(ctx, owner, req.Timestamp)}, nil } -// AccountLockedLongerDurationNotUnlockingOnly Returns account locked records with longer duration excluding tokens started unlocking +// AccountLockedLongerDurationNotUnlockingOnly Returns account locked records with longer duration excluding tokens started unlocking. func (k Keeper) AccountLockedLongerDurationNotUnlockingOnly(goCtx context.Context, req *types.AccountLockedLongerDurationNotUnlockingOnlyRequest) (*types.AccountLockedLongerDurationNotUnlockingOnlyResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) owner, err := sdk.AccAddressFromBech32(req.Owner) diff --git a/x/lockup/keeper/invariants.go b/x/lockup/keeper/invariants.go index 007f768ae6f..5e1241bf23a 100644 --- a/x/lockup/keeper/invariants.go +++ b/x/lockup/keeper/invariants.go @@ -10,7 +10,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/gamm/types" ) -// RegisterInvariants registers all governance invariants +// RegisterInvariants registers all governance invariants. func RegisterInvariants(ir sdk.InvariantRegistry, keeper Keeper) { ir.RegisterRoute(types.ModuleName, "synthetic-lockup-invariant", SyntheticLockupInvariant(keeper)) } diff --git a/x/lockup/keeper/iterator.go b/x/lockup/keeper/iterator.go index fab4caa7626..37850e2c1a9 100644 --- a/x/lockup/keeper/iterator.go +++ b/x/lockup/keeper/iterator.go @@ -25,7 +25,7 @@ func (k Keeper) iteratorAfterTime(ctx sdk.Context, prefix []byte, time time.Time return store.Iterator(storetypes.PrefixEndBytes(key), storetypes.PrefixEndBytes(prefix)) } -// iterate through keys between that use prefix, and have a time LTE max time +// iterate through keys between that use prefix, and have a time LTE max time. func (k Keeper) iteratorBeforeTime(ctx sdk.Context, prefix []byte, maxTime time.Time) sdk.Iterator { store := ctx.KVStore(k.storeKey) timeKey := getTimeKey(maxTime) @@ -63,103 +63,103 @@ func (k Keeper) iterator(ctx sdk.Context, prefix []byte) sdk.Iterator { return sdk.KVStorePrefixIterator(store, prefix) } -// LockIteratorAfterTime returns the iterator to get locked coins +// LockIteratorAfterTime returns the iterator to get locked coins. func (k Keeper) LockIteratorAfterTime(ctx sdk.Context, time time.Time) sdk.Iterator { unlockingPrefix := unlockingPrefix(true) return k.iteratorAfterTime(ctx, combineKeys(unlockingPrefix, types.KeyPrefixLockTimestamp), time) } -// LockIteratorBeforeTime returns the iterator to get unlockable coins +// LockIteratorBeforeTime returns the iterator to get unlockable coins. func (k Keeper) LockIteratorBeforeTime(ctx sdk.Context, time time.Time) sdk.Iterator { unlockingPrefix := unlockingPrefix(true) return k.iteratorBeforeTime(ctx, combineKeys(unlockingPrefix, types.KeyPrefixLockTimestamp), time) } -// LockIterator returns the iterator used for getting all locks +// LockIterator returns the iterator used for getting all locks. func (k Keeper) LockIterator(ctx sdk.Context, isUnlocking bool) sdk.Iterator { unlockingPrefix := unlockingPrefix(isUnlocking) return k.iterator(ctx, combineKeys(unlockingPrefix, types.KeyPrefixLockDuration)) } -// LockIteratorAfterTimeDenom returns the iterator to get locked coins by denom +// LockIteratorAfterTimeDenom returns the iterator to get locked coins by denom. func (k Keeper) LockIteratorAfterTimeDenom(ctx sdk.Context, denom string, time time.Time) sdk.Iterator { unlockingPrefix := unlockingPrefix(true) return k.iteratorAfterTime(ctx, combineKeys(unlockingPrefix, types.KeyPrefixDenomLockTimestamp, []byte(denom)), time) } -// LockIteratorBeforeTimeDenom returns the iterator to get unlockable coins by denom +// LockIteratorBeforeTimeDenom returns the iterator to get unlockable coins by denom. func (k Keeper) LockIteratorBeforeTimeDenom(ctx sdk.Context, denom string, time time.Time) sdk.Iterator { unlockingPrefix := unlockingPrefix(true) return k.iteratorBeforeTime(ctx, combineKeys(unlockingPrefix, types.KeyPrefixDenomLockTimestamp, []byte(denom)), time) } -// LockIteratorLongerThanDurationDenom returns the iterator to get locked locks by denom +// LockIteratorLongerThanDurationDenom returns the iterator to get locked locks by denom. func (k Keeper) LockIteratorLongerThanDurationDenom(ctx sdk.Context, isUnlocking bool, denom string, duration time.Duration) sdk.Iterator { unlockingPrefix := unlockingPrefix(isUnlocking) return k.iteratorLongerDuration(ctx, combineKeys(unlockingPrefix, types.KeyPrefixDenomLockDuration, []byte(denom)), duration) } -// LockIteratorDenom returns the iterator used for getting all locks by denom +// LockIteratorDenom returns the iterator used for getting all locks by denom. func (k Keeper) LockIteratorDenom(ctx sdk.Context, isUnlocking bool, denom string) sdk.Iterator { unlockingPrefix := unlockingPrefix(isUnlocking) return k.iterator(ctx, combineKeys(unlockingPrefix, types.KeyPrefixDenomLockDuration, []byte(denom))) } -// AccountLockIteratorAfterTime returns the iterator to get locked coins by account +// AccountLockIteratorAfterTime returns the iterator to get locked coins by account. func (k Keeper) AccountLockIteratorAfterTime(ctx sdk.Context, addr sdk.AccAddress, time time.Time) sdk.Iterator { unlockingPrefix := unlockingPrefix(true) return k.iteratorAfterTime(ctx, combineKeys(unlockingPrefix, types.KeyPrefixAccountLockTimestamp, addr), time) } -// AccountLockIteratorBeforeTime returns the iterator to get unlockable coins by account +// AccountLockIteratorBeforeTime returns the iterator to get unlockable coins by account. func (k Keeper) AccountLockIteratorBeforeTime(ctx sdk.Context, addr sdk.AccAddress, time time.Time) sdk.Iterator { unlockingPrefix := unlockingPrefix(true) return k.iteratorBeforeTime(ctx, combineKeys(unlockingPrefix, types.KeyPrefixAccountLockTimestamp, addr), time) } -// AccountLockIterator returns the iterator used for getting all locks by account +// AccountLockIterator returns the iterator used for getting all locks by account. func (k Keeper) AccountLockIterator(ctx sdk.Context, isUnlocking bool, addr sdk.AccAddress) sdk.Iterator { unlockingPrefix := unlockingPrefix(isUnlocking) return k.iterator(ctx, combineKeys(unlockingPrefix, types.KeyPrefixAccountLockDuration, addr)) } -// AccountLockIteratorAfterTimeDenom returns the iterator to get locked coins by account and denom +// AccountLockIteratorAfterTimeDenom returns the iterator to get locked coins by account and denom. func (k Keeper) AccountLockIteratorAfterTimeDenom(ctx sdk.Context, addr sdk.AccAddress, denom string, time time.Time) sdk.Iterator { unlockingPrefix := unlockingPrefix(true) return k.iteratorAfterTime(ctx, combineKeys(unlockingPrefix, types.KeyPrefixAccountDenomLockTimestamp, addr, []byte(denom)), time) } -// AccountLockIteratorBeforeTimeDenom returns the iterator to get unlockable coins by account and denom +// AccountLockIteratorBeforeTimeDenom returns the iterator to get unlockable coins by account and denom. func (k Keeper) AccountLockIteratorBeforeTimeDenom(ctx sdk.Context, addr sdk.AccAddress, denom string, time time.Time) sdk.Iterator { unlockingPrefix := unlockingPrefix(true) return k.iteratorBeforeTime(ctx, combineKeys(unlockingPrefix, types.KeyPrefixAccountDenomLockTimestamp, addr, []byte(denom)), time) } -// AccountLockIteratorDenom returns the iterator used for getting all locks by account and denom +// AccountLockIteratorDenom returns the iterator used for getting all locks by account and denom. func (k Keeper) AccountLockIteratorDenom(ctx sdk.Context, isUnlocking bool, addr sdk.AccAddress, denom string) sdk.Iterator { unlockingPrefix := unlockingPrefix(isUnlocking) return k.iterator(ctx, combineKeys(unlockingPrefix, types.KeyPrefixAccountDenomLockDuration, addr, []byte(denom))) } -// AccountLockIteratorLongerDuration returns iterator used for getting all locks by account longer than duration +// AccountLockIteratorLongerDuration returns iterator used for getting all locks by account longer than duration. func (k Keeper) AccountLockIteratorLongerDuration(ctx sdk.Context, isUnlocking bool, addr sdk.AccAddress, duration time.Duration) sdk.Iterator { unlockingPrefix := unlockingPrefix(isUnlocking) return k.iteratorLongerDuration(ctx, combineKeys(unlockingPrefix, types.KeyPrefixAccountLockDuration, addr), duration) } -// AccountLockIteratorShorterThanDuration returns iterator used for getting all locks by account longer than duration +// AccountLockIteratorShorterThanDuration returns iterator used for getting all locks by account longer than duration. func (k Keeper) AccountLockIteratorShorterThanDuration(ctx sdk.Context, isUnlocking bool, addr sdk.AccAddress, duration time.Duration) sdk.Iterator { unlockingPrefix := unlockingPrefix(isUnlocking) return k.iteratorShorterDuration(ctx, combineKeys(unlockingPrefix, types.KeyPrefixAccountLockDuration, addr), duration) } -// AccountLockIteratorLongerDurationDenom returns iterator used for getting all locks by account and denom longer than duration +// AccountLockIteratorLongerDurationDenom returns iterator used for getting all locks by account and denom longer than duration. func (k Keeper) AccountLockIteratorLongerDurationDenom(ctx sdk.Context, isUnlocking bool, addr sdk.AccAddress, denom string, duration time.Duration) sdk.Iterator { unlockingPrefix := unlockingPrefix(isUnlocking) return k.iteratorLongerDuration(ctx, combineKeys(unlockingPrefix, types.KeyPrefixAccountDenomLockDuration, addr, []byte(denom)), duration) } -// AccountLockIteratorDurationDenom returns iterator used for getting all locks by account and denom with specific duration +// AccountLockIteratorDurationDenom returns iterator used for getting all locks by account and denom with specific duration. func (k Keeper) AccountLockIteratorDurationDenom(ctx sdk.Context, isUnlocking bool, addr sdk.AccAddress, denom string, duration time.Duration) sdk.Iterator { unlockingPrefix := unlockingPrefix(isUnlocking) return k.iteratorDuration(ctx, combineKeys(unlockingPrefix, types.KeyPrefixAccountDenomLockDuration, addr, []byte(denom)), duration) diff --git a/x/lockup/keeper/keeper.go b/x/lockup/keeper/keeper.go index 003f37874b9..d6c98a37729 100644 --- a/x/lockup/keeper/keeper.go +++ b/x/lockup/keeper/keeper.go @@ -10,7 +10,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/lockup/types" ) -// Keeper provides a way to manage module storage +// Keeper provides a way to manage module storage. type Keeper struct { cdc codec.Codec storeKey sdk.StoreKey @@ -22,7 +22,7 @@ type Keeper struct { dk types.DistrKeeper } -// NewKeeper returns an instance of Keeper +// NewKeeper returns an instance of Keeper. func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, ak types.AccountKeeper, bk types.BankKeeper, dk types.DistrKeeper) *Keeper { return &Keeper{ cdc: cdc, @@ -33,12 +33,12 @@ func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, ak types.AccountKeeper, b } } -// Logger returns a logger instance +// Logger returns a logger instance. func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -// Set the lockup hooks +// Set the lockup hooks. func (k *Keeper) SetHooks(lh types.LockupHooks) *Keeper { if k.hooks != nil { panic("cannot set lockup hooks twice") @@ -49,13 +49,13 @@ func (k *Keeper) SetHooks(lh types.LockupHooks) *Keeper { return k } -// AdminKeeper defines a god priviledge keeper functions to remove tokens from locks and create new locks +// AdminKeeper defines a god privilege keeper functions to remove tokens from locks and create new locks // For the governance system of token pools, we want a "ragequit" feature // So governance changes will take 1 week to go into effect // During that time, people can choose to "ragequit" which means they would leave the original pool // and form a new pool with the old parameters but if they still had 2 months of lockup left, // their liquidity still needs to be 2 month lockup-ed, just in the new pool -// And we need to replace their pool1 LP tokens with pool2 LP tokens with the same lock duration and end time +// And we need to replace their pool1 LP tokens with pool2 LP tokens with the same lock duration and end time. type AdminKeeper struct { Keeper } diff --git a/x/lockup/keeper/lock.go b/x/lockup/keeper/lock.go index 469f58381df..e83b0b11ea0 100644 --- a/x/lockup/keeper/lock.go +++ b/x/lockup/keeper/lock.go @@ -32,14 +32,14 @@ func (k Keeper) accumulationStore(ctx sdk.Context, denom string) store.Tree { return store.NewTree(prefix.NewStore(ctx.KVStore(k.storeKey), accumulationStorePrefix(denom)), 10) } -// GetModuleBalance Returns full balance of the module +// GetModuleBalance Returns full balance of the module. func (k Keeper) GetModuleBalance(ctx sdk.Context) sdk.Coins { // TODO: should add invariant test for module balance and lock items acc := k.ak.GetModuleAccount(ctx, types.ModuleName) return k.bk.GetAllBalances(ctx, acc.GetAddress()) } -// GetModuleLockedCoins Returns locked balance of the module +// GetModuleLockedCoins Returns locked balance of the module. func (k Keeper) GetModuleLockedCoins(ctx sdk.Context) sdk.Coins { // all not unlocking + not finished unlocking notUnlockingCoins := k.getCoinsFromIterator(ctx, k.LockIterator(ctx, false)) @@ -48,13 +48,13 @@ func (k Keeper) GetModuleLockedCoins(ctx sdk.Context) sdk.Coins { } // GetPeriodLocksByDuration returns the total amount of query.Denom tokens locked for longer than -// query.Duration +// query.Duration. func (k Keeper) GetPeriodLocksAccumulation(ctx sdk.Context, query types.QueryCondition) sdk.Int { beginKey := accumulationKey(query.Duration) return k.accumulationStore(ctx, query.Denom).SubsetAccumulation(beginKey, nil) } -// BeginUnlockAllNotUnlockings begins unlock for all not unlocking coins +// BeginUnlockAllNotUnlockings begins unlock for all not unlocking coins. func (k Keeper) BeginUnlockAllNotUnlockings(ctx sdk.Context, account sdk.AccAddress) ([]types.PeriodLock, error) { locks, err := k.beginUnlockFromIterator(ctx, k.AccountLockIterator(ctx, false, account)) return locks, err @@ -87,7 +87,7 @@ func (k Keeper) addTokensToLock(ctx sdk.Context, lock *types.PeriodLock, coins s return nil } -// removeTokensFromLock is called by lockup slash function - called by superfluid module only +// removeTokensFromLock is called by lockup slash function - called by superfluid module only. func (k Keeper) removeTokensFromLock(ctx sdk.Context, lock *types.PeriodLock, coins sdk.Coins) error { // TODO: Handle 100% slash eventually, not needed for osmosis codebase atm. lock.Coins = lock.Coins.Sub(coins) @@ -137,7 +137,7 @@ func (k Keeper) AddTokensToLockByID(ctx sdk.Context, lockID uint64, coins sdk.Co return lock, nil } -// SlashTokensFromLockByID send slashed tokens to community pool - called by superfluid module only +// SlashTokensFromLockByID send slashed tokens to community pool - called by superfluid module only. func (k Keeper) SlashTokensFromLockByID(ctx sdk.Context, lockID uint64, coins sdk.Coins) (*types.PeriodLock, error) { lock, err := k.GetLockByID(ctx, lockID) if err != nil { @@ -163,7 +163,7 @@ func (k Keeper) SlashTokensFromLockByID(ctx sdk.Context, lockID uint64, coins sd return lock, nil } -// LockTokens lock tokens from an account for specified duration +// LockTokens lock tokens from an account for specified duration. func (k Keeper) LockTokens(ctx sdk.Context, owner sdk.AccAddress, coins sdk.Coins, duration time.Duration) (types.PeriodLock, error) { ID := k.GetLastLockID(ctx) + 1 // unlock time is set at the beginning of unlocking time @@ -341,7 +341,7 @@ func (k Keeper) setLockAndResetLockRefs(ctx sdk.Context, lock types.PeriodLock) return k.addLockRefs(ctx, lock) } -// setLock is a utility to store lock object into the store +// setLock is a utility to store lock object into the store. func (k Keeper) setLock(ctx sdk.Context, lock types.PeriodLock) error { store := ctx.KVStore(k.storeKey) bz, err := proto.Marshal(&lock) @@ -352,13 +352,13 @@ func (k Keeper) setLock(ctx sdk.Context, lock types.PeriodLock) error { return nil } -// deleteLock removes the lock object from the state +// deleteLock removes the lock object from the state. func (k Keeper) deleteLock(ctx sdk.Context, id uint64) { store := ctx.KVStore(k.storeKey) store.Delete(lockStoreKey(id)) } -// Lock is a utility to lock coins into module account +// Lock is a utility to lock coins into module account. func (k Keeper) Lock(ctx sdk.Context, lock types.PeriodLock) error { owner, err := sdk.AccAddressFromBech32(lock.Owner) if err != nil { @@ -391,7 +391,7 @@ func (k Keeper) Lock(ctx sdk.Context, lock types.PeriodLock) error { return nil } -// splitLock splits a lock with the given amount, and stores split new lock to the state +// splitLock splits a lock with the given amount, and stores split new lock to the state. func (k Keeper) splitLock(ctx sdk.Context, lock types.PeriodLock, coins sdk.Coins) (types.PeriodLock, error) { if lock.IsUnlocking() { return types.PeriodLock{}, fmt.Errorf("cannot split unlocking lock") @@ -410,7 +410,7 @@ func (k Keeper) splitLock(ctx sdk.Context, lock types.PeriodLock, coins sdk.Coin return splitLock, err } -// BeginUnlock is a utility to start unlocking coins from NotUnlocking queue +// BeginUnlock is a utility to start unlocking coins from NotUnlocking queue. func (k Keeper) BeginUnlock(ctx sdk.Context, lockID uint64, coins sdk.Coins) error { // prohibit BeginUnlock if synthetic locks are referring to this // TODO: In the future, make synthetic locks only get partial restrictions on the main lock. @@ -476,7 +476,7 @@ func (k Keeper) beginForceUnlock(ctx sdk.Context, lock types.PeriodLock, coins s return nil } -// Unlock is a utility to unlock coins from module account +// Unlock is a utility to unlock coins from module account. func (k Keeper) Unlock(ctx sdk.Context, lockID uint64) error { lock, err := k.GetLockByID(ctx, lockID) if err != nil { @@ -497,7 +497,7 @@ func (k Keeper) Unlock(ctx sdk.Context, lockID uint64) error { // ForceUnlock ignores unlock duration and immediately unlock and refund. // CONTRACT: should be used only at the chain upgrade script -// TODO: Revisit for Superfluid Staking +// TODO: Revisit for Superfluid Staking. func (k Keeper) ForceUnlock(ctx sdk.Context, lock types.PeriodLock) error { if !lock.IsUnlocking() { err := k.BeginUnlock(ctx, lock.ID, nil) diff --git a/x/lockup/keeper/lock_refs.go b/x/lockup/keeper/lock_refs.go index 4f06b467b3a..30be8f0b5f3 100644 --- a/x/lockup/keeper/lock_refs.go +++ b/x/lockup/keeper/lock_refs.go @@ -33,7 +33,7 @@ func (k Keeper) deleteLockRefs(ctx sdk.Context, lockRefPrefix []byte, lock types return nil } -// make references for +// make references for. func (k Keeper) addSyntheticLockRefs(ctx sdk.Context, lock types.PeriodLock, synthLock types.SyntheticLock) error { refKeys, err := syntheticLockRefKeys(lock, synthLock) if err != nil { diff --git a/x/lockup/keeper/migration.go b/x/lockup/keeper/migration.go index f9d159a45ba..dac7785eb98 100644 --- a/x/lockup/keeper/migration.go +++ b/x/lockup/keeper/migration.go @@ -16,7 +16,7 @@ var ( BaselineDurations = []time.Duration{DayDuration, WeekDuration, TwoWeekDuration} ) -// baselineDurations is expected to be sorted by the caller +// baselineDurations is expected to be sorted by the caller. func normalizeDuration(baselineDurations []time.Duration, allowedDiff time.Duration, duration time.Duration) (time.Duration, bool) { for _, base := range baselineDurations { // if base > duration, continue to next base size. diff --git a/x/lockup/keeper/msg_server.go b/x/lockup/keeper/msg_server.go index 962e59e37d9..bef5b45565b 100644 --- a/x/lockup/keeper/msg_server.go +++ b/x/lockup/keeper/msg_server.go @@ -14,7 +14,7 @@ type msgServer struct { keeper *Keeper } -// NewMsgServerImpl returns an instance of MsgServer +// NewMsgServerImpl returns an instance of MsgServer. func NewMsgServerImpl(keeper *Keeper) types.MsgServer { return &msgServer{ keeper: keeper, diff --git a/x/lockup/keeper/query.go b/x/lockup/keeper/query.go index fac3a3c3a77..ef88092f202 100644 --- a/x/lockup/keeper/query.go +++ b/x/lockup/keeper/query.go @@ -9,7 +9,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" ) -// NewQuerier returns an instance of querier +// NewQuerier returns an instance of querier. func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { var ( diff --git a/x/lockup/keeper/store.go b/x/lockup/keeper/store.go index cfa0117992e..98d91680f07 100644 --- a/x/lockup/keeper/store.go +++ b/x/lockup/keeper/store.go @@ -12,7 +12,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/lockup/types" ) -// GetLastLockID returns ID used last time +// GetLastLockID returns ID used last time. func (k Keeper) GetLastLockID(ctx sdk.Context) uint64 { store := ctx.KVStore(k.storeKey) @@ -24,23 +24,23 @@ func (k Keeper) GetLastLockID(ctx sdk.Context) uint64 { return sdk.BigEndianToUint64(bz) } -// SetLastLockID save ID used by last lock +// SetLastLockID save ID used by last lock. func (k Keeper) SetLastLockID(ctx sdk.Context, ID uint64) { store := ctx.KVStore(k.storeKey) store.Set(types.KeyLastLockID, sdk.Uint64ToBigEndian(ID)) } -// lockStoreKey returns action store key from ID +// lockStoreKey returns action store key from ID. func lockStoreKey(ID uint64) []byte { return combineKeys(types.KeyPrefixPeriodLock, sdk.Uint64ToBigEndian(ID)) } -// syntheticLockStoreKey returns synthetic store key from ID and synth denom +// syntheticLockStoreKey returns synthetic store key from ID and synth denom. func syntheticLockStoreKey(lockID uint64, synthDenom string) []byte { return combineKeys(combineKeys(types.KeyPrefixSyntheticLockup, sdk.Uint64ToBigEndian(lockID)), []byte(synthDenom)) } -// syntheticLockTimeStoreKey returns synthetic store key from ID, synth denom and time +// syntheticLockTimeStoreKey returns synthetic store key from ID, synth denom and time. func syntheticLockTimeStoreKey(lockID uint64, synthDenom string, endTime time.Time) []byte { return combineKeys( combineKeys( @@ -50,7 +50,7 @@ func syntheticLockTimeStoreKey(lockID uint64, synthDenom string, endTime time.Ti []byte(synthDenom)) } -// getLockRefs get lock IDs specified on the prefix and timestamp key +// getLockRefs get lock IDs specified on the prefix and timestamp key. func (k Keeper) getLockRefs(ctx sdk.Context, key []byte) []uint64 { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, key) @@ -64,7 +64,7 @@ func (k Keeper) getLockRefs(ctx sdk.Context, key []byte) []uint64 { return lockIDs } -// addLockRefByKey make a lockID iterable with the prefix `key` +// addLockRefByKey make a lockID iterable with the prefix `key`. func (k Keeper) addLockRefByKey(ctx sdk.Context, key []byte, lockID uint64) error { store := ctx.KVStore(k.storeKey) lockIDBz := sdk.Uint64ToBigEndian(lockID) @@ -76,7 +76,7 @@ func (k Keeper) addLockRefByKey(ctx sdk.Context, key []byte, lockID uint64) erro return nil } -// deleteLockRefByKey removes lock ID from an array associated to provided key +// deleteLockRefByKey removes lock ID from an array associated to provided key. func (k Keeper) deleteLockRefByKey(ctx sdk.Context, key []byte, lockID uint64) { store := ctx.KVStore(k.storeKey) lockIDKey := sdk.Uint64ToBigEndian(lockID) @@ -107,17 +107,17 @@ func (k Keeper) ClearAllAccumulationStores(ctx sdk.Context) { } } -// GetAccountUnlockableCoins Returns whole unlockable coins which are not withdrawn yet +// GetAccountUnlockableCoins Returns whole unlockable coins which are not withdrawn yet. func (k Keeper) GetAccountUnlockableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins { return k.getCoinsFromIterator(ctx, k.AccountLockIteratorBeforeTime(ctx, addr, ctx.BlockTime())) } -// GetAccountUnlockingCoins Returns whole unlocking coins +// GetAccountUnlockingCoins Returns whole unlocking coins. func (k Keeper) GetAccountUnlockingCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins { return k.getCoinsFromIterator(ctx, k.AccountLockIteratorAfterTime(ctx, addr, ctx.BlockTime())) } -// GetAccountLockedCoins Returns a locked coins that can't be withdrawn +// GetAccountLockedCoins Returns a locked coins that can't be withdrawn. func (k Keeper) GetAccountLockedCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins { // all account unlocking + not finished unlocking notUnlockingCoins := k.getCoinsFromIterator(ctx, k.AccountLockIterator(ctx, false, addr)) @@ -125,7 +125,7 @@ func (k Keeper) GetAccountLockedCoins(ctx sdk.Context, addr sdk.AccAddress) sdk. return notUnlockingCoins.Add(unlockingCoins...) } -// GetAccountLockedPastTime Returns the total locks of an account whose unlock time is beyond timestamp +// GetAccountLockedPastTime Returns the total locks of an account whose unlock time is beyond timestamp. func (k Keeper) GetAccountLockedPastTime(ctx sdk.Context, addr sdk.AccAddress, timestamp time.Time) []types.PeriodLock { // unlockings finish after specific time + not started locks that will finish after the time even though it start now unlockings := k.getLocksFromIterator(ctx, k.AccountLockIteratorAfterTime(ctx, addr, timestamp)) @@ -137,7 +137,7 @@ func (k Keeper) GetAccountLockedPastTime(ctx sdk.Context, addr sdk.AccAddress, t return combineLocks(notUnlockings, unlockings) } -// GetAccountLockedPastTimeNotUnlockingOnly Returns the total locks of an account whose unlock time is beyond timestamp +// GetAccountLockedPastTimeNotUnlockingOnly Returns the total locks of an account whose unlock time is beyond timestamp. func (k Keeper) GetAccountLockedPastTimeNotUnlockingOnly(ctx sdk.Context, addr sdk.AccAddress, timestamp time.Time) []types.PeriodLock { duration := time.Duration(0) if timestamp.After(ctx.BlockTime()) { @@ -146,7 +146,7 @@ func (k Keeper) GetAccountLockedPastTimeNotUnlockingOnly(ctx sdk.Context, addr s return k.getLocksFromIterator(ctx, k.AccountLockIteratorLongerDuration(ctx, false, addr, duration)) } -// GetAccountUnlockedBeforeTime Returns the total unlocks of an account whose unlock time is before timestamp +// GetAccountUnlockedBeforeTime Returns the total unlocks of an account whose unlock time is before timestamp. func (k Keeper) GetAccountUnlockedBeforeTime(ctx sdk.Context, addr sdk.AccAddress, timestamp time.Time) []types.PeriodLock { // unlockings finish before specific time + not started locks that can finish before the time if start now unlockings := k.getLocksFromIterator(ctx, k.AccountLockIteratorBeforeTime(ctx, addr, timestamp)) @@ -158,7 +158,7 @@ func (k Keeper) GetAccountUnlockedBeforeTime(ctx sdk.Context, addr sdk.AccAddres return combineLocks(notUnlockings, unlockings) } -// GetAccountLockedPastTimeDenom is equal to GetAccountLockedPastTime but denom specific +// GetAccountLockedPastTimeDenom is equal to GetAccountLockedPastTime but denom specific. func (k Keeper) GetAccountLockedPastTimeDenom(ctx sdk.Context, addr sdk.AccAddress, denom string, timestamp time.Time) []types.PeriodLock { // unlockings finish after specific time + not started locks that will finish after the time even though it start now unlockings := k.getLocksFromIterator(ctx, k.AccountLockIteratorAfterTimeDenom(ctx, addr, denom, timestamp)) @@ -170,12 +170,12 @@ func (k Keeper) GetAccountLockedPastTimeDenom(ctx sdk.Context, addr sdk.AccAddre return combineLocks(notUnlockings, unlockings) } -// GetAccountLockedDurationNotUnlockingOnly Returns account locked with specific duration within not unlockings +// GetAccountLockedDurationNotUnlockingOnly Returns account locked with specific duration within not unlockings. func (k Keeper) GetAccountLockedDurationNotUnlockingOnly(ctx sdk.Context, addr sdk.AccAddress, denom string, duration time.Duration) []types.PeriodLock { return k.getLocksFromIterator(ctx, k.AccountLockIteratorDurationDenom(ctx, false, addr, denom, duration)) } -// GetAccountLockedLongerDuration Returns account locked with duration longer than specified +// GetAccountLockedLongerDuration Returns account locked with duration longer than specified. func (k Keeper) GetAccountLockedLongerDuration(ctx sdk.Context, addr sdk.AccAddress, duration time.Duration) []types.PeriodLock { // it does not matter started unlocking or not for duration query unlockings := k.getLocksFromIterator(ctx, k.AccountLockIteratorLongerDuration(ctx, true, addr, duration)) @@ -183,12 +183,12 @@ func (k Keeper) GetAccountLockedLongerDuration(ctx sdk.Context, addr sdk.AccAddr return combineLocks(notUnlockings, unlockings) } -// GetAccountLockedLongerDurationNotUnlockingOnly Returns account locked with duration longer than specified +// GetAccountLockedLongerDurationNotUnlockingOnly Returns account locked with duration longer than specified. func (k Keeper) GetAccountLockedLongerDurationNotUnlockingOnly(ctx sdk.Context, addr sdk.AccAddress, duration time.Duration) []types.PeriodLock { return k.getLocksFromIterator(ctx, k.AccountLockIteratorLongerDuration(ctx, false, addr, duration)) } -// GetAccountLockedLongerDurationDenom Returns account locked with duration longer than specified with specific denom +// GetAccountLockedLongerDurationDenom Returns account locked with duration longer than specified with specific denom. func (k Keeper) GetAccountLockedLongerDurationDenom(ctx sdk.Context, addr sdk.AccAddress, denom string, duration time.Duration) []types.PeriodLock { // it does not matter started unlocking or not for duration query unlockings := k.getLocksFromIterator(ctx, k.AccountLockIteratorLongerDurationDenom(ctx, true, addr, denom, duration)) @@ -196,12 +196,12 @@ func (k Keeper) GetAccountLockedLongerDurationDenom(ctx sdk.Context, addr sdk.Ac return combineLocks(notUnlockings, unlockings) } -// GetAccountLockedLongerDurationDenom Returns account locked with duration longer than specified with specific denom +// GetAccountLockedLongerDurationDenom Returns account locked with duration longer than specified with specific denom. func (k Keeper) GetAccountLockedLongerDurationDenomNotUnlockingOnly(ctx sdk.Context, addr sdk.AccAddress, denom string, duration time.Duration) []types.PeriodLock { return k.getLocksFromIterator(ctx, k.AccountLockIteratorLongerDurationDenom(ctx, false, addr, denom, duration)) } -// GetLocksPastTimeDenom Returns the locks whose unlock time is beyond timestamp +// GetLocksPastTimeDenom Returns the locks whose unlock time is beyond timestamp. func (k Keeper) GetLocksPastTimeDenom(ctx sdk.Context, denom string, timestamp time.Time) []types.PeriodLock { // returns both unlocking started and not started assuming it started unlocking current time unlockings := k.getLocksFromIterator(ctx, k.LockIteratorAfterTimeDenom(ctx, denom, timestamp)) @@ -217,7 +217,7 @@ func (k Keeper) GetLocksDenom(ctx sdk.Context, denom string) []types.PeriodLock return k.GetLocksLongerThanDurationDenom(ctx, denom, time.Duration(0)) } -// GetLockedDenom Returns the total amount of denom that are locked +// GetLockedDenom Returns the total amount of denom that are locked. func (k Keeper) GetLockedDenom(ctx sdk.Context, denom string, duration time.Duration) sdk.Int { totalAmtLocked := k.GetPeriodLocksAccumulation(ctx, types.QueryCondition{ LockQueryType: types.ByDuration, @@ -227,7 +227,7 @@ func (k Keeper) GetLockedDenom(ctx sdk.Context, denom string, duration time.Dura return totalAmtLocked } -// GetLocksLongerThanDurationDenom Returns the locks whose unlock duration is longer than duration +// GetLocksLongerThanDurationDenom Returns the locks whose unlock duration is longer than duration. func (k Keeper) GetLocksLongerThanDurationDenom(ctx sdk.Context, denom string, duration time.Duration) []types.PeriodLock { // returns both unlocking started and not started unlockings := k.getLocksFromIterator(ctx, k.LockIteratorLongerThanDurationDenom(ctx, true, denom, duration)) @@ -235,7 +235,7 @@ func (k Keeper) GetLocksLongerThanDurationDenom(ctx sdk.Context, denom string, d return combineLocks(notUnlockings, unlockings) } -// GetLockByID Returns lock from lockID +// GetLockByID Returns lock from lockID. func (k Keeper) GetLockByID(ctx sdk.Context, lockID uint64) (*types.PeriodLock, error) { lock := types.PeriodLock{} store := ctx.KVStore(k.storeKey) @@ -248,14 +248,14 @@ func (k Keeper) GetLockByID(ctx sdk.Context, lockID uint64) (*types.PeriodLock, return &lock, err } -// GetPeriodLocks Returns the period locks on pool +// GetPeriodLocks Returns the period locks on pool. func (k Keeper) GetPeriodLocks(ctx sdk.Context) ([]types.PeriodLock, error) { unlockings := k.getLocksFromIterator(ctx, k.LockIterator(ctx, true)) notUnlockings := k.getLocksFromIterator(ctx, k.LockIterator(ctx, false)) return combineLocks(notUnlockings, unlockings), nil } -// GetAccountPeriodLocks Returns the period locks associated to an account +// GetAccountPeriodLocks Returns the period locks associated to an account. func (k Keeper) GetAccountPeriodLocks(ctx sdk.Context, addr sdk.AccAddress) []types.PeriodLock { unlockings := k.getLocksFromIterator(ctx, k.AccountLockIterator(ctx, true, addr)) notUnlockings := k.getLocksFromIterator(ctx, k.AccountLockIterator(ctx, false, addr)) diff --git a/x/lockup/keeper/synthetic_lock.go b/x/lockup/keeper/synthetic_lock.go index 1403de5c109..1ba2eec6094 100644 --- a/x/lockup/keeper/synthetic_lock.go +++ b/x/lockup/keeper/synthetic_lock.go @@ -101,7 +101,7 @@ func (k Keeper) GetAllSyntheticLockups(ctx sdk.Context) []types.SyntheticLock { return synthLocks } -// CreateSyntheticLockup create synthetic lockup with lock id and synthdenom +// CreateSyntheticLockup create synthetic lockup with lock id and synthdenom. func (k Keeper) CreateSyntheticLockup(ctx sdk.Context, lockID uint64, synthDenom string, unlockDuration time.Duration, isUnlocking bool) error { // Note: synthetic lockup is doing everything same as lockup except coin movement // There is no relationship between unbonding and bonding synthetic lockup, it's managed separately @@ -152,7 +152,7 @@ func (k Keeper) CreateSyntheticLockup(ctx sdk.Context, lockID uint64, synthDenom return nil } -// DeleteSyntheticLockup delete synthetic lockup with lock id and synthdenom +// DeleteSyntheticLockup delete synthetic lockup with lock id and synthdenom. func (k Keeper) DeleteSyntheticLockup(ctx sdk.Context, lockID uint64, synthdenom string) error { synthLock, err := k.GetSyntheticLockup(ctx, lockID, synthdenom) if err != nil { diff --git a/x/lockup/keeper/utils.go b/x/lockup/keeper/utils.go index 6afe03b8452..f0479b23138 100644 --- a/x/lockup/keeper/utils.go +++ b/x/lockup/keeper/utils.go @@ -8,13 +8,13 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/lockup/types" ) -// combineKeys combine bytes array into a single bytes +// combineKeys combine bytes array into a single bytes. func combineKeys(keys ...[]byte) []byte { return bytes.Join(keys, types.KeyIndexSeparator) } // getTimeKey returns the key used for getting a set of period locks -// where unlockTime is after a specific time +// where unlockTime is after a specific time. func getTimeKey(timestamp time.Time) []byte { timeBz := sdk.FormatTimeBytes(timestamp) timeBzL := len(timeBz) @@ -34,7 +34,7 @@ func getTimeKey(timestamp time.Time) []byte { } // getDurationKey returns the key used for getting a set of period locks -// where duration is longer than a specific duration +// where duration is longer than a specific duration. func getDurationKey(duration time.Duration) []byte { if duration < 0 { duration = 0 diff --git a/x/lockup/module.go b/x/lockup/module.go index 914dfe8da43..9ce6df6a5fd 100644 --- a/x/lockup/module.go +++ b/x/lockup/module.go @@ -55,7 +55,7 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { types.RegisterCodec(cdc) } -// RegisterInterfaces registers the module's interface types +// RegisterInterfaces registers the module's interface types. func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { types.RegisterInterfaces(reg) } @@ -197,7 +197,7 @@ func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { return nil // TODO } -// RegisterStoreDecoder registers a decoder for supply module's types +// RegisterStoreDecoder registers a decoder for supply module's types. func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { // TODO } diff --git a/x/lockup/simulation/operations.go b/x/lockup/simulation/operations.go index eefc50921aa..a48b8b9f8e8 100644 --- a/x/lockup/simulation/operations.go +++ b/x/lockup/simulation/operations.go @@ -17,7 +17,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/lockup/types" ) -// Simulation operation weights constants +// Simulation operation weights constants. const ( DefaultWeightMsgLockTokens int = 10 DefaultWeightMsgBeginUnlockingAll int = 10 @@ -27,7 +27,7 @@ const ( OpWeightMsgBeginUnlocking = "op_weight_msg_begin_unlocking" ) -// WeightedOperations returns all the operations from the module with their respective weights +// WeightedOperations returns all the operations from the module with their respective weights. func WeightedOperations( appParams simtypes.AppParams, cdc codec.JSONCodec, ak stakingTypes.AccountKeeper, bk stakingTypes.BankKeeper, k keeper.Keeper, @@ -89,7 +89,7 @@ func Max(x, y int) int { return y } -// SimulateMsgLockTokens generates a MsgLockTokens with random values +// SimulateMsgLockTokens generates a MsgLockTokens with random values. func SimulateMsgLockTokens(ak stakingTypes.AccountKeeper, bk stakingTypes.BankKeeper, k keeper.Keeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, @@ -135,7 +135,6 @@ func SimulateMsgBeginUnlockingAll(ak stakingTypes.AccountKeeper, bk stakingTypes txGen := simappparams.MakeTestEncodingConfig().TxConfig return osmo_simulation.GenAndDeliverTxWithRandFees( r, app, txGen, &msg, nil, ctx, simAccount, ak, bk, types.ModuleName) - } } @@ -164,7 +163,6 @@ func SimulateMsgBeginUnlocking(ak stakingTypes.AccountKeeper, bk stakingTypes.Ba txGen := simappparams.MakeTestEncodingConfig().TxConfig return osmo_simulation.GenAndDeliverTxWithRandFees( r, app, txGen, &msg, nil, ctx, simAccount, ak, bk, types.ModuleName) - } } diff --git a/x/lockup/types/errors.go b/x/lockup/types/errors.go index bd49604a14c..6301861bf5e 100644 --- a/x/lockup/types/errors.go +++ b/x/lockup/types/errors.go @@ -6,7 +6,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -// x/lockup module sentinel errors +// x/lockup module sentinel errors. var ( ErrNotLockOwner = sdkerrors.Register(ModuleName, 1, "msg sender is not the owner of specified lock") ErrSyntheticLockupAlreadyExists = sdkerrors.Register(ModuleName, 2, "synthetic lockup already exists for same lock and suffix") diff --git a/x/lockup/types/events.go b/x/lockup/types/events.go index e66d2d953a6..8dbd4f6166c 100644 --- a/x/lockup/types/events.go +++ b/x/lockup/types/events.go @@ -1,6 +1,6 @@ package types -// event types +// event types. const ( TypeEvtLockTokens = "lock_tokens" TypeEvtAddTokensToLock = "add_tokens_to_lock" diff --git a/x/lockup/types/genesis.go b/x/lockup/types/genesis.go index 094d1119cc5..e883ff8d4af 100644 --- a/x/lockup/types/genesis.go +++ b/x/lockup/types/genesis.go @@ -1,9 +1,9 @@ package types -// DefaultIndex is the default capability global index +// DefaultIndex is the default capability global index. const DefaultIndex uint64 = 1 -// DefaultGenesis returns the default Capability genesis state +// DefaultGenesis returns the default Capability genesis state. func DefaultGenesis() *GenesisState { return &GenesisState{} } diff --git a/x/lockup/types/hooks.go b/x/lockup/types/hooks.go index fc039bf2894..716ba0697a2 100644 --- a/x/lockup/types/hooks.go +++ b/x/lockup/types/hooks.go @@ -16,7 +16,7 @@ type LockupHooks interface { var _ LockupHooks = MultiLockupHooks{} -// combine multiple gamm hooks, all hook functions are run in array sequence +// combine multiple gamm hooks, all hook functions are run in array sequence. type MultiLockupHooks []LockupHooks func NewMultiLockupHooks(hooks ...LockupHooks) MultiLockupHooks { diff --git a/x/lockup/types/keys.go b/x/lockup/types/keys.go index e53e609c744..2f321aab483 100644 --- a/x/lockup/types/keys.go +++ b/x/lockup/types/keys.go @@ -1,69 +1,69 @@ package types var ( - // ModuleName defines the module name + // ModuleName defines the module name. ModuleName = "lockup" - // StoreKey defines the primary module store key + // StoreKey defines the primary module store key. StoreKey = ModuleName - // RouterKey is the message route for slashing + // RouterKey is the message route for slashing. RouterKey = ModuleName - // QuerierRoute defines the module's query routing key + // QuerierRoute defines the module's query routing key. QuerierRoute = ModuleName - // KeyLastLockID defines key to store lock ID used by last + // KeyLastLockID defines key to store lock ID used by last. KeyLastLockID = []byte{0x01} - // KeyPrefixPeriodLock defines prefix to store period lock by ID + // KeyPrefixPeriodLock defines prefix to store period lock by ID. KeyPrefixPeriodLock = []byte{0x02} - // KeyPrefixNotUnlocking defines prefix to query iterators which hasn't started unlocking + // KeyPrefixNotUnlocking defines prefix to query iterators which hasn't started unlocking. KeyPrefixNotUnlocking = []byte{0x03} - // KeyPrefixUnlocking defines prefix to query iterators which has started unlocking + // KeyPrefixUnlocking defines prefix to query iterators which has started unlocking. KeyPrefixUnlocking = []byte{0x04} - // KeyPrefixTimestamp defines prefix key for timestamp iterator key + // KeyPrefixTimestamp defines prefix key for timestamp iterator key. KeyPrefixTimestamp = []byte{0x05} - // KeyPrefixDuration defines prefix key for duration iterator key + // KeyPrefixDuration defines prefix key for duration iterator key. KeyPrefixDuration = []byte{0x06} - // KeyPrefixLockDuration defines prefix for the iteration of lock IDs by duration + // KeyPrefixLockDuration defines prefix for the iteration of lock IDs by duration. KeyPrefixLockDuration = []byte{0x07} - // KeyPrefixAccountLockDuration defines prefix for the iteration of lock IDs by account and duration + // KeyPrefixAccountLockDuration defines prefix for the iteration of lock IDs by account and duration. KeyPrefixAccountLockDuration = []byte{0x08} - // KeyPrefixDenomLockDuration defines prefix for the iteration of lock IDs by denom and duration + // KeyPrefixDenomLockDuration defines prefix for the iteration of lock IDs by denom and duration. KeyPrefixDenomLockDuration = []byte{0x09} - // KeyPrefixAccountDenomLockDuration defines prefix for the iteration of lock IDs by account, denomination and duration + // KeyPrefixAccountDenomLockDuration defines prefix for the iteration of lock IDs by account, denomination and duration. KeyPrefixAccountDenomLockDuration = []byte{0x0A} - // KeyPrefixLockTimestamp defines prefix for the iteration of lock IDs by timestamp + // KeyPrefixLockTimestamp defines prefix for the iteration of lock IDs by timestamp. KeyPrefixLockTimestamp = []byte{0x0B} - // KeyPrefixAccountLockTimestamp defines prefix for the iteration of lock IDs by account and timestamp + // KeyPrefixAccountLockTimestamp defines prefix for the iteration of lock IDs by account and timestamp. KeyPrefixAccountLockTimestamp = []byte{0x0C} - // KeyPrefixDenomLockTimestamp defines prefix for the iteration of lock IDs by denom and timestamp + // KeyPrefixDenomLockTimestamp defines prefix for the iteration of lock IDs by denom and timestamp. KeyPrefixDenomLockTimestamp = []byte{0x0D} - // KeyPrefixAccountDenomLockTimestamp defines prefix for the iteration of lock IDs by account, denomination and timestamp + // KeyPrefixAccountDenomLockTimestamp defines prefix for the iteration of lock IDs by account, denomination and timestamp. KeyPrefixAccountDenomLockTimestamp = []byte{0x0E} - // KeyPrefixPeriodLock defines prefix to store synthetic lockup by lock ID and synthetic suffix + // KeyPrefixPeriodLock defines prefix to store synthetic lockup by lock ID and synthetic suffix. KeyPrefixSyntheticLockup = []byte{0x0F} - // KeyPrefixSyntheticLockTimestamp defines prefix for the iteration of synthetic lockups by timestamp + // KeyPrefixSyntheticLockTimestamp defines prefix for the iteration of synthetic lockups by timestamp. KeyPrefixSyntheticLockTimestamp = []byte{0x10} - // KeyPrefixLockAccumulation defines prefix for the lock accumulation store + // KeyPrefixLockAccumulation defines prefix for the lock accumulation store. KeyPrefixLockAccumulation = []byte{0x20} - // KeyIndexSeparator defines separator between keys when combine, it should be one that is not used in denom expression + // KeyIndexSeparator defines separator between keys when combine, it should be one that is not used in denom expression. KeyIndexSeparator = []byte{0xFF} ) diff --git a/x/lockup/types/lock.go b/x/lockup/types/lock.go index 70afa4466ff..24cd878115c 100644 --- a/x/lockup/types/lock.go +++ b/x/lockup/types/lock.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// NewPeriodLock returns a new instance of period lock +// NewPeriodLock returns a new instance of period lock. func NewPeriodLock(ID uint64, owner sdk.AccAddress, duration time.Duration, endTime time.Time, coins sdk.Coins) PeriodLock { return PeriodLock{ ID: ID, @@ -19,17 +19,17 @@ func NewPeriodLock(ID uint64, owner sdk.AccAddress, duration time.Duration, endT } } -// IsUnlocking returns lock started unlocking already +// IsUnlocking returns lock started unlocking already. func (p PeriodLock) IsUnlocking() bool { return !p.EndTime.Equal(time.Time{}) } -// IsUnlocking returns lock started unlocking already +// IsUnlocking returns lock started unlocking already. func (p SyntheticLock) IsUnlocking() bool { return !p.EndTime.Equal(time.Time{}) } -// OwnerAddress returns locks owner address +// OwnerAddress returns locks owner address. func (p PeriodLock) OwnerAddress() sdk.AccAddress { addr, err := sdk.AccAddressFromBech32(p.Owner) if err != nil { @@ -58,7 +58,7 @@ func SumLocksByDenom(locks []PeriodLock, denom string) sdk.Int { return sum } -// quick fix for getting native denom from synthetic denom +// quick fix for getting native denom from synthetic denom. func NativeDenom(denom string) string { if strings.Contains(denom, "/superbonding") { return strings.Split(denom, "/superbonding")[0] diff --git a/x/lockup/types/msgs.go b/x/lockup/types/msgs.go index 14bf8a52e80..17eaf0974bb 100644 --- a/x/lockup/types/msgs.go +++ b/x/lockup/types/msgs.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// constants +// constants. const ( TypeMsgLockTokens = "lock_tokens" TypeMsgBeginUnlockingAll = "begin_unlocking_all" @@ -16,7 +16,7 @@ const ( var _ sdk.Msg = &MsgLockTokens{} -// NewMsgLockTokens creates a message to lock tokens +// NewMsgLockTokens creates a message to lock tokens. func NewMsgLockTokens(owner sdk.AccAddress, duration time.Duration, coins sdk.Coins) *MsgLockTokens { return &MsgLockTokens{ Owner: owner.String(), @@ -33,9 +33,11 @@ func (m MsgLockTokens) ValidateBasic() error { } return nil } + func (m MsgLockTokens) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } + func (m MsgLockTokens) GetSigners() []sdk.AccAddress { owner, _ := sdk.AccAddressFromBech32(m.Owner) return []sdk.AccAddress{owner} @@ -43,7 +45,7 @@ func (m MsgLockTokens) GetSigners() []sdk.AccAddress { var _ sdk.Msg = &MsgBeginUnlockingAll{} -// NewMsgBeginUnlockingAll creates a message to begin unlocking tokens +// NewMsgBeginUnlockingAll creates a message to begin unlocking tokens. func NewMsgBeginUnlockingAll(owner sdk.AccAddress) *MsgBeginUnlockingAll { return &MsgBeginUnlockingAll{ Owner: owner.String(), @@ -55,9 +57,11 @@ func (m MsgBeginUnlockingAll) Type() string { return TypeMsgBeginUnlockingAll } func (m MsgBeginUnlockingAll) ValidateBasic() error { return nil } + func (m MsgBeginUnlockingAll) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } + func (m MsgBeginUnlockingAll) GetSigners() []sdk.AccAddress { owner, _ := sdk.AccAddressFromBech32(m.Owner) return []sdk.AccAddress{owner} @@ -65,7 +69,7 @@ func (m MsgBeginUnlockingAll) GetSigners() []sdk.AccAddress { var _ sdk.Msg = &MsgBeginUnlocking{} -// NewMsgBeginUnlocking creates a message to begin unlocking the tokens of a specific lock +// NewMsgBeginUnlocking creates a message to begin unlocking the tokens of a specific lock. func NewMsgBeginUnlocking(owner sdk.AccAddress, id uint64, coins sdk.Coins) *MsgBeginUnlocking { return &MsgBeginUnlocking{ Owner: owner.String(), @@ -79,9 +83,11 @@ func (m MsgBeginUnlocking) Type() string { return TypeMsgBeginUnlocking } func (m MsgBeginUnlocking) ValidateBasic() error { return nil } + func (m MsgBeginUnlocking) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } + func (m MsgBeginUnlocking) GetSigners() []sdk.AccAddress { owner, _ := sdk.AccAddressFromBech32(m.Owner) return []sdk.AccAddress{owner} diff --git a/x/lockup/types/querier.go b/x/lockup/types/querier.go index 942b050329a..2792cf27f57 100644 --- a/x/lockup/types/querier.go +++ b/x/lockup/types/querier.go @@ -1,14 +1,14 @@ package types -// query endpoints supported by the lockup Querier +// query endpoints supported by the lockup Querier. const ( QueryModuleBalance = "module_balance" QueryModuleLockedAmount = "module_locked_amount" QueryAccountUnlockableCoins = "account_unlockable_coins" QueryAccountLockedCoins = "account_locked_coins" - QueryAccountLockedPastTime = "account_locked_pasttime" + QueryAccountLockedPastTime = "account_locked_pastime" QueryAccountUnlockedBeforeTime = "account_unlocked_beforetime" - QueryAccountLockedPastTimeDenom = "account_locked_denom_pasttime" + QueryAccountLockedPastTimeDenom = "account_locked_denom_pastime" QueryLockedByID = "locked_by_id" QueryAccountLockedLongerDuration = "account_locked_longer_than_duration" QueryAccountLockedLongerDurationDenom = "account_locked_longer_than_duration_denom" diff --git a/x/mint/client/cli/query.go b/x/mint/client/cli/query.go index d370a970d9b..ec6da9d25c9 100644 --- a/x/mint/client/cli/query.go +++ b/x/mint/client/cli/query.go @@ -45,7 +45,6 @@ func GetCmdQueryParams() *cobra.Command { params := &types.QueryParamsRequest{} res, err := queryClient.Params(context.Background(), params) - if err != nil { return err } @@ -75,7 +74,6 @@ func GetCmdQueryEpochProvisions() *cobra.Command { params := &types.QueryEpochProvisionsRequest{} res, err := queryClient.EpochProvisions(context.Background(), params) - if err != nil { return err } diff --git a/x/mint/genesis.go b/x/mint/genesis.go index a4dadf75eb9..ef11acc963e 100644 --- a/x/mint/genesis.go +++ b/x/mint/genesis.go @@ -6,7 +6,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/mint/types" ) -// InitGenesis new mint genesis +// InitGenesis new mint genesis. func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper, data *types.GenesisState) { data.Minter.EpochProvisions = data.Params.GenesisEpochProvisions keeper.SetMinter(ctx, data.Minter) diff --git a/x/mint/keeper/hooks.go b/x/mint/keeper/hooks.go index 4a53caea20e..e8debc6ab57 100644 --- a/x/mint/keeper/hooks.go +++ b/x/mint/keeper/hooks.go @@ -69,19 +69,19 @@ func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumb // ___________________________________________________________________________________________________ -// Hooks wrapper struct for incentives keeper +// Hooks wrapper struct for incentives keeper. type Hooks struct { k Keeper } var _ epochstypes.EpochHooks = Hooks{} -// Return the wrapper struct +// Return the wrapper struct. func (k Keeper) Hooks() Hooks { return Hooks{k} } -// epochs hooks +// epochs hooks. func (h Hooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) { h.k.BeforeEpochStart(ctx, epochIdentifier, epochNumber) } diff --git a/x/mint/keeper/keeper.go b/x/mint/keeper/keeper.go index 8e97a321c73..8f88c387258 100644 --- a/x/mint/keeper/keeper.go +++ b/x/mint/keeper/keeper.go @@ -10,7 +10,7 @@ import ( "github.com/tendermint/tendermint/libs/log" ) -// Keeper of the mint store +// Keeper of the mint store. type Keeper struct { cdc codec.BinaryCodec storeKey sdk.StoreKey @@ -23,7 +23,7 @@ type Keeper struct { feeCollectorName string } -// NewKeeper creates a new mint Keeper instance +// NewKeeper creates a new mint Keeper instance. func NewKeeper( cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace, ak types.AccountKeeper, bk types.BankKeeper, dk types.DistrKeeper, epochKeeper types.EpochKeeper, @@ -52,15 +52,15 @@ func NewKeeper( } // SetInitialSupplyOffsetDuringMigration sets the supply offset based on the balance of the -// Develope rVesting Module Account. It should only be called one time during the initial -// migration to v7 +// Develop rVesting Module Account. It should only be called one time during the initial +// migration to v7. func SetInitialSupplyOffsetDuringMigration(ctx sdk.Context, k Keeper) { moduleAccBalance := k.bankKeeper.GetBalance(ctx, k.accountKeeper.GetModuleAddress(types.DeveloperVestingModuleAcctName), k.GetParams(ctx).MintDenom) k.bankKeeper.AddSupplyOffset(ctx, moduleAccBalance.Denom, moduleAccBalance.Amount.Neg()) } // CreateDeveloperVestingModuleAccount creates the module account for developer vesting. -// Should only be called in initial genesis creation, never again +// Should only be called in initial genesis creation, never again. func (k Keeper) CreateDeveloperVestingModuleAccount(ctx sdk.Context, amount sdk.Coin) { moduleAcc := authtypes.NewEmptyModuleAccount( types.DeveloperVestingModuleAcctName, authtypes.Minter) @@ -80,7 +80,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+types.ModuleName) } -// Set the mint hooks +// Set the mint hooks. func (k *Keeper) SetHooks(h types.MintHooks) *Keeper { if k.hooks != nil { panic("cannot set mint hooks twice") @@ -91,7 +91,7 @@ func (k *Keeper) SetHooks(h types.MintHooks) *Keeper { return k } -// GetLastHalvenEpochNum returns last halven epoch number +// GetLastHalvenEpochNum returns last halven epoch number. func (k Keeper) GetLastHalvenEpochNum(ctx sdk.Context) int64 { store := ctx.KVStore(k.storeKey) b := store.Get(types.LastHalvenEpochKey) @@ -102,13 +102,13 @@ func (k Keeper) GetLastHalvenEpochNum(ctx sdk.Context) int64 { return int64(sdk.BigEndianToUint64(b)) } -// SetLastHalvenEpochNum set last halven epoch number +// SetLastHalvenEpochNum set last halven epoch number. func (k Keeper) SetLastHalvenEpochNum(ctx sdk.Context, epochNum int64) { store := ctx.KVStore(k.storeKey) store.Set(types.LastHalvenEpochKey, sdk.Uint64ToBigEndian(uint64(epochNum))) } -// get the minter +// get the minter. func (k Keeper) GetMinter(ctx sdk.Context) (minter types.Minter) { store := ctx.KVStore(k.storeKey) b := store.Get(types.MinterKey) @@ -120,7 +120,7 @@ func (k Keeper) GetMinter(ctx sdk.Context) (minter types.Minter) { return } -// set the minter +// set the minter. func (k Keeper) SetMinter(ctx sdk.Context, minter types.Minter) { store := ctx.KVStore(k.storeKey) b := k.cdc.MustMarshal(&minter) @@ -153,7 +153,7 @@ func (k Keeper) MintCoins(ctx sdk.Context, newCoins sdk.Coins) error { return k.bankKeeper.MintCoins(ctx, types.ModuleName, newCoins) } -// GetProportions gets the balance of the `MintedDenom` from minted coins and returns coins according to the `AllocationRatio` +// GetProportions gets the balance of the `MintedDenom` from minted coins and returns coins according to the `AllocationRatio`. func (k Keeper) GetProportions(ctx sdk.Context, mintedCoin sdk.Coin, ratio sdk.Dec) sdk.Coin { return sdk.NewCoin(mintedCoin.Denom, mintedCoin.Amount.ToDec().Mul(ratio).TruncateInt()) } diff --git a/x/mint/module.go b/x/mint/module.go index 61a46f79130..e758ace0660 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -45,7 +45,7 @@ func (AppModuleBasic) Name() string { // RegisterLegacyAminoCodec registers the mint module's types on the given LegacyAmino codec. func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} -// RegisterInterfaces registers the module's interface types +// RegisterInterfaces registers the module's interface types. func (b AppModuleBasic) RegisterInterfaces(_ cdctypes.InterfaceRegistry) {} // DefaultGenesis returns default genesis state as raw bytes for the mint @@ -74,7 +74,6 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { return } - } // GetTxCmd returns no root tx command for the mint module. @@ -96,7 +95,7 @@ type AppModule struct { bankKeeper types.BankKeeper } -// NewAppModule creates a new AppModule object +// NewAppModule creates a new AppModule object. func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, diff --git a/x/mint/simulation/genesis.go b/x/mint/simulation/genesis.go index dcd61815ab7..a2a150f4ed0 100644 --- a/x/mint/simulation/genesis.go +++ b/x/mint/simulation/genesis.go @@ -11,7 +11,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/mint/types" ) -// RandomizedGenState generates a random GenesisState for mint +// RandomizedGenState generates a random GenesisState for mint. func RandomizedGenState(simState *module.SimulationState) { // minter diff --git a/x/mint/simulation/params.go b/x/mint/simulation/params.go index 170277c2a3e..c86471bdd08 100644 --- a/x/mint/simulation/params.go +++ b/x/mint/simulation/params.go @@ -14,7 +14,7 @@ import ( // ) // ParamChanges defines the parameters that can be modified by param change proposals -// on the simulation +// on the simulation. func ParamChanges(r *rand.Rand) []simtypes.ParamChange { return []simtypes.ParamChange{ // simulation.NewSimParamChange(types.ModuleName, keyMaxRewardPerEpoch, diff --git a/x/mint/types/codec.go b/x/mint/types/codec.go index b436c10298d..a7067d90c2c 100644 --- a/x/mint/types/codec.go +++ b/x/mint/types/codec.go @@ -5,9 +5,7 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" ) -var ( - amino = codec.NewLegacyAmino() -) +var amino = codec.NewLegacyAmino() func init() { cryptocodec.RegisterCrypto(amino) diff --git a/x/mint/types/events.go b/x/mint/types/events.go index 5f6374c548e..6ad8f851868 100644 --- a/x/mint/types/events.go +++ b/x/mint/types/events.go @@ -1,6 +1,6 @@ package types -// Minting module event types +// Minting module event types. const ( EventTypeMint = ModuleName diff --git a/x/mint/types/expected_keepers.go b/x/mint/types/expected_keepers.go index 0c823d316ca..ed3b11c83e9 100644 --- a/x/mint/types/expected_keepers.go +++ b/x/mint/types/expected_keepers.go @@ -27,12 +27,12 @@ type BankKeeper interface { AddSupplyOffset(ctx sdk.Context, denom string, offsetAmount sdk.Int) } -// DistrKeeper defines the contract needed to be fulfilled for distribution keeper +// DistrKeeper defines the contract needed to be fulfilled for distribution keeper. type DistrKeeper interface { FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error } -// EpochKeeper defines the contract needed to be fulfilled for epochs keeper +// EpochKeeper defines the contract needed to be fulfilled for epochs keeper. type EpochKeeper interface { GetEpochInfo(ctx sdk.Context, identifier string) epochstypes.EpochInfo } diff --git a/x/mint/types/genesis.go b/x/mint/types/genesis.go index 4b3fc029900..eae6321d589 100644 --- a/x/mint/types/genesis.go +++ b/x/mint/types/genesis.go @@ -1,6 +1,6 @@ package types -// NewGenesisState creates a new GenesisState object +// NewGenesisState creates a new GenesisState object. func NewGenesisState(minter Minter, params Params, halvenStartedEpoch int64) *GenesisState { return &GenesisState{ Minter: minter, @@ -9,7 +9,7 @@ func NewGenesisState(minter Minter, params Params, halvenStartedEpoch int64) *Ge } } -// DefaultGenesisState creates a default GenesisState object +// DefaultGenesisState creates a default GenesisState object. func DefaultGenesisState() *GenesisState { return &GenesisState{ Minter: DefaultInitialMinter(), diff --git a/x/mint/types/hooks.go b/x/mint/types/hooks.go index 296aa1d1201..ff2b3c3d4d1 100644 --- a/x/mint/types/hooks.go +++ b/x/mint/types/hooks.go @@ -10,7 +10,7 @@ type MintHooks interface { var _ MintHooks = MultiMintHooks{} -// combine multiple mint hooks, all hook functions are run in array sequence +// combine multiple mint hooks, all hook functions are run in array sequence. type MultiMintHooks []MintHooks func NewMultiMintHooks(hooks ...MintHooks) MultiMintHooks { diff --git a/x/mint/types/keys.go b/x/mint/types/keys.go index e46e6dab0a2..6812a631889 100644 --- a/x/mint/types/keys.go +++ b/x/mint/types/keys.go @@ -7,18 +7,18 @@ var MinterKey = []byte{0x00} var LastHalvenEpochKey = []byte{0x03} const ( - // module name + // module name. ModuleName = "mint" - // module acct name for developer vesting + // module acct name for developer vesting. DeveloperVestingModuleAcctName = "developer_vesting_unvested" - // StoreKey is the default store key for mint + // StoreKey is the default store key for mint. StoreKey = ModuleName // QuerierRoute is the querier route for the minting store. QuerierRoute = StoreKey - // Query endpoints supported by the minting querier + // Query endpoints supported by the minting querier. QueryParameters = "parameters" QueryEpochProvisions = "epoch_provisions" ) diff --git a/x/mint/types/minter.go b/x/mint/types/minter.go index 60699d6c465..e9ba2b5d5f3 100644 --- a/x/mint/types/minter.go +++ b/x/mint/types/minter.go @@ -12,22 +12,22 @@ func NewMinter(epochProvisions sdk.Dec) Minter { } } -// InitialMinter returns an initial Minter object +// InitialMinter returns an initial Minter object. func InitialMinter() Minter { return NewMinter(sdk.NewDec(0)) } -// DefaultInitialMinter returns a default initial Minter object for a new chain +// DefaultInitialMinter returns a default initial Minter object for a new chain. func DefaultInitialMinter() Minter { return InitialMinter() } -// validate minter +// validate minter. func ValidateMinter(minter Minter) error { return nil } -// NextEpochProvisions returns the epoch provisions +// NextEpochProvisions returns the epoch provisions. func (m Minter) NextEpochProvisions(params Params) sdk.Dec { return m.EpochProvisions.Mul(params.ReductionFactor) } diff --git a/x/mint/types/params.go b/x/mint/types/params.go index 44094ec181e..00ce93f3d3d 100644 --- a/x/mint/types/params.go +++ b/x/mint/types/params.go @@ -11,7 +11,7 @@ import ( yaml "gopkg.in/yaml.v2" ) -// Parameter store keys +// Parameter store keys. var ( KeyMintDenom = []byte("MintDenom") KeyGenesisEpochProvisions = []byte("GenesisEpochProvisions") @@ -33,7 +33,6 @@ func NewParams( ReductionFactor sdk.Dec, reductionPeriodInEpochs int64, distrProportions DistributionProportions, weightedDevRewardsReceivers []WeightedAddress, mintingRewardsDistributionStartEpoch int64, ) Params { - return Params{ MintDenom: mintDenom, GenesisEpochProvisions: genesisEpochProvisions, @@ -46,7 +45,7 @@ func NewParams( } } -// default minting module parameters +// default minting module parameters. func DefaultParams() Params { return Params{ MintDenom: sdk.DefaultBondDenom, @@ -65,7 +64,7 @@ func DefaultParams() Params { } } -// validate params +// validate params. func (p Params) Validate() error { if err := validateMintDenom(p.MintDenom); err != nil { return err @@ -101,7 +100,7 @@ func (p Params) String() string { return string(out) } -// Implements params.ParamSet +// Implements params.ParamSet. func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyMintDenom, &p.MintDenom, validateMintDenom), diff --git a/x/pool-incentives/client/cli/cli_test.go b/x/pool-incentives/client/cli/cli_test.go index 69abbc47578..f76ae27b945 100644 --- a/x/pool-incentives/client/cli/cli_test.go +++ b/x/pool-incentives/client/cli/cli_test.go @@ -62,7 +62,7 @@ func (s *IntegrationTestSuite) TestGetCmdGaugeIds() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) } }) } @@ -96,7 +96,7 @@ func (s *IntegrationTestSuite) TestGetCmdDistrInfo() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) } }) } @@ -130,7 +130,7 @@ func (s *IntegrationTestSuite) TestGetCmdParams() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) } }) } @@ -164,7 +164,7 @@ func (s *IntegrationTestSuite) TestGetCmdLockableDurations() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) } }) } @@ -198,7 +198,7 @@ func (s *IntegrationTestSuite) TestGetCmdIncentivizedPools() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) } }) } @@ -232,7 +232,7 @@ func (s *IntegrationTestSuite) TestGetCmdExternalIncentiveGauges() { s.Require().Error(err) } else { s.Require().NoError(err, out.String()) - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) } }) } diff --git a/x/pool-incentives/client/cli/query.go b/x/pool-incentives/client/cli/query.go index 20237f41e5b..644f670b219 100644 --- a/x/pool-incentives/client/cli/query.go +++ b/x/pool-incentives/client/cli/query.go @@ -12,7 +12,7 @@ import ( "github.com/spf13/cobra" ) -// GetQueryCmd returns the cli query commands for this module +// GetQueryCmd returns the cli query commands for this module. func GetQueryCmd(queryRoute string) *cobra.Command { // Group queries under a subcommand cmd := &cobra.Command{ @@ -35,7 +35,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { return cmd } -// GetCmdGaugeIds takes the pool id and returns the matching gauge ids and durations +// GetCmdGaugeIds takes the pool id and returns the matching gauge ids and durations. func GetCmdGaugeIds() *cobra.Command { cmd := &cobra.Command{ Use: "gauge-ids [pool-id]", @@ -78,7 +78,7 @@ $ %s query pool-incentives gauge-ids 1 return cmd } -// GetCmdDistrInfo takes the pool id and returns the matching gauge ids and weights +// GetCmdDistrInfo takes the pool id and returns the matching gauge ids and weights. func GetCmdDistrInfo() *cobra.Command { cmd := &cobra.Command{ Use: "distr-info", @@ -114,7 +114,7 @@ $ %s query pool-incentives distr-info return cmd } -// GetCmdParams returns module params +// GetCmdParams returns module params. func GetCmdParams() *cobra.Command { cmd := &cobra.Command{ Use: "params", @@ -150,7 +150,7 @@ $ %s query pool-incentives params return cmd } -// GetCmdLockableDurations returns lockable durations +// GetCmdLockableDurations returns lockable durations. func GetCmdLockableDurations() *cobra.Command { cmd := &cobra.Command{ Use: "lockable-durations", @@ -186,7 +186,7 @@ $ %s query pool-incentives lockable-durations return cmd } -// GetCmdIncentivizedPools returns incentivized pools +// GetCmdIncentivizedPools returns incentivized pools. func GetCmdIncentivizedPools() *cobra.Command { cmd := &cobra.Command{ Use: "incentivized-pools", @@ -222,7 +222,7 @@ $ %s query pool-incentives incentivized-pools return cmd } -// GetCmdIncentivizedPools returns incentivized pools +// GetCmdIncentivizedPools returns incentivized pools. func GetCmdExternalIncentiveGauges() *cobra.Command { cmd := &cobra.Command{ Use: "external-incentivized-gauges", diff --git a/x/pool-incentives/client/cli/tx.go b/x/pool-incentives/client/cli/tx.go index a71b8607180..2101b591470 100644 --- a/x/pool-incentives/client/cli/tx.go +++ b/x/pool-incentives/client/cli/tx.go @@ -56,7 +56,7 @@ func NewCmdSubmitUpdatePoolIncentivesProposal() *cobra.Command { } if len(gaugeIds) != len(weights) { - return fmt.Errorf("the length of gauge ids and wieghts not matched") + return fmt.Errorf("the length of gauge ids and weights not matched") } if len(gaugeIds) == 0 { @@ -138,7 +138,7 @@ func NewCmdSubmitReplacePoolIncentivesProposal() *cobra.Command { } if len(gaugeIds) != len(weights) { - return fmt.Errorf("the length of gauge ids and wieghts not matched") + return fmt.Errorf("the length of gauge ids and weights not matched") } if len(gaugeIds) == 0 { diff --git a/x/pool-incentives/keeper/distr.go b/x/pool-incentives/keeper/distr.go index 973e7997595..600e26dd4b5 100644 --- a/x/pool-incentives/keeper/distr.go +++ b/x/pool-incentives/keeper/distr.go @@ -21,7 +21,7 @@ func (k Keeper) FundCommunityPoolFromModule(ctx sdk.Context, asset sdk.Coin) err return nil } -// AllocateAsset allocates and distributes coin according a gauge’s proportional weight that is recorded in the record +// AllocateAsset allocates and distributes coin according a gauge’s proportional weight that is recorded in the record. func (k Keeper) AllocateAsset(ctx sdk.Context) error { logger := k.Logger(ctx) params := k.GetParams(ctx) @@ -85,7 +85,7 @@ func (k Keeper) SetDistrInfo(ctx sdk.Context, distrInfo types.DistrInfo) { // Validates a list of records to ensure that: // 1) there are no duplicates, // 2) the records are in sorted order. -// 3) the records only pay to gauges that exist +// 3) the records only pay to gauges that exist. func (k Keeper) validateRecords(ctx sdk.Context, records ...types.DistrRecord) error { lastGaugeID := uint64(0) gaugeIdFlags := make(map[uint64]bool) @@ -127,7 +127,7 @@ func (k Keeper) validateRecords(ctx sdk.Context, records ...types.DistrRecord) e return nil } -// This is checked for no err when a proposal is made, and executed when a proposal passes +// This is checked for no err when a proposal is made, and executed when a proposal passes. func (k Keeper) ReplaceDistrRecords(ctx sdk.Context, records ...types.DistrRecord) error { distrInfo := k.GetDistrInfo(ctx) @@ -149,9 +149,8 @@ func (k Keeper) ReplaceDistrRecords(ctx sdk.Context, records ...types.DistrRecor return nil } -// This is checked for no err when a proposal is made, and executed when a proposal passes +// This is checked for no err when a proposal is made, and executed when a proposal passes. func (k Keeper) UpdateDistrRecords(ctx sdk.Context, records ...types.DistrRecord) error { - recordsMap := make(map[uint64]types.DistrRecord) totalWeight := sdk.NewInt(0) diff --git a/x/pool-incentives/keeper/grpc_query.go b/x/pool-incentives/keeper/grpc_query.go index 02e46cf89f2..28d1fd45db2 100644 --- a/x/pool-incentives/keeper/grpc_query.go +++ b/x/pool-incentives/keeper/grpc_query.go @@ -28,7 +28,6 @@ func (k Keeper) GaugeIds(ctx context.Context, req *types.QueryGaugeIdsRequest) ( for i, duration := range lockableDurations { gaugeId, err := k.GetPoolGaugeId(sdkCtx, req.PoolId, duration) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -83,7 +82,6 @@ func (k Keeper) IncentivizedPools(ctx context.Context, _ *types.QueryIncentivize incentivizedPools = append(incentivizedPools, incentivizedPool) } } - } return &types.QueryIncentivizedPoolsResponse{ @@ -92,7 +90,7 @@ func (k Keeper) IncentivizedPools(ctx context.Context, _ *types.QueryIncentivize } // ExternalIncentiveGauges iterates over all gauges, returns gauges externally incentivized, -// excluding default gagues created with pool +// excluding default gagues created with pool. func (k Keeper) ExternalIncentiveGauges(ctx context.Context, req *types.QueryExternalIncentiveGaugesRequest) (*types.QueryExternalIncentiveGaugesResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) store := sdkCtx.KVStore(k.storeKey) diff --git a/x/pool-incentives/keeper/hooks.go b/x/pool-incentives/keeper/hooks.go index 5135c5fedb5..4fe21bf1979 100644 --- a/x/pool-incentives/keeper/hooks.go +++ b/x/pool-incentives/keeper/hooks.go @@ -12,10 +12,10 @@ type Hooks struct { var _ gammtypes.GammHooks = Hooks{} -// Create new pool incentives hooks +// Create new pool incentives hooks. func (k Keeper) Hooks() Hooks { return Hooks{k} } -// AfterPoolCreated creates a gauge for each pool’s lockable duration +// AfterPoolCreated creates a gauge for each pool’s lockable duration. func (h Hooks) AfterPoolCreated(ctx sdk.Context, sender sdk.AccAddress, poolId uint64) { err := h.k.CreatePoolGauges(ctx, poolId) if err != nil { @@ -23,22 +23,19 @@ func (h Hooks) AfterPoolCreated(ctx sdk.Context, sender sdk.AccAddress, poolId u } } -// AfterJoinPool hook is a noop +// AfterJoinPool hook is a noop. func (h Hooks) AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, enterCoins sdk.Coins, shareOutAmount sdk.Int) { - } -// AfterExitPool hook is a noop +// AfterExitPool hook is a noop. func (h Hooks) AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, shareInAmount sdk.Int, exitCoins sdk.Coins) { - } -// AfterSwap hook is a noop +// AfterSwap hook is a noop. func (h Hooks) AfterSwap(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) { - } -// Distribute coins after minter module allocate assets to pool-incentives module +// Distribute coins after minter module allocate assets to pool-incentives module. func (h Hooks) AfterDistributeMintedCoin(ctx sdk.Context, mintedCoin sdk.Coin) { // @Sunny, @Tony, @Dev, what comments should we keep after modifying own BeginBlocker to hooks? diff --git a/x/pool-incentives/module.go b/x/pool-incentives/module.go index 4ffc667e528..6ac205bd05c 100644 --- a/x/pool-incentives/module.go +++ b/x/pool-incentives/module.go @@ -58,7 +58,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod } //--------------------------------------- -// Interfaces +// Interfaces. func (b AppModuleBasic) RegisterRESTRoutes(ctx client.Context, r *mux.Router) { // noop } @@ -101,7 +101,6 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { // RegisterInvariants registers the pool-incentives module invariants. func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { - return } // Route returns the message routing key for the pool-incentives module. @@ -164,9 +163,8 @@ func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { return simulation.ParamChanges(r) } -// RegisterStoreDecoder registers a decoder for supply module's types +// RegisterStoreDecoder registers a decoder for supply module's types. func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { - } // WeightedOperations returns the all the gov module operations with their respective weights. diff --git a/x/pool-incentives/types/genesis.go b/x/pool-incentives/types/genesis.go index fdaefeadd63..119ec526758 100644 --- a/x/pool-incentives/types/genesis.go +++ b/x/pool-incentives/types/genesis.go @@ -18,7 +18,7 @@ func NewGenesisState(params Params, lockableDurations []time.Duration, distrInfo } } -// DefaultGenesisState gets the raw genesis raw message for testing +// DefaultGenesisState gets the raw genesis raw message for testing. func DefaultGenesisState() *GenesisState { return &GenesisState{ Params: DefaultParams(), @@ -47,7 +47,7 @@ func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.R } // ValidateGenesis validates the provided pool-yield genesis state to ensure the -// expected invariants holds. (i.e. params in correct bounds) +// expected invariants holds. (i.e. params in correct bounds). func ValidateGenesis(data *GenesisState) error { if err := data.Params.Validate(); err != nil { return err diff --git a/x/pool-incentives/types/gov.go b/x/pool-incentives/types/gov.go index 4f517b1e710..53af9ca90e9 100644 --- a/x/pool-incentives/types/gov.go +++ b/x/pool-incentives/types/gov.go @@ -19,8 +19,10 @@ func init() { govtypes.RegisterProposalTypeCodec(&ReplacePoolIncentivesProposal{}, "osmosis/ReplacePoolIncentivesProposal") } -var _ govtypes.Content = &UpdatePoolIncentivesProposal{} -var _ govtypes.Content = &ReplacePoolIncentivesProposal{} +var ( + _ govtypes.Content = &UpdatePoolIncentivesProposal{} + _ govtypes.Content = &ReplacePoolIncentivesProposal{} +) func NewReplacePoolIncentivesProposal(title, description string, records []DistrRecord) govtypes.Content { return &ReplacePoolIncentivesProposal{ diff --git a/x/pool-incentives/types/params.go b/x/pool-incentives/types/params.go index 3435a69c759..5fdb99307d3 100644 --- a/x/pool-incentives/types/params.go +++ b/x/pool-incentives/types/params.go @@ -11,9 +11,7 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) -var ( - KeyMintedDenom = []byte("MintedDenom") -) +var KeyMintedDenom = []byte("MintedDenom") func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) @@ -25,7 +23,7 @@ func NewParams(mintedDenom string) Params { } } -// DefaultParams is the default parameter configuration for the pool-incentives module +// DefaultParams is the default parameter configuration for the pool-incentives module. func DefaultParams() Params { return NewParams(sdk.DefaultBondDenom) } diff --git a/x/simulation/mod.go b/x/simulation/mod.go index 56f7aeb95f1..736b2ee6bc5 100644 --- a/x/simulation/mod.go +++ b/x/simulation/mod.go @@ -43,7 +43,8 @@ func GenAndDeliverTxWithRandFees( simAccount simtypes.Account, ak stakingTypes.AccountKeeper, bk stakingTypes.BankKeeper, - moduleName string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + moduleName string, +) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { account := ak.GetAccount(ctx, simAccount.Address) spendable := bk.SpendableCoins(ctx, account.GetAddress()) @@ -73,7 +74,8 @@ func GenAndDeliverTx( ctx sdk.Context, simAccount simtypes.Account, ak stakingTypes.AccountKeeper, - moduleName string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + moduleName string, +) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { account := ak.GetAccount(ctx, simAccount.Address) tx, err := helpers.GenTx( txGen, @@ -85,7 +87,6 @@ func GenAndDeliverTx( []uint64{account.GetSequence()}, simAccount.PrivKey, ) - if err != nil { return simtypes.NoOpMsg(moduleName, msg.Type(), "unable to generate mock tx"), nil, err } @@ -96,5 +97,4 @@ func GenAndDeliverTx( } return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil - } diff --git a/x/superfluid/abci.go b/x/superfluid/abci.go index 8b4a2bd479e..36acf7e16da 100644 --- a/x/superfluid/abci.go +++ b/x/superfluid/abci.go @@ -8,7 +8,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/superfluid/types" ) -// BeginBlocker is called on every block +// BeginBlocker is called on every block. func BeginBlocker(ctx sdk.Context, k keeper.Keeper, ek types.EpochKeeper) { numBlocksSinceEpochStart, err := ek.NumBlocksSinceEpochStart(ctx, k.GetEpochIdentifier(ctx)) if err != nil { @@ -19,7 +19,7 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper, ek types.EpochKeeper) { } } -// Called every block to automatically unlock matured locks +// Called every block to automatically unlock matured locks. func EndBlocker(ctx sdk.Context, k keeper.Keeper) []abci.ValidatorUpdate { return []abci.ValidatorUpdate{} } diff --git a/x/superfluid/client/cli/flags.go b/x/superfluid/client/cli/flags.go index 8ba44decf18..92d4d3c631c 100644 --- a/x/superfluid/client/cli/flags.go +++ b/x/superfluid/client/cli/flags.go @@ -1,6 +1,6 @@ package cli -// Proposal flags +// Proposal flags. const ( FlagSuperfluidAssets = "superfluid-assets" ) diff --git a/x/superfluid/client/cli/query.go b/x/superfluid/client/cli/query.go index 80f37909950..f9ed9ecb70b 100644 --- a/x/superfluid/client/cli/query.go +++ b/x/superfluid/client/cli/query.go @@ -12,7 +12,7 @@ import ( "github.com/spf13/cobra" ) -// GetQueryCmd returns the cli query commands for this module +// GetQueryCmd returns the cli query commands for this module. func GetQueryCmd(queryRoute string) *cobra.Command { // Group superfluid queries under a subcommand cmd := &cobra.Command{ @@ -70,7 +70,7 @@ $ query superfluid params return cmd } -// GetCmdAllSuperfluidAssets returns all superfluid enabled assets +// GetCmdAllSuperfluidAssets returns all superfluid enabled assets. func GetCmdAllSuperfluidAssets() *cobra.Command { cmd := &cobra.Command{ Use: "all-superfluid-assets", @@ -106,7 +106,7 @@ $ %s query superfluid all-superfluid-assets return cmd } -// GetCmdAssetMultiplier returns multiplier of an asset by denom +// GetCmdAssetMultiplier returns multiplier of an asset by denom. func GetCmdAssetMultiplier() *cobra.Command { cmd := &cobra.Command{ Use: "asset-multiplier [denom]", @@ -144,7 +144,7 @@ $ %s query superfluid asset-multiplier gamm/pool/1 return cmd } -// GetCmdAllIntermediaryAccounts returns all superfluid intermediary accounts +// GetCmdAllIntermediaryAccounts returns all superfluid intermediary accounts. func GetCmdAllIntermediaryAccounts() *cobra.Command { cmd := &cobra.Command{ Use: "all-intermediary-accounts", @@ -188,7 +188,7 @@ $ %s query superfluid all-intermediary-accounts return cmd } -// GetCmdConnectedIntermediaryAccount returns connected intermediary account +// GetCmdConnectedIntermediaryAccount returns connected intermediary account. func GetCmdConnectedIntermediaryAccount() *cobra.Command { cmd := &cobra.Command{ Use: "connected-intermediary-account [lock_id]", @@ -232,7 +232,7 @@ $ %s query superfluid connected-intermediary-account 1 } // GetCmdSuperfluidDelegationAmount returns the coins superfluid delegated for a -// delegator, validator, denom +// delegator, validator, denom. func GetCmdSuperfluidDelegationAmount() *cobra.Command { cmd := &cobra.Command{ Use: "superfluid-delegation-amount [delegator_address] [validator_address] [denom]", @@ -250,7 +250,6 @@ func GetCmdSuperfluidDelegationAmount() *cobra.Command { ValidatorAddress: args[1], Denom: args[2], }) - if err != nil { return err } @@ -264,7 +263,7 @@ func GetCmdSuperfluidDelegationAmount() *cobra.Command { return cmd } -// GetCmdSuperfluidDelegationsByDelegator returns the coins superfluid delegated for the specified delegator +// GetCmdSuperfluidDelegationsByDelegator returns the coins superfluid delegated for the specified delegator. func GetCmdSuperfluidDelegationsByDelegator() *cobra.Command { cmd := &cobra.Command{ Use: "superfluid-delegation-by-delegator [delegator_address]", @@ -280,7 +279,6 @@ func GetCmdSuperfluidDelegationsByDelegator() *cobra.Command { res, err := queryClient.SuperfluidDelegationsByDelegator(cmd.Context(), &types.SuperfluidDelegationsByDelegatorRequest{ DelegatorAddress: args[0], }) - if err != nil { return err } @@ -294,7 +292,7 @@ func GetCmdSuperfluidDelegationsByDelegator() *cobra.Command { return cmd } -// GetCmdSuperfluidUndelegationsByDelegator returns the coins superfluid undelegated for the specified delegator +// GetCmdSuperfluidUndelegationsByDelegator returns the coins superfluid undelegated for the specified delegator. func GetCmdSuperfluidUndelegationsByDelegator() *cobra.Command { cmd := &cobra.Command{ Use: "superfluid-undelegation-by-delegator [delegator_address]", @@ -310,7 +308,6 @@ func GetCmdSuperfluidUndelegationsByDelegator() *cobra.Command { res, err := queryClient.SuperfluidUndelegationsByDelegator(cmd.Context(), &types.SuperfluidUndelegationsByDelegatorRequest{ DelegatorAddress: args[0], }) - if err != nil { return err } @@ -324,7 +321,7 @@ func GetCmdSuperfluidUndelegationsByDelegator() *cobra.Command { return cmd } -// GetCmdTotalSuperfluidDelegations returns total amount of base denom delegated via superfluid staking +// GetCmdTotalSuperfluidDelegations returns total amount of base denom delegated via superfluid staking. func GetCmdTotalSuperfluidDelegations() *cobra.Command { cmd := &cobra.Command{ Use: "total-superfluid-delegations", @@ -338,7 +335,6 @@ func GetCmdTotalSuperfluidDelegations() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) res, err := queryClient.TotalSuperfluidDelegations(cmd.Context(), &types.TotalSuperfluidDelegationsRequest{}) - if err != nil { return err } diff --git a/x/superfluid/client/cli/tx.go b/x/superfluid/client/cli/tx.go index fa7a7a0350c..aa0ce7ca4dc 100644 --- a/x/superfluid/client/cli/tx.go +++ b/x/superfluid/client/cli/tx.go @@ -15,7 +15,7 @@ import ( "github.com/spf13/cobra" ) -// GetTxCmd returns the transaction commands for this module +// GetTxCmd returns the transaction commands for this module. func GetTxCmd() *cobra.Command { cmd := &cobra.Command{ Use: types.ModuleName, @@ -38,7 +38,7 @@ func GetTxCmd() *cobra.Command { return cmd } -// NewSuperfluidDelegateCmd broadcast MsgSuperfluidDelegate +// NewSuperfluidDelegateCmd broadcast MsgSuperfluidDelegate. func NewSuperfluidDelegateCmd() *cobra.Command { cmd := &cobra.Command{ Use: "delegate [lock_id] [val_addr] [flags]", @@ -76,7 +76,7 @@ func NewSuperfluidDelegateCmd() *cobra.Command { return cmd } -// NewSuperfluidUndelegateCmd broadcast MsgSuperfluidUndelegate +// NewSuperfluidUndelegateCmd broadcast MsgSuperfluidUndelegate. func NewSuperfluidUndelegateCmd() *cobra.Command { cmd := &cobra.Command{ Use: "undelegate [lock_id] [flags]", @@ -108,7 +108,7 @@ func NewSuperfluidUndelegateCmd() *cobra.Command { return cmd } -// NewSuperfluidUnbondLock broadcast MsgSuperfluidUndelegate and +// NewSuperfluidUnbondLock broadcast MsgSuperfluidUndelegate and. func NewSuperfluidUnbondLockCmd() *cobra.Command { cmd := &cobra.Command{ Use: "unbond-lock [lock_id] [flags]", diff --git a/x/superfluid/client/proposal_handler.go b/x/superfluid/client/proposal_handler.go index 5a2132b1bde..d1a2ada1a5c 100644 --- a/x/superfluid/client/proposal_handler.go +++ b/x/superfluid/client/proposal_handler.go @@ -6,5 +6,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/superfluid/client/rest" ) -var SetSuperfluidAssetsProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitSetSuperfluidAssetsProposal, rest.ProposalSetSuperfluidAssetsRESTHandler) -var RemoveSuperfluidAssetsProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitRemoveSuperfluidAssetsProposal, rest.ProposalRemoveSuperfluidAssetsRESTHandler) +var ( + SetSuperfluidAssetsProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitSetSuperfluidAssetsProposal, rest.ProposalSetSuperfluidAssetsRESTHandler) + RemoveSuperfluidAssetsProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitRemoveSuperfluidAssetsProposal, rest.ProposalRemoveSuperfluidAssetsRESTHandler) +) diff --git a/x/superfluid/client/rest/tx.go b/x/superfluid/client/rest/tx.go index 9830411e3ff..24c67bb3775 100644 --- a/x/superfluid/client/rest/tx.go +++ b/x/superfluid/client/rest/tx.go @@ -16,7 +16,6 @@ func ProposalSetSuperfluidAssetsRESTHandler(clientCtx client.Context) govrest.Pr func newSetSuperfluidAssetsHandler(clientCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - } } @@ -29,6 +28,5 @@ func ProposalRemoveSuperfluidAssetsRESTHandler(clientCtx client.Context) govrest func newRemoveSuperfluidAssetsHandler(clientCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - } } diff --git a/x/superfluid/keeper/grpc_query.go b/x/superfluid/keeper/grpc_query.go index 13411c29bb2..c67cf220a94 100644 --- a/x/superfluid/keeper/grpc_query.go +++ b/x/superfluid/keeper/grpc_query.go @@ -13,7 +13,7 @@ import ( var _ types.QueryServer = Keeper{} -// Params returns the superfluid module params +// Params returns the superfluid module params. func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -24,7 +24,7 @@ func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*t }, nil } -// AssetType Returns superfluid asset type +// AssetType Returns superfluid asset type. func (k Keeper) AssetType(goCtx context.Context, req *types.AssetTypeRequest) (*types.AssetTypeResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) asset := k.GetSuperfluidAsset(ctx, req.Denom) @@ -33,7 +33,7 @@ func (k Keeper) AssetType(goCtx context.Context, req *types.AssetTypeRequest) (* }, nil } -// AllAssets Returns all superfluid assets info +// AllAssets Returns all superfluid assets info. func (k Keeper) AllAssets(goCtx context.Context, req *types.AllAssetsRequest) (*types.AllAssetsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) assets := k.GetAllSuperfluidAssets(ctx) @@ -42,7 +42,7 @@ func (k Keeper) AllAssets(goCtx context.Context, req *types.AllAssetsRequest) (* }, nil } -// AssetMultiplier returns superfluid asset multiplier +// AssetMultiplier returns superfluid asset multiplier. func (k Keeper) AssetMultiplier(goCtx context.Context, req *types.AssetMultiplierRequest) (*types.AssetMultiplierResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) epochInfo := k.ek.GetEpochInfo(ctx, k.GetEpochIdentifier(ctx)) @@ -56,7 +56,7 @@ func (k Keeper) AssetMultiplier(goCtx context.Context, req *types.AssetMultiplie }, nil } -// AllIntermediaryAccounts returns all superfluid intermediary accounts +// AllIntermediaryAccounts returns all superfluid intermediary accounts. func (k Keeper) AllIntermediaryAccounts(goCtx context.Context, req *types.AllIntermediaryAccountsRequest) (*types.AllIntermediaryAccountsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) accounts := k.GetAllIntermediaryAccounts(ctx) @@ -74,7 +74,7 @@ func (k Keeper) AllIntermediaryAccounts(goCtx context.Context, req *types.AllInt }, nil } -// ConnectedIntermediaryAccount returns intermediary account connected to a superfluid staked lock by id +// ConnectedIntermediaryAccount returns intermediary account connected to a superfluid staked lock by id. func (k Keeper) ConnectedIntermediaryAccount(goCtx context.Context, req *types.ConnectedIntermediaryAccountRequest) (*types.ConnectedIntermediaryAccountResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) address := k.GetLockIdIntermediaryAccountConnection(ctx, req.LockId) @@ -102,7 +102,7 @@ func (k Keeper) ConnectedIntermediaryAccount(goCtx context.Context, req *types.C } // SuperfluidDelegationAmount returns the coins superfluid delegated for a -//delegator, validator, denom triplet + func (k Keeper) SuperfluidDelegationAmount(goCtx context.Context, req *types.SuperfluidDelegationAmountRequest) (*types.SuperfluidDelegationAmountResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -125,13 +125,13 @@ func (k Keeper) SuperfluidDelegationAmount(goCtx context.Context, req *types.Sup periodLocks := k.lk.GetAccountLockedLongerDurationDenomNotUnlockingOnly(ctx, delAddr, syntheticDenom, time.Second) if len(periodLocks) == 0 { - return &types.SuperfluidDelegationAmountResponse{sdk.NewCoins()}, nil + return &types.SuperfluidDelegationAmountResponse{Amount: sdk.NewCoins()}, nil } - return &types.SuperfluidDelegationAmountResponse{periodLocks[0].GetCoins()}, nil + return &types.SuperfluidDelegationAmountResponse{Amount: periodLocks[0].GetCoins()}, nil } -// SuperfluidDelegationsByDelegator returns all the superfluid poistions for a specific delegator +// SuperfluidDelegationsByDelegator returns all the superfluid poistions for a specific delegator. func (k Keeper) SuperfluidDelegationsByDelegator(goCtx context.Context, req *types.SuperfluidDelegationsByDelegatorRequest) (*types.SuperfluidDelegationsByDelegatorResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -174,10 +174,9 @@ func (k Keeper) SuperfluidDelegationsByDelegator(goCtx context.Context, req *typ res.TotalDelegatedCoins = res.TotalDelegatedCoins.Add(lockedCoins) } return &res, nil - } -// SuperfluidUndelegationsByDelegator returns total amount undelegating by delegator +// SuperfluidUndelegationsByDelegator returns total amount undelegating by delegator. func (k Keeper) SuperfluidUndelegationsByDelegator(goCtx context.Context, req *types.SuperfluidUndelegationsByDelegatorRequest) (*types.SuperfluidUndelegationsByDelegatorResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -224,7 +223,7 @@ func (k Keeper) SuperfluidUndelegationsByDelegator(goCtx context.Context, req *t } // SuperfluidDelegationsByValidatorDenom returns all the superfluid positions -// of a specific denom delegated to one validator +// of a specific denom delegated to one validator. func (k Keeper) SuperfluidDelegationsByValidatorDenom(goCtx context.Context, req *types.SuperfluidDelegationsByValidatorDenomRequest) (*types.SuperfluidDelegationsByValidatorDenomResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -261,7 +260,7 @@ func (k Keeper) SuperfluidDelegationsByValidatorDenom(goCtx context.Context, req // EstimateSuperfluidDelegatedAmountByValidatorDenom returns the amount of a // specific denom delegated to a specific validator // This is labeled an estimate, because the way it calculates the amount can -// lead rounding errors from the true delegated amount +// lead rounding errors from the true delegated amount. func (k Keeper) EstimateSuperfluidDelegatedAmountByValidatorDenom(goCtx context.Context, req *types.EstimateSuperfluidDelegatedAmountByValidatorDenomRequest) (*types.EstimateSuperfluidDelegatedAmountByValidatorDenomResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -298,7 +297,7 @@ func (k Keeper) EstimateSuperfluidDelegatedAmountByValidatorDenom(goCtx context. }, nil } -// TotalSuperfluidDelegations returns total amount of osmo delegated via superfluid staking +// TotalSuperfluidDelegations returns total amount of osmo delegated via superfluid staking. func (k Keeper) TotalSuperfluidDelegations(goCtx context.Context, req *types.TotalSuperfluidDelegationsRequest) (*types.TotalSuperfluidDelegationsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/x/superfluid/keeper/hooks.go b/x/superfluid/keeper/hooks.go index 298ff908ded..5f74f4f13b2 100644 --- a/x/superfluid/keeper/hooks.go +++ b/x/superfluid/keeper/hooks.go @@ -9,20 +9,20 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/superfluid/types" ) -// Hooks wrapper struct for incentives keeper +// Hooks wrapper struct for incentives keeper. type Hooks struct { k Keeper } var _ epochstypes.EpochHooks = Hooks{} -// Return the wrapper struct +// Return the wrapper struct. func (k Keeper) Hooks() Hooks { return Hooks{k} } // epochs hooks -// Don't do anything pre epoch start +// Don't do anything pre epoch start. func (h Hooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) { } @@ -58,36 +58,42 @@ func (h Hooks) OnStartUnlock(ctx sdk.Context, address sdk.AccAddress, lockID uin } func (h Hooks) OnTokenUnlocked(ctx sdk.Context, address sdk.AccAddress, lockID uint64, amount sdk.Coins, lockDuration time.Duration, unlockTime time.Time) { - } func (h Hooks) OnTokenSlashed(ctx sdk.Context, lockID uint64, amount sdk.Coins) { - } -// staking hooks +// staking hooks. func (h Hooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) {} func (h Hooks) BeforeValidatorModified(ctx sdk.Context, valAddr sdk.ValAddress) {} func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) { } + func (h Hooks) AfterValidatorBonded(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) { } + func (h Hooks) AfterValidatorBeginUnbonding(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) { } + func (h Hooks) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) { } + func (h Hooks) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) { } + func (h Hooks) BeforeDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) { } + func (h Hooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) { } + func (h Hooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, infractionHeight int64, slashFactor sdk.Dec, effectiveSlashFactor sdk.Dec) { if slashFactor.IsZero() { return } h.k.SlashLockupsForValidatorSlash(ctx, valAddr, infractionHeight, slashFactor) } + func (h Hooks) AfterValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, infractionHeight int64, slashFactor sdk.Dec, effectiveSlashFactor sdk.Dec) { if slashFactor.IsZero() { return diff --git a/x/superfluid/keeper/intermediary_account.go b/x/superfluid/keeper/intermediary_account.go index 992d5522fd2..cc6d3c5fbe6 100644 --- a/x/superfluid/keeper/intermediary_account.go +++ b/x/superfluid/keeper/intermediary_account.go @@ -77,7 +77,6 @@ func (k Keeper) GetOrCreateIntermediaryAccount(ctx sdk.Context, denom, valAddr s Denom: stakingSyntheticDenom(denom, valAddr), Duration: k.sk.GetParams(ctx).UnbondingTime, }, ctx.BlockTime(), 1) - if err != nil { k.Logger(ctx).Error(err.Error()) return types.SuperfluidIntermediaryAccount{}, err @@ -143,7 +142,7 @@ func (k Keeper) GetAllLockIdIntermediaryAccountConnections(ctx sdk.Context) []ty return connections } -// Returns Superfluid Intermediate Account and a bool if found / not found +// Returns Superfluid Intermediate Account and a bool if found / not found. func (k Keeper) GetIntermediaryAccountFromLockId(ctx sdk.Context, lockId uint64) (types.SuperfluidIntermediaryAccount, bool) { addr := k.GetLockIdIntermediaryAccountConnection(ctx, lockId) if addr.Empty() { diff --git a/x/superfluid/keeper/invariants.go b/x/superfluid/keeper/invariants.go index a9ce58b76ef..52ff07e4162 100644 --- a/x/superfluid/keeper/invariants.go +++ b/x/superfluid/keeper/invariants.go @@ -10,19 +10,19 @@ import ( const totalSuperfluidDelegationInvariantName = "total-superfluid-delegation-invariant-name" -// RegisterInvariants registers all governance invariants +// RegisterInvariants registers all governance invariants. func RegisterInvariants(ir sdk.InvariantRegistry, keeper Keeper) { ir.RegisterRoute(types.ModuleName, totalSuperfluidDelegationInvariantName, TotalSuperfluidDelegationInvariant(keeper)) } -// AllInvariants runs all invariants of the gamm module +// AllInvariants runs all invariants of the gamm module. func AllInvariants(keeper Keeper) sdk.Invariant { return func(ctx sdk.Context) (string, bool) { return TotalSuperfluidDelegationInvariant(keeper)(ctx) } } -// TotalSuperfluidDelegationInvariant checks the sum of intermediary account delegation is same as sum of individual lockup delegation +// TotalSuperfluidDelegationInvariant checks the sum of intermediary account delegation is same as sum of individual lockup delegation. func TotalSuperfluidDelegationInvariant(keeper Keeper) sdk.Invariant { return func(ctx sdk.Context) (string, bool) { accs := keeper.GetAllIntermediaryAccounts(ctx) diff --git a/x/superfluid/keeper/keeper.go b/x/superfluid/keeper/keeper.go index 496b0db179b..e50e248562f 100644 --- a/x/superfluid/keeper/keeper.go +++ b/x/superfluid/keeper/keeper.go @@ -11,7 +11,7 @@ import ( "github.com/tendermint/tendermint/libs/log" ) -// Keeper provides a way to manage module storage +// Keeper provides a way to manage module storage. type Keeper struct { cdc codec.Codec storeKey sdk.StoreKey @@ -29,7 +29,7 @@ type Keeper struct { lms types.LockupMsgServer } -// NewKeeper returns an instance of Keeper +// NewKeeper returns an instance of Keeper. func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, paramSpace paramtypes.Subspace, ak authkeeper.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper, dk types.DistrKeeper, ek types.EpochKeeper, lk types.LockupKeeper, gk types.GammKeeper, ik types.IncentivesKeeper, lms types.LockupMsgServer) *Keeper { // set KeyTable if it has not already been set if !paramSpace.HasKeyTable() { @@ -53,7 +53,7 @@ func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, paramSpace paramtypes.Sub } } -// Logger returns a logger instance +// Logger returns a logger instance. func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } diff --git a/x/superfluid/keeper/msg_server.go b/x/superfluid/keeper/msg_server.go index 74347481f2b..67df89e50b1 100644 --- a/x/superfluid/keeper/msg_server.go +++ b/x/superfluid/keeper/msg_server.go @@ -13,7 +13,7 @@ type msgServer struct { keeper *Keeper } -// NewMsgServerImpl returns an instance of MsgServer +// NewMsgServerImpl returns an instance of MsgServer. func NewMsgServerImpl(keeper *Keeper) types.MsgServer { return &msgServer{ keeper: keeper, @@ -57,7 +57,8 @@ func (server msgServer) SuperfluidUndelegate(goCtx context.Context, msg *types.M // } func (server msgServer) SuperfluidUnbondLock(goCtx context.Context, msg *types.MsgSuperfluidUnbondLock) ( - *types.MsgSuperfluidUnbondLockResponse, error) { + *types.MsgSuperfluidUnbondLockResponse, error, +) { ctx := sdk.UnwrapSDKContext(goCtx) err := server.keeper.SuperfluidUnbondLock(ctx, msg.LockId, msg.Sender) diff --git a/x/superfluid/keeper/params.go b/x/superfluid/keeper/params.go index ba7019fec1d..2e1add40857 100644 --- a/x/superfluid/keeper/params.go +++ b/x/superfluid/keeper/params.go @@ -5,18 +5,18 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/superfluid/types" ) -// GetParams returns the total set params +// GetParams returns the total set params. func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { k.paramSpace.GetParamSet(ctx, ¶ms) return params } -// GetParams returns the total set params +// GetParams returns the total set params. func (k Keeper) GetEpochIdentifier(ctx sdk.Context) (epochIdentifier string) { return k.ik.GetParams(ctx).DistrEpochIdentifier } -// SetParams sets the total set of params +// SetParams sets the total set of params. func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { k.paramSpace.SetParamSet(ctx, ¶ms) } diff --git a/x/superfluid/keeper/stake.go b/x/superfluid/keeper/stake.go index 95a98c73f86..9a5ac9c0881 100644 --- a/x/superfluid/keeper/stake.go +++ b/x/superfluid/keeper/stake.go @@ -60,7 +60,6 @@ func (k Keeper) RefreshIntermediaryDelegationAmounts(ctx sdk.Context) { refreshedAmount := k.GetExpectedDelegationAmount(ctx, acc) if refreshedAmount.GT(currentAmount) { - //need to mint and delegate adjustment := refreshedAmount.Sub(currentAmount) err = k.mintOsmoTokensAndDelegate(ctx, adjustment, acc) if err != nil { @@ -157,7 +156,7 @@ func (k Keeper) validateValAddrForDelegate(ctx sdk.Context, valAddr string) (sta return validator, nil } -// TODO: Merge a lot of logic with IncreaseSuperfluidDelegation +// TODO: Merge a lot of logic with IncreaseSuperfluidDelegation. func (k Keeper) SuperfluidDelegate(ctx sdk.Context, sender string, lockID uint64, valAddr string) error { lock, err := k.lk.GetLockByID(ctx, lockID) if err != nil { @@ -270,7 +269,7 @@ func (k Keeper) alreadySuperfluidStaking(ctx sdk.Context, lockID uint64) bool { return len(synthLocks) > 0 } -// mint osmoAmount of OSMO tokens, and immediately delegate them to validator on behalf of intermediary account +// mint osmoAmount of OSMO tokens, and immediately delegate them to validator on behalf of intermediary account. func (k Keeper) mintOsmoTokensAndDelegate(ctx sdk.Context, osmoAmount sdk.Int, intermediaryAccount types.SuperfluidIntermediaryAccount) error { validator, err := k.validateValAddrForDelegate(ctx, intermediaryAccount.ValAddr) if err != nil { @@ -304,7 +303,8 @@ func (k Keeper) mintOsmoTokensAndDelegate(ctx sdk.Context, osmoAmount sdk.Int, i // force undelegate osmoAmount worth of delegation shares from delegations between intermediary account and valAddr // We take the returned tokens, and then immediately burn them. func (k Keeper) forceUndelegateAndBurnOsmoTokens(ctx sdk.Context, - osmoAmount sdk.Int, intermediaryAcc types.SuperfluidIntermediaryAccount) error { + osmoAmount sdk.Int, intermediaryAcc types.SuperfluidIntermediaryAccount, +) error { valAddr, err := sdk.ValAddressFromBech32(intermediaryAcc.ValAddr) if err != nil { return err diff --git a/x/superfluid/keeper/synthetic_lock_wrapper.go b/x/superfluid/keeper/synthetic_lock_wrapper.go index 427af6c7657..033a87949a1 100644 --- a/x/superfluid/keeper/synthetic_lock_wrapper.go +++ b/x/superfluid/keeper/synthetic_lock_wrapper.go @@ -16,7 +16,7 @@ func unstakingSyntheticDenom(denom, valAddr string) string { return fmt.Sprintf("%s/superunbonding/%s", denom, valAddr) } -// quick fix for getting the validator addresss from a synthetic denom +// quick fix for getting the validator addresss from a synthetic denom. func ValidatorAddressFromSyntheticDenom(syntheticDenom string) (string, error) { if strings.Contains(syntheticDenom, "superbonding") { splitString := strings.Split(syntheticDenom, "/superbonding/") @@ -39,7 +39,8 @@ const ( ) func (k Keeper) createSyntheticLockup(ctx sdk.Context, - underlyingLockId uint64, intermediateAcc types.SuperfluidIntermediaryAccount, lockingStat lockingStatus) error { + underlyingLockId uint64, intermediateAcc types.SuperfluidIntermediaryAccount, lockingStat lockingStatus, +) error { unbondingDuration := k.sk.GetParams(ctx).UnbondingTime if lockingStat == unlockingStatus { isUnlocking := true diff --git a/x/superfluid/module.go b/x/superfluid/module.go index d67d14fd915..b9de6d887d3 100644 --- a/x/superfluid/module.go +++ b/x/superfluid/module.go @@ -55,7 +55,7 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { types.RegisterCodec(cdc) } -// RegisterInterfaces registers the module's interface types +// RegisterInterfaces registers the module's interface types. func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { types.RegisterInterfaces(reg) } @@ -210,7 +210,7 @@ func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { return nil // TODO } -// RegisterStoreDecoder registers a decoder for supply module's types +// RegisterStoreDecoder registers a decoder for supply module's types. func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { // TODO } diff --git a/x/superfluid/simulation/genesis.go b/x/superfluid/simulation/genesis.go index 40d4f48963d..1d1e5e9fa14 100644 --- a/x/superfluid/simulation/genesis.go +++ b/x/superfluid/simulation/genesis.go @@ -9,7 +9,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/superfluid/types" ) -// RandomizedGenState generates a random GenesisState for staking +// RandomizedGenState generates a random GenesisState for staking. func RandomizedGenState(simState *module.SimulationState) { superfluidGenesis := &types.GenesisState{ Params: types.Params{ diff --git a/x/superfluid/simulation/operations.go b/x/superfluid/simulation/operations.go index b60fcabccc3..8c3b613e789 100644 --- a/x/superfluid/simulation/operations.go +++ b/x/superfluid/simulation/operations.go @@ -17,7 +17,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/superfluid/types" ) -// Simulation operation weights constants +// Simulation operation weights constants. const ( DefaultWeightMsgSuperfluidDelegate int = 100 DefaultWeightMsgSuperfluidUndelegate int = 50 @@ -30,7 +30,7 @@ const ( OpWeightMsgSuperfluidRedelegate = "op_weight_msg_superfluid_redelegate" ) -// WeightedOperations returns all the operations from the module with their respective weights +// WeightedOperations returns all the operations from the module with their respective weights. func WeightedOperations( appParams simtypes.AppParams, cdc codec.JSONCodec, ak stakingtypes.AccountKeeper, bk stakingtypes.BankKeeper, sk types.StakingKeeper, lk types.LockupKeeper, k keeper.Keeper, @@ -75,12 +75,11 @@ func WeightedOperations( } } -// SimulateMsgSuperfluidDelegate generates a MsgSuperfluidDelegate with random values +// SimulateMsgSuperfluidDelegate generates a MsgSuperfluidDelegate with random values. func SimulateMsgSuperfluidDelegate(ak stakingtypes.AccountKeeper, bk stakingtypes.BankKeeper, sk types.StakingKeeper, lk types.LockupKeeper, k keeper.Keeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - // select random validator validator := RandomValidator(ctx, r, sk) if validator == nil { @@ -122,7 +121,6 @@ func SimulateMsgSuperfluidUndelegate(ak stakingtypes.AccountKeeper, bk stakingty return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - lock, simAccount := RandomLockAndAccount(ctx, r, lk, accs) if lock == nil { return simtypes.NoOpMsg( @@ -142,7 +140,6 @@ func SimulateMsgSuperfluidUndelegate(ak stakingtypes.AccountKeeper, bk stakingty txGen := simappparams.MakeTestEncodingConfig().TxConfig return osmo_simulation.GenAndDeliverTxWithRandFees( r, app, txGen, &msg, nil, ctx, simAccount, ak, bk, types.ModuleName) - } } diff --git a/x/superfluid/simulation/proposals.go b/x/superfluid/simulation/proposals.go index a219194d54d..71fabae56aa 100644 --- a/x/superfluid/simulation/proposals.go +++ b/x/superfluid/simulation/proposals.go @@ -17,7 +17,7 @@ const ( OpWeightRemoveSuperfluidAssetsProposal = "op_weight_remove_superfluid_assets_proposal" ) -// ProposalContents defines the module weighted proposals' contents +// ProposalContents defines the module weighted proposals' contents. func ProposalContents(k keeper.Keeper, gk types.GammKeeper) []simtypes.WeightedProposalContent { return []simtypes.WeightedProposalContent{ simulation.NewWeightedProposalContent( @@ -28,10 +28,9 @@ func ProposalContents(k keeper.Keeper, gk types.GammKeeper) []simtypes.WeightedP } } -// SimulateSetSuperfluidAssetsProposal generates random superfluid asset set proposal content +// SimulateSetSuperfluidAssetsProposal generates random superfluid asset set proposal content. func SimulateSetSuperfluidAssetsProposal(k keeper.Keeper, gk types.GammKeeper) simtypes.ContentSimulatorFn { return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { - pools, err := gk.GetPools(ctx) if err != nil { return nil @@ -57,10 +56,9 @@ func SimulateSetSuperfluidAssetsProposal(k keeper.Keeper, gk types.GammKeeper) s } } -// SimulateRemoveSuperfluidAssetsProposal generates random superfluid asset removal proposal content +// SimulateRemoveSuperfluidAssetsProposal generates random superfluid asset removal proposal content. func SimulateRemoveSuperfluidAssetsProposal(k keeper.Keeper, gk types.GammKeeper) simtypes.ContentSimulatorFn { return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { - assets := k.GetAllSuperfluidAssets(ctx) if len(assets) == 0 { diff --git a/x/superfluid/types/errors.go b/x/superfluid/types/errors.go index 963445a981d..430e6ab8d7e 100644 --- a/x/superfluid/types/errors.go +++ b/x/superfluid/types/errors.go @@ -4,7 +4,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -// x/superfluid module errors +// x/superfluid module errors. var ( ErrMultipleCoinsLockupNotSupported = sdkerrors.Register(ModuleName, 1, "multiple coins lockup is not supported") ErrUnbondingLockupNotSupported = sdkerrors.Register(ModuleName, 2, "unbonding lockup is not allowed to participate in superfluid staking") diff --git a/x/superfluid/types/events.go b/x/superfluid/types/events.go index cd29d1f79fe..ecd6a42fd7a 100644 --- a/x/superfluid/types/events.go +++ b/x/superfluid/types/events.go @@ -1,6 +1,6 @@ package types -// event types +// event types. const ( TypeEvtSetSuperfluidAsset = "set_superfluid_asset" TypeEvtRemoveSuperfluidAsset = "remove_superfluid_asset" diff --git a/x/superfluid/types/expected_keepers.go b/x/superfluid/types/expected_keepers.go index 11a3af5e6b2..1705a34511f 100644 --- a/x/superfluid/types/expected_keepers.go +++ b/x/superfluid/types/expected_keepers.go @@ -12,7 +12,7 @@ import ( lockuptypes "github.com/osmosis-labs/osmosis/v7/x/lockup/types" ) -// LockupKeeper defines the expected interface needed to retrieve locks +// LockupKeeper defines the expected interface needed to retrieve locks. type LockupKeeper interface { GetLocksPastTimeDenom(ctx sdk.Context, denom string, timestamp time.Time) []lockuptypes.PeriodLock GetLocksLongerThanDurationDenom(ctx sdk.Context, denom string, duration time.Duration) []lockuptypes.PeriodLock @@ -36,7 +36,7 @@ type LockupMsgServer interface { LockTokens(goCtx context.Context, msg *lockuptypes.MsgLockTokens) (*lockuptypes.MsgLockTokensResponse, error) } -// GammKeeper defines the expected interface needed for superfluid module +// GammKeeper defines the expected interface needed for superfluid module. type GammKeeper interface { CalculateSpotPrice(ctx sdk.Context, poolId uint64, tokenInDenom, tokenOutDenom string) (sdk.Dec, error) GetPool(ctx sdk.Context, poolId uint64) (gammtypes.PoolI, error) @@ -54,7 +54,7 @@ type BankKeeper interface { SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error } -// StakingKeeper expected staking keeper +// StakingKeeper expected staking keeper. type StakingKeeper interface { BondDenom(ctx sdk.Context) string GetAllValidators(ctx sdk.Context) (validators []stakingtypes.Validator) @@ -70,12 +70,12 @@ type StakingKeeper interface { GetParams(ctx sdk.Context) stakingtypes.Params } -// DistrKeeper expected distribution keeper +// DistrKeeper expected distribution keeper. type DistrKeeper interface { WithdrawDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (sdk.Coins, error) } -// IncentivesKeeper expected incentives keeper +// IncentivesKeeper expected incentives keeper. type IncentivesKeeper interface { CreateGauge(ctx sdk.Context, isPerpetual bool, owner sdk.AccAddress, coins sdk.Coins, distrTo lockuptypes.QueryCondition, startTime time.Time, numEpochsPaidOver uint64) (uint64, error) AddToGaugeRewards(ctx sdk.Context, owner sdk.AccAddress, coins sdk.Coins, gaugeID uint64) error diff --git a/x/superfluid/types/genesis.go b/x/superfluid/types/genesis.go index 5a09520fbe3..6e025d03576 100644 --- a/x/superfluid/types/genesis.go +++ b/x/superfluid/types/genesis.go @@ -6,10 +6,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec" ) -// DefaultIndex is the default capability global index +// DefaultIndex is the default capability global index. const DefaultIndex uint64 = 1 -// DefaultGenesis returns the default Capability genesis state +// DefaultGenesis returns the default Capability genesis state. func DefaultGenesis() *GenesisState { return &GenesisState{ Params: DefaultParams(), diff --git a/x/superfluid/types/gov.go b/x/superfluid/types/gov.go index 4255c203dd1..2d52c0b1946 100644 --- a/x/superfluid/types/gov.go +++ b/x/superfluid/types/gov.go @@ -20,8 +20,10 @@ func init() { govtypes.RegisterProposalTypeCodec(&RemoveSuperfluidAssetsProposal{}, "osmosis/RemoveSuperfluidAssetsProposal") } -var _ govtypes.Content = &SetSuperfluidAssetsProposal{} -var _ govtypes.Content = &RemoveSuperfluidAssetsProposal{} +var ( + _ govtypes.Content = &SetSuperfluidAssetsProposal{} + _ govtypes.Content = &RemoveSuperfluidAssetsProposal{} +) func NewSetSuperfluidAssetsProposal(title, description string, assets []SuperfluidAsset) govtypes.Content { return &SetSuperfluidAssetsProposal{ diff --git a/x/superfluid/types/keys.go b/x/superfluid/types/keys.go index 4bdeaea64e9..a0037308105 100644 --- a/x/superfluid/types/keys.go +++ b/x/superfluid/types/keys.go @@ -1,27 +1,27 @@ package types var ( - // ModuleName defines the module name + // ModuleName defines the module name. ModuleName = "superfluid" - // StoreKey defines the primary module store key + // StoreKey defines the primary module store key. StoreKey = ModuleName - // RouterKey is the message route for slashing + // RouterKey is the message route for slashing. RouterKey = ModuleName - // QuerierRoute defines the module's query routing key + // QuerierRoute defines the module's query routing key. QuerierRoute = ModuleName - // KeyPrefixSuperfluidAsset defines prefix key for superfluid asset + // KeyPrefixSuperfluidAsset defines prefix key for superfluid asset. KeyPrefixSuperfluidAsset = []byte{0x01} - // KeyPrefixTokenMultiplier defines prefix key per epoch + // KeyPrefixTokenMultiplier defines prefix key per epoch. KeyPrefixTokenMultiplier = []byte{0x03} - // KeyPrefixIntermediaryAccount defines prefix to set intermediary account struct to its address + // KeyPrefixIntermediaryAccount defines prefix to set intermediary account struct to its address. KeyPrefixIntermediaryAccount = []byte{0x04} - // KeyPrefixLockIntermediaryAccAddr defines prefix to connect lockId and intermediary account address + // KeyPrefixLockIntermediaryAccAddr defines prefix to connect lockId and intermediary account address. KeyPrefixLockIntermediaryAccAddr = []byte{0x05} ) diff --git a/x/superfluid/types/msgs.go b/x/superfluid/types/msgs.go index bb40d67fe3c..a2763afc1b1 100644 --- a/x/superfluid/types/msgs.go +++ b/x/superfluid/types/msgs.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// constants +// constants. const ( TypeMsgSuperfluidDelegate = "superfluid_delegate" TypeMsgSuperfluidUndelegate = "superfluid_undelegate" @@ -17,7 +17,7 @@ const ( var _ sdk.Msg = &MsgSuperfluidDelegate{} -// NewMsgSuperfluidDelegate creates a message to do superfluid delegation +// NewMsgSuperfluidDelegate creates a message to do superfluid delegation. func NewMsgSuperfluidDelegate(sender sdk.AccAddress, lockId uint64, valAddr sdk.ValAddress) *MsgSuperfluidDelegate { return &MsgSuperfluidDelegate{ Sender: sender.String(), @@ -40,9 +40,11 @@ func (m MsgSuperfluidDelegate) ValidateBasic() error { } return nil } + func (m MsgSuperfluidDelegate) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } + func (m MsgSuperfluidDelegate) GetSigners() []sdk.AccAddress { sender, _ := sdk.AccAddressFromBech32(m.Sender) return []sdk.AccAddress{sender} @@ -50,7 +52,7 @@ func (m MsgSuperfluidDelegate) GetSigners() []sdk.AccAddress { var _ sdk.Msg = &MsgSuperfluidUndelegate{} -// NewMsgSuperfluidUndelegate creates a message to do superfluid undelegation +// NewMsgSuperfluidUndelegate creates a message to do superfluid undelegation. func NewMsgSuperfluidUndelegate(sender sdk.AccAddress, lockId uint64) *MsgSuperfluidUndelegate { return &MsgSuperfluidUndelegate{ Sender: sender.String(), @@ -69,9 +71,11 @@ func (m MsgSuperfluidUndelegate) ValidateBasic() error { } return nil } + func (m MsgSuperfluidUndelegate) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } + func (m MsgSuperfluidUndelegate) GetSigners() []sdk.AccAddress { sender, _ := sdk.AccAddressFromBech32(m.Sender) return []sdk.AccAddress{sender} @@ -124,6 +128,7 @@ func (m MsgSuperfluidUnbondLock) Route() string { return RouterKey } func (m MsgSuperfluidUnbondLock) Type() string { return TypeMsgSuperfluidUnbondLock } + func (m MsgSuperfluidUnbondLock) ValidateBasic() error { if m.Sender == "" { return fmt.Errorf("sender should not be an empty address") @@ -133,9 +138,11 @@ func (m MsgSuperfluidUnbondLock) ValidateBasic() error { } return nil } + func (m MsgSuperfluidUnbondLock) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } + func (m MsgSuperfluidUnbondLock) GetSigners() []sdk.AccAddress { sender, _ := sdk.AccAddressFromBech32(m.Sender) return []sdk.AccAddress{sender} @@ -143,7 +150,7 @@ func (m MsgSuperfluidUnbondLock) GetSigners() []sdk.AccAddress { var _ sdk.Msg = &MsgLockAndSuperfluidDelegate{} -// NewMsgLockAndSuperfluidDelegate creates a message to create a lockup lock and superfluid delegation +// NewMsgLockAndSuperfluidDelegate creates a message to create a lockup lock and superfluid delegation. func NewMsgLockAndSuperfluidDelegate(sender sdk.AccAddress, coins sdk.Coins, valAddr sdk.ValAddress) *MsgLockAndSuperfluidDelegate { return &MsgLockAndSuperfluidDelegate{ Sender: sender.String(), @@ -168,9 +175,11 @@ func (m MsgLockAndSuperfluidDelegate) ValidateBasic() error { } return nil } + func (m MsgLockAndSuperfluidDelegate) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } + func (m MsgLockAndSuperfluidDelegate) GetSigners() []sdk.AccAddress { sender, _ := sdk.AccAddressFromBech32(m.Sender) return []sdk.AccAddress{sender} diff --git a/x/superfluid/types/params.go b/x/superfluid/types/params.go index b7ebbf9dc2b..5fd26f855a2 100644 --- a/x/superfluid/types/params.go +++ b/x/superfluid/types/params.go @@ -8,7 +8,7 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) -// Parameter store keys +// Parameter store keys. var ( KeyMinimumRiskFactor = []byte("MinimumRiskFactor") defaultMinimumRiskFactor = sdk.NewDecWithPrec(5, 1) // 50% @@ -25,19 +25,19 @@ func NewParams(minimumRiskFactor sdk.Dec) Params { } } -// default minting module parameters +// default minting module parameters. func DefaultParams() Params { return Params{ MinimumRiskFactor: defaultMinimumRiskFactor, // 5% } } -// validate params +// validate params. func (p Params) Validate() error { return nil } -// Implements params.ParamSet +// Implements params.ParamSet. func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyMinimumRiskFactor, &p.MinimumRiskFactor, ValidateMinimumRiskFactor), diff --git a/x/superfluid/types/superfluid.go b/x/superfluid/types/superfluid.go index 71b1f40bd75..9aac5042c54 100644 --- a/x/superfluid/types/superfluid.go +++ b/x/superfluid/types/superfluid.go @@ -5,7 +5,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) -// NewSuperfluidAsset returns a new instance of SuperfluidAsset +// NewSuperfluidAsset returns a new instance of SuperfluidAsset. func NewSuperfluidAsset(assetType SuperfluidAssetType, denom string) SuperfluidAsset { return SuperfluidAsset{ AssetType: assetType, diff --git a/x/txfees/client/cli/query.go b/x/txfees/client/cli/query.go index 16e9e95b6dc..400d76006a2 100644 --- a/x/txfees/client/cli/query.go +++ b/x/txfees/client/cli/query.go @@ -11,7 +11,7 @@ import ( "github.com/spf13/cobra" ) -// GetQueryCmd returns the cli query commands for this module +// GetQueryCmd returns the cli query commands for this module. func GetQueryCmd(queryRoute string) *cobra.Command { // Group queries under a subcommand cmd := &cobra.Command{ @@ -31,7 +31,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { return cmd } -// GetCmdFeeTokens takes the pool id and returns the matching gauge ids and durations +// GetCmdFeeTokens takes the pool id and returns the matching gauge ids and durations. func GetCmdFeeTokens() *cobra.Command { cmd := &cobra.Command{ Use: "fee-tokens", @@ -67,7 +67,7 @@ $ %s query txfees fee-tokens return cmd } -// GetCmdDenomPoolID takes the pool id and returns the matching gauge ids and durations +// GetCmdDenomPoolID takes the pool id and returns the matching gauge ids and durations. func GetCmdDenomPoolID() *cobra.Command { cmd := &cobra.Command{ Use: "denom-pool-id", @@ -105,7 +105,7 @@ $ %s query txfees denom-pool-id [denom] return cmd } -// GetCmdBaseDenom takes the pool id and returns the matching gauge ids and weights +// GetCmdBaseDenom takes the pool id and returns the matching gauge ids and weights. func GetCmdBaseDenom() *cobra.Command { cmd := &cobra.Command{ Use: "base-denom", diff --git a/x/txfees/keeper/feedecorator.go b/x/txfees/keeper/feedecorator.go index e6bcd4a7eba..17e30c27b70 100644 --- a/x/txfees/keeper/feedecorator.go +++ b/x/txfees/keeper/feedecorator.go @@ -13,7 +13,7 @@ import ( // If fee is too low, decorator returns error and tx is rejected from mempool. // Note this only applies when ctx.CheckTx = true // If fee is high enough or not CheckTx, then call next AnteHandler -// CONTRACT: Tx must implement FeeTx to use MempoolFeeDecorator +// CONTRACT: Tx must implement FeeTx to use MempoolFeeDecorator. type MempoolFeeDecorator struct { TxFeesKeeper Keeper Opts types.MempoolFeeOptions diff --git a/x/txfees/keeper/feetokens.go b/x/txfees/keeper/feetokens.go index 71ff747a29a..aca91f9f53a 100644 --- a/x/txfees/keeper/feetokens.go +++ b/x/txfees/keeper/feetokens.go @@ -7,7 +7,7 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/txfees/types" ) -// ConvertToBaseToken converts a fee amount in a whitelisted fee token to the base fee token amount +// ConvertToBaseToken converts a fee amount in a whitelisted fee token to the base fee token amount. func (k Keeper) ConvertToBaseToken(ctx sdk.Context, inputFee sdk.Coin) (sdk.Coin, error) { baseDenom, err := k.GetBaseDenom(ctx) if err != nil { @@ -31,7 +31,7 @@ func (k Keeper) ConvertToBaseToken(ctx sdk.Context, inputFee sdk.Coin) (sdk.Coin return sdk.NewCoin(baseDenom, spotPrice.MulInt(inputFee.Amount).Ceil().RoundInt()), nil } -// GetFeeToken returns the fee token record for a specific denom +// GetFeeToken returns the fee token record for a specific denom. func (k Keeper) GetBaseDenom(ctx sdk.Context) (denom string, err error) { store := ctx.KVStore(k.storeKey) @@ -62,7 +62,7 @@ func (k Keeper) SetBaseDenom(ctx sdk.Context, denom string) error { // - The denom exists // - The denom is not the base denom // - The gamm pool exists -// - The gamm pool includes the base token and fee token +// - The gamm pool includes the base token and fee token. func (k Keeper) ValidateFeeToken(ctx sdk.Context, feeToken types.FeeToken) error { baseDenom, err := k.GetBaseDenom(ctx) if err != nil { @@ -134,7 +134,6 @@ func (k Keeper) GetFeeTokens(ctx sdk.Context) (feetokens []types.FeeToken) { feeTokens := []types.FeeToken{} for ; iterator.Valid(); iterator.Next() { - feeToken := types.FeeToken{} err := proto.Unmarshal(iterator.Value(), &feeToken) diff --git a/x/txfees/keeper/keeper.go b/x/txfees/keeper/keeper.go index f0e5b021dcb..8970f424487 100644 --- a/x/txfees/keeper/keeper.go +++ b/x/txfees/keeper/keeper.go @@ -39,5 +39,5 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { func (k Keeper) GetFeeTokensStore(ctx sdk.Context) sdk.KVStore { store := ctx.KVStore(k.storeKey) - return prefix.NewStore(store, []byte(types.FeeTokensStorePrefix)) + return prefix.NewStore(store, types.FeeTokensStorePrefix) } diff --git a/x/txfees/keeper/txfee_filters/arb_tx.go b/x/txfees/keeper/txfee_filters/arb_tx.go index 7d243553a3c..db955dffb49 100644 --- a/x/txfees/keeper/txfee_filters/arb_tx.go +++ b/x/txfees/keeper/txfee_filters/arb_tx.go @@ -13,7 +13,7 @@ import ( // 3) We record all denoms seen across all swaps, and see if any duplicates. (TODO) // 4) Contains both JoinPool and ExitPool messages in one tx. // - Has some false positives, but they seem relatively contrived. -// TODO: Move the first component to a future router module +// TODO: Move the first component to a future router module. func IsArbTxLoose(tx sdk.Tx) bool { msgs := tx.GetMsgs() diff --git a/x/txfees/module.go b/x/txfees/module.go index 9176a3cdea5..f66f655a899 100644 --- a/x/txfees/module.go +++ b/x/txfees/module.go @@ -57,7 +57,7 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { types.RegisterLegacyAminoCodec(cdc) } -// RegisterInterfaces registers the module's interface types +// RegisterInterfaces registers the module's interface types. func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { types.RegisterInterfaces(reg) } @@ -191,7 +191,7 @@ func (am AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { return nil } -// RegisterStoreDecoder registers a decoder for supply module's types +// RegisterStoreDecoder registers a decoder for supply module's types. func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { } diff --git a/x/txfees/types/errors.go b/x/txfees/types/errors.go index 335f1c6f201..9e1ab036f87 100644 --- a/x/txfees/types/errors.go +++ b/x/txfees/types/errors.go @@ -6,7 +6,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -// x/txfees module errors +// x/txfees module errors. var ( ErrNoBaseDenom = sdkerrors.Register(ModuleName, 1, "no base denom was set") ErrTooManyFeeCoins = sdkerrors.Register(ModuleName, 2, "too many fee coins. only accepts fees in one denom") diff --git a/x/txfees/types/expected_keepers.go b/x/txfees/types/expected_keepers.go index 713d485cf4e..a65e78098c6 100644 --- a/x/txfees/types/expected_keepers.go +++ b/x/txfees/types/expected_keepers.go @@ -5,7 +5,7 @@ import ( ) // SpotPriceCalculator defines the contract that must be fulfilled by a spot price calculator -// The x/gamm keeper is expected to satisfy this interface +// The x/gamm keeper is expected to satisfy this interface. type SpotPriceCalculator interface { CalculateSpotPrice(ctx sdk.Context, poolId uint64, tokenInDenom, tokenOutDenom string) (sdk.Dec, error) } diff --git a/x/txfees/types/genesis.go b/x/txfees/types/genesis.go index c71cb4f8b1f..8f874dddbae 100644 --- a/x/txfees/types/genesis.go +++ b/x/txfees/types/genesis.go @@ -2,7 +2,7 @@ package types import sdk "github.com/cosmos/cosmos-sdk/types" -// DefaultGenesis returns the default txfee genesis state +// DefaultGenesis returns the default txfee genesis state. func DefaultGenesis() *GenesisState { return &GenesisState{ Basedenom: sdk.DefaultBondDenom, @@ -12,7 +12,7 @@ func DefaultGenesis() *GenesisState { // Validate performs basic genesis state validation returning an error upon any // failure. It does not verify that the corresponding pool IDs actually exist. -// This is done in InitGenesis +// This is done in InitGenesis. func (gs GenesisState) Validate() error { err := sdk.ValidateDenom(gs.Basedenom) if err != nil { diff --git a/x/txfees/types/keys.go b/x/txfees/types/keys.go index af4946db8c3..d10ac077242 100644 --- a/x/txfees/types/keys.go +++ b/x/txfees/types/keys.go @@ -1,16 +1,16 @@ package types const ( - // ModuleName defines the module name + // ModuleName defines the module name. ModuleName = "txfees" - // StoreKey defines the primary module store key + // StoreKey defines the primary module store key. StoreKey = ModuleName - // RouterKey is the message route for slashing + // RouterKey is the message route for slashing. RouterKey = ModuleName - // QuerierRoute defines the module's query routing key + // QuerierRoute defines the module's query routing key. QuerierRoute = ModuleName ) diff --git a/x/txfees/types/options.go b/x/txfees/types/options.go index a7922ef3407..049284ae7e2 100644 --- a/x/txfees/types/options.go +++ b/x/txfees/types/options.go @@ -2,6 +2,7 @@ package types import ( "fmt" + servertypes "github.com/cosmos/cosmos-sdk/server/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/cast" @@ -10,11 +11,14 @@ import ( // If Options are not set in a config somewhere, // use defaults to preserve functionality with old node software -// TODO: Bump after next minor version. (in 6.2+) +// TODO: Bump after next minor version. (in 6.2+). var DefaultMinGasPriceForArbitrageTx = sdk.ZeroDec() -var DefaultMinGasPriceForHighGasTx = sdk.ZeroDec() -var DefaultMaxGasWantedPerTx = uint64(25 * 1000 * 1000) -var DefaultHighGasTxThreshold = uint64(1 * 1000 * 1000) + +var ( + DefaultMinGasPriceForHighGasTx = sdk.ZeroDec() + DefaultMaxGasWantedPerTx = uint64(25 * 1000 * 1000) + DefaultHighGasTxThreshold = uint64(1 * 1000 * 1000) +) type MempoolFeeOptions struct { MaxGasWantedPerTx uint64