From b341f24c0bcdc64e34bc58bdc190073b5dde0f97 Mon Sep 17 00:00:00 2001 From: Harish Marri Date: Wed, 14 Aug 2024 19:09:23 +0530 Subject: [PATCH] fix lint --- app/app.go | 88 +++++++-- app/apptesting/events.go | 3 +- app/apptesting/test_suite.go | 254 +++++++++++++++++++------ app/encoding.go | 6 + app/export.go | 3 +- app/genesis.go | 30 ++- app/helpers/mock.go | 2 +- app/params/proto.go | 20 +- app/prefix.go | 8 + app/test_helpers.go | 255 ++++++++++++++------------ cmd/streampayd/cmd/root.go | 82 +++++++-- cmd/streampayd/main.go | 1 + go.mod | 54 +++--- go.sum | 84 +++++---- x/streampay/keeper/alias.go | 3 +- x/streampay/keeper/keeper.go | 3 +- x/streampay/keeper/keeper_test.go | 7 +- x/streampay/keeper/msg_server.go | 1 + x/streampay/keeper/msg_server_test.go | 9 +- x/streampay/keeper/stream_payment.go | 3 +- x/streampay/module.go | 3 +- x/streampay/types/codec.go | 17 -- x/streampay/types/expected_keepers.go | 1 + x/streampay/types/genesis_test.go | 3 +- x/streampay/types/messages.go | 22 --- x/streampay/types/params.go | 3 +- x/streampay/types/params_test.go | 3 +- x/streampay/types/validation.go | 3 +- 28 files changed, 641 insertions(+), 330 deletions(-) diff --git a/app/app.go b/app/app.go index 883a532..a0417d8 100644 --- a/app/app.go +++ b/app/app.go @@ -13,6 +13,10 @@ import ( "github.com/OmniFlix/streampay/v2/docs" + autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" + reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" + runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/evidence" @@ -31,7 +35,6 @@ import ( 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" @@ -49,7 +52,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/ante" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" 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" @@ -94,6 +96,8 @@ 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" + ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" 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" @@ -187,6 +191,8 @@ type StreamPayApp struct { invCheckPeriod uint + ModuleBasics module.BasicManager + // keys to access the substores keys map[string]*storetypes.KVStoreKey tkeys map[string]*storetypes.TransientStoreKey @@ -398,8 +404,8 @@ func NewStreamPayApp( 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(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). + // AddRoute(ibcexported.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)) // Create Transfer Keepers app.TransferKeeper = ibctransferkeeper.NewKeeper( @@ -473,12 +479,12 @@ func NewStreamPayApp( // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. - enabledSignModes := append(tx.DefaultSignModes, signingtypes.SignMode_SIGN_MODE_TEXTUAL) - txConfigOpts := tx.ConfigOptions{ + enabledSignModes := append(authtx.DefaultSignModes, signingtypes.SignMode_SIGN_MODE_TEXTUAL) + txConfigOpts := authtx.ConfigOptions{ EnabledSignModes: enabledSignModes, TextualCoinMetadataQueryFn: txconfig.NewBankKeeperCoinMetadataQueryFn(app.BankKeeper), } - txConfig, err := tx.NewTxConfigWithOptions( + txConfig, err := authtx.NewTxConfigWithOptions( appCodec, txConfigOpts, ) @@ -512,12 +518,14 @@ func NewStreamPayApp( streampayModule, ) + // part of sdk v0.50.x migration + app.mm.SetOrderPreBlockers(upgradetypes.ModuleName) + // During begin block slashing happens after distr.BeginBlocker so that // there is nothing left over in the validator fee pool, so as to keep the // CanWithdrawInvariant invariant. // NOTE: staking module is required if HistoricalEntries param > 0 app.mm.SetOrderBeginBlockers( - upgradetypes.ModuleName, capabilitytypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, @@ -589,7 +597,21 @@ func NewStreamPayApp( app.mm.RegisterInvariants(app.CrisisKeeper) app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) - app.mm.RegisterServices(app.configurator) + err = app.mm.RegisterServices(app.configurator) + if err != nil { + panic(err) + } + + // Migration check + app.ModuleBasics = module.NewBasicManagerFromManager( + app.mm, + map[string]module.AppModuleBasic{ + "gov": gov.NewAppModuleBasic( + []govclient.ProposalHandler{ + paramsclient.ProposalHandler, + }), + }, + ) app.sm = module.NewSimulationManager( auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), @@ -607,6 +629,15 @@ func NewStreamPayApp( transferModule, ) + // SDK v47 - since we do not use dep inject, this gives us access to newer gRPC services. + autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.mm.Modules)) + + reflectionSvc, err := runtimeservices.NewReflectionService() + if err != nil { + panic(err) + } + reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc) + // initialize stores app.MountKVStores(keys) app.MountTransientStores(tkeys) @@ -614,6 +645,7 @@ func NewStreamPayApp( // initialize BaseApp app.SetInitChainer(app.InitChainer) + app.SetPreBlocker(app.PreBlocker) app.SetBeginBlocker(app.BeginBlocker) anteHandler, err := NewAnteHandler( @@ -637,6 +669,8 @@ func NewStreamPayApp( app.SetAnteHandler(anteHandler) app.SetEndBlocker(app.EndBlocker) + app.SetPrecommiter(app.PreCommitter) + app.SetPrepareCheckStater(app.PrepareCheckStater) if loadLatest { if err := app.LoadLatestVersion(); err != nil { @@ -676,6 +710,26 @@ func (app *StreamPayApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain return app.mm.InitGenesis(ctx, app.appCodec, genesisState) } +// PreBlocker application updates before begin of the block +func (app *StreamPayApp) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { + return app.mm.PreBlock(ctx) +} + +// PreCommitter application updates before the commit of a block after all transactions have been delivered. +func (app *StreamPayApp) PreCommitter(ctx sdk.Context) { + mm := app.ModuleManager() + if err := mm.Precommit(ctx); err != nil { + panic(err) + } +} + +func (app *StreamPayApp) PrepareCheckStater(ctx sdk.Context) { + mm := app.ModuleManager() + if err := mm.PrepareCheckState(ctx); err != nil { + panic(err) + } +} + // LoadHeight loads a particular height func (app *StreamPayApp) LoadHeight(height int64) error { return app.LoadVersion(height) @@ -741,6 +795,10 @@ func (app *StreamPayApp) GetSubspace(moduleName string) paramstypes.Subspace { return subspace } +func (app *StreamPayApp) ModuleManager() module.Manager { + return *app.mm +} + // SimulationManager implements the SimulationApp interface func (app *StreamPayApp) SimulationManager() *module.SimulationManager { return app.sm @@ -765,12 +823,12 @@ func (app *StreamPayApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config. } // RegisterTxService implements the Application.RegisterTxService method. -func (app *StreamPayApp) RegisterTxService(clientCtx client.Context) { +func (app *StreamPayApp) RegisterTxService(clientCtx sdkclient.Context) { authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) } // RegisterTendermintService implements the Application.RegisterTendermintService method. -func (app *StreamPayApp) RegisterTendermintService(clientCtx client.Context) { +func (app *StreamPayApp) RegisterTendermintService(clientCtx sdkclient.Context) { cmtservice.RegisterTendermintService( clientCtx, app.BaseApp.GRPCQueryRouter(), @@ -780,7 +838,7 @@ func (app *StreamPayApp) RegisterTendermintService(clientCtx client.Context) { } // RegisterNodeService allows query minimum-gas-prices in app.toml -func (app *StreamPayApp) RegisterNodeService(clientCtx client.Context, cfg config.Config) { +func (app *StreamPayApp) RegisterNodeService(clientCtx sdkclient.Context, cfg config.Config) { nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) } @@ -805,8 +863,10 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(slashingtypes.ModuleName) paramsKeeper.Subspace(govtypes.ModuleName) paramsKeeper.Subspace(crisistypes.ModuleName) - paramsKeeper.Subspace(ibctransfertypes.ModuleName) - paramsKeeper.Subspace(ibcexported.ModuleName) + keyTable := ibcclienttypes.ParamKeyTable() + keyTable.RegisterParamSet(&ibcconnectiontypes.Params{}) + paramsKeeper.Subspace(ibctransfertypes.ModuleName).WithKeyTable(ibctransfertypes.ParamKeyTable()) + paramsKeeper.Subspace(ibcexported.ModuleName).WithKeyTable(keyTable) paramsKeeper.Subspace(streampaytypes.ModuleName) return paramsKeeper diff --git a/app/apptesting/events.go b/app/apptesting/events.go index 905edf9..40d7efb 100644 --- a/app/apptesting/events.go +++ b/app/apptesting/events.go @@ -4,8 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// AssertEventEmitted asserts that ctx's event manager has emitted the given number of events -// of the given type. +// AssertEventEmitted asserts that ctx's event manager has emitted the given number of events of the given type. func (s *KeeperTestHelper) AssertEventEmitted(ctx sdk.Context, eventTypeExpected string, numEventsExpected int) { allEvents := ctx.EventManager().Events() // filter out other events diff --git a/app/apptesting/test_suite.go b/app/apptesting/test_suite.go index d7cbbcf..ce3827e 100644 --- a/app/apptesting/test_suite.go +++ b/app/apptesting/test_suite.go @@ -1,18 +1,23 @@ package apptesting import ( - storetypes "cosmossdk.io/store/types" "fmt" + "os" "time" + "github.com/cosmos/cosmos-sdk/x/consensus/testutil" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + + coreheader "cosmossdk.io/core/header" sdkmath "cosmossdk.io/math" "github.com/OmniFlix/streampay/v2/app" "cosmossdk.io/log" "cosmossdk.io/store/rootmulti" + abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/crypto/ed25519" - tmtypes "github.com/cometbft/cometbft/proto/tendermint/types" + cmtproto "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" @@ -28,62 +33,186 @@ import ( "github.com/stretchr/testify/suite" ) +var ( + SecondaryDenom = "uxpy" + SecondaryAmount = sdkmath.NewInt(100000000) + baseTestAccts = []sdk.AccAddress{} + defaultTestStartTime = time.Now().UTC() + testDescription = stakingtypes.NewDescription("test_moniker", "test_identity", "test_website", "test_security_contact", "test_details") +) + +func init() { + baseTestAccts = CreateRandomAccounts(3) +} + type KeeperTestHelper struct { suite.Suite + // defaults to false, + // set to true if any method that potentially alters baseapp/abci is used. + // this controls whether we can reuse the app instance, or have to set a new one. + hasUsedAbci bool + // defaults to false, set to true if we want to use a new app instance with caching enabled. + // then on new setup test call, we just drop the current cache. + // this is not always enabled, because some tests may take a painful performance hit due to CacheKv. + withCaching bool + App *app.StreamPayApp Ctx sdk.Context QueryHelper *baseapp.QueryServiceTestHelper TestAccs []sdk.AccAddress } -var ( - ChainID = "sp-test-1" - Denom = "uspay" - 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.NewContextLegacy(false, tmtypes.Header{Height: 1, ChainID: ChainID, Time: time.Now().UTC()}) + dir, err := os.MkdirTemp("", "streampay-test-home") + if err != nil { + panic(fmt.Sprintf("failed creating temporary directory: %v", err)) + } + s.T().Cleanup(func() { os.RemoveAll(dir); s.withCaching = false }) + s.App = app.SetupWithCustomHome(false, dir) + s.setupGeneral() + + // Manually set validator signing info, otherwise we panic + vals, err := s.App.StakingKeeper.GetAllValidators(s.Ctx) + if err != nil { + panic(err) + } + for _, val := range vals { + consAddr, _ := val.GetConsAddr() + signingInfo := slashingtypes.NewValidatorSigningInfo( + consAddr, + s.Ctx.BlockHeight(), + s.Ctx.BlockTime().Unix(), + time.Unix(0, 0), + false, + 0, + ) + err := s.App.SlashingKeeper.SetValidatorSigningInfo(s.Ctx, consAddr, signingInfo) + if err != nil { + panic(err) + } + } +} + +func (s *KeeperTestHelper) SetupWithCustomChainId(chainId string) { + dir, err := os.MkdirTemp("", "streampay-test-home") + if err != nil { + panic(fmt.Sprintf("failed creating temporary directory: %v", err)) + } + s.T().Cleanup(func() { os.RemoveAll(dir); s.withCaching = false }) + s.App = app.SetupWithCustomHomeAndChainId(false, dir, chainId) + s.setupGeneralCustomChainId(chainId) + + // Manually set validator signing info, otherwise we panic + vals, err := s.App.StakingKeeper.GetAllValidators(s.Ctx) + if err != nil { + panic(err) + } + for _, val := range vals { + consAddr, _ := val.GetConsAddr() + signingInfo := slashingtypes.NewValidatorSigningInfo( + consAddr, + s.Ctx.BlockHeight(), + 0, + time.Unix(0, 0), + false, + 0, + ) + err := s.App.SlashingKeeper.SetValidatorSigningInfo(s.Ctx, consAddr, signingInfo) + if err != nil { + panic(err) + } + } +} + +func (s *KeeperTestHelper) Reset() { + if s.hasUsedAbci || !s.withCaching { + s.withCaching = true + s.Setup() + } else { + s.setupGeneral() + } +} + +func (s *KeeperTestHelper) SetupWithLevelDb() func() { + tapp, cleanup := app.SetupTestingAppWithLevelDb(false) + s.App = tapp + s.setupGeneral() + return cleanup +} + +func (s *KeeperTestHelper) setupGeneral() { + s.setupGeneralCustomChainId("streampay-1") +} + +func (s *KeeperTestHelper) setupGeneralCustomChainId(chainId string) { + s.Ctx = s.App.BaseApp.NewContextLegacy(false, cmtproto.Header{Height: 1, ChainID: chainId, Time: defaultTestStartTime}) + if s.withCaching { + s.Ctx, _ = s.Ctx.CacheContext() + } s.QueryHelper = &baseapp.QueryServiceTestHelper{ GRPCQueryRouter: s.App.GRPCQueryRouter(), Ctx: s.Ctx, } - s.TestAccs = CreateRandomAccounts(3) + s.TestAccs = []sdk.AccAddress{} + s.TestAccs = append(s.TestAccs, baseTestAccts...) + s.hasUsedAbci = false } 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.NewContextLegacy(true, tmtypes.Header{}) + s.App = app.Setup(true) + s.Ctx = s.App.BaseApp.NewContextLegacy(true, cmtproto.Header{}) + s.hasUsedAbci = true } // CreateTestContext creates a test context. func (s *KeeperTestHelper) CreateTestContext() sdk.Context { - ctx, _ := s.CreateTestContextWithMultiStore() + ctx := s.CreateTestContextWithMultiStore() return ctx } // CreateTestContextWithMultiStore creates a test context and returns it together with multi store. -func (s *KeeperTestHelper) CreateTestContextWithMultiStore() (sdk.Context, storetypes.CommitMultiStore) { +func (s *KeeperTestHelper) CreateTestContextWithMultiStore() sdk.Context { db := dbm.NewMemDB() logger := log.NewNopLogger() ms := rootmulti.NewStore(db, logger, nil) - return sdk.NewContext(ms, tmtypes.Header{}, false, logger), ms + return sdk.NewContext(ms, cmtproto.Header{}, false, logger) } func (s *KeeperTestHelper) Commit() { - oldHeight := s.Ctx.BlockHeight() - 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.NewContextLegacy(false, newHeader) + // oldHeight := s.Ctx.BlockHeight() + // oldHeader := s.Ctx.BlockHeader() + // commit, _ := s.App.Commit() + // newHeader := cmtproto.Header{Height: oldHeight + 1, ChainID: oldHeader.ChainID, Time: oldHeader.Time.Add(time.Second)} + // s.App.PreBlocker(s.Ctx, abci.Request_Commit{Commit: commit}) + // s.Ctx = s.App.BaseApp.NewContextLegacy(false, newHeader) + + _, err := s.App.FinalizeBlock(&abci.RequestFinalizeBlock{Height: s.Ctx.BlockHeight(), Time: s.Ctx.BlockTime()}) + if err != nil { + panic(err) + } + _, err = s.App.Commit() + if err != nil { + panic(err) + } + + newBlockTime := s.Ctx.BlockTime().Add(time.Second) + + header := s.Ctx.BlockHeader() + header.Time = newBlockTime + header.Height++ + + s.Ctx = s.App.BaseApp.NewUncachedContext(false, header).WithHeaderInfo(coreheader.Info{ + Height: header.Height, + Time: header.Time, + }) + + s.hasUsedAbci = true } // FundAcc funds target address with specified amount. @@ -107,25 +236,29 @@ 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()) - 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}) + stakingParams, err := s.App.StakingKeeper.GetParams(s.Ctx) + s.Require().NoError(err) + bondDenom := stakingParams.BondDenom + bondAmt := sdk.DefaultPowerReduction + selfBond := sdk.NewCoins(sdk.Coin{Amount: bondAmt, Denom: bondDenom}) s.FundAcc(sdk.AccAddress(valAddr), selfBond) - stakingCoin := sdk.NewCoin(sdk.DefaultBondDenom, selfBond[0].Amount) + stakingCoin := sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: selfBond[0].Amount} ZeroCommission := stakingtypes.NewCommissionRates(sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec()) - _, err = stakingtypes.NewMsgCreateValidator(valAddr.String(), valPub, stakingCoin, stakingtypes.Description{}, ZeroCommission, sdkmath.OneInt()) + valCreateMsg, err := stakingtypes.NewMsgCreateValidator(valAddr.String(), valPub, stakingCoin, testDescription, ZeroCommission, sdkmath.OneInt()) s.Require().NoError(err) + stakingMsgSvr := stakingkeeper.NewMsgServerImpl(s.App.StakingKeeper) + res, err := stakingMsgSvr.CreateValidator(s.Ctx, valCreateMsg) + s.Require().NoError(err) + s.Require().NotNil(res) val, err := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) s.Require().NoError(err) val = val.UpdateStatus(bondStatus) - s.App.StakingKeeper.SetValidator(s.Ctx, val) + err = s.App.StakingKeeper.SetValidator(s.Ctx, val) + s.Require().NoError(err) consAddr, err := val.GetConsAddr() s.Suite.Require().NoError(err) @@ -138,7 +271,8 @@ func (s *KeeperTestHelper) SetupValidator(bondStatus stakingtypes.BondStatus) sd false, 0, ) - s.App.SlashingKeeper.SetValidatorSigningInfo(s.Ctx, consAddr, signingInfo) + err = s.App.SlashingKeeper.SetValidatorSigningInfo(s.Ctx, consAddr, signingInfo) + s.Require().NoError(err) return valAddr } @@ -158,9 +292,7 @@ func (s *KeeperTestHelper) BeginNewBlock(executeNextEpoch bool) { var valAddr []byte validators, err := s.App.StakingKeeper.GetAllValidators(s.Ctx) - if err != nil { - return - } + s.Require().NoError(err) if len(validators) >= 1 { valAddrFancy, err := validators[0].GetConsAddr() s.Require().NoError(err) @@ -177,35 +309,48 @@ func (s *KeeperTestHelper) BeginNewBlock(executeNextEpoch bool) { // BeginNewBlockWithProposer begins a new block with a proposer. func (s *KeeperTestHelper) BeginNewBlockWithProposer(executeNextEpoch bool, proposer sdk.ValAddress) { - //validator, err := s.App.StakingKeeper.GetValidator(s.Ctx, proposer) - //s.Assert().NoError(err) + // 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 + // valAddr := valConsAddr + + validator, err := s.App.StakingKeeper.GetValidator(s.Ctx, proposer) + s.Assert().NoError(err) + + valAddr, err := validator.GetConsAddr() + s.Require().NoError(err) newBlockTime := s.Ctx.BlockTime().Add(5 * time.Second) - header := tmtypes.Header{Height: s.Ctx.BlockHeight() + 1, Time: newBlockTime} + header := cmtproto.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}, - // }}, - //} - //reqBeginBlock := abci.RequestBeginBlock{Header: header, LastCommitInfo: lastCommitInfo} - - //fmt.Println("beginning block ", s.Ctx.BlockHeight()) - //s.App.BeginBlocker(s.Ctx, reqBeginBlock) + + voteInfos := []abci.VoteInfo{ + { + Validator: abci.Validator{Address: valAddr, Power: 1000}, + BlockIdFlag: cmtproto.BlockIDFlagCommit, + }, + } + s.Ctx = s.Ctx.WithVoteInfos(voteInfos) + + fmt.Println("beginning block ", s.Ctx.BlockHeight()) + + _, err = s.App.BeginBlocker(s.Ctx) + s.Require().NoError(err) + s.Ctx = s.App.NewContextLegacy(false, header) + s.hasUsedAbci = true } // EndBlock ends the block, and runs commit func (s *KeeperTestHelper) EndBlock() { - //reqEndBlock := abci.RequestEndBlock{Height: s.Ctx.BlockHeight()} - s.App.EndBlocker(s.Ctx) + _, err := s.App.EndBlocker(s.Ctx) + s.Require().NoError(err) + s.hasUsedAbci = true } func (s *KeeperTestHelper) RunMsg(msg sdk.Msg) (*sdk.Result, error) { @@ -226,13 +371,14 @@ func (s *KeeperTestHelper) AllocateRewardsToValidator(valAddr sdk.ValAddress, re // allocate reward tokens to distribution module coins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, rewardAmt)} - err = banktestutil.FundModuleAccount(s.Ctx, s.App.BankKeeper, distrtypes.ModuleName, coins) + err = testutil.FundModuleAccount(s.App.BankKeeper, s.Ctx, 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: sdkmath.LegacyNewDec(20000)}} - s.App.DistrKeeper.AllocateTokensToValidator(s.Ctx, validator, decTokens) + err = s.App.DistrKeeper.AllocateTokensToValidator(s.Ctx, validator, decTokens) + s.Require().NoError(err) } // BuildTx builds a transaction. diff --git a/app/encoding.go b/app/encoding.go index ebbc18d..3d0a166 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -5,6 +5,12 @@ import ( "github.com/cosmos/cosmos-sdk/std" ) +var encodingConfig params.EncodingConfig = MakeEncodingConfig() + +func GetEncodingConfig() params.EncodingConfig { + return encodingConfig +} + // MakeEncodingConfig creates an EncodingConfig for testing func MakeEncodingConfig() params.EncodingConfig { encodingConfig := params.MakeEncodingConfig() diff --git a/app/export.go b/app/export.go index a3fd956..2576c3c 100644 --- a/app/export.go +++ b/app/export.go @@ -1,10 +1,11 @@ package app import ( - storetypes "cosmossdk.io/store/types" "encoding/json" "log" + storetypes "cosmossdk.io/store/types" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" servertypes "github.com/cosmos/cosmos-sdk/server/types" diff --git a/app/genesis.go b/app/genesis.go index 8d5048f..e923ec6 100644 --- a/app/genesis.go +++ b/app/genesis.go @@ -2,8 +2,6 @@ package app import ( "encoding/json" - - "github.com/cosmos/cosmos-sdk/codec" ) // GenesisState The genesis state of the blockchain is represented here as a map of raw json @@ -15,7 +13,31 @@ import ( // object provided to it during init. type GenesisState map[string]json.RawMessage +var defaultGenesisState GenesisState = nil + +// CloneGenesisState creates a deep clone of the provided GenesisState. +func cloneGenesisState(original GenesisState) GenesisState { + clone := make(GenesisState, len(original)) + for key, value := range original { + // Make a copy of the json.RawMessage (which is a []byte slice). + copiedValue := make(json.RawMessage, len(value)) + copy(copiedValue, value) + if len(copiedValue) == 0 { + // If the value is empty, set it to nil. + copiedValue = nil + } + clone[key] = copiedValue + } + return clone +} + // NewDefaultGenesisState generates the default state for the application. -func NewDefaultGenesisState(cdc codec.JSONCodec) GenesisState { - return ModuleBasics.DefaultGenesis(cdc) +func NewDefaultGenesisState() GenesisState { + if defaultGenesisState != nil { + return cloneGenesisState(defaultGenesisState) + } + encCfg := GetEncodingConfig() + gen := ModuleBasics.DefaultGenesis(encCfg.Marshaler) + defaultGenesisState = cloneGenesisState(gen) + return gen } diff --git a/app/helpers/mock.go b/app/helpers/mock.go index ffbfc82..832a5e5 100644 --- a/app/helpers/mock.go +++ b/app/helpers/mock.go @@ -24,7 +24,7 @@ func NewPV() PV { // GetPubKey implements PrivValidator interface func (pv PV) GetPubKey() (crypto.PubKey, error) { - return cryptocodec.ToTmPubKeyInterface(pv.PrivKey.PubKey()) + return cryptocodec.ToCmtPubKeyInterface(pv.PrivKey.PubKey()) } // SignVote implements PrivValidator interface diff --git a/app/params/proto.go b/app/params/proto.go index 84ff35a..c534be9 100644 --- a/app/params/proto.go +++ b/app/params/proto.go @@ -1,15 +1,33 @@ package params import ( + "cosmossdk.io/x/tx/signing" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/x/auth/tx" + "github.com/cosmos/gogoproto/proto" ) // MakeEncodingConfig creates an EncodingConfig for an amino based test configuration. func MakeEncodingConfig() EncodingConfig { amino := codec.NewLegacyAmino() - interfaceRegistry := types.NewInterfaceRegistry() + // interfaceRegistry := types.NewInterfaceRegistry() + // interfaceRegistry := testutil.CodecOptions{AccAddressPrefix: "streampay", ValAddressPrefix: "streampayvaloper"}.NewInterfaceRegistry() + interfaceRegistry, err := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ + ProtoFiles: proto.HybridResolver, + SigningOptions: signing.Options{ + AddressCodec: address.Bech32Codec{ + Bech32Prefix: Bech32AddressPrefix, + }, + ValidatorAddressCodec: address.Bech32Codec{ + Bech32Prefix: Bech32AddressPrefix + "valoper", + }, + }, + }) + if err != nil { + panic(err) + } marshaler := codec.NewProtoCodec(interfaceRegistry) txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes) diff --git a/app/prefix.go b/app/prefix.go index 10c224e..ad58071 100644 --- a/app/prefix.go +++ b/app/prefix.go @@ -23,3 +23,11 @@ func SetConfig() { config.SetBech32PrefixForConsensusNode(ConsNodeAddressPrefix, ConsNodePubKeyPrefix) config.Seal() } + +// SetAddressPrefixes sets the global prefixes to be used when serializing addresses and public keys to Bech32 strings. +func SetAddressPrefixes() { + config := sdk.GetConfig() + config.SetBech32PrefixForAccount(AccountAddressPrefix, AccountPubKeyPrefix) + config.SetBech32PrefixForValidator(ValidatorAddressPrefix, ValidatorPubKeyPrefix) + config.SetBech32PrefixForConsensusNode(ConsNodeAddressPrefix, ConsNodePubKeyPrefix) +} diff --git a/app/test_helpers.go b/app/test_helpers.go index 5abd6e7..488b8a1 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -1,18 +1,22 @@ package app import ( - sdkmath "cosmossdk.io/math" - "testing" + "encoding/json" + "os" "time" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/testutil/sims" + "cosmossdk.io/log" + sdkmath "cosmossdk.io/math" apphelpers "github.com/OmniFlix/streampay/v2/app/helpers" - appparams "github.com/OmniFlix/streampay/v2/app/params" + abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/crypto" "github.com/cometbft/cometbft/crypto/ed25519" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" tmtypes "github.com/cometbft/cometbft/types" - dbm "github.com/cosmos/cosmos-db" + cosmosdb "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" @@ -20,12 +24,11 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/stretchr/testify/require" ) // SimAppChainID hardcoded chainID for simulation const ( - SimAppChainID = "streampay-app" + SimAppChainID = "streampay-1" ) // EmptyBaseAppOptions is a stub implementing AppOptions @@ -36,8 +39,7 @@ func (ao EmptyBaseAppOptions) Get(_ string) interface{} { return nil } -// DefaultConsensusParams defines the default Tendermint consensus params used -// in streamPayApp testing. +// DefaultConsensusParams defines the default Tendermint consensus params used in StreamPayApp testing. var DefaultConsensusParams = &tmproto.ConsensusParams{ Block: &tmproto.BlockParams{ MaxBytes: 200000, @@ -59,114 +61,37 @@ type EmptyAppOptions struct{} func (EmptyAppOptions) Get(_ string) interface{} { return nil } -func Setup(t *testing.T, _ bool, _ uint) *StreamPayApp { - t.Helper() - +// SetupWithGenesisValSet initializes a new StreamPayApp with a validator set and genesis accounts +// that also act as delegators. For simplicity, each validator is bonded with a delegation +// of one consensus engine unit in the default token of the StreamPayApp from first genesis +// account. A Nop logger is set in StreamPayApp. +func GenesisStateWithValSet(streamPayApp *StreamPayApp) GenesisState { privVal := apphelpers.NewPV() - pubKey, err := privVal.GetPubKey() - require.NoError(t, err) - // create validator set with single validator + pubKey, _ := privVal.GetPubKey() validator := tmtypes.NewValidator(pubKey, 1) valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) // generate genesis account senderPrivKey := secp256k1.GenPrivKey() - 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, sdkmath.NewInt(100000000000000))), - } - - app := SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, balance) - - return app -} - -// SetupWithGenesisValSet initializes a new streamPayApp with a validator set and genesis accounts -// that also act as delegators. For simplicity, each validator is bonded with a delegation -// of one consensus engine unit in the default token of the streamPayApp from first genesis -// account. A Nop logger is set in streamPayApp. -func SetupWithGenesisValSet( - t *testing.T, - valSet *tmtypes.ValidatorSet, - genAccs []authtypes.GenesisAccount, - balances ...banktypes.Balance, -) *StreamPayApp { - t.Helper() - - streamPayApp, genesisState := setup(true, 5) - genesisState = genesisStateWithValSet(t, streamPayApp, genesisState, valSet, genAccs, balances...) - - // 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 -} + senderPrivKey.PubKey().Address() + acc := authtypes.NewBaseAccountWithAddress(senderPrivKey.PubKey().Address().Bytes()) -func setup(withGenesis bool, invCheckPeriod uint) (*StreamPayApp, GenesisState) { - db := dbm.NewMemDB() - encCdc := MakeEncodingConfig() - - app := NewStreamPayApp( - log.NewNopLogger(), - db, - nil, - true, - map[int64]bool{}, - DefaultNodeHome, - invCheckPeriod, - encCdc, - EmptyBaseAppOptions{}, - ) - if withGenesis { - return app, NewDefaultGenesisState(encCdc.Marshaler) - } - - return app, GenesisState{} -} - -func genesisStateWithValSet( - t *testing.T, - app *StreamPayApp, - genesisState GenesisState, - valSet *tmtypes.ValidatorSet, - genAccs []authtypes.GenesisAccount, - balances ...banktypes.Balance, -) GenesisState { - t.Helper() - // set genesis accounts + ////////////////////// + balances := []banktypes.Balance{} + genesisState := NewDefaultGenesisState() + genAccs := []authtypes.GenesisAccount{acc} authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) - genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis) + genesisState[authtypes.ModuleName] = encodingConfig.Marshaler.MustMarshalJSON(authGenesis) validators := make([]stakingtypes.Validator, 0, len(valSet.Validators)) delegations := make([]stakingtypes.Delegation, 0, len(valSet.Validators)) bondAmt := sdk.DefaultPowerReduction + initValPowers := []abci.ValidatorUpdate{} for _, val := range valSet.Validators { - pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey) - require.NoError(t, err) - pkAny, err := codectypes.NewAnyWithValue(pk) - require.NoError(t, err) + pk, _ := cryptocodec.FromCmtPubKeyInterface(val.PubKey) + pkAny, _ := codectypes.NewAnyWithValue(pk) validator := stakingtypes.Validator{ OperatorAddress: sdk.ValAddress(val.Address).String(), ConsensusPubkey: pkAny, @@ -181,23 +106,18 @@ func genesisStateWithValSet( MinSelfDelegation: sdkmath.ZeroInt(), } validators = append(validators, validator) - delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress().String(), val.Address.String(), sdkmath.LegacyOneDec())) - + delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress().String(), sdk.ValAddress(val.Address).String(), sdkmath.LegacyOneDec())) + + // add initial validator powers so consumer InitGenesis runs correctly + pub, _ := val.ToProto() + initValPowers = append(initValPowers, abci.ValidatorUpdate{ + Power: val.VotingPower, + PubKey: pub.PubKey, + }) } // set validators and delegations - defaultStParams := stakingtypes.DefaultParams() - stParams := stakingtypes.NewParams( - defaultStParams.UnbondingTime, - defaultStParams.MaxValidators, - defaultStParams.MaxEntries, - defaultStParams.HistoricalEntries, - appparams.BondDenom, - defaultStParams.MinCommissionRate, - ) - - // set validators and delegations - stakingGenesis := stakingtypes.NewGenesisState(stParams, validators, delegations) - genesisState[stakingtypes.ModuleName] = app.AppCodec().MustMarshalJSON(stakingGenesis) + stakingGenesis := stakingtypes.NewGenesisState(stakingtypes.DefaultParams(), validators, delegations) + genesisState[stakingtypes.ModuleName] = encodingConfig.Marshaler.MustMarshalJSON(stakingGenesis) totalSupply := sdk.NewCoins() for _, b := range balances { @@ -207,13 +127,13 @@ func genesisStateWithValSet( for range delegations { // add delegated tokens to total supply - totalSupply = totalSupply.Add(sdk.NewCoin(appparams.BondDenom, bondAmt)) + totalSupply = totalSupply.Add(sdk.NewCoin(sdk.DefaultBondDenom, bondAmt)) } // add bonded amount to bonded pool module account balances = append(balances, banktypes.Balance{ Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(), - Coins: sdk.Coins{sdk.NewCoin(appparams.BondDenom, bondAmt)}, + Coins: sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, bondAmt)}, }) // update total supply @@ -224,12 +144,109 @@ func genesisStateWithValSet( []banktypes.Metadata{}, []banktypes.SendEnabled{}, ) + genesisState[banktypes.ModuleName] = encodingConfig.Marshaler.MustMarshalJSON(bankGenesis) - genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis) + _, err := tmtypes.PB2TM.ValidatorUpdates(initValPowers) + if err != nil { + panic("failed to get vals") + } return genesisState } +var defaultGenesisStatebytes = []byte{} + +// SetupWithCustomHome initializes a new StreamPayApp with a custom home directory +func SetupWithCustomHome(isCheckTx bool, dir string) *StreamPayApp { + return SetupWithCustomHomeAndChainId(isCheckTx, dir, "streampay-1") +} + +func SetupWithCustomHomeAndChainId(isCheckTx bool, dir, chainId string) *StreamPayApp { + db := cosmosdb.NewMemDB() + app := NewStreamPayApp( + log.NewNopLogger(), + db, + nil, + true, + map[int64]bool{}, + dir, + 0, + encodingConfig, + sims.EmptyAppOptions{}, + baseapp.SetChainID(chainId)) + if !isCheckTx { + if len(defaultGenesisStatebytes) == 0 { + var err error + genesisState := GenesisStateWithValSet(app) + defaultGenesisStatebytes, err = json.Marshal(genesisState) + if err != nil { + panic(err) + } + } + + _, err := app.InitChain( + &abci.RequestInitChain{ + Validators: []abci.ValidatorUpdate{}, + ConsensusParams: sims.DefaultConsensusParams, + AppStateBytes: defaultGenesisStatebytes, + ChainId: chainId, + }, + ) + if err != nil { + panic(err) + } + } + + return app +} + +func Setup(isCheckTx bool) *StreamPayApp { + return SetupWithCustomHome(isCheckTx, DefaultNodeHome) +} + +// SetupTestingAppWithLevelDb initializes a new StreamPayApp intended for testing, +// with LevelDB as a db. +func SetupTestingAppWithLevelDb(isCheckTx bool) (app *StreamPayApp, cleanupFn func()) { + dir, err := os.MkdirTemp(os.TempDir(), "streampay_leveldb_testing") + if err != nil { + panic(err) + } + db, err := cosmosdb.NewGoLevelDB("streampay_leveldb_testing", dir, nil) + if err != nil { + panic(err) + } + app = NewStreamPayApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, encodingConfig, sims.EmptyAppOptions{}, baseapp.SetChainID("streampay-1")) + if !isCheckTx { + genesisState := GenesisStateWithValSet(app) + stateBytes, err := json.MarshalIndent(genesisState, "", " ") + if err != nil { + panic(err) + } + + _, err = app.InitChain( + &abci.RequestInitChain{ + Validators: []abci.ValidatorUpdate{}, + ConsensusParams: sims.DefaultConsensusParams, + AppStateBytes: stateBytes, + ChainId: "streampay-1", + }, + ) + if err != nil { + panic(err) + } + } + + cleanupFn = func() { + db.Close() + err = os.RemoveAll(dir) + if err != nil { + panic(err) + } + } + + return app, cleanupFn +} + func keyPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccAddress) { key := ed25519.GenPrivKey() pub := key.PubKey() diff --git a/cmd/streampayd/cmd/root.go b/cmd/streampayd/cmd/root.go index dedb4f4..3c47c24 100644 --- a/cmd/streampayd/cmd/root.go +++ b/cmd/streampayd/cmd/root.go @@ -5,14 +5,18 @@ import ( "io" "os" - "github.com/cosmos/cosmos-sdk/client/config" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/types/module" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/spf13/viper" "cosmossdk.io/log" "github.com/OmniFlix/streampay/v2/app/params" tmcfg "github.com/cometbft/cometbft/config" tmcli "github.com/cometbft/cometbft/libs/cli" dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/cosmos-sdk/client/config" "github.com/spf13/cast" "github.com/spf13/cobra" @@ -34,8 +38,30 @@ import ( // main function. func NewRootCmd() (*cobra.Command, params.EncodingConfig) { // Set config for prefixes - encodingConfig := app.MakeEncodingConfig() - app.SetConfig() + encodingConfig := app.GetEncodingConfig() + + initAppOptions := viper.New() + tempDir := tempDir() + initAppOptions.Set(flags.FlagHome, tempDir) + + tempApp := app.NewStreamPayApp( + log.NewNopLogger(), + dbm.NewMemDB(), + nil, + true, + nil, + tempDir, + 0, + encodingConfig, + initAppOptions, + nil, + baseapp.SetChainID("streampay-1"), + ) + defer func() { + if err := tempApp.Close(); err != nil { + panic(err) + } + }() initClientCtx := client.Context{}. WithCodec(encodingConfig.Marshaler). @@ -72,7 +98,7 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { }, } - initRootCmd(rootCmd, encodingConfig) + initRootCmd(rootCmd, encodingConfig, tempApp) return rootCmd, encodingConfig } @@ -89,21 +115,27 @@ func initTendermintConfig() *tmcfg.Config { return cfg } -func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { - // To-Do Check in gaia new release - // authclient.Codec = encodingConfig.Marshaler - - cfg := sdk.GetConfig() - cfg.Seal() - - //ac := appCreator{encodingConfig} - +func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, tempApp *app.StreamPayApp) { rootCmd.AddCommand( - genutilcli.InitCmd(app.ModuleBasics, app.DefaultNodeHome), + genutilcli.InitCmd(tempApp.ModuleBasics, app.DefaultNodeHome), + tmcli.NewCompletionCmd(rootCmd, true), + genutilcli.CollectGenTxsCmd( + banktypes.GenesisBalancesIterator{}, + app.DefaultNodeHome, + genutiltypes.DefaultMessageValidator, + encodingConfig.TxConfig.SigningContext().ValidatorAddressCodec(), + ), + genutilcli.MigrateGenesisCmd(genutilcli.MigrationMap), + genutilcli.GenTxCmd( + tempApp.ModuleBasics, + encodingConfig.TxConfig, + banktypes.GenesisBalancesIterator{}, + app.DefaultNodeHome, + encodingConfig.TxConfig.SigningContext().ValidatorAddressCodec(), + ), + genutilcli.ValidateGenesisCmd(tempApp.ModuleBasics), tmcli.NewCompletionCmd(rootCmd, true), addDebugCommands(debug.Cmd()), - //config.Cmd(), - //pruning.PruningCmd(ac.newApp), ) a := appCreator{encodingConfig} @@ -114,7 +146,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { server.StatusCommand(), genesisCommand(encodingConfig), queryCommand(), - txCommand(), + txCommand(tempApp.ModuleBasics), keys.Commands(), ) } @@ -155,7 +187,7 @@ func queryCommand() *cobra.Command { return cmd } -func txCommand() *cobra.Command { +func txCommand(moduleBasics module.BasicManager) *cobra.Command { cmd := &cobra.Command{ Use: "tx", Short: "Transactions subcommands", @@ -176,7 +208,7 @@ func txCommand() *cobra.Command { flags.LineBreak, ) - app.ModuleBasics.AddTxCommands(cmd) + moduleBasics.AddTxCommands(cmd) cmd.PersistentFlags().String(flags.FlagChainID, "", "The network chain ID") return cmd @@ -260,3 +292,13 @@ func (a appCreator) appExport( return anApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) } + +func tempDir() string { + dir, err := os.MkdirTemp("", "streampaytemp") + if err != nil { + dir = app.DefaultNodeHome + } + defer os.RemoveAll(dir) + + return dir +} diff --git a/cmd/streampayd/main.go b/cmd/streampayd/main.go index 1fcc7a4..5a7e5c4 100644 --- a/cmd/streampayd/main.go +++ b/cmd/streampayd/main.go @@ -9,6 +9,7 @@ import ( ) func main() { + app.SetConfig() rootCmd, _ := cmd.NewRootCmd() if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil { os.Exit(1) diff --git a/go.mod b/go.mod index 7c9e1c3..8456885 100644 --- a/go.mod +++ b/go.mod @@ -1,31 +1,39 @@ module github.com/OmniFlix/streampay/v2 -go 1.21 +go 1.22.2 + +toolchain go1.22.5 require ( + cosmossdk.io/api v0.7.5 + cosmossdk.io/core v0.11.1 cosmossdk.io/errors v1.0.1 + cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.0 cosmossdk.io/x/evidence v0.1.0 cosmossdk.io/x/feegrant v0.1.0 + cosmossdk.io/x/tx v0.13.4 cosmossdk.io/x/upgrade v0.1.0 - github.com/cometbft/cometbft v0.38.7 - github.com/cometbft/cometbft-db v0.9.1 + github.com/cometbft/cometbft v0.38.10 + github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.50.6 - github.com/cosmos/gogoproto v1.4.12 + github.com/cosmos/cosmos-sdk v0.50.9 + github.com/cosmos/gogoproto v1.5.0 github.com/cosmos/ibc-go/modules/capability v1.0.0 - github.com/cosmos/ibc-go/v8 v8.3.1 + github.com/cosmos/ibc-go/v8 v8.4.0 + github.com/cosmos/rosetta v0.50.9 github.com/golang/protobuf v1.5.4 github.com/gorilla/mux v1.8.1 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/spf13/cast v1.6.0 github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 + github.com/spf13/viper v1.18.2 github.com/stretchr/testify v1.9.0 - google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de - google.golang.org/grpc v1.63.2 - google.golang.org/protobuf v1.33.0 + google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 + google.golang.org/grpc v1.64.1 + google.golang.org/protobuf v1.34.2 ) require ( @@ -34,17 +42,15 @@ require ( cloud.google.com/go/compute/metadata v0.2.3 // indirect cloud.google.com/go/iam v1.1.6 // indirect cloud.google.com/go/storage v1.36.0 // indirect - cosmossdk.io/api v0.7.4 // indirect cosmossdk.io/collections v0.4.0 // indirect - cosmossdk.io/core v0.11.0 // indirect - cosmossdk.io/depinject v1.0.0-alpha.4 // indirect - cosmossdk.io/log v1.3.1 // indirect - cosmossdk.io/x/tx v0.13.2 // indirect + cosmossdk.io/depinject v1.0.0 // indirect filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect github.com/DataDog/datadog-go v3.2.0+incompatible // indirect github.com/DataDog/zstd v1.5.5 // indirect + github.com/PuerkitoBio/purell v1.1.1 // indirect + github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/aws/aws-sdk-go v1.44.224 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect @@ -61,13 +67,15 @@ require ( github.com/cockroachdb/pebble v1.1.0 // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect + github.com/coinbase/rosetta-sdk-go/types v1.0.0 // indirect + github.com/cometbft/cometbft-db v0.9.1 // indirect github.com/cosmos/btcutil v1.0.5 // indirect - github.com/cosmos/cosmos-db v1.0.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v1.1.2 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect + github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect github.com/danieljoos/wincred v1.1.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect @@ -104,6 +112,7 @@ require ( github.com/googleapis/gax-go/v2 v2.12.0 // indirect github.com/gorilla/handlers v1.5.2 // indirect github.com/gorilla/websocket v1.5.0 // indirect + github.com/goware/urlx v0.3.2 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect @@ -115,6 +124,7 @@ require ( github.com/hashicorp/go-safetemp v1.0.0 // indirect github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect + github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/hdevalence/ed25519consensus v0.1.0 // indirect @@ -128,7 +138,6 @@ require ( github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/lib/pq v1.10.7 // indirect - github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/linxGnu/grocksdb v1.8.14 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/manifoldco/promptui v0.9.0 // indirect @@ -158,7 +167,6 @@ require ( github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect - github.com/spf13/viper v1.18.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect @@ -174,19 +182,19 @@ require ( go.opentelemetry.io/otel/metric v1.22.0 // indirect go.opentelemetry.io/otel/trace v1.22.0 // indirect go.uber.org/multierr v1.10.0 // indirect - golang.org/x/crypto v0.22.0 // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect - golang.org/x/net v0.24.0 // indirect + golang.org/x/net v0.27.0 // indirect golang.org/x/oauth2 v0.18.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.19.0 // indirect - golang.org/x/term v0.19.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/sys v0.22.0 // indirect + golang.org/x/term v0.22.0 // indirect + golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/api v0.162.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.1 // indirect diff --git a/go.sum b/go.sum index b37a1b4..a1d6bfe 100644 --- a/go.sum +++ b/go.sum @@ -392,16 +392,16 @@ cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1V cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= cloud.google.com/go/workflows v1.8.0/go.mod h1:ysGhmEajwZxGn1OhGOGKsTXc5PyxOc0vfKf5Af+to4M= cloud.google.com/go/workflows v1.9.0/go.mod h1:ZGkj1aFIOd9c8Gerkjjq7OW7I5+l6cSvT3ujaO/WwSA= -cosmossdk.io/api v0.7.4 h1:sPo8wKwCty1lht8kgL3J7YL1voJywP3YWuA5JKkBz30= -cosmossdk.io/api v0.7.4/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= +cosmossdk.io/api v0.7.5 h1:eMPTReoNmGUm8DeiQL9DyM8sYDjEhWzL1+nLbI9DqtQ= +cosmossdk.io/api v0.7.5/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= cosmossdk.io/client/v2 v2.0.0-beta.1 h1:XkHh1lhrLYIT9zKl7cIOXUXg2hdhtjTPBUfqERNA1/Q= cosmossdk.io/client/v2 v2.0.0-beta.1/go.mod h1:JEUSu9moNZQ4kU3ir1DKD5eU4bllmAexrGWjmb9k8qU= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= -cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo= -cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= +cosmossdk.io/core v0.11.1 h1:h9WfBey7NAiFfIcUhDVNS503I2P2HdZLebJlUIs8LPA= +cosmossdk.io/core v0.11.1/go.mod h1:OJzxcdC+RPrgGF8NJZR2uoQr56tc7gfBKhiKeDO7hH0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= @@ -416,8 +416,8 @@ cosmossdk.io/x/evidence v0.1.0 h1:J6OEyDl1rbykksdGynzPKG5R/zm6TacwW2fbLTW4nCk= cosmossdk.io/x/evidence v0.1.0/go.mod h1:hTaiiXsoiJ3InMz1uptgF0BnGqROllAN8mwisOMMsfw= cosmossdk.io/x/feegrant v0.1.0 h1:c7s3oAq/8/UO0EiN1H5BIjwVntujVTkYs35YPvvrdQk= cosmossdk.io/x/feegrant v0.1.0/go.mod h1:4r+FsViJRpcZif/yhTn+E0E6OFfg4n0Lx+6cCtnZElU= -cosmossdk.io/x/tx v0.13.2 h1:Kh90UH30bhnnUdJH+CmWLyaH8IKdY6BBGY3EkdOk82o= -cosmossdk.io/x/tx v0.13.2/go.mod h1:yhPokDCfXVIuAtyp49IFlWB5YAXUgD7Zek+ZHwsHzvU= +cosmossdk.io/x/tx v0.13.4 h1:Eg0PbJgeO0gM8p5wx6xa0fKR7hIV6+8lC56UrsvSo0Y= +cosmossdk.io/x/tx v0.13.4/go.mod h1:BkFqrnGGgW50Y6cwTy+JvgAhiffbGEKW6KF9ufcDpvk= cosmossdk.io/x/upgrade v0.1.0 h1:z1ZZG4UL9ICTNbJDYZ6jOnF9GdEK9wyoEFi4BUScHXE= cosmossdk.io/x/upgrade v0.1.0/go.mod h1:/6jjNGbiPCNtmA1N+rBtP601sr0g4ZXuj3yC6ClPCGY= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= @@ -440,6 +440,10 @@ github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEV github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= +github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= @@ -543,8 +547,10 @@ github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZ github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/cometbft/cometbft v0.38.7 h1:ULhIOJ9+LgSy6nLekhq9ae3juX3NnQUMMPyVdhZV6Hk= -github.com/cometbft/cometbft v0.38.7/go.mod h1:HIyf811dFMI73IE0F7RrnY/Fr+d1+HuJAgtkEpQjCMY= +github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA= +github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c= +github.com/cometbft/cometbft v0.38.10 h1:2ePuglchT+j0Iao+cfmt/nw5U7K2lnGDzXSUPGVdXaU= +github.com/cometbft/cometbft v0.38.10/go.mod h1:jHPx9vQpWzPHEAiYI/7EDKaB1NXhK6o3SArrrY8ExKc= github.com/cometbft/cometbft-db v0.9.1 h1:MIhVX5ja5bXNHF8EYrThkG9F7r9kSfv8BX4LWaxWJ4M= github.com/cometbft/cometbft-db v0.9.1/go.mod h1:iliyWaoV0mRwBJoizElCwwRA9Tf7jZJOURcRZF9m60U= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= @@ -561,27 +567,31 @@ github.com/cosmos/cosmos-db v1.0.2 h1:hwMjozuY1OlJs/uh6vddqnk9j7VamLv+0DBlbEXbAK github.com/cosmos/cosmos-db v1.0.2/go.mod h1:Z8IXcFJ9PqKK6BIsVOB3QXtkKoqUOp1vRvPT39kOXEA= github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= -github.com/cosmos/cosmos-sdk v0.50.6 h1:efR3MsvMHX5sxS3be+hOobGk87IzlZbSpsI2x/Vw3hk= -github.com/cosmos/cosmos-sdk v0.50.6/go.mod h1:lVkRY6cdMJ0fG3gp8y4hFrsKZqF4z7y0M2UXFb9Yt40= +github.com/cosmos/cosmos-sdk v0.50.9 h1:gt2usjz0H0qW6KwAxWw7ZJ3XU8uDwmhN+hYG3nTLeSg= +github.com/cosmos/cosmos-sdk v0.50.9/go.mod h1:TMH6wpoYBcg7Cp5BEg8fneLr+8XloNQkf2MRNF9V6JE= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ4GUkT+tbFI= github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= -github.com/cosmos/gogoproto v1.4.12 h1:vB6Lbe/rtnYGjQuFxkPiPYiCybqFT8QvLipDZP8JpFE= -github.com/cosmos/gogoproto v1.4.12/go.mod h1:LnZob1bXRdUoqMMtwYlcR3wjiElmlC+FkjaZRv1/eLY= +github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= +github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= github.com/cosmos/iavl v1.1.2 h1:zL9FK7C4L/P4IF1Dm5fIwz0WXCnn7Bp1M2FxH0ayM7Y= github.com/cosmos/iavl v1.1.2/go.mod h1:jLeUvm6bGT1YutCaL2fIar/8vGUE8cPZvh/gXEWDaDM= github.com/cosmos/ibc-go/modules/capability v1.0.0 h1:r/l++byFtn7jHYa09zlAdSeevo8ci1mVZNO9+V0xsLE= github.com/cosmos/ibc-go/modules/capability v1.0.0/go.mod h1:D81ZxzjZAe0ZO5ambnvn1qedsFQ8lOwtqicG6liLBco= -github.com/cosmos/ibc-go/v8 v8.3.1 h1:cUNWvTCftKQIcpbf2y/jVzo2OY3g4GVFw6tTC/pQ+tA= -github.com/cosmos/ibc-go/v8 v8.3.1/go.mod h1:izwHZvn9lKrBn8xWj0aXWut6HKcwHMPD3uyuvOJoPSA= +github.com/cosmos/ibc-go/v8 v8.4.0 h1:K2PfX0AZ+1XKZytHGEMuSjQXG/MZshPb83RSTQt2+cE= +github.com/cosmos/ibc-go/v8 v8.4.0/go.mod h1:zh6x1osR0hNvEcFrC/lhGD08sMfQmr9wHVvZ/mRWMCs= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= github.com/cosmos/keyring v1.2.0/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= +github.com/cosmos/rosetta v0.50.9 h1:mV09lIDlEnbe8D1yuldY5GBjqk0ggkAbjbRQOrpoOIs= +github.com/cosmos/rosetta v0.50.9/go.mod h1:EYloh7qKmHpqiOB133k2WS6jqZsf3RIPLrVpFz48ZZU= +github.com/cosmos/rosetta-sdk-go v0.10.0 h1:E5RhTruuoA7KTIXUcMicL76cffyeoyvNybzUGSKFTcM= +github.com/cosmos/rosetta-sdk-go v0.10.0/go.mod h1:SImAZkb96YbwvoRkzSMQB6noNJXFgWl/ENIznEoYQI4= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -837,6 +847,8 @@ github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/goware/urlx v0.3.2 h1:gdoo4kBHlkqZNaf6XlQ12LGtQOmpKJrR04Rc3RnpJEo= +github.com/goware/urlx v0.3.2/go.mod h1:h8uwbJy68o+tQXCGZNa9D73WN8n0r9OBae5bUnLcgjw= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= @@ -887,6 +899,8 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= +github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= @@ -965,8 +979,6 @@ github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= -github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/linxGnu/grocksdb v1.8.14 h1:HTgyYalNwBSG/1qCQUIott44wU5b2Y9Kr3z7SK5OfGQ= @@ -1311,8 +1323,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1422,8 +1434,8 @@ golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1574,8 +1586,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1584,8 +1596,8 @@ golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= -golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= +golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1601,8 +1613,8 @@ golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1674,8 +1686,8 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= -golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1868,10 +1880,10 @@ google.golang.org/genproto v0.0.0-20221202195650-67e5cbc046fd/go.mod h1:cTsE614G google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= -google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de h1:jFNzHPIeuzhdRwVhbZdiym9q0ory/xY3sA+v2wPg8I0= -google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:5iCWqnniDlqZHrd3neWVTOwvh/v6s3232omMecelax8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4= +google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237/go.mod h1:Z5Iiy3jtmioajWHDGFk7CeugTyHtPvMHA4UTmUkyalE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 h1:SbSDUWW1PAO24TNpLdeheoYPd7kllICcLU52x6eD4kQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag= google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -1891,8 +1903,8 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/x/streampay/keeper/alias.go b/x/streampay/keeper/alias.go index 5cda364..221d61d 100644 --- a/x/streampay/keeper/alias.go +++ b/x/streampay/keeper/alias.go @@ -3,11 +3,10 @@ package keeper import ( "github.com/OmniFlix/streampay/v2/x/streampay/types" sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) // GetPaymentStreamModuleAccount returns PaymentStream ModuleAccount -func (k Keeper) GetPaymentStreamModuleAccount(ctx sdk.Context) authtypes.ModuleAccountI { +func (k Keeper) GetPaymentStreamModuleAccount(ctx sdk.Context) sdk.ModuleAccountI { return k.accountKeeper.GetModuleAccount(ctx, types.ModuleName) } diff --git a/x/streampay/keeper/keeper.go b/x/streampay/keeper/keeper.go index c856163..57b9e01 100644 --- a/x/streampay/keeper/keeper.go +++ b/x/streampay/keeper/keeper.go @@ -1,10 +1,11 @@ package keeper import ( - sdkmath "cosmossdk.io/math" "fmt" "time" + sdkmath "cosmossdk.io/math" + errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" diff --git a/x/streampay/keeper/keeper_test.go b/x/streampay/keeper/keeper_test.go index 4b96cb5..fdf4ad7 100644 --- a/x/streampay/keeper/keeper_test.go +++ b/x/streampay/keeper/keeper_test.go @@ -1,9 +1,10 @@ package keeper_test import ( - sdkmath "cosmossdk.io/math" "testing" + sdkmath "cosmossdk.io/math" + "github.com/OmniFlix/streampay/v2/app/apptesting" "github.com/OmniFlix/streampay/v2/x/streampay/keeper" "github.com/OmniFlix/streampay/v2/x/streampay/types" @@ -38,7 +39,7 @@ func (suite *KeeperTestSuite) SetupTest() { } func (suite *KeeperTestSuite) CreateDefaultStreamPayment(cancellable bool) { - ctx := sdk.WrapSDKContext(suite.Ctx) + ctx := suite.Ctx res, _ := suite.msgServer.StreamSend(ctx, &types.MsgStreamSend{ Sender: suite.TestAccs[0].String(), Recipient: suite.TestAccs[1].String(), @@ -53,7 +54,7 @@ func (suite *KeeperTestSuite) CreateDefaultStreamPayment(cancellable bool) { } func (suite *KeeperTestSuite) CreateStreamPayment(streamType types.StreamType, cancellable bool) string { - ctx := sdk.WrapSDKContext(suite.Ctx) + ctx := suite.Ctx res, _ := suite.msgServer.StreamSend(ctx, &types.MsgStreamSend{ Sender: suite.TestAccs[0].String(), Recipient: suite.TestAccs[1].String(), diff --git a/x/streampay/keeper/msg_server.go b/x/streampay/keeper/msg_server.go index 5b13e63..87bf08e 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" diff --git a/x/streampay/keeper/msg_server_test.go b/x/streampay/keeper/msg_server_test.go index bb4643c..d28c188 100644 --- a/x/streampay/keeper/msg_server_test.go +++ b/x/streampay/keeper/msg_server_test.go @@ -1,9 +1,10 @@ package keeper_test import ( - sdkmath "cosmossdk.io/math" "time" + sdkmath "cosmossdk.io/math" + "github.com/OmniFlix/streampay/v2/x/streampay/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -218,7 +219,7 @@ func (suite *KeeperTestSuite) TestStreamSendMsg() { err := msg.ValidateBasic() if err == nil { _, err = suite.msgServer.StreamSend( - sdk.WrapSDKContext(ctx), + ctx, msg, ) } @@ -265,7 +266,7 @@ func (suite *KeeperTestSuite) TestStopStreamMsg() { suite.Require().Equal(0, len(ctx.EventManager().Events())) // Test stream send message _, err := suite.msgServer.StopStream( - sdk.WrapSDKContext(ctx), + ctx, types.NewMsgStopStream( tc.streamId, tc.sender, @@ -307,7 +308,7 @@ func (suite *KeeperTestSuite) TestClaimStreamedAmountMsg() { suite.Require().Equal(0, len(ctx.EventManager().Events())) // Test stream send message _, err := suite.msgServer.ClaimStreamedAmount( - sdk.WrapSDKContext(ctx), + ctx, types.NewMsgClaimStreamedAmount( tc.streamId, tc.recipient, diff --git a/x/streampay/keeper/stream_payment.go b/x/streampay/keeper/stream_payment.go index 3724375..69be192 100644 --- a/x/streampay/keeper/stream_payment.go +++ b/x/streampay/keeper/stream_payment.go @@ -1,10 +1,11 @@ package keeper import ( - storetypes "cosmossdk.io/store/types" "encoding/binary" "math" + storetypes "cosmossdk.io/store/types" + "github.com/OmniFlix/streampay/v2/x/streampay/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/gogoproto/proto" diff --git a/x/streampay/module.go b/x/streampay/module.go index e041761..6ca8c44 100644 --- a/x/streampay/module.go +++ b/x/streampay/module.go @@ -2,10 +2,11 @@ package streampay import ( "context" - "cosmossdk.io/core/appmodule" "encoding/json" "fmt" + "cosmossdk.io/core/appmodule" + "github.com/OmniFlix/streampay/v2/x/streampay/client/cli" "github.com/OmniFlix/streampay/v2/x/streampay/keeper" "github.com/OmniFlix/streampay/v2/x/streampay/types" diff --git a/x/streampay/types/codec.go b/x/streampay/types/codec.go index 1ed474a..8176bf5 100644 --- a/x/streampay/types/codec.go +++ b/x/streampay/types/codec.go @@ -5,7 +5,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) @@ -45,19 +44,3 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } - -var ( - amino = codec.NewLegacyAmino() - ModuleCdc = codec.NewAminoCodec(amino) -) - -func init() { - RegisterLegacyAminoCodec(amino) - cryptocodec.RegisterCrypto(amino) - - // 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) - //RegisterLegacyAminoCodec(govcodec) -} diff --git a/x/streampay/types/expected_keepers.go b/x/streampay/types/expected_keepers.go index 4a5e6ea..3cd00ed 100644 --- a/x/streampay/types/expected_keepers.go +++ b/x/streampay/types/expected_keepers.go @@ -2,6 +2,7 @@ package types import ( "context" + sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/streampay/types/genesis_test.go b/x/streampay/types/genesis_test.go index 0cdc9da..333896b 100644 --- a/x/streampay/types/genesis_test.go +++ b/x/streampay/types/genesis_test.go @@ -1,9 +1,10 @@ package types_test import ( - sdkmath "cosmossdk.io/math" "testing" + sdkmath "cosmossdk.io/math" + "github.com/OmniFlix/streampay/v2/x/streampay/types" "github.com/cometbft/cometbft/crypto/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/streampay/types/messages.go b/x/streampay/types/messages.go index 685b521..d11f00c 100644 --- a/x/streampay/types/messages.go +++ b/x/streampay/types/messages.go @@ -72,11 +72,6 @@ func (msg MsgStreamSend) ValidateBasic() error { return validateStreamType(msg.StreamType) } -// GetSignBytes Implements Msg. -func (msg *MsgStreamSend) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) -} - // GetSigners Implements Msg. func (msg MsgStreamSend) GetSigners() []sdk.AccAddress { from, err := sdk.AccAddressFromBech32(msg.Sender) @@ -105,11 +100,6 @@ func (msg MsgStopStream) ValidateBasic() error { return nil } -// GetSignBytes Implements Msg. -func (msg *MsgStopStream) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) -} - // GetSigners Implements Msg. func (msg MsgStopStream) GetSigners() []sdk.AccAddress { from, err := sdk.AccAddressFromBech32(msg.Sender) @@ -138,11 +128,6 @@ func (msg MsgClaimStreamedAmount) ValidateBasic() error { return nil } -// GetSignBytes Implements Msg. -func (msg *MsgClaimStreamedAmount) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg)) -} - // GetSigners Implements Msg. func (msg MsgClaimStreamedAmount) GetSigners() []sdk.AccAddress { from, err := sdk.AccAddressFromBech32(msg.Claimer) @@ -152,13 +137,6 @@ func (msg MsgClaimStreamedAmount) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{from} } -// MsgUpdateParams - -// GetSignBytes implements the LegacyMsg interface. -func (m MsgUpdateParams) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - // GetSigners returns the expected signers for a MsgUpdateParams message. func (m *MsgUpdateParams) GetSigners() []sdk.AccAddress { addr, _ := sdk.AccAddressFromBech32(m.Authority) diff --git a/x/streampay/types/params.go b/x/streampay/types/params.go index 6b9e47c..2a3e21b 100644 --- a/x/streampay/types/params.go +++ b/x/streampay/types/params.go @@ -1,9 +1,10 @@ package types import ( - sdkmath "cosmossdk.io/math" "fmt" + sdkmath "cosmossdk.io/math" + errorsmod "cosmossdk.io/errors" ) diff --git a/x/streampay/types/params_test.go b/x/streampay/types/params_test.go index c44dca8..d14ff65 100644 --- a/x/streampay/types/params_test.go +++ b/x/streampay/types/params_test.go @@ -1,9 +1,10 @@ package types import ( - sdkmath "cosmossdk.io/math" "testing" + sdkmath "cosmossdk.io/math" + "github.com/stretchr/testify/require" ) diff --git a/x/streampay/types/validation.go b/x/streampay/types/validation.go index 5aee0a6..1c49415 100644 --- a/x/streampay/types/validation.go +++ b/x/streampay/types/validation.go @@ -1,10 +1,11 @@ package types import ( - sdkmath "cosmossdk.io/math" "fmt" "time" + sdkmath "cosmossdk.io/math" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" )