Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

!chore: remove all lint errors in repo #125

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ func GenesisStateWithValSet(app *RealioNetwork, genesisState simapp.GenesisState
CoinDenom: valMsCoin.Denom,
})

lockId := multistakingtypes.MultiStakingLockID(genAccs[0].GetAddress().String(), sdk.ValAddress(val.Address).String())
lockRecord := multistakingtypes.NewMultiStakingLock(lockId, valMsCoin)
lockID := multistakingtypes.MultiStakingLockID(genAccs[0].GetAddress().String(), sdk.ValAddress(val.Address).String())
lockRecord := multistakingtypes.NewMultiStakingLock(lockID, valMsCoin)

locks = append(locks, lockRecord)
lockCoins = lockCoins.Add(valMsCoin.ToCoin())
Expand Down
7 changes: 2 additions & 5 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ func (app *RealioNetwork) setupUpgradeHandlers(appOpts servertypes.AppOptions) {
appOpts,
app.AppCodec(),
app.BankKeeper,
app.MultiStakingKeeper,
app.AccountKeeper,
app.keys,
),
)

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(fmt.Errorf("Failed to read upgrade info from disk: %w", err))
panic(fmt.Errorf("failed to read upgrade info from disk: %w", err))
}

if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
Expand All @@ -37,8 +35,7 @@ func (app *RealioNetwork) setupUpgradeHandlers(appOpts servertypes.AppOptions) {

var storeUpgrades *storetypes.StoreUpgrades

switch upgradeInfo.Name {
case multistaking.UpgradeName:
if upgradeInfo.Name == multistaking.UpgradeName {
storeUpgrades = &storetypes.StoreUpgrades{
Added: []string{multistakingtypes.ModuleName},
}
Expand Down
6 changes: 5 additions & 1 deletion app/upgrades/multi-staking/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Validator struct {
// status is the validator status (bonded/unbonding/unbonded).
Status string `protobuf:"varint,4,opt,name=status,proto3,enum=cosmos.staking.v1beta1.BondStatus" json:"status,omitempty"`
// tokens define the delegated tokens (incl. self-delegation).
//nolint:staticcheck
Tokens sdk.Int `protobuf:"bytes,5,opt,name=tokens,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"tokens"`
// delegator_shares defines total shares issued to a validator's delegators.
DelegatorShares sdk.Dec `protobuf:"bytes,6,opt,name=delegator_shares,json=delegatorShares,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"delegator_shares"`
Expand All @@ -48,14 +49,16 @@ type Validator struct {
// min_self_delegation is the validator's self declared minimum self delegation.
//
// Since: cosmos-sdk 0.46
//nolint:staticcheck
MinSelfDelegation sdk.Int `protobuf:"bytes,11,opt,name=min_self_delegation,json=minSelfDelegation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_self_delegation"`
}

type GenesisState struct {
// params defines all the paramaters of related to deposit.
// params defines all the parameters of related to deposit.
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
// last_total_power tracks the total amounts of bonded tokens recorded during
// the previous end block.
//nolint:staticcheck
LastTotalPower sdk.Int `protobuf:"bytes,2,opt,name=last_total_power,json=lastTotalPower,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"last_total_power"`
// last_validator_powers is a special index that provides a historical list
// of the last-block's bonded validators.
Expand All @@ -71,6 +74,7 @@ type GenesisState struct {
Exported bool `protobuf:"varint,8,opt,name=exported,proto3" json:"exported,omitempty"`
}

//nolint:revive
type MultiStakingGenesisState struct {
MultiStakingLocks []multistakingtypes.MultiStakingLock `protobuf:"bytes,1,rep,name=multi_staking_locks,json=multiStakingLocks,proto3" json:"multi_staking_locks"`
MultiStakingUnlocks []multistakingtypes.MultiStakingUnlock `protobuf:"bytes,2,rep,name=multi_staking_unlocks,json=multiStakingUnlocks,proto3" json:"multi_staking_unlocks"`
Expand Down
20 changes: 12 additions & 8 deletions app/upgrades/multi-staking/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand All @@ -20,7 +19,6 @@ import (

authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
multistakingkeeper "github.com/realio-tech/multi-staking-module/x/multi-staking/keeper"

"cosmossdk.io/math"
multistakingtypes "github.com/realio-tech/multi-staking-module/x/multi-staking/types"
Expand All @@ -43,9 +41,7 @@ func CreateUpgradeHandler(
appOpts servertypes.AppOptions,
cdc codec.Codec,
bk bankkeeper.Keeper,
msk multistakingkeeper.Keeper,
ak authkeeper.AccountKeeper,
keys map[string]*storetypes.KVStoreKey,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("Starting upgrade for multi staking...")
Expand Down Expand Up @@ -94,15 +90,24 @@ func migrateBank(ctx sdk.Context, bk bankkeeper.Keeper) {
func convertStakingModulePoolBalances(ctx sdk.Context, bk bankkeeper.Keeper, accAddr sdk.AccAddress) {
// Send coins from accAddr add same amout to multistaking account
accountBalances := bk.GetAllBalances(ctx, accAddr)
bk.SendCoins(ctx, accAddr, multiStakingAddress, accountBalances)
err := bk.SendCoins(ctx, accAddr, multiStakingAddress, accountBalances)
if err != nil {
panic(err)
}
// mint stake to bonded pool
convertedCoinsAmount := math.ZeroInt()
for _, coinAmount := range accountBalances {
convertedCoinsAmount = convertedCoinsAmount.Add(coinAmount.Amount)
}
amount := sdk.NewCoins(sdk.NewCoin(newBondedCoinDenom, convertedCoinsAmount))
bk.MintCoins(ctx, minttypes.ModuleName, amount)
bk.SendCoins(ctx, mintModuleAddress, accAddr, amount)
err = bk.MintCoins(ctx, minttypes.ModuleName, amount)
if err != nil {
panic(err)
}
err = bk.SendCoins(ctx, mintModuleAddress, accAddr, amount)
if err != nil {
panic(err)
}
}

func migrateMultiStaking(appState map[string]json.RawMessage) (map[string]json.RawMessage, error) {
Expand Down Expand Up @@ -164,7 +169,6 @@ func migrateMultiStaking(appState map[string]json.RawMessage) (map[string]json.R
}
newState.MultiStakingLocks = append(newState.MultiStakingLocks, lock)
}

}
}

Expand Down
14 changes: 7 additions & 7 deletions x/mint/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"

"cosmossdk.io/math"
"github.com/realiotech/realio-network/app"
realiotypes "github.com/realiotech/realio-network/types"
"github.com/realiotech/realio-network/x/mint/types"
abci "github.com/tendermint/tendermint/abci/types"
"cosmossdk.io/math"
)

type KeeperTestSuite struct {
Expand Down Expand Up @@ -102,7 +102,7 @@ func (suite *KeeperTestSuite) TestMintedCoinsEachBlock() {

// block 1 vs block 2
currentSupply := suite.app.BankKeeper.GetSupply(suite.ctx, params.MintDenom).Amount
annualProvisions := minter.Inflation.MulInt(rioSupplyCap.Sub(currentSupply))
annualProvisions := minter.Inflation.MulInt(rioSupplyCap.Sub(currentSupply))
blockProvision := annualProvisions.QuoInt(math.NewInt(int64(params.BlocksPerYear))).TruncateInt()
currentHeight := suite.app.LastBlockHeight()

Expand All @@ -117,7 +117,7 @@ func (suite *KeeperTestSuite) TestMintedCoinsEachBlock() {

// block 2 vs block 3
currentSupply = suite.app.BankKeeper.GetSupply(suite.ctx, params.MintDenom).Amount
annualProvisions = minter.Inflation.MulInt(rioSupplyCap.Sub(currentSupply))
annualProvisions = minter.Inflation.MulInt(rioSupplyCap.Sub(currentSupply))
blockProvision = annualProvisions.QuoInt(math.NewInt(int64(params.BlocksPerYear))).TruncateInt()
currentHeight = suite.app.LastBlockHeight()

Expand All @@ -132,7 +132,7 @@ func (suite *KeeperTestSuite) TestMintedCoinsEachBlock() {

// block 3 vs block 4
currentSupply = suite.app.BankKeeper.GetSupply(suite.ctx, params.MintDenom).Amount
annualProvisions = minter.Inflation.MulInt(rioSupplyCap.Sub(currentSupply))
annualProvisions = minter.Inflation.MulInt(rioSupplyCap.Sub(currentSupply))
blockProvision = annualProvisions.QuoInt(math.NewInt(int64(params.BlocksPerYear))).TruncateInt()
currentHeight = suite.app.LastBlockHeight()

Expand All @@ -147,7 +147,7 @@ func (suite *KeeperTestSuite) TestMintedCoinsEachBlock() {

// block 4 vs block 5
currentSupply = suite.app.BankKeeper.GetSupply(suite.ctx, params.MintDenom).Amount
annualProvisions = minter.Inflation.MulInt(rioSupplyCap.Sub(currentSupply))
annualProvisions = minter.Inflation.MulInt(rioSupplyCap.Sub(currentSupply))
blockProvision = annualProvisions.QuoInt(math.NewInt(int64(params.BlocksPerYear))).TruncateInt()
currentHeight = suite.app.LastBlockHeight()

Expand All @@ -162,7 +162,7 @@ func (suite *KeeperTestSuite) TestMintedCoinsEachBlock() {

// block 5 vs block 6
currentSupply = suite.app.BankKeeper.GetSupply(suite.ctx, params.MintDenom).Amount
annualProvisions = minter.Inflation.MulInt(rioSupplyCap.Sub(currentSupply))
annualProvisions = minter.Inflation.MulInt(rioSupplyCap.Sub(currentSupply))
blockProvision = annualProvisions.QuoInt(math.NewInt(int64(params.BlocksPerYear))).TruncateInt()
currentHeight = suite.app.LastBlockHeight()

Expand All @@ -174,4 +174,4 @@ func (suite *KeeperTestSuite) TestMintedCoinsEachBlock() {
expectedMintedAmount = newSupply.Sub(currentSupply).String()
calculatedMintedAmount = blockProvision.String()
suite.Require().Equal(expectedMintedAmount, calculatedMintedAmount)
}
}
Loading