From 767b263c3aa03e3df049c70c141d30a2d1a900c5 Mon Sep 17 00:00:00 2001 From: Harish Marri Date: Wed, 10 Jul 2024 01:43:24 +0530 Subject: [PATCH] update cosmos-sdk v0.50.x changes --- app/app.go | 100 ++++++++++++++--------- app/apptesting/test_suite.go | 92 +++++++++++---------- app/export.go | 71 ++++++++++------ app/params/constants.go | 5 +- app/test_helpers.go | 58 ++++++------- cmd/streampayd/cmd/root.go | 20 ++--- proto/OmniFlix/streampay/v1/params.proto | 2 +- x/streampay/keeper/keeper.go | 11 +-- x/streampay/keeper/keeper_test.go | 7 +- x/streampay/keeper/msg_server.go | 5 +- x/streampay/keeper/msg_server_test.go | 9 +- x/streampay/keeper/params.go | 3 +- x/streampay/keeper/stream_payment.go | 3 +- x/streampay/module.go | 18 ++-- x/streampay/types/codec.go | 6 +- x/streampay/types/expected_keepers.go | 18 ++-- x/streampay/types/genesis_test.go | 5 +- x/streampay/types/params.go | 10 +-- x/streampay/types/params.pb.go | 40 ++++----- x/streampay/types/params_test.go | 8 +- x/streampay/types/validation.go | 5 +- 21 files changed, 272 insertions(+), 224 deletions(-) diff --git a/app/app.go b/app/app.go index 43a9507..883a532 100644 --- a/app/app.go +++ b/app/app.go @@ -13,6 +13,7 @@ import ( "github.com/OmniFlix/streampay/v2/docs" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/evidence" evidencekeeper "cosmossdk.io/x/evidence/keeper" @@ -20,28 +21,29 @@ import ( "cosmossdk.io/x/feegrant" feegrantkeeper "cosmossdk.io/x/feegrant/keeper" feegrantmodule "cosmossdk.io/x/feegrant/module" - "cosmossdk.io/x/upgrade" upgrade "cosmossdk.io/x/upgrade" upgradekeeper "cosmossdk.io/x/upgrade/keeper" upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/OmniFlix/streampay/v2/app/openapiconsole" appparams "github.com/OmniFlix/streampay/v2/app/params" - dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" tmjson "github.com/cometbft/cometbft/libs/json" - "github.com/cometbft/cometbft/libs/log" tmos "github.com/cometbft/cometbft/libs/os" + dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" + sdkclient "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" "github.com/cosmos/cosmos-sdk/codec" + addresscodec "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/server/api" "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/ante" @@ -49,6 +51,7 @@ import ( authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" "github.com/cosmos/cosmos-sdk/x/auth/tx" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" + txconfig "github.com/cosmos/cosmos-sdk/x/auth/tx/config" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" @@ -91,7 +94,6 @@ import ( ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" ibc "github.com/cosmos/ibc-go/v8/modules/core" - ibcclient "github.com/cosmos/ibc-go/v8/modules/core/02-client" ibcporttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" @@ -219,6 +221,7 @@ type StreamPayApp struct { // simulation manager sm *module.SimulationManager configurator module.Configurator + txConfig sdkclient.TxConfig } // NewStreamPayApp returns a reference to an initialized Gaia. @@ -243,7 +246,7 @@ func NewStreamPayApp( bApp.SetVersion(version.Version) bApp.SetInterfaceRegistry(interfaceRegistry) - keys := sdk.NewKVStoreKeys( + keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, @@ -262,8 +265,8 @@ func NewStreamPayApp( crisistypes.StoreKey, streampaytypes.StoreKey, ) - tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) - memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey) + memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) app := &StreamPayApp{ BaseApp: bApp, @@ -282,10 +285,11 @@ func NewStreamPayApp( // set the BaseApp's parameter store app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper( appCodec, - keys[consensusparamtypes.StoreKey], + runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), govModAddress, + runtime.EventService{}, ) - bApp.SetParamStore(&app.ConsensusParamsKeeper) + bApp.SetParamStore(&app.ConsensusParamsKeeper.ParamsStore) // add capability keeper and ScopeToModule for ibc module app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey]) @@ -297,29 +301,33 @@ func NewStreamPayApp( // add keepers app.AccountKeeper = authkeeper.NewAccountKeeper( appCodec, - keys[authtypes.StoreKey], + runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, + addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), AccountAddressPrefix, govModAddress, ) app.BankKeeper = bankkeeper.NewBaseKeeper( appCodec, - keys[banktypes.StoreKey], + runtime.NewKVStoreService(keys[banktypes.StoreKey]), app.AccountKeeper, app.ModuleAccountAddrs(), govModAddress, + logger, ) app.StakingKeeper = stakingkeeper.NewKeeper( appCodec, - keys[stakingtypes.StoreKey], + runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, govModAddress, + addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), ) app.MintKeeper = mintkeeper.NewKeeper( appCodec, - keys[minttypes.StoreKey], + runtime.NewKVStoreService(keys[minttypes.StoreKey]), app.StakingKeeper, app.AccountKeeper, app.BankKeeper, @@ -328,7 +336,7 @@ func NewStreamPayApp( ) app.DistrKeeper = distrkeeper.NewKeeper( appCodec, - keys[distrtypes.StoreKey], + runtime.NewKVStoreService(keys[distrtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, @@ -338,23 +346,29 @@ func NewStreamPayApp( app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, cdc, - keys[slashingtypes.StoreKey], + runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), app.StakingKeeper, govModAddress, ) app.CrisisKeeper = crisiskeeper.NewKeeper( appCodec, - keys[crisistypes.StoreKey], + runtime.NewKVStoreService(keys[crisistypes.StoreKey]), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, govModAddress, + addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + ) + + app.FeeGrantKeeper = feegrantkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[feegrant.StoreKey]), + app.AccountKeeper, ) - app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper) app.UpgradeKeeper = upgradekeeper.NewKeeper( skipUpgradeHeights, - keys[upgradetypes.StoreKey], + runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), appCodec, homePath, app.BaseApp, @@ -377,14 +391,15 @@ func NewStreamPayApp( app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, + govModAddress, ) // register the proposal types govRouter := govv1beta1.NewRouter() govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). - AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). - AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). - AddRoute(ibcexported.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)) + AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)) + //AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). + //AddRoute(ibcexported.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)) // Create Transfer Keepers app.TransferKeeper = ibctransferkeeper.NewKeeper( @@ -393,10 +408,11 @@ func NewStreamPayApp( app.GetSubspace(ibctransfertypes.ModuleName), app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, + app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, + govModAddress, ) transferModule := transfer.NewAppModule(app.TransferKeeper) transferIBCModule := transfer.NewIBCModule(app.TransferKeeper) @@ -404,19 +420,22 @@ func NewStreamPayApp( // Create evidence Keeper for to register the IBC light client misbehaviour evidence route evidenceKeeper := evidencekeeper.NewKeeper( appCodec, - keys[evidencetypes.StoreKey], + runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), app.StakingKeeper, app.SlashingKeeper, + addresscodec.NewBech32Codec(sdk.Bech32PrefixAccAddr), + runtime.ProvideCometInfoService(), ) // If evidence needs to be handled for the app, set routes in router here and seal app.EvidenceKeeper = *evidenceKeeper govKeeper := govkeeper.NewKeeper( appCodec, - keys[govtypes.StoreKey], + runtime.NewKVStoreService(keys[govtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, + app.DistrKeeper, bApp.MsgServiceRouter(), govtypes.DefaultConfig(), govModAddress, @@ -454,23 +473,23 @@ func NewStreamPayApp( // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. - enabledSignModes := append(tx.DefaultSignModes, sigtypes.SignMode_SIGN_MODE_TEXTUAL) + enabledSignModes := append(tx.DefaultSignModes, signingtypes.SignMode_SIGN_MODE_TEXTUAL) txConfigOpts := tx.ConfigOptions{ EnabledSignModes: enabledSignModes, - TextualCoinMetadataQueryFn: txmodule.NewBankKeeperCoinMetadataQueryFn(app.BankKeeper), + TextualCoinMetadataQueryFn: txconfig.NewBankKeeperCoinMetadataQueryFn(app.BankKeeper), } txConfig, err := tx.NewTxConfigWithOptions( appCodec, txConfigOpts, ) if err != nil { - log.Fatalf("Failed to create new TxConfig with options: %v", err) + logger.Error("Failed to create new TxConfig with options: %v", err) } app.txConfig = txConfig app.mm = module.NewManager( genutil.NewAppModule( - app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx, + app.AccountKeeper, app.StakingKeeper, app.BaseApp, encodingConfig.TxConfig, ), auth.NewAppModule(appCodec, app.AccountKeeper, nil, app.GetSubspace(authtypes.ModuleName)), @@ -481,10 +500,10 @@ func NewStreamPayApp( crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry), distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), - upgrade.NewAppModule(app.UpgradeKeeper), + upgrade.NewAppModule(app.UpgradeKeeper, addresscodec.NewBech32Codec(appparams.Bech32AddressPrefix)), evidence.NewAppModule(app.EvidenceKeeper), ibc.NewAppModule(app.IBCKeeper), params.NewAppModule(app.ParamsKeeper), @@ -581,7 +600,7 @@ func NewStreamPayApp( mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry), params.NewAppModule(app.ParamsKeeper), evidence.NewAppModule(app.EvidenceKeeper), ibc.NewAppModule(app.IBCKeeper), @@ -635,22 +654,25 @@ func NewStreamPayApp( func (app *StreamPayApp) Name() string { return app.BaseApp.Name() } // BeginBlocker application updates every begin block -func (app *StreamPayApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { - return app.mm.BeginBlock(ctx, req) +func (app *StreamPayApp) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) { + return app.mm.BeginBlock(ctx) } // EndBlocker application updates every end block -func (app *StreamPayApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { - return app.mm.EndBlock(ctx, req) +func (app *StreamPayApp) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) { + return app.mm.EndBlock(ctx) } // InitChainer application update at chain initialization -func (app *StreamPayApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { +func (app *StreamPayApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { var genesisState GenesisState if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) } - app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) + err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) + if err != nil { + panic(err) + } return app.mm.InitGenesis(ctx, app.appCodec, genesisState) } @@ -758,8 +780,8 @@ func (app *StreamPayApp) RegisterTendermintService(clientCtx client.Context) { } // RegisterNodeService allows query minimum-gas-prices in app.toml -func (app *StreamPayApp) RegisterNodeService(clientCtx client.Context) { - nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter()) +func (app *StreamPayApp) RegisterNodeService(clientCtx client.Context, cfg config.Config) { + nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) } // GetMaccPerms returns a copy of the module account permissions diff --git a/app/apptesting/test_suite.go b/app/apptesting/test_suite.go index 239b0c5..d7cbbcf 100644 --- a/app/apptesting/test_suite.go +++ b/app/apptesting/test_suite.go @@ -1,6 +1,7 @@ package apptesting import ( + storetypes "cosmossdk.io/store/types" "fmt" "time" @@ -8,12 +9,11 @@ import ( "github.com/OmniFlix/streampay/v2/app" + "cosmossdk.io/log" "cosmossdk.io/store/rootmulti" - dbm "github.com/cometbft/cometbft-db" - abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/crypto/ed25519" - "github.com/cometbft/cometbft/libs/log" tmtypes "github.com/cometbft/cometbft/proto/tendermint/types" + dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -40,13 +40,13 @@ type KeeperTestHelper struct { var ( ChainID = "sp-test-1" Denom = "uspay" - Amount = sdk.NewInt(100000000) + Amount = sdkmath.NewInt(100000000) ) // Setup sets up basic environment for suite (App, Ctx, and test accounts) func (s *KeeperTestHelper) Setup() { s.App = app.Setup(s.T(), true, 0) - s.Ctx = s.App.BaseApp.NewContext(false, tmtypes.Header{Height: 1, ChainID: ChainID, Time: time.Now().UTC()}) + s.Ctx = s.App.BaseApp.NewContextLegacy(false, tmtypes.Header{Height: 1, ChainID: ChainID, Time: time.Now().UTC()}) s.QueryHelper = &baseapp.QueryServiceTestHelper{ GRPCQueryRouter: s.App.GRPCQueryRouter(), Ctx: s.Ctx, @@ -58,7 +58,7 @@ func (s *KeeperTestHelper) Setup() { func (s *KeeperTestHelper) SetupTestForInitGenesis() { // Setting to True, leads to init genesis not running s.App = app.Setup(s.T(), true, 0) - s.Ctx = s.App.BaseApp.NewContext(true, tmtypes.Header{}) + s.Ctx = s.App.BaseApp.NewContextLegacy(true, tmtypes.Header{}) } // CreateTestContext creates a test context. @@ -68,11 +68,11 @@ func (s *KeeperTestHelper) CreateTestContext() sdk.Context { } // CreateTestContextWithMultiStore creates a test context and returns it together with multi store. -func (s *KeeperTestHelper) CreateTestContextWithMultiStore() (sdk.Context, sdk.CommitMultiStore) { +func (s *KeeperTestHelper) CreateTestContextWithMultiStore() (sdk.Context, storetypes.CommitMultiStore) { db := dbm.NewMemDB() logger := log.NewNopLogger() - ms := rootmulti.NewStore(db, logger) + ms := rootmulti.NewStore(db, logger, nil) return sdk.NewContext(ms, tmtypes.Header{}, false, logger), ms } @@ -82,19 +82,19 @@ func (s *KeeperTestHelper) Commit() { oldHeader := s.Ctx.BlockHeader() s.App.Commit() newHeader := tmtypes.Header{Height: oldHeight + 1, ChainID: oldHeader.ChainID, Time: oldHeader.Time.Add(time.Second)} - s.App.BeginBlock(abci.RequestBeginBlock{Header: newHeader}) - s.Ctx = s.App.BaseApp.NewContext(false, newHeader) + // s.App.BeginBlock(abci.RequestBeginBlock{Header: newHeader}) + s.Ctx = s.App.BaseApp.NewContextLegacy(false, newHeader) } // FundAcc funds target address with specified amount. func (s *KeeperTestHelper) FundAcc(acc sdk.AccAddress, amounts sdk.Coins) { - err := banktestutil.FundAccount(s.App.BankKeeper, s.Ctx, acc, amounts) + err := banktestutil.FundAccount(s.Ctx, s.App.BankKeeper, acc, amounts) s.Require().NoError(err) } // FundModuleAcc funds target modules with specified amount. func (s *KeeperTestHelper) FundModuleAcc(moduleName string, amounts sdk.Coins) { - err := banktestutil.FundModuleAccount(s.App.BankKeeper, s.Ctx, moduleName, amounts) + err := banktestutil.FundModuleAccount(s.Ctx, s.App.BankKeeper, moduleName, amounts) s.Require().NoError(err) } @@ -107,18 +107,22 @@ func (s *KeeperTestHelper) MintCoins(coins sdk.Coins) { func (s *KeeperTestHelper) SetupValidator(bondStatus stakingtypes.BondStatus) sdk.ValAddress { valPub := secp256k1.GenPrivKey().PubKey() valAddr := sdk.ValAddress(valPub.Address()) - bondDenom := s.App.StakingKeeper.GetParams(s.Ctx).BondDenom - selfBond := sdk.NewCoins(sdk.Coin{Amount: sdk.NewInt(100), Denom: bondDenom}) + bondDenomResp, err := s.App.StakingKeeper.GetParams(s.Ctx) + if err != nil { + return nil + } + bondDenom := bondDenomResp.BondDenom + selfBond := sdk.NewCoins(sdk.Coin{Amount: sdkmath.NewInt(100), Denom: bondDenom}) s.FundAcc(sdk.AccAddress(valAddr), selfBond) stakingCoin := sdk.NewCoin(sdk.DefaultBondDenom, selfBond[0].Amount) - ZeroCommission := stakingtypes.NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) - _, err := stakingtypes.NewMsgCreateValidator(valAddr, valPub, stakingCoin, stakingtypes.Description{}, ZeroCommission, sdk.OneInt()) + ZeroCommission := stakingtypes.NewCommissionRates(sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec()) + _, err = stakingtypes.NewMsgCreateValidator(valAddr.String(), valPub, stakingCoin, stakingtypes.Description{}, ZeroCommission, sdkmath.OneInt()) s.Require().NoError(err) - val, found := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) - s.Require().True(found) + val, err := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) + s.Require().NoError(err) val = val.UpdateStatus(bondStatus) s.App.StakingKeeper.SetValidator(s.Ctx, val) @@ -153,16 +157,19 @@ func (s *KeeperTestHelper) SetupMultipleValidators(numValidator int) []string { func (s *KeeperTestHelper) BeginNewBlock(executeNextEpoch bool) { var valAddr []byte - validators := s.App.StakingKeeper.GetAllValidators(s.Ctx) + validators, err := s.App.StakingKeeper.GetAllValidators(s.Ctx) + if err != nil { + return + } if len(validators) >= 1 { valAddrFancy, err := validators[0].GetConsAddr() s.Require().NoError(err) - valAddr = valAddrFancy.Bytes() + valAddr = valAddrFancy } else { valAddrFancy := s.SetupValidator(stakingtypes.Bonded) validator, _ := s.App.StakingKeeper.GetValidator(s.Ctx, valAddrFancy) valAddr2, _ := validator.GetConsAddr() - valAddr = valAddr2.Bytes() + valAddr = valAddr2 } s.BeginNewBlockWithProposer(executeNextEpoch, valAddr) @@ -170,36 +177,35 @@ func (s *KeeperTestHelper) BeginNewBlock(executeNextEpoch bool) { // BeginNewBlockWithProposer begins a new block with a proposer. func (s *KeeperTestHelper) BeginNewBlockWithProposer(executeNextEpoch bool, proposer sdk.ValAddress) { - validator, found := s.App.StakingKeeper.GetValidator(s.Ctx, proposer) - s.Assert().True(found) + //validator, err := s.App.StakingKeeper.GetValidator(s.Ctx, proposer) + //s.Assert().NoError(err) - valConsAddr, err := validator.GetConsAddr() - s.Require().NoError(err) + //valConsAddr, err := validator.GetConsAddr() + //s.Require().NoError(err) - valAddr := valConsAddr.Bytes() + //valAddr := valConsAddr newBlockTime := s.Ctx.BlockTime().Add(5 * time.Second) header := tmtypes.Header{Height: s.Ctx.BlockHeight() + 1, Time: newBlockTime} newCtx := s.Ctx.WithBlockTime(newBlockTime).WithBlockHeight(s.Ctx.BlockHeight() + 1) s.Ctx = newCtx - lastCommitInfo := abci.CommitInfo{ - Votes: []abci.VoteInfo{{ - Validator: abci.Validator{Address: valAddr, Power: 1000}, - SignedLastBlock: true, - }}, - } - reqBeginBlock := abci.RequestBeginBlock{Header: header, LastCommitInfo: lastCommitInfo} - - fmt.Println("beginning block ", s.Ctx.BlockHeight()) - s.App.BeginBlocker(s.Ctx, reqBeginBlock) - s.Ctx = s.App.NewContext(false, reqBeginBlock.Header) + //lastCommitInfo := abci.CommitInfo{ + // Votes: []abci.VoteInfo{{ + // Validator: abci.Validator{Address: valAddr, Power: 1000}, + // }}, + //} + //reqBeginBlock := abci.RequestBeginBlock{Header: header, LastCommitInfo: lastCommitInfo} + + //fmt.Println("beginning block ", s.Ctx.BlockHeight()) + //s.App.BeginBlocker(s.Ctx, reqBeginBlock) + s.Ctx = s.App.NewContextLegacy(false, header) } // EndBlock ends the block, and runs commit func (s *KeeperTestHelper) EndBlock() { - reqEndBlock := abci.RequestEndBlock{Height: s.Ctx.BlockHeight()} - s.App.EndBlocker(s.Ctx, reqEndBlock) + //reqEndBlock := abci.RequestEndBlock{Height: s.Ctx.BlockHeight()} + s.App.EndBlocker(s.Ctx) } func (s *KeeperTestHelper) RunMsg(msg sdk.Msg) (*sdk.Result, error) { @@ -215,17 +221,17 @@ func (s *KeeperTestHelper) RunMsg(msg sdk.Msg) (*sdk.Result, error) { // AllocateRewardsToValidator allocates reward tokens to a distribution module then allocates rewards to the validator address. func (s *KeeperTestHelper) AllocateRewardsToValidator(valAddr sdk.ValAddress, rewardAmt sdkmath.Int) { - validator, found := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) - s.Require().True(found) + validator, err := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) + s.Require().NoError(err) // allocate reward tokens to distribution module coins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, rewardAmt)} - err := banktestutil.FundModuleAccount(s.App.BankKeeper, s.Ctx, distrtypes.ModuleName, coins) + err = banktestutil.FundModuleAccount(s.Ctx, s.App.BankKeeper, distrtypes.ModuleName, coins) s.Require().NoError(err) // allocate rewards to validator s.Ctx = s.Ctx.WithBlockHeight(s.Ctx.BlockHeight() + 1) - decTokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(20000)}} + decTokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdkmath.LegacyNewDec(20000)}} s.App.DistrKeeper.AllocateTokensToValidator(s.Ctx, validator, decTokens) } diff --git a/app/export.go b/app/export.go index 0591c03..a3fd956 100644 --- a/app/export.go +++ b/app/export.go @@ -1,6 +1,7 @@ package app import ( + storetypes "cosmossdk.io/store/types" "encoding/json" "log" @@ -21,7 +22,7 @@ func (app *StreamPayApp) ExportAppStateAndValidators( modulesToExport []string, ) (servertypes.ExportedApp, error) { // as if they could withdraw from the start of the next block - ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) + ctx := app.NewContextLegacy(true, tmproto.Header{Height: app.LastBlockHeight()}) // We export at last height + 1, because that's the height at which // Tendermint will start InitChain. @@ -31,7 +32,10 @@ func (app *StreamPayApp) ExportAppStateAndValidators( app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs) } - genState := app.mm.ExportGenesisForModules(ctx, app.appCodec, modulesToExport) + genState, err := app.mm.ExportGenesisForModules(ctx, app.appCodec, modulesToExport) + if err != nil { + return servertypes.ExportedApp{}, err + } appState, err := json.MarshalIndent(genState, "", " ") if err != nil { return servertypes.ExportedApp{}, err @@ -77,18 +81,27 @@ func (app *StreamPayApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAd /* Handle fee distribution state. */ // withdraw all validator commission - app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { - _, err := app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator()) + err := app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { + addr, _ := sdk.ValAddressFromBech32(val.GetOperator()) + _, err := app.DistrKeeper.WithdrawValidatorCommission(ctx, addr) if err != nil { panic(err) } return false }) + if err != nil { + return + } // withdraw all delegator rewards - dels := app.StakingKeeper.GetAllDelegations(ctx) + dels, err := app.StakingKeeper.GetAllDelegations(ctx) + if err != nil { + panic(err) + } for _, delegation := range dels { - _, err := app.DistrKeeper.WithdrawDelegationRewards(ctx, delegation.GetDelegatorAddr(), delegation.GetValidatorAddr()) + delegatorAddr, _ := sdk.AccAddressFromBech32(delegation.GetDelegatorAddr()) + valAddr, _ := sdk.ValAddressFromBech32(delegation.GetValidatorAddr()) + _, err := app.DistrKeeper.WithdrawDelegationRewards(ctx, delegatorAddr, valAddr) if err != nil { panic(err) } @@ -103,24 +116,30 @@ func (app *StreamPayApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAd // set context height to zero height := ctx.BlockHeight() ctx = ctx.WithBlockHeight(0) + /* + // reinitialize all validators + app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { + // donate any unwithdrawn outstanding reward fraction tokens to the community pool + valOperator, _ := sdk.ValAddressFromBech32(val.GetOperator()) + scraps, err := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, valOperator) + if err != nil { + panic(err) + } + distributionAccount := app.DistrKeeper.GetDistributionAccount(ctx) + feePool := app.BankKeeper.GetBalance(ctx, distributionAccount.GetAddress(), "uspay") + feePool = feePool.Add(scraps) + app.DistrKeeper.SetFeePool(ctx, feePool) + + app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()) + return false + }) - // reinitialize all validators - app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { - // donate any unwithdrawn outstanding reward fraction tokens to the community pool - scraps := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator()) - feePool := app.DistrKeeper.GetFeePool(ctx) - feePool.CommunityPool = feePool.CommunityPool.Add(scraps...) - app.DistrKeeper.SetFeePool(ctx, feePool) - - app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()) - return false - }) - - // reinitialize all delegations - for _, del := range dels { - app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, del.GetDelegatorAddr(), del.GetValidatorAddr()) - app.DistrKeeper.Hooks().AfterDelegationModified(ctx, del.GetDelegatorAddr(), del.GetValidatorAddr()) - } + // reinitialize all delegations + for _, del := range dels { + app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, del.GetDelegatorAddr(), del.GetValidatorAddr()) + app.DistrKeeper.Hooks().AfterDelegationModified(ctx, del.GetDelegatorAddr(), del.GetValidatorAddr()) + } + */ // reset context height ctx = ctx.WithBlockHeight(height) @@ -148,13 +167,13 @@ func (app *StreamPayApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAd // Iterate through validators by power descending, reset bond heights, and // update bond intra-tx counters. store := ctx.KVStore(app.keys[stakingtypes.StoreKey]) - iter := sdk.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) + iter := storetypes.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) counter := int16(0) for ; iter.Valid(); iter.Next() { addr := sdk.ValAddress(iter.Key()[1:]) - validator, found := app.StakingKeeper.GetValidator(ctx, addr) - if !found { + validator, err := app.StakingKeeper.GetValidator(ctx, addr) + if err != nil { panic("expected validator, not found") } diff --git a/app/params/constants.go b/app/params/constants.go index c927596..8dc0ca7 100644 --- a/app/params/constants.go +++ b/app/params/constants.go @@ -1,6 +1,7 @@ package params const ( - Name = "StreamPay" - BondDenom = "uspay" + Name = "StreamPay" + BondDenom = "uspay" + Bech32AddressPrefix = "streampay" ) diff --git a/app/test_helpers.go b/app/test_helpers.go index 11a2c18..5abd6e7 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -1,19 +1,18 @@ package app import ( - "encoding/json" + sdkmath "cosmossdk.io/math" "testing" "time" + "cosmossdk.io/log" apphelpers "github.com/OmniFlix/streampay/v2/app/helpers" appparams "github.com/OmniFlix/streampay/v2/app/params" - dbm "github.com/cometbft/cometbft-db" - abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/crypto" "github.com/cometbft/cometbft/crypto/ed25519" - "github.com/cometbft/cometbft/libs/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" tmtypes "github.com/cometbft/cometbft/types" + dbm "github.com/cosmos/cosmos-db" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -75,7 +74,7 @@ func Setup(t *testing.T, _ bool, _ uint) *StreamPayApp { acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) balance := banktypes.Balance{ Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(appparams.BondDenom, sdk.NewInt(100000000000000))), + Coins: sdk.NewCoins(sdk.NewCoin(appparams.BondDenom, sdkmath.NewInt(100000000000000))), } app := SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, balance) @@ -98,26 +97,27 @@ func SetupWithGenesisValSet( streamPayApp, genesisState := setup(true, 5) genesisState = genesisStateWithValSet(t, streamPayApp, genesisState, valSet, genAccs, balances...) - stateBytes, err := json.MarshalIndent(genesisState, "", " ") - require.NoError(t, err) - - // init chain will set the validator set and initialize the genesis accounts - streamPayApp.InitChain( - abci.RequestInitChain{ - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: DefaultConsensusParams, - AppStateBytes: stateBytes, - }, - ) - - // commit genesis changes - streamPayApp.Commit() - streamPayApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{ - Height: streamPayApp.LastBlockHeight() + 1, - AppHash: streamPayApp.LastCommitID().Hash, - ValidatorsHash: valSet.Hash(), - NextValidatorsHash: valSet.Hash(), - }}) + // stateBytes, err := json.MarshalIndent(genesisState, "", " ") + // require.NoError(t, err) + // TODO: update to sdk v0.50.x + /* + // init chain will set the validator set and initialize the genesis accounts + streamPayApp.InitChain( + abci.RequestInitChain{ + Validators: []abci.ValidatorUpdate{}, + ConsensusParams: DefaultConsensusParams, + AppStateBytes: stateBytes, + }, + ) + + // commit genesis changes + streamPayApp.Commit() + streamPayApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{ + Height: streamPayApp.LastBlockHeight() + 1, + AppHash: streamPayApp.LastCommitID().Hash, + ValidatorsHash: valSet.Hash(), + NextValidatorsHash: valSet.Hash(), + }})*/ return streamPayApp } @@ -173,15 +173,15 @@ func genesisStateWithValSet( Jailed: false, Status: stakingtypes.Bonded, Tokens: bondAmt, - DelegatorShares: sdk.OneDec(), + DelegatorShares: sdkmath.LegacyOneDec(), Description: stakingtypes.Description{}, UnbondingHeight: int64(0), UnbondingTime: time.Unix(0, 0).UTC(), - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), - MinSelfDelegation: sdk.ZeroInt(), + Commission: stakingtypes.NewCommission(sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec()), + MinSelfDelegation: sdkmath.ZeroInt(), } validators = append(validators, validator) - delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) + delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress().String(), val.Address.String(), sdkmath.LegacyOneDec())) } // set validators and delegations diff --git a/cmd/streampayd/cmd/root.go b/cmd/streampayd/cmd/root.go index e4813bd..dedb4f4 100644 --- a/cmd/streampayd/cmd/root.go +++ b/cmd/streampayd/cmd/root.go @@ -6,14 +6,13 @@ import ( "os" "github.com/cosmos/cosmos-sdk/client/config" - "github.com/cosmos/cosmos-sdk/client/pruning" sdk "github.com/cosmos/cosmos-sdk/types" + "cosmossdk.io/log" "github.com/OmniFlix/streampay/v2/app/params" - dbm "github.com/cometbft/cometbft-db" tmcfg "github.com/cometbft/cometbft/config" tmcli "github.com/cometbft/cometbft/libs/cli" - "github.com/cometbft/cometbft/libs/log" + dbm "github.com/cosmos/cosmos-db" "github.com/spf13/cast" "github.com/spf13/cobra" @@ -27,7 +26,6 @@ import ( servertypes "github.com/cosmos/cosmos-sdk/server/types" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" "github.com/cosmos/cosmos-sdk/x/auth/types" - vestingcli "github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli" "github.com/cosmos/cosmos-sdk/x/crisis" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" ) @@ -98,14 +96,14 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { cfg := sdk.GetConfig() cfg.Seal() - ac := appCreator{encodingConfig} + //ac := appCreator{encodingConfig} rootCmd.AddCommand( genutilcli.InitCmd(app.ModuleBasics, app.DefaultNodeHome), tmcli.NewCompletionCmd(rootCmd, true), addDebugCommands(debug.Cmd()), - config.Cmd(), - pruning.PruningCmd(ac.newApp), + //config.Cmd(), + //pruning.PruningCmd(ac.newApp), ) a := appCreator{encodingConfig} @@ -113,11 +111,11 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { // add keybase, auxiliary RPC, query, genesis and tx child commands rootCmd.AddCommand( - rpc.StatusCommand(), + server.StatusCommand(), genesisCommand(encodingConfig), queryCommand(), txCommand(), - keys.Commands(app.DefaultNodeHome), + keys.Commands(), ) } @@ -145,9 +143,8 @@ func queryCommand() *cobra.Command { } cmd.AddCommand( - authcmd.GetAccountCmd(), rpc.ValidatorCommand(), - rpc.BlockCommand(), + server.QueryBlockCmd(), authcmd.QueryTxsByEventsCmd(), authcmd.QueryTxCmd(), ) @@ -177,7 +174,6 @@ func txCommand() *cobra.Command { authcmd.GetEncodeCommand(), authcmd.GetDecodeCommand(), flags.LineBreak, - vestingcli.GetTxCmd(), ) app.ModuleBasics.AddTxCommands(cmd) diff --git a/proto/OmniFlix/streampay/v1/params.proto b/proto/OmniFlix/streampay/v1/params.proto index 96c7682..f3714fd 100644 --- a/proto/OmniFlix/streampay/v1/params.proto +++ b/proto/OmniFlix/streampay/v1/params.proto @@ -12,7 +12,7 @@ option (gogoproto.goproto_getters_all) = false; message Params { string stream_payment_fee_percentage = 1 [ (gogoproto.moretags) = "yaml:\"stream_payment_fee_percentage\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; } \ No newline at end of file diff --git a/x/streampay/keeper/keeper.go b/x/streampay/keeper/keeper.go index cef5ef9..c856163 100644 --- a/x/streampay/keeper/keeper.go +++ b/x/streampay/keeper/keeper.go @@ -1,13 +1,14 @@ package keeper import ( + sdkmath "cosmossdk.io/math" "fmt" "time" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "github.com/OmniFlix/streampay/v2/x/streampay/types" - "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -99,7 +100,7 @@ func (k Keeper) CreateStreamPayment(ctx sdk.Context, // update stream payment streamPayment.Id = types.StreamPaymentPrefix + fmt.Sprint(pNum) - streamPayment.StreamedAmount = sdk.NewCoin(streamPayment.TotalAmount.Denom, sdk.NewInt(0)) + streamPayment.StreamedAmount = sdk.NewCoin(streamPayment.TotalAmount.Denom, sdkmath.NewInt(0)) k.SetStreamPayment(ctx, streamPayment) k.SetNextStreamPaymentNumber(ctx, pNum+1) @@ -151,7 +152,7 @@ func (k Keeper) StopStreamPayment(ctx sdk.Context, streamId string, sender sdk.A streamedAmount = k.getStreamedAmountForPeriodicStreamPayment(ctx, streamPayment) } lastStreamedAmount := streamPayment.StreamedAmount - streamPayment.StreamedAmount.Amount = sdk.NewInt(int64(streamedAmount)) + streamPayment.StreamedAmount.Amount = sdkmath.NewInt(int64(streamedAmount)) remainingAmount := streamPayment.TotalAmount.Sub(streamPayment.StreamedAmount) // transfer remaining amount to sender if err := k.TransferAmountFromModuleAccount(ctx, sender, sdk.NewCoins(remainingAmount)); err != nil { @@ -253,7 +254,7 @@ func (k Keeper) claimDelayedStreamPayment(ctx sdk.Context, streamPayment types.S func (k Keeper) claimContinuousStreamPayment(ctx sdk.Context, streamPayment types.StreamPayment, claimer sdk.AccAddress) error { streamedAmount := k.getStreamedAmount(ctx, streamPayment) amountToSend := int64(streamedAmount) - streamPayment.StreamedAmount.Amount.Int64() - amount := sdk.NewCoin(streamPayment.TotalAmount.Denom, sdk.NewInt(amountToSend)) + amount := sdk.NewCoin(streamPayment.TotalAmount.Denom, sdkmath.NewInt(amountToSend)) if amount.IsZero() || amount.IsNil() { return errorsmod.Wrapf( @@ -282,7 +283,7 @@ func (k Keeper) claimContinuousStreamPayment(ctx sdk.Context, streamPayment type func (k Keeper) claimPeriodicStreamPayment(ctx sdk.Context, streamPayment types.StreamPayment, claimer sdk.AccAddress) error { streamedAmount := k.getStreamedAmountForPeriodicStreamPayment(ctx, streamPayment) amountToSend := int64(streamedAmount) - streamPayment.StreamedAmount.Amount.Int64() - amount := sdk.NewCoin(streamPayment.TotalAmount.Denom, sdk.NewInt(amountToSend)) + amount := sdk.NewCoin(streamPayment.TotalAmount.Denom, sdkmath.NewInt(amountToSend)) if amount.IsZero() || amount.IsNil() { return errorsmod.Wrapf( diff --git a/x/streampay/keeper/keeper_test.go b/x/streampay/keeper/keeper_test.go index ef8a3b3..4b96cb5 100644 --- a/x/streampay/keeper/keeper_test.go +++ b/x/streampay/keeper/keeper_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + sdkmath "cosmossdk.io/math" "testing" "github.com/OmniFlix/streampay/v2/app/apptesting" @@ -25,7 +26,7 @@ func TestKeeperTestSuite(t *testing.T) { func (suite *KeeperTestSuite) SetupTest() { suite.Setup() fundAccsAmount := sdk.NewCoins( - sdk.NewCoin("uspay", sdk.NewInt(10_000_000_000)), + sdk.NewCoin("uspay", sdkmath.NewInt(10_000_000_000)), ) for _, acc := range suite.TestAccs { suite.FundAcc(acc, fundAccsAmount) @@ -75,14 +76,14 @@ func (suite *KeeperTestSuite) TestParams() { { name: "set invalid fee", input: types.Params{ - StreamPaymentFeePercentage: sdk.NewDec(1), + StreamPaymentFeePercentage: sdkmath.LegacyNewDec(1), }, expectErr: true, }, { name: "set invalid fee", input: types.Params{ - StreamPaymentFeePercentage: sdk.NewDec(-1), + StreamPaymentFeePercentage: sdkmath.LegacyNewDec(-1), }, expectErr: true, }, diff --git a/x/streampay/keeper/msg_server.go b/x/streampay/keeper/msg_server.go index 272afb3..5b13e63 100644 --- a/x/streampay/keeper/msg_server.go +++ b/x/streampay/keeper/msg_server.go @@ -2,6 +2,7 @@ package keeper import ( "context" + sdkmath "cosmossdk.io/math" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -53,11 +54,11 @@ func (m msgServer) StreamSend(goCtx context.Context, msg *types.MsgStreamSend) ( } feePercentage := m.Keeper.GetStreamPaymentFeePercentage(ctx) - requiredFeeAmount := sdk.NewCoin(msg.Amount.Denom, sdk.NewDecFromInt(msg.Amount.Amount).Mul(feePercentage).TruncateInt()) + requiredFeeAmount := sdk.NewCoin(msg.Amount.Denom, sdkmath.LegacyNewDecFromInt(msg.Amount.Amount).Mul(feePercentage).TruncateInt()) if !msg.PaymentFee.Equal(requiredFeeAmount) { return nil, errorsmod.Wrap(types.ErrInvalidStreamPaymentFee, "fee coin didn't match with stream coin") } - if requiredFeeAmount.Amount.GTE(sdk.NewInt(1)) { + if requiredFeeAmount.Amount.GTE(sdkmath.NewInt(1)) { if err := m.distributionKeeper.FundCommunityPool(ctx, sdk.NewCoins(requiredFeeAmount), sender); err != nil { return nil, err } diff --git a/x/streampay/keeper/msg_server_test.go b/x/streampay/keeper/msg_server_test.go index f026704..bb4643c 100644 --- a/x/streampay/keeper/msg_server_test.go +++ b/x/streampay/keeper/msg_server_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + sdkmath "cosmossdk.io/math" "time" "github.com/OmniFlix/streampay/v2/x/streampay/types" @@ -65,14 +66,14 @@ func (suite *KeeperTestSuite) TestStreamSendMsg() { duration: time.Second * 100, periods: nil, cancellable: false, - paymentFee: sdk.Coin{Denom: "", Amount: sdk.NewInt(-1)}, + paymentFee: sdk.Coin{Denom: "", Amount: sdkmath.NewInt(-1)}, valid: false, expectedMessageEvents: 0, }, { sender: suite.TestAccs[0].String(), recipient: suite.TestAccs[1].String(), - amount: sdk.Coin{Denom: "", Amount: sdk.NewInt(-1)}, + amount: sdk.Coin{Denom: "", Amount: sdkmath.NewInt(-1)}, streamType: types.TypeContinuous, duration: time.Second * 100, periods: nil, @@ -339,7 +340,7 @@ func (suite *KeeperTestSuite) TestUpdateParams() { request: &types.MsgUpdateParams{ Authority: suite.App.StreamPayKeeper.GetAuthority(), Params: types.Params{ - StreamPaymentFeePercentage: sdk.NewDec(1), + StreamPaymentFeePercentage: sdkmath.LegacyNewDec(1), }, }, expectErr: true, @@ -349,7 +350,7 @@ func (suite *KeeperTestSuite) TestUpdateParams() { request: &types.MsgUpdateParams{ Authority: suite.App.StreamPayKeeper.GetAuthority(), Params: types.Params{ - StreamPaymentFeePercentage: sdk.NewDecWithPrec(-5, 2), + StreamPaymentFeePercentage: sdkmath.LegacyNewDecWithPrec(-5, 2), }, }, expectErr: true, diff --git a/x/streampay/keeper/params.go b/x/streampay/keeper/params.go index 0d1d7c9..cbcf6e7 100644 --- a/x/streampay/keeper/params.go +++ b/x/streampay/keeper/params.go @@ -1,6 +1,7 @@ package keeper import ( + sdkmath "cosmossdk.io/math" "github.com/OmniFlix/streampay/v2/x/streampay/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -31,7 +32,7 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { } // GetStreamPaymentFeePercentage returns the current stream payment fee. -func (k Keeper) GetStreamPaymentFeePercentage(ctx sdk.Context) sdk.Dec { +func (k Keeper) GetStreamPaymentFeePercentage(ctx sdk.Context) sdkmath.LegacyDec { params := k.GetParams(ctx) return params.StreamPaymentFeePercentage } diff --git a/x/streampay/keeper/stream_payment.go b/x/streampay/keeper/stream_payment.go index c25a041..3724375 100644 --- a/x/streampay/keeper/stream_payment.go +++ b/x/streampay/keeper/stream_payment.go @@ -1,6 +1,7 @@ package keeper import ( + storetypes "cosmossdk.io/store/types" "encoding/binary" "math" @@ -61,7 +62,7 @@ func (k Keeper) RemoveStreamPayment(ctx sdk.Context, id string) { func (k Keeper) IterateStreamPayments(ctx sdk.Context, fn func(index int64, streamPayment types.StreamPayment) (stop bool)) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.PrefixPaymentStreamId) + iterator := storetypes.KVStorePrefixIterator(store, types.PrefixPaymentStreamId) defer iterator.Close() i := int64(0) diff --git a/x/streampay/module.go b/x/streampay/module.go index a8fb426..e041761 100644 --- a/x/streampay/module.go +++ b/x/streampay/module.go @@ -2,6 +2,7 @@ package streampay import ( "context" + "cosmossdk.io/core/appmodule" "encoding/json" "fmt" @@ -20,7 +21,7 @@ import ( ) var ( - _ module.AppModule = AppModule{} + _ appmodule.AppModule = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} ) @@ -100,6 +101,12 @@ type AppModule struct { keeper keeper.Keeper } +func (am AppModule) IsOnePerModuleType() { +} + +func (am AppModule) IsAppModule() { +} + func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { return AppModule{ AppModuleBasic: NewAppModuleBasic(cdc), @@ -147,12 +154,3 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } - -// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. -func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} - -// EndBlock executes all ABCI EndBlock logic respective to the capability module. It -// returns no validator updates. -func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - return []abci.ValidatorUpdate{} -} diff --git a/x/streampay/types/codec.go b/x/streampay/types/codec.go index 122bfdd..1ed474a 100644 --- a/x/streampay/types/codec.go +++ b/x/streampay/types/codec.go @@ -8,8 +8,6 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" - authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" - govcodec "github.com/cosmos/cosmos-sdk/x/gov/codec" ) const ( @@ -60,6 +58,6 @@ func init() { // Register all Amino interfaces and concrete types on the authz Amino codec // so that this can later be used to properly serialize MsgGrant and MsgExec // instances. - RegisterLegacyAminoCodec(authzcodec.Amino) - RegisterLegacyAminoCodec(govcodec.Amino) + //RegisterLegacyAminoCodec(authzcodec) + //RegisterLegacyAminoCodec(govcodec) } diff --git a/x/streampay/types/expected_keepers.go b/x/streampay/types/expected_keepers.go index 3c170a9..4a5e6ea 100644 --- a/x/streampay/types/expected_keepers.go +++ b/x/streampay/types/expected_keepers.go @@ -1,27 +1,27 @@ package types import ( + "context" sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) // AccountKeeper Methods imported from account should be defined here type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI - GetModuleAccount(ctx sdk.Context, name string) authtypes.ModuleAccountI + GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI + GetModuleAccount(ctx context.Context, name string) sdk.ModuleAccountI GetModuleAddress(module string) sdk.AccAddress - SetModuleAccount(sdk.Context, authtypes.ModuleAccountI) + SetModuleAccount(context.Context, sdk.ModuleAccountI) } // BankKeeper Methods imported from bank should be defined here type BankKeeper interface { BlockedAddr(recipient sdk.AccAddress) bool - SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins - SendCoins(ctx sdk.Context, from sdk.AccAddress, to sdk.AccAddress, amount sdk.Coins) error - SendCoinsFromModuleToAccount(ctx sdk.Context, fromModule string, toAddr sdk.AccAddress, amt sdk.Coins) error - SendCoinsFromAccountToModule(ctx sdk.Context, fromAddr sdk.AccAddress, toModule string, amt sdk.Coins) error + SpendableCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins + SendCoins(ctx context.Context, from sdk.AccAddress, to sdk.AccAddress, amount sdk.Coins) error + SendCoinsFromModuleToAccount(ctx context.Context, fromModule string, toAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx context.Context, fromAddr sdk.AccAddress, toModule string, amt sdk.Coins) error } type DistributionKeeper interface { - FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error + FundCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error } diff --git a/x/streampay/types/genesis_test.go b/x/streampay/types/genesis_test.go index 6609171..0cdc9da 100644 --- a/x/streampay/types/genesis_test.go +++ b/x/streampay/types/genesis_test.go @@ -1,6 +1,7 @@ package types_test import ( + sdkmath "cosmossdk.io/math" "testing" "github.com/OmniFlix/streampay/v2/x/streampay/types" @@ -39,7 +40,7 @@ func TestGenesisState_Validate(t *testing.T) { Recipient: addr2.String(), StreamType: types.TypeDelayed, TotalAmount: defaultAmount, - StreamedAmount: sdk.NewCoin(defaultAmount.Denom, sdk.ZeroInt()), + StreamedAmount: sdk.NewCoin(defaultAmount.Denom, sdkmath.ZeroInt()), }, { Id: "sp2", @@ -47,7 +48,7 @@ func TestGenesisState_Validate(t *testing.T) { Recipient: addr2.String(), StreamType: types.TypeContinuous, TotalAmount: defaultAmount, - StreamedAmount: sdk.NewCoin(defaultAmount.Denom, sdk.ZeroInt()), + StreamedAmount: sdk.NewCoin(defaultAmount.Denom, sdkmath.ZeroInt()), }, }, NextStreamPaymentNumber: 3, diff --git a/x/streampay/types/params.go b/x/streampay/types/params.go index 5df650d..6b9e47c 100644 --- a/x/streampay/types/params.go +++ b/x/streampay/types/params.go @@ -1,15 +1,15 @@ package types import ( + sdkmath "cosmossdk.io/math" "fmt" errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" ) -var DefaultStreamPaymentFeePercentage = sdk.NewDecWithPrec(1, 2) // 1% +var DefaultStreamPaymentFeePercentage = sdkmath.LegacyNewDecWithPrec(1, 2) // 1% -func NewStreampayParams(streamPaymentFeePercentage sdk.Dec) Params { +func NewStreampayParams(streamPaymentFeePercentage sdkmath.LegacyDec) Params { return Params{ StreamPaymentFeePercentage: streamPaymentFeePercentage, } @@ -33,12 +33,12 @@ func (p Params) ValidateBasic() error { // validateStreamPaymentFee performs validation of stream payment fee func validateStreamPaymentFeePercentage(i interface{}) error { - fee, ok := i.(sdk.Dec) + fee, ok := i.(sdkmath.LegacyDec) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } - if fee.IsNegative() || fee.GTE(sdk.OneDec()) { + if fee.IsNegative() || fee.GTE(sdkmath.LegacyOneDec()) { return errorsmod.Wrapf( ErrInvalidStreamPaymentFee, "invalid fee percentage %s, only accepts value which is positive and less than 1.00", diff --git a/x/streampay/types/params.pb.go b/x/streampay/types/params.pb.go index c484ee8..e0849c1 100644 --- a/x/streampay/types/params.pb.go +++ b/x/streampay/types/params.pb.go @@ -4,9 +4,9 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-sdk/types" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -26,7 +26,7 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { - StreamPaymentFeePercentage github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=stream_payment_fee_percentage,json=streamPaymentFeePercentage,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stream_payment_fee_percentage" yaml:"stream_payment_fee_percentage"` + StreamPaymentFeePercentage cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=stream_payment_fee_percentage,json=streamPaymentFeePercentage,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"stream_payment_fee_percentage" yaml:"stream_payment_fee_percentage"` } func (m *Params) Reset() { *m = Params{} } @@ -71,24 +71,24 @@ func init() { } var fileDescriptor_f8d8e5be08a0a998 = []byte{ - // 269 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xf2, 0xcf, 0xcd, 0xcb, - 0x74, 0xcb, 0xc9, 0xac, 0xd0, 0x2f, 0x2e, 0x29, 0x4a, 0x4d, 0xcc, 0x2d, 0x48, 0xac, 0xd4, 0x2f, - 0x33, 0xd4, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, - 0x85, 0xa9, 0xd1, 0x83, 0xab, 0xd1, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xab, - 0xd0, 0x07, 0xb1, 0x20, 0x8a, 0xa5, 0xe4, 0x92, 0xf3, 0x8b, 0x73, 0xf3, 0x8b, 0xf5, 0x93, 0x12, - 0x8b, 0x53, 0xf5, 0xcb, 0x0c, 0x93, 0x52, 0x4b, 0x12, 0x0d, 0xf5, 0x93, 0xf3, 0x33, 0xf3, 0x20, - 0xf2, 0x4a, 0x4b, 0x18, 0xb9, 0xd8, 0x02, 0xc0, 0xa6, 0x0b, 0xcd, 0x64, 0xe4, 0x92, 0x85, 0x98, - 0x18, 0x5f, 0x90, 0x58, 0x99, 0x9b, 0x9a, 0x57, 0x12, 0x9f, 0x96, 0x9a, 0x1a, 0x5f, 0x90, 0x5a, - 0x94, 0x9c, 0x9a, 0x57, 0x92, 0x98, 0x9e, 0x2a, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0xe9, 0x14, 0x76, - 0xe2, 0x9e, 0x3c, 0xc3, 0xad, 0x7b, 0xf2, 0x6a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, - 0xf9, 0xb9, 0xfa, 0x50, 0x5b, 0x20, 0x94, 0x6e, 0x71, 0x4a, 0xb6, 0x7e, 0x49, 0x65, 0x41, 0x6a, - 0xb1, 0x9e, 0x4b, 0x6a, 0xf2, 0xa7, 0x7b, 0xf2, 0x2a, 0x95, 0x89, 0xb9, 0x39, 0x56, 0x4a, 0x78, - 0x0d, 0x57, 0x0a, 0x92, 0x82, 0xc8, 0x07, 0x40, 0xa4, 0xdd, 0x52, 0x53, 0x03, 0xe0, 0x92, 0x4e, - 0xbe, 0x27, 0x1e, 0xca, 0x31, 0x9c, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, - 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, - 0x3e, 0x92, 0x4b, 0xb0, 0x04, 0x20, 0x32, 0x1b, 0xec, 0xac, 0x24, 0x36, 0xb0, 0xe7, 0x8d, 0x01, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x44, 0xec, 0xa2, 0xc1, 0x6f, 0x01, 0x00, 0x00, + // 270 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0xb1, 0x4a, 0xf4, 0x40, + 0x14, 0x46, 0x33, 0xcd, 0xc2, 0x9f, 0x72, 0xf9, 0x05, 0x89, 0x38, 0x91, 0x60, 0x61, 0x35, 0x43, + 0xb0, 0xb3, 0x5c, 0x64, 0x1b, 0x15, 0x83, 0xa5, 0x4d, 0xb8, 0x19, 0xaf, 0xd9, 0xe0, 0x4e, 0x66, + 0xc8, 0x8c, 0xc1, 0x79, 0x09, 0xb1, 0xf5, 0x8d, 0x52, 0x6e, 0x29, 0x16, 0x41, 0x93, 0x37, 0xf0, + 0x09, 0xc4, 0x0c, 0x2e, 0x16, 0x62, 0xf7, 0xc1, 0x39, 0x1c, 0xb8, 0x37, 0x4c, 0x2e, 0x65, 0x5d, + 0x2d, 0xd7, 0xd5, 0x03, 0x37, 0xb6, 0x41, 0x90, 0x1a, 0x1c, 0x6f, 0x53, 0xae, 0xa1, 0x01, 0x69, + 0x98, 0x6e, 0x94, 0x55, 0xf3, 0x9d, 0x6f, 0x87, 0x6d, 0x1d, 0xd6, 0xa6, 0xd1, 0xff, 0x52, 0x95, + 0x6a, 0x32, 0xf8, 0xd7, 0xf2, 0x72, 0x44, 0x85, 0x32, 0x52, 0x19, 0x5e, 0x80, 0x41, 0xde, 0xa6, + 0x05, 0x5a, 0x48, 0xb9, 0x50, 0x55, 0xed, 0x79, 0xf2, 0x4c, 0xc2, 0x59, 0x36, 0xd5, 0xe7, 0x8f, + 0x24, 0xdc, 0xf7, 0xc5, 0x5c, 0x83, 0x93, 0x58, 0xdb, 0xfc, 0x16, 0x31, 0xd7, 0xd8, 0x08, 0xac, + 0x2d, 0x94, 0xb8, 0x4b, 0x0e, 0xc8, 0xd1, 0xbf, 0xc5, 0x59, 0xd7, 0xc7, 0xc1, 0x6b, 0x1f, 0xef, + 0xf9, 0xb4, 0xb9, 0xb9, 0x63, 0x95, 0xe2, 0x12, 0xec, 0x8a, 0x9d, 0x63, 0x09, 0xc2, 0x9d, 0xa2, + 0xf8, 0xe8, 0xe3, 0x43, 0x07, 0x72, 0x7d, 0x92, 0xfc, 0x59, 0x4c, 0xae, 0x22, 0xcf, 0x33, 0x8f, + 0x97, 0x88, 0xd9, 0x16, 0x2e, 0x2e, 0xba, 0x77, 0x1a, 0x74, 0x03, 0x25, 0x9b, 0x81, 0x92, 0xb7, + 0x81, 0x92, 0xa7, 0x91, 0x06, 0x9b, 0x91, 0x06, 0x2f, 0x23, 0x0d, 0xae, 0x79, 0x59, 0xd9, 0xd5, + 0x7d, 0xc1, 0x84, 0x92, 0xfc, 0x97, 0xaf, 0xfd, 0xdc, 0xd6, 0x69, 0x34, 0xc5, 0x6c, 0xba, 0xf8, + 0xf8, 0x33, 0x00, 0x00, 0xff, 0xff, 0xb6, 0x9b, 0x0c, 0xf9, 0x64, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/streampay/types/params_test.go b/x/streampay/types/params_test.go index 9956ab0..c44dca8 100644 --- a/x/streampay/types/params_test.go +++ b/x/streampay/types/params_test.go @@ -1,9 +1,9 @@ package types import ( + sdkmath "cosmossdk.io/math" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" ) @@ -14,9 +14,9 @@ func TestParams_ValidateBasic(t *testing.T) { expError bool }{ {"default params", DefaultParams(), false}, - {"valid params", Params{StreamPaymentFeePercentage: sdk.NewDec(0)}, false}, - {"invalid stream fee percentage", Params{StreamPaymentFeePercentage: sdk.NewDec(1)}, true}, - {"invalid stream fee percentage", Params{StreamPaymentFeePercentage: sdk.NewDec(-1)}, true}, + {"valid params", Params{StreamPaymentFeePercentage: sdkmath.LegacyNewDec(0)}, false}, + {"invalid stream fee percentage", Params{StreamPaymentFeePercentage: sdkmath.LegacyNewDec(1)}, true}, + {"invalid stream fee percentage", Params{StreamPaymentFeePercentage: sdkmath.LegacyNewDec(-1)}, true}, } for _, tc := range testCases { err := tc.params.ValidateBasic() diff --git a/x/streampay/types/validation.go b/x/streampay/types/validation.go index 415b647..5aee0a6 100644 --- a/x/streampay/types/validation.go +++ b/x/streampay/types/validation.go @@ -1,6 +1,7 @@ package types import ( + sdkmath "cosmossdk.io/math" "fmt" "time" @@ -29,7 +30,7 @@ func validateStreamPayment(streamPayment StreamPayment) error { } func validateStreamAmount(amount sdk.Coin) error { - if !amount.IsValid() || amount.IsNil() || amount.Amount.LTE(sdk.ZeroInt()) { + if !amount.IsValid() || amount.IsNil() || amount.Amount.LTE(sdkmath.ZeroInt()) { return errorsmod.Wrapf( ErrInvalidAmount, fmt.Sprintf("amount %s is not valid", amount.String()), @@ -39,7 +40,7 @@ func validateStreamAmount(amount sdk.Coin) error { } func validateFeeAmount(amount sdk.Coin) error { - if !amount.IsValid() || amount.IsNil() || amount.Amount.LT(sdk.ZeroInt()) { + if !amount.IsValid() || amount.IsNil() || amount.Amount.LT(sdkmath.ZeroInt()) { return errorsmod.Wrapf( ErrInvalidAmount, fmt.Sprintf("fee amount %s is not valid", amount.String()),