diff --git a/app/app.go b/app/app.go index 21fa6198..5018d2f0 100644 --- a/app/app.go +++ b/app/app.go @@ -899,6 +899,13 @@ func (app *App) registerUpgradeHandlers() { return app.mm.RunMigrations(ctx, app.configurator, fromVM) }) + app.UpgradeKeeper.SetUpgradeHandler("v1.6.1", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + app.Logger().Info("Starting v1.6.1 upgrade") + + app.Logger().Info("v1.6.1 upgrade applied") + return app.mm.RunMigrations(ctx, app.configurator, fromVM) + }) + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() if err != nil { panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) @@ -985,4 +992,9 @@ func (app *App) registerUpgradeHandlers() { storeUpgrades := storetypes.StoreUpgrades{} app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) } + + if upgradeInfo.Name == "v1.6.1" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + storeUpgrades := storetypes.StoreUpgrades{} + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) + } } diff --git a/proto/lum/network/millions/deposit.proto b/proto/lum/network/millions/deposit.proto index 599aa7a7..f8d9380c 100644 --- a/proto/lum/network/millions/deposit.proto +++ b/proto/lum/network/millions/deposit.proto @@ -22,6 +22,16 @@ enum DepositState { DEPOSIT_STATE_FAILURE = 4 [ (gogoproto.enumvalue_customname) = "Failure" ]; } +enum DepositOrigin { + option (gogoproto.goproto_enum_prefix) = true; + + DEPOSIT_ORIGIN_UNSPECIFIED = 0 + [ (gogoproto.enumvalue_customname) = "Unspecified" ]; + DEPOSIT_ORIGIN_DIRECT = 1 [ (gogoproto.enumvalue_customname) = "Direct" ]; + DEPOSIT_ORIGIN_AUTOCOMPOUND = 2 + [ (gogoproto.enumvalue_customname) = "Autocompound" ]; +} + message Deposit { uint64 pool_id = 1; uint64 deposit_id = 2; @@ -35,7 +45,7 @@ message Deposit { string winner_address = 7 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; bool is_sponsor = 8; - reserved 9; + DepositOrigin origin = 9; int64 created_at_height = 10; int64 updated_at_height = 11; diff --git a/proto/lum/network/millions/tx.proto b/proto/lum/network/millions/tx.proto index b69c1b0a..501260de 100644 --- a/proto/lum/network/millions/tx.proto +++ b/proto/lum/network/millions/tx.proto @@ -127,6 +127,8 @@ message MsgClaimPrize { uint64 draw_id = 2; uint64 prize_id = 3; string winner_address = 4 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + bool is_auto_compound = 5; + bool is_sponsor = 6; } message MsgClaimPrizeResponse {} diff --git a/x/millions/client/cli/tx.go b/x/millions/client/cli/tx.go index 6608222d..f3aa7712 100644 --- a/x/millions/client/cli/tx.go +++ b/x/millions/client/cli/tx.go @@ -238,14 +238,20 @@ $ %s tx %s deposit-edit --winner_address=
--spon func CmdTxClaimPrize() *cobra.Command { cmd := &cobra.Command{ - Use: "claim-prize ", + Use: "claim-prize [autocompound] [sponsor]", Short: "Claim a millions prize", Long: strings.TrimSpace( fmt.Sprintf(`Claim a millions prize to send the funds to the prize winner address. Example: -$ %s tx %s claim-prize `, - version.AppName, types.ModuleName), +$ %s tx %s claim-prize + +To claim a prize and auto compound it (create a new deposit with the prize amount) +$ %s tx %s claim-prize --autocompound=true + +To claim a prize and create a sponsorship from the auto compound deposit (no drawing chances at all) +$ %s tx %s claim-prize --autocompound=true --sponsor=true`, + version.AppName, types.ModuleName, version.AppName, types.ModuleName, version.AppName, types.ModuleName), ), Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { @@ -275,13 +281,27 @@ $ %s tx %s claim-prize `, return err } + isAutoCompound, err := cmd.Flags().GetBool("autocompound") + if err != nil { + return err + } + + isSponsor, err := cmd.Flags().GetBool("sponsor") + if err != nil { + return err + } + // Build the message msg := types.NewMsgMsgClaimPrize(clientCtx.GetFromAddress().String(), poolID, drawID, prizeID) + msg.IsAutoCompound = isAutoCompound + msg.IsSponsor = isSponsor // Generate the transaction return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) }, } + cmd.Flags().Bool("autocompound", false, "(optional) creates a new auto compound deposit with the prize amount") + cmd.Flags().Bool("sponsor", false, "(optional) active sponsor mode for the new auto compound deposit") flags.AddTxFlagsToCmd(cmd) _ = cmd.MarkFlagRequired(flags.FlagFrom) return cmd diff --git a/x/millions/genesis_test.go b/x/millions/genesis_test.go index 6b2ae5bd..9dab1a46 100644 --- a/x/millions/genesis_test.go +++ b/x/millions/genesis_test.go @@ -78,17 +78,17 @@ var testGenesis = millionstypes.GenesisState{ }, }, Deposits: []millionstypes.Deposit{ - {PoolId: 1, DepositId: 1, DepositorAddress: testAccs[0], WinnerAddress: testAccs[0], Amount: sdk.NewCoin("denom-1", sdk.NewInt(100)), State: millionstypes.DepositState_IbcTransfer}, - {PoolId: 1, DepositId: 2, DepositorAddress: testAccs[0], WinnerAddress: testAccs[0], Amount: sdk.NewCoin("denom-1", sdk.NewInt(101)), State: millionstypes.DepositState_IcaDelegate}, - {PoolId: 1, DepositId: 3, DepositorAddress: testAccs[1], WinnerAddress: testAccs[1], Amount: sdk.NewCoin("denom-1", sdk.NewInt(102)), State: millionstypes.DepositState_Success}, - {PoolId: 1, DepositId: 4, DepositorAddress: testAccs[1], WinnerAddress: testAccs[1], Amount: sdk.NewCoin("denom-1", sdk.NewInt(103)), State: millionstypes.DepositState_Failure}, - {PoolId: 1, DepositId: 5, DepositorAddress: testAccs[2], WinnerAddress: testAccs[2], Amount: sdk.NewCoin("denom-1", sdk.NewInt(104)), State: millionstypes.DepositState_IbcTransfer}, - {PoolId: 2, DepositId: 6, DepositorAddress: testAccs[2], WinnerAddress: testAccs[2], Amount: sdk.NewCoin("denom-2", sdk.NewInt(200)), IsSponsor: true, State: millionstypes.DepositState_IbcTransfer}, - {PoolId: 2, DepositId: 7, DepositorAddress: testAccs[3], WinnerAddress: testAccs[3], Amount: sdk.NewCoin("denom-2", sdk.NewInt(201)), IsSponsor: true, State: millionstypes.DepositState_IbcTransfer}, - {PoolId: 2, DepositId: 8, DepositorAddress: testAccs[3], WinnerAddress: testAccs[3], Amount: sdk.NewCoin("denom-2", sdk.NewInt(202)), State: millionstypes.DepositState_IbcTransfer}, - {PoolId: 3, DepositId: 9, DepositorAddress: testAccs[4], WinnerAddress: testAccs[4], Amount: sdk.NewCoin("denom-3", sdk.NewInt(300)), State: millionstypes.DepositState_Success}, - {PoolId: 3, DepositId: 10, DepositorAddress: testAccs[4], WinnerAddress: testAccs[4], Amount: sdk.NewCoin("denom-3", sdk.NewInt(301)), State: millionstypes.DepositState_Success}, - {PoolId: 4, DepositId: 11, DepositorAddress: testAccs[5], WinnerAddress: testAccs[5], Amount: sdk.NewCoin("denom-4", sdk.NewInt(400)), State: millionstypes.DepositState_Success}, + {PoolId: 1, DepositId: 1, DepositorAddress: testAccs[0], WinnerAddress: testAccs[0], Amount: sdk.NewCoin("denom-1", sdk.NewInt(100)), State: millionstypes.DepositState_IbcTransfer, Origin: millionstypes.DepositOrigin_Direct}, + {PoolId: 1, DepositId: 2, DepositorAddress: testAccs[0], WinnerAddress: testAccs[0], Amount: sdk.NewCoin("denom-1", sdk.NewInt(101)), State: millionstypes.DepositState_IcaDelegate, Origin: millionstypes.DepositOrigin_Autocompound}, + {PoolId: 1, DepositId: 3, DepositorAddress: testAccs[1], WinnerAddress: testAccs[1], Amount: sdk.NewCoin("denom-1", sdk.NewInt(102)), State: millionstypes.DepositState_Success, Origin: millionstypes.DepositOrigin_Direct}, + {PoolId: 1, DepositId: 4, DepositorAddress: testAccs[1], WinnerAddress: testAccs[1], Amount: sdk.NewCoin("denom-1", sdk.NewInt(103)), State: millionstypes.DepositState_Failure, Origin: millionstypes.DepositOrigin_Direct}, + {PoolId: 1, DepositId: 5, DepositorAddress: testAccs[2], WinnerAddress: testAccs[2], Amount: sdk.NewCoin("denom-1", sdk.NewInt(104)), State: millionstypes.DepositState_IbcTransfer, Origin: millionstypes.DepositOrigin_Direct}, + {PoolId: 2, DepositId: 6, DepositorAddress: testAccs[2], WinnerAddress: testAccs[2], Amount: sdk.NewCoin("denom-2", sdk.NewInt(200)), IsSponsor: true, State: millionstypes.DepositState_IbcTransfer, Origin: millionstypes.DepositOrigin_Direct}, + {PoolId: 2, DepositId: 7, DepositorAddress: testAccs[3], WinnerAddress: testAccs[3], Amount: sdk.NewCoin("denom-2", sdk.NewInt(201)), IsSponsor: true, State: millionstypes.DepositState_IbcTransfer, Origin: millionstypes.DepositOrigin_Direct}, + {PoolId: 2, DepositId: 8, DepositorAddress: testAccs[3], WinnerAddress: testAccs[3], Amount: sdk.NewCoin("denom-2", sdk.NewInt(202)), State: millionstypes.DepositState_IbcTransfer, Origin: millionstypes.DepositOrigin_Direct}, + {PoolId: 3, DepositId: 9, DepositorAddress: testAccs[4], WinnerAddress: testAccs[4], Amount: sdk.NewCoin("denom-3", sdk.NewInt(300)), State: millionstypes.DepositState_Success, Origin: millionstypes.DepositOrigin_Direct}, + {PoolId: 3, DepositId: 10, DepositorAddress: testAccs[4], WinnerAddress: testAccs[4], Amount: sdk.NewCoin("denom-3", sdk.NewInt(301)), State: millionstypes.DepositState_Success, Origin: millionstypes.DepositOrigin_Direct}, + {PoolId: 4, DepositId: 11, DepositorAddress: testAccs[5], WinnerAddress: testAccs[5], Amount: sdk.NewCoin("denom-4", sdk.NewInt(400)), State: millionstypes.DepositState_Success, Origin: millionstypes.DepositOrigin_Autocompound}, }, Draws: []millionstypes.Draw{ {PoolId: 1, DrawId: 1, RandSeed: 10, TotalWinCount: 100, TotalWinAmount: sdk.NewInt(1000)}, diff --git a/x/millions/keeper/keeper_deposit.go b/x/millions/keeper/keeper_deposit.go index f705496c..28adc51e 100644 --- a/x/millions/keeper/keeper_deposit.go +++ b/x/millions/keeper/keeper_deposit.go @@ -2,6 +2,8 @@ package keeper import ( "fmt" + "strconv" + "strings" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -213,6 +215,101 @@ func (k Keeper) AddDeposit(ctx sdk.Context, deposit *types.Deposit) { k.updatePool(ctx, &pool) } +// CreateDeposit creates a deposit from the transaction message +// Holds the internal validation logic +func (k Keeper) CreateDeposit(ctx sdk.Context, msg *types.MsgDeposit, depositOrigin types.DepositOrigin) (*types.Deposit, error) { + // Get the pool to validate id and denom + pool, err := k.GetPool(ctx, msg.GetPoolId()) + if err != nil { + return nil, types.ErrPoolNotFound + } + + if pool.State != types.PoolState_Ready && pool.State != types.PoolState_Paused { + return nil, errorsmod.Wrapf( + types.ErrInvalidPoolState, "cannot deposit in pool during state %s", pool.State.String(), + ) + } + + depositorAddr, err := sdk.AccAddressFromBech32(msg.GetDepositorAddress()) + if err != nil { + return nil, types.ErrInvalidDepositorAddress + } + + if msg.Amount.Denom != pool.Denom { + return nil, types.ErrInvalidDepositDenom + } + + // Make sure the deposit is sufficient for direct deposits + if depositOrigin == types.DepositOrigin_Direct { + if msg.GetAmount().Amount.LT(pool.MinDepositAmount) { + return nil, types.ErrInsufficientDepositAmount + } + } + + winnerAddress := depositorAddr + if strings.TrimSpace(msg.GetWinnerAddress()) != "" { + winnerAddress, err = sdk.AccAddressFromBech32(msg.GetWinnerAddress()) + if err != nil { + return nil, types.ErrInvalidWinnerAddress + } + } + + if !depositorAddr.Equals(winnerAddress) && msg.GetIsSponsor() { + return nil, types.ErrInvalidSponsorWinnerCombo + } + + // New deposit instance + deposit := types.Deposit{ + PoolId: pool.PoolId, + State: types.DepositState_IbcTransfer, + DepositorAddress: depositorAddr.String(), + Amount: msg.Amount, + WinnerAddress: winnerAddress.String(), + IsSponsor: msg.GetIsSponsor(), + Origin: depositOrigin, + CreatedAtHeight: ctx.BlockHeight(), + UpdatedAtHeight: ctx.BlockHeight(), + CreatedAt: ctx.BlockTime(), + UpdatedAt: ctx.BlockTime(), + } + + // Move funds + poolRunner, err := k.GetPoolRunner(pool.PoolType) + if err != nil { + return nil, errorsmod.Wrapf(types.ErrInvalidPoolType, err.Error()) + } + if err := poolRunner.SendDepositToPool(ctx, pool, deposit); err != nil { + return nil, err + } + + // Store deposit + k.AddDeposit(ctx, &deposit) + + if err := k.TransferDepositToRemoteZone(ctx, deposit.GetPoolId(), deposit.GetDepositId()); err != nil { + return nil, err + } + + // Emit event + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + ), + sdk.NewEvent( + types.EventTypeDeposit, + sdk.NewAttribute(types.AttributeKeyPoolID, strconv.FormatUint(deposit.DepositId, 10)), + sdk.NewAttribute(types.AttributeKeyDepositID, strconv.FormatUint(deposit.DepositId, 10)), + sdk.NewAttribute(types.AttributeKeyDepositor, deposit.GetDepositorAddress()), + sdk.NewAttribute(types.AttributeKeyWinner, deposit.GetWinnerAddress()), + sdk.NewAttribute(sdk.AttributeKeyAmount, deposit.Amount.String()), + sdk.NewAttribute(types.AttributeKeySponsor, strconv.FormatBool(deposit.IsSponsor)), + sdk.NewAttribute(types.AttributeKeyOrigin, deposit.Origin.String()), + ), + }) + + return &deposit, nil +} + // RemoveDeposit removes a deposit from a pool // - removes it from the {pool_id, deposit_id} // - removes it from the {address, pool_id, deposit_id} deposits @@ -329,6 +426,25 @@ func (k Keeper) hasPoolDeposit(ctx sdk.Context, address string, poolID uint64) b return iterator.Valid() } +// UnsafeUpdateAutoCompoundDeposits raw updates deposit's origin +// It's heavily unsafe and should only be used by store migrations +func (k Keeper) UnsafeUpdateAutoCompoundDeposits(ctx sdk.Context, poolID uint64, depositID uint64, depositOrigin types.DepositOrigin) (types.Deposit, error) { + // Acquire the deposit + deposit, err := k.GetPoolDeposit(ctx, poolID, depositID) + if err != nil { + return types.Deposit{}, err + } + + deposit.Origin = depositOrigin + deposit.UpdatedAtHeight = ctx.BlockHeight() + deposit.UpdatedAt = ctx.BlockTime() + + k.setPoolDeposit(ctx, &deposit) + k.setAccountDeposit(ctx, &deposit) + + return deposit, nil +} + // ListPoolDeposits returns all deposits for a given poolID // Warning: expensive operation func (k Keeper) ListPoolDeposits(ctx sdk.Context, poolID uint64) (deposits []types.Deposit) { diff --git a/x/millions/keeper/keeper_deposit_test.go b/x/millions/keeper/keeper_deposit_test.go index 28eed3d9..821b2a32 100644 --- a/x/millions/keeper/keeper_deposit_test.go +++ b/x/millions/keeper/keeper_deposit_test.go @@ -31,6 +31,7 @@ func (suite *KeeperTestSuite) TestDeposit_IDsGeneration() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) // Test that depositID is incremented suite.Require().Equal(uint64(i+1), depositID) @@ -43,6 +44,7 @@ func (suite *KeeperTestSuite) TestDeposit_IDsGeneration() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) } suite.Require().Panics(panicF) @@ -103,6 +105,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -122,6 +125,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: suite.addrs[1].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) } suite.Require().NotPanics(panicF) @@ -134,6 +138,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) } suite.Require().Panics(panicF) @@ -152,6 +157,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Unspecified, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) } suite.Require().Panics(panicF) @@ -164,6 +170,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) } suite.Require().Panics(panicF) @@ -176,6 +183,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: "", State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) } suite.Require().Panics(panicF) @@ -190,6 +198,7 @@ func (suite *KeeperTestSuite) TestDeposit_AddDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) } suite.Require().Panics(panicF) @@ -298,6 +307,7 @@ func (suite *KeeperTestSuite) TestDeposit_RemoveDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -312,6 +322,7 @@ func (suite *KeeperTestSuite) TestDeposit_RemoveDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) } suite.Require().NotPanics(panicF) @@ -482,6 +493,7 @@ func (suite *KeeperTestSuite) TestDeposit_UpdateDepositStatus() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -580,6 +592,7 @@ func (suite *KeeperTestSuite) TestDeposit_EditDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -669,6 +682,7 @@ func (suite *KeeperTestSuite) TestDeposit_TransferDeposit() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin("uatom", sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(pools[0].Denom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -748,6 +762,7 @@ func (suite *KeeperTestSuite) TestDeposit_TransferDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(pools[1].Denom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -822,6 +837,7 @@ func (suite *KeeperTestSuite) TestDeposit_DelegateDeposit() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_IcaDelegate, Amount: sdk.NewCoin("uatom", sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(pools[0].Denom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -897,6 +913,7 @@ func (suite *KeeperTestSuite) TestDeposit_DelegateDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IcaDelegate, Amount: sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(pools[1].Denom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -982,6 +999,7 @@ func (suite *KeeperTestSuite) TestDeposit_BalanceDeposit() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin("uatom", sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(pools[0].Denom, sdk.NewInt(1_000_000))}) @@ -1012,7 +1030,6 @@ func (suite *KeeperTestSuite) TestDeposit_BalanceDeposit() { suite.Require().NoError(err) // For remote pools we don't reach the success as k.BroadcastICAMessages fails on OnDelegateDepositOnRemoteZoneCompleted - // Balance should remain unchanged balance = app.BankKeeper.GetBalance(ctx, uatomAddresses[0], "uatom") suite.Require().Equal(balanceBefore.Amount.Int64()-1_000_000, balance.Amount.Int64()) @@ -1069,6 +1086,7 @@ func (suite *KeeperTestSuite) TestDeposit_BalanceDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(2_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(pools[1].Denom, sdk.NewInt(2_000_000))}) suite.Require().NoError(err) @@ -1189,6 +1207,7 @@ func (suite *KeeperTestSuite) TestDeposit_FullDepositProcess() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(denom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[0].IcaDepositAddress), sdk.Coins{sdk.NewCoin(pools[0].Denom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) diff --git a/x/millions/keeper/keeper_epoch_test.go b/x/millions/keeper/keeper_epoch_test.go index fafa80e8..96cbb07e 100644 --- a/x/millions/keeper/keeper_epoch_test.go +++ b/x/millions/keeper/keeper_epoch_test.go @@ -65,6 +65,7 @@ func (suite *KeeperTestSuite) TestEpoch_BeforeEpochStartHook() { WinnerAddress: suite.addrs[i].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_0)), + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -204,6 +205,7 @@ func (suite *KeeperTestSuite) TestEpoch_AddEpochUnbonding() { WinnerAddress: suite.addrs[i].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_0)), + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -257,6 +259,7 @@ func (suite *KeeperTestSuite) TestEpoch_AddEpochUnbonding() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_0)), + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -342,6 +345,7 @@ func (suite *KeeperTestSuite) TestEpoch_AddWithdrawalsToNextAvailableEpoch() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000)), + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -421,6 +425,7 @@ func (suite *KeeperTestSuite) TestEpoch_AddWithdrawalsToNextAvailableEpoch() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000)), + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -510,6 +515,7 @@ func (suite *KeeperTestSuite) TestEpoch_AddFailedIcaUndelegationsToEpochUnbondin WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000)), + Origin: millionstypes.DepositOrigin_Direct, }) } deposits := app.MillionsKeeper.ListDeposits(ctx) @@ -605,6 +611,7 @@ func (suite *KeeperTestSuite) TestEpoch_RemoveEpochUnbonding() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000)), + Origin: millionstypes.DepositOrigin_Direct, }) } deposits := app.MillionsKeeper.ListDeposits(ctx) diff --git a/x/millions/keeper/keeper_pool_test.go b/x/millions/keeper/keeper_pool_test.go index c40b3ad1..0ce8734d 100644 --- a/x/millions/keeper/keeper_pool_test.go +++ b/x/millions/keeper/keeper_pool_test.go @@ -812,6 +812,7 @@ func (suite *KeeperTestSuite) TestPool_ValidatorsSplitConsistency() { DepositorAddress: suite.addrs[0].String(), WinnerAddress: suite.addrs[0].String(), Amount: sdk.NewCoin("uatom", sdk.NewInt(111)), + Origin: millionstypes.DepositOrigin_Direct, } app.MillionsKeeper.AddDeposit(ctx, &d1) d2 := millionstypes.Deposit{ @@ -821,6 +822,7 @@ func (suite *KeeperTestSuite) TestPool_ValidatorsSplitConsistency() { DepositorAddress: suite.addrs[1].String(), WinnerAddress: suite.addrs[1].String(), Amount: sdk.NewCoin("uatom", sdk.NewInt(222)), + Origin: millionstypes.DepositOrigin_Direct, } app.MillionsKeeper.AddDeposit(ctx, &d2) d3 := millionstypes.Deposit{ @@ -830,6 +832,7 @@ func (suite *KeeperTestSuite) TestPool_ValidatorsSplitConsistency() { DepositorAddress: suite.addrs[2].String(), WinnerAddress: suite.addrs[2].String(), Amount: sdk.NewCoin("uatom", sdk.NewInt(333)), + Origin: millionstypes.DepositOrigin_Direct, } app.MillionsKeeper.AddDeposit(ctx, &d3) @@ -1164,6 +1167,7 @@ func (suite *KeeperTestSuite) TestPool_UpdatePool() { Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(5_000_000)), DepositorAddress: suite.addrs[0].String(), WinnerAddress: suite.addrs[0].String(), + Origin: millionstypes.DepositOrigin_Direct, }) pool, err = app.MillionsKeeper.GetPool(ctx, 2) suite.Require().NoError(err) diff --git a/x/millions/keeper/keeper_withdrawal_test.go b/x/millions/keeper/keeper_withdrawal_test.go index 3ac31fc9..a34b689f 100644 --- a/x/millions/keeper/keeper_withdrawal_test.go +++ b/x/millions/keeper/keeper_withdrawal_test.go @@ -111,6 +111,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_AddWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -141,6 +142,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_AddWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) } @@ -169,6 +171,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_AddWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) withdrawals = app.MillionsKeeper.ListWithdrawals(ctx) suite.Require().Len(withdrawals, 5) @@ -584,6 +587,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_UndelegateWithdrawals() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_IcaDelegate, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000))}) @@ -622,6 +626,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_UndelegateWithdrawals() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) withdrawals = app.MillionsKeeper.ListWithdrawals(ctx) @@ -709,6 +714,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_UndelegateWithdrawals() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -746,6 +752,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_UndelegateWithdrawals() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) // There should be ne more deposits deposits = app.MillionsKeeper.ListAccountDeposits(ctx, suite.addrs[0]) @@ -832,6 +839,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_TransferWithdrawal() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -863,6 +871,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_TransferWithdrawal() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) deposits = app.MillionsKeeper.ListAccountDeposits(ctx, uatomAddresses[0]) @@ -930,6 +939,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_TransferWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -960,6 +970,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_TransferWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) // There should be no more deposits @@ -1029,6 +1040,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_BankSend() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -1060,6 +1072,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_BankSend() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) deposits = app.MillionsKeeper.ListAccountDeposits(ctx, uatomAddresses[0]) @@ -1144,6 +1157,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_ProcessWithdrawal() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[0].LocalAddress), sdk.Coins{sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -1175,6 +1189,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_ProcessWithdrawal() { WinnerAddress: uatomAddresses[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) deposits = app.MillionsKeeper.ListAccountDeposits(ctx, uatomAddresses[0]) @@ -1229,6 +1244,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_ProcessWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -1259,6 +1275,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_ProcessWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) // There should be no more deposits @@ -1386,6 +1403,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_BalanceWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) // Send coin err := app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pool.IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) @@ -1404,6 +1422,7 @@ func (suite *KeeperTestSuite) TestWithdrawal_BalanceWithdrawal() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pool.IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) diff --git a/x/millions/keeper/msg_server_deposit.go b/x/millions/keeper/msg_server_deposit.go index 67e80c5a..1e7c19ea 100644 --- a/x/millions/keeper/msg_server_deposit.go +++ b/x/millions/keeper/msg_server_deposit.go @@ -15,90 +15,12 @@ import ( func (k msgServer) Deposit(goCtx context.Context, msg *types.MsgDeposit) (*types.MsgDepositResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // Get the pool to validate id and denom - pool, err := k.GetPool(ctx, msg.GetPoolId()) + // Check internal validation before creating a deposit + deposit, err := k.CreateDeposit(ctx, msg, types.DepositOrigin_Direct) if err != nil { - return nil, types.ErrPoolNotFound - } - - if pool.State != types.PoolState_Ready && pool.State != types.PoolState_Paused { - return nil, errorsmod.Wrapf( - types.ErrInvalidPoolState, "cannot deposit in pool during state %s", pool.State.String(), - ) - } - - depositorAddr, err := sdk.AccAddressFromBech32(msg.GetDepositorAddress()) - if err != nil { - return nil, types.ErrInvalidDepositorAddress - } - - if msg.Amount.Denom != pool.Denom { - return nil, types.ErrInvalidDepositDenom - } - - // Make sure the deposit is sufficient - if msg.GetAmount().Amount.LT(pool.MinDepositAmount) { - return nil, types.ErrInsufficientDepositAmount - } - - winnerAddress := depositorAddr - if strings.TrimSpace(msg.GetWinnerAddress()) != "" { - winnerAddress, err = sdk.AccAddressFromBech32(msg.GetWinnerAddress()) - if err != nil { - return nil, types.ErrInvalidWinnerAddress - } - } - - if !depositorAddr.Equals(winnerAddress) && msg.GetIsSponsor() { - return nil, types.ErrInvalidSponsorWinnerCombo - } - - // New deposit instance - deposit := types.Deposit{ - PoolId: pool.PoolId, - State: types.DepositState_IbcTransfer, - DepositorAddress: depositorAddr.String(), - Amount: msg.Amount, - WinnerAddress: winnerAddress.String(), - IsSponsor: msg.GetIsSponsor(), - CreatedAtHeight: ctx.BlockHeight(), - UpdatedAtHeight: ctx.BlockHeight(), - CreatedAt: ctx.BlockTime(), - UpdatedAt: ctx.BlockTime(), - } - - // Move funds - poolRunner, err := k.GetPoolRunner(pool.PoolType) - if err != nil { - return nil, errorsmod.Wrapf(types.ErrInvalidPoolType, err.Error()) - } - if err := poolRunner.SendDepositToPool(ctx, pool, deposit); err != nil { return nil, err } - // Store deposit - k.AddDeposit(ctx, &deposit) - - // Emit event - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - ), - sdk.NewEvent( - types.EventTypeDeposit, - sdk.NewAttribute(types.AttributeKeyPoolID, strconv.FormatUint(deposit.PoolId, 10)), - sdk.NewAttribute(types.AttributeKeyDepositID, strconv.FormatUint(deposit.DepositId, 10)), - sdk.NewAttribute(types.AttributeKeyDepositor, deposit.DepositorAddress), - sdk.NewAttribute(types.AttributeKeyWinner, deposit.WinnerAddress), - sdk.NewAttribute(sdk.AttributeKeyAmount, deposit.Amount.String()), - sdk.NewAttribute(types.AttributeKeySponsor, strconv.FormatBool(msg.IsSponsor)), - ), - }) - - if err := k.TransferDepositToRemoteZone(ctx, deposit.GetPoolId(), deposit.GetDepositId()); err != nil { - return nil, err - } return &types.MsgDepositResponse{DepositId: deposit.DepositId}, nil } diff --git a/x/millions/keeper/msg_server_prize.go b/x/millions/keeper/msg_server_prize.go index 3d7ba3b6..4ba2725f 100644 --- a/x/millions/keeper/msg_server_prize.go +++ b/x/millions/keeper/msg_server_prize.go @@ -39,7 +39,7 @@ func (k msgServer) ClaimPrize(goCtx context.Context, msg *types.MsgClaimPrize) ( return nil, types.ErrPoolNotFound } - // Move funds + // Move funds to winner address if err := k.BankKeeper.SendCoins( ctx, sdk.MustAccAddressFromBech32(pool.GetLocalAddress()), @@ -53,6 +53,22 @@ func (k msgServer) ClaimPrize(goCtx context.Context, msg *types.MsgClaimPrize) ( return nil, err } + if msg.IsAutoCompound { + // Construct the deposit msg + msg := types.MsgDeposit{ + PoolId: pool.PoolId, + Amount: prize.Amount, + DepositorAddress: winnerAddr.String(), + WinnerAddress: winnerAddr.String(), + IsSponsor: msg.GetIsSponsor(), + } + + // Check internal validation before creating a deposit + if _, err := k.CreateDeposit(ctx, &msg, types.DepositOrigin_Autocompound); err != nil { + return nil, err + } + } + // Emit event ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( @@ -66,6 +82,7 @@ func (k msgServer) ClaimPrize(goCtx context.Context, msg *types.MsgClaimPrize) ( sdk.NewAttribute(types.AttributeKeyPrizeID, strconv.FormatUint(prize.PrizeId, 10)), sdk.NewAttribute(types.AttributeKeyWinner, prize.WinnerAddress), sdk.NewAttribute(sdk.AttributeKeyAmount, prize.Amount.String()), + sdk.NewAttribute(types.AttributeKeyAutoCompound, strconv.FormatBool(msg.IsAutoCompound)), ), }) diff --git a/x/millions/keeper/msg_server_test.go b/x/millions/keeper/msg_server_test.go index f04c644c..8d8e4cde 100644 --- a/x/millions/keeper/msg_server_test.go +++ b/x/millions/keeper/msg_server_test.go @@ -481,6 +481,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DepositRetry() { State: millionstypes.DepositState_Failure, ErrorState: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[0].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -540,6 +541,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DepositRetry() { State: millionstypes.DepositState_Failure, ErrorState: millionstypes.DepositState_IcaDelegate, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[1].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -563,6 +565,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DepositRetry() { State: millionstypes.DepositState_Failure, ErrorState: millionstypes.DepositState_Unspecified, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], suite.moduleAddrs[0], sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -611,6 +614,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DepositEdit() { State: millionstypes.DepositState_Success, ErrorState: millionstypes.DepositState_Unspecified, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[0].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -829,6 +833,7 @@ func (suite *KeeperTestSuite) TestMsgServer_WithdrawDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) deposits := app.MillionsKeeper.ListAccountDeposits(ctx, suite.addrs[0]) err = app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pools[0].IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) @@ -844,6 +849,7 @@ func (suite *KeeperTestSuite) TestMsgServer_WithdrawDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Failure, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) // List deposits deposits := app.MillionsKeeper.ListAccountDeposits(ctx, suite.addrs[0]) @@ -974,6 +980,7 @@ func (suite *KeeperTestSuite) TestMsgServer_WithdrawDeposit() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_Success, Amount: sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) deposits = app.MillionsKeeper.ListAccountDeposits(ctx, suite.addrs[0]) err = app.BankKeeper.SendCoins(ctx, uatomAddresses[0], sdk.MustAccAddressFromBech32(pools[2].LocalAddress), sdk.Coins{sdk.NewCoin(remotePoolDenom, sdk.NewInt(1_000_000))}) @@ -1051,6 +1058,7 @@ func (suite *KeeperTestSuite) TestMsgServer_WithdrawDepositRetry() { WinnerAddress: suite.addrs[0].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + Origin: millionstypes.DepositOrigin_Direct, }) err := app.BankKeeper.SendCoins(ctx, suite.addrs[0], sdk.MustAccAddressFromBech32(pool.IcaDepositAddress), sdk.Coins{sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000))}) suite.Require().NoError(err) @@ -1186,6 +1194,20 @@ func (suite *KeeperTestSuite) TestMsgServer_ClaimPrize() { }) app.MillionsKeeper.AddPool(ctx, pool) + _, err := app.MillionsKeeper.GetPool(ctx, poolID) + suite.Require().NoError(err) + + // Add a deposit + app.MillionsKeeper.AddDeposit(ctx, &millionstypes.Deposit{ + PoolId: poolID, + DepositorAddress: suite.addrs[0].String(), + WinnerAddress: suite.addrs[0].String(), + State: millionstypes.DepositState_Failure, + ErrorState: millionstypes.DepositState_IbcTransfer, + Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(500_000)), + Origin: millionstypes.DepositOrigin_Direct, + }) + // Create prizes at various stages app.MillionsKeeper.AddPrize(ctx, millionstypes.Prize{ PoolId: poolID, @@ -1249,27 +1271,120 @@ func (suite *KeeperTestSuite) TestMsgServer_ClaimPrize() { suite.Require().Error(err) suite.Require().ErrorIs(err, millionstypes.ErrPrizeNotFound) + // Test claim autocompound without sponsorship + prizes = app.MillionsKeeper.ListPrizes(ctx) + addr := sdk.MustAccAddressFromBech32(prizes[0].WinnerAddress) + // Get the module balance before claimPrize + moduleBalanceBefore := app.BankKeeper.GetBalance(ctx, modAddr, pool.Denom) + suite.Require().Equal(sdk.NewCoin(localPoolDenom, sdk.NewInt(6_000_000)), moduleBalanceBefore) + // Get the balance before claimPrize + accountBalanceBefore := app.BankKeeper.GetBalance(ctx, addr, pool.Denom) + // Check pool tvl + p1, err := app.MillionsKeeper.GetPool(ctx, poolID) + suite.Require().NoError(err) + suite.Require().Equal(sdk.NewInt(500_000), p1.TvlAmount) + suite.Require().Equal(sdk.NewInt(0), p1.SponsorshipAmount) + // claimPrize + _, err = msgServer.ClaimPrize(goCtx, &millionstypes.MsgClaimPrize{ + PoolId: prizes[0].PoolId, + DrawId: prizes[0].DrawId, + PrizeId: prizes[0].PrizeId, + WinnerAddress: addr.String(), + IsAutoCompound: true, + }) + suite.Require().NoError(err) + // Account balance should have not moved (as directly re-deposited) + accountBalance := app.BankKeeper.GetBalance(ctx, addr, pool.Denom) + suite.Require().True(accountBalanceBefore.Equal(accountBalance)) + // The new moduleBalance should be less 1_000_000 which is the prize amount + expectedModuleBalance := moduleBalanceBefore.Sub(prizes[0].Amount) + moduleBalance := app.BankKeeper.GetBalance(ctx, modAddr, pool.Denom) + suite.Require().True(expectedModuleBalance.Equal(moduleBalance)) + // There should be 2 prizes left prizes = app.MillionsKeeper.ListPrizes(ctx) + suite.Require().Len(prizes, 2) + // There should be a new deposit + deposits := app.MillionsKeeper.ListDeposits(ctx) + suite.Require().Len(deposits, 2) + suite.Require().Equal(millionstypes.DepositOrigin_Autocompound, deposits[1].Origin) + suite.Require().Equal(millionstypes.DepositState_Success, deposits[1].State) + suite.Require().Equal(millionstypes.DepositState_Unspecified, deposits[1].ErrorState) + // Pool tvl should have increased by 1_000_000 + p1, err = app.MillionsKeeper.GetPool(ctx, poolID) + suite.Require().NoError(err) + suite.Require().Equal(sdk.NewInt(1_500_000), p1.TvlAmount) + suite.Require().Equal(sdk.NewInt(0), p1.SponsorshipAmount) - for _, prize := range prizes { - addr := sdk.MustAccAddressFromBech32(prize.WinnerAddress) - // Get the module balance before claimPrize - moduleBalanceBefore := app.BankKeeper.GetBalance(ctx, modAddr, pool.Denom) - // Get the balance before claimPrize - balanceBefore := app.BankKeeper.GetBalance(ctx, addr, pool.Denom) - // claimPrize - _, err = msgServer.ClaimPrize(goCtx, millionstypes.NewMsgMsgClaimPrize(addr.String(), prize.PoolId, prize.DrawId, prize.PrizeId)) - suite.Require().NoError(err) - // Compare the new balance with the expected balance - balance := app.BankKeeper.GetBalance(ctx, addr, pool.Denom) - expectedBalance := balanceBefore.Add(prize.Amount) - suite.Require().True(expectedBalance.Equal(balance)) - // Compare the new module balance with the expected module balance - expectedModuleBalance := moduleBalanceBefore.Sub(prize.Amount) - moduleBalance := app.BankKeeper.GetBalance(ctx, modAddr, pool.Denom) - suite.Require().True(expectedModuleBalance.Equal(moduleBalance)) - } - // There should be no more prizes + // Test claim autocompound with sponsorship + prizes = app.MillionsKeeper.ListPrizes(ctx) + addr = sdk.MustAccAddressFromBech32(prizes[0].WinnerAddress) + // Get the module balance before claimPrize + moduleBalanceBefore = app.BankKeeper.GetBalance(ctx, modAddr, pool.Denom) + suite.Require().Equal(sdk.NewCoin(localPoolDenom, sdk.NewInt(5_000_000)), moduleBalanceBefore) + // Get the balance before claimPrize + accountBalanceBefore = app.BankKeeper.GetBalance(ctx, addr, pool.Denom) + // Check pool tvl + p1, err = app.MillionsKeeper.GetPool(ctx, poolID) + suite.Require().NoError(err) + suite.Require().Equal(sdk.NewInt(1_500_000), p1.TvlAmount) + suite.Require().Equal(sdk.NewInt(0), p1.SponsorshipAmount) + // claimPrize + _, err = msgServer.ClaimPrize(goCtx, &millionstypes.MsgClaimPrize{ + PoolId: prizes[0].PoolId, + DrawId: prizes[0].DrawId, + PrizeId: prizes[0].PrizeId, + WinnerAddress: addr.String(), + IsAutoCompound: true, + IsSponsor: true, + }) + suite.Require().NoError(err) + // Account balance should have not moved (as directly re-deposited) + accountBalance = app.BankKeeper.GetBalance(ctx, addr, pool.Denom) + suite.Require().True(accountBalanceBefore.Equal(accountBalance)) + // The new moduleBalance should be less 2_000_000 which is the prize amount + expectedModuleBalance = moduleBalanceBefore.Sub(prizes[0].Amount) + moduleBalance = app.BankKeeper.GetBalance(ctx, modAddr, pool.Denom) + suite.Require().True(expectedModuleBalance.Equal(moduleBalance)) + // There should be 1 prizes left + prizes = app.MillionsKeeper.ListPrizes(ctx) + suite.Require().Len(prizes, 1) + // There should be a new deposit + deposits = app.MillionsKeeper.ListDeposits(ctx) + suite.Require().Len(deposits, 3) + suite.Require().Equal(millionstypes.DepositOrigin_Autocompound, deposits[2].Origin) + suite.Require().Equal(millionstypes.DepositState_Success, deposits[2].State) + suite.Require().Equal(millionstypes.DepositState_Unspecified, deposits[2].ErrorState) + // Pool tvl should have increased by 2_000_000 + p1, err = app.MillionsKeeper.GetPool(ctx, poolID) + suite.Require().NoError(err) + suite.Require().Equal(sdk.NewInt(3_500_000), p1.TvlAmount) + suite.Require().Equal(sdk.NewInt(2_000_000), p1.SponsorshipAmount) + + // Test last prize as normal claim + prizes = app.MillionsKeeper.ListPrizes(ctx) + suite.Require().Len(prizes, 1) + addr = sdk.MustAccAddressFromBech32(prizes[0].WinnerAddress) + // Get the module balance before claimPrize + moduleBalanceBefore = app.BankKeeper.GetBalance(ctx, modAddr, pool.Denom) + // Get the balance before claimPrize + accountBalanceBefore = app.BankKeeper.GetBalance(ctx, addr, pool.Denom) + // claimPrize + _, err = msgServer.ClaimPrize(goCtx, &millionstypes.MsgClaimPrize{ + PoolId: prizes[0].PoolId, + DrawId: prizes[0].DrawId, + PrizeId: prizes[0].PrizeId, + WinnerAddress: addr.String(), + }) + suite.Require().NoError(err) + // Account balance should have increased by the prize amount as it's a simple claim + balance := app.BankKeeper.GetBalance(ctx, addr, pool.Denom) + expectedBalance := accountBalanceBefore.Add(prizes[0].Amount) + suite.Require().True(expectedBalance.Equal(balance)) + // The new moduleBalance should be less 3_000_000 which is the prize amount + expectedModuleBalance = moduleBalanceBefore.Sub(prizes[0].Amount) + moduleBalance = app.BankKeeper.GetBalance(ctx, modAddr, pool.Denom) + suite.Require().True(expectedModuleBalance.Equal(moduleBalance)) + // There should be no prize left prizes = app.MillionsKeeper.ListPrizes(ctx) suite.Require().Len(prizes, 0) } diff --git a/x/millions/migrations/migrator.go b/x/millions/migrations/migrator.go index 603a614c..fcf996a2 100644 --- a/x/millions/migrations/migrator.go +++ b/x/millions/migrations/migrator.go @@ -7,6 +7,7 @@ import ( v150 "github.com/lum-network/chain/x/millions/migrations/v150" v152 "github.com/lum-network/chain/x/millions/migrations/v152" v160 "github.com/lum-network/chain/x/millions/migrations/v160" + v161 "github.com/lum-network/chain/x/millions/migrations/v161" ) type Migrator struct { @@ -31,3 +32,8 @@ func (m Migrator) Migrate2To3(ctx sdk.Context) error { func (m Migrator) Migrate3To4(ctx sdk.Context) error { return v160.MigratePoolTypeAndUnbondingFrequency(ctx, m.keeper) } + +// Migrate4To5 migrates from version 4 to 5 +func (m Migrator) Migrate4To5(ctx sdk.Context) error { + return v161.MigrateAutoCompoundDeposits(ctx, m.keeper) +} diff --git a/x/millions/migrations/v152/store_test.go b/x/millions/migrations/v152/store_test.go index 783425be..5cd332e2 100644 --- a/x/millions/migrations/v152/store_test.go +++ b/x/millions/migrations/v152/store_test.go @@ -169,6 +169,7 @@ func (suite *StoreMigrationTestSuite) TestMigrateUndelegations() { WinnerAddress: suite.addrs[i].String(), State: millionstypes.DepositState_IbcTransfer, Amount: sdk.NewCoin("ulum", sdk.NewInt(1_000_0)), + Origin: millionstypes.DepositOrigin_Direct, }) } diff --git a/x/millions/migrations/v161/store.go b/x/millions/migrations/v161/store.go new file mode 100644 index 00000000..14d3ffe6 --- /dev/null +++ b/x/millions/migrations/v161/store.go @@ -0,0 +1,26 @@ +package v161 + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + millionskeeper "github.com/lum-network/chain/x/millions/keeper" + millionstypes "github.com/lum-network/chain/x/millions/types" +) + +func MigrateAutoCompoundDeposits(ctx sdk.Context, k millionskeeper.Keeper) error { + ctx.Logger().Info("Processing autocompound deposits") + + deposits := k.ListDeposits(ctx) + updatedEntityCount := 0 + for _, d := range deposits { + if _, err := k.UnsafeUpdateAutoCompoundDeposits(ctx, d.PoolId, d.DepositId, millionstypes.DepositOrigin_Direct); err != nil { + panic(err) + } + updatedEntityCount++ + } + + ctx.Logger().Info(fmt.Sprintf("Successfully updated %d deposits with %s state", updatedEntityCount, millionstypes.DepositOrigin_Direct.String())) + return nil +} diff --git a/x/millions/migrations/v161/store_test.go b/x/millions/migrations/v161/store_test.go new file mode 100644 index 00000000..c2d3c2dc --- /dev/null +++ b/x/millions/migrations/v161/store_test.go @@ -0,0 +1,189 @@ +package v161_test + +import ( + "testing" + "time" + + icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" + + apptesting "github.com/lum-network/chain/app/testing" + + "github.com/stretchr/testify/suite" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + apptypes "github.com/lum-network/chain/app" + v161 "github.com/lum-network/chain/x/millions/migrations/v161" + millionstypes "github.com/lum-network/chain/x/millions/types" +) + +type StoreMigrationTestSuite struct { + suite.Suite + + ctx sdk.Context + app *apptypes.App + addrs []sdk.AccAddress + moduleAddrs []sdk.AccAddress + valAddrs []sdk.ValAddress +} + +// newValidPool fills up missing params to the pool to make it valid in order to ease testing +func newValidPool(suite *StoreMigrationTestSuite, pool millionstypes.Pool) *millionstypes.Pool { + params := suite.app.MillionsKeeper.GetParams(suite.ctx) + + if pool.Denom == "" { + pool.Denom = suite.app.StakingKeeper.BondDenom(suite.ctx) + } + if pool.NativeDenom == "" { + pool.NativeDenom = suite.app.StakingKeeper.BondDenom(suite.ctx) + } + if pool.ChainId == "" { + pool.ChainId = "lum-network-devnet" + } + + if pool.PoolType == millionstypes.PoolType_Unspecified { + pool.PoolType = millionstypes.PoolType_Staking + } + + if pool.UnbondingDuration == 0 { + pool.UnbondingDuration = millionstypes.DefaultUnbondingDuration + } + if pool.MaxUnbondingEntries.IsNil() { + pool.MaxUnbondingEntries = sdk.NewInt(millionstypes.DefaultMaxUnbondingEntries) + } + + if pool.Validators == nil { + for _, addr := range suite.valAddrs { + pool.Validators = append(pool.Validators, millionstypes.PoolValidator{ + OperatorAddress: addr.String(), + BondedAmount: sdk.ZeroInt(), + IsEnabled: true, + }) + } + } + if pool.Bech32PrefixAccAddr == "" { + pool.Bech32PrefixAccAddr = sdk.GetConfig().GetBech32AccountAddrPrefix() + } + if pool.Bech32PrefixValAddr == "" { + pool.Bech32PrefixValAddr = sdk.GetConfig().GetBech32ValidatorAddrPrefix() + } + if pool.MinDepositAmount.IsNil() { + pool.MinDepositAmount = params.MinDepositAmount + } + if err := pool.DrawSchedule.ValidateBasic(params); err != nil { + pool.DrawSchedule = millionstypes.DrawSchedule{DrawDelta: 1 * time.Hour, InitialDrawAt: time.Now().UTC()} + } + if err := pool.PrizeStrategy.Validate(params); err != nil { + pool.PrizeStrategy = millionstypes.PrizeStrategy{PrizeBatches: []millionstypes.PrizeBatch{{PoolPercent: 100, Quantity: 1, DrawProbability: sdk.NewDec(1)}}} + } + if pool.LocalAddress == "" { + pool.LocalAddress = suite.moduleAddrs[0].String() + } + if pool.IcaDepositAddress == "" { + pool.IcaDepositAddress = suite.moduleAddrs[1].String() + } + if pool.IcaPrizepoolAddress == "" { + pool.IcaPrizepoolAddress = suite.moduleAddrs[2].String() + } + if pool.NextDrawId == millionstypes.UnknownID { + pool.NextDrawId = millionstypes.UnknownID + 1 + } + if pool.TvlAmount.IsNil() { + pool.TvlAmount = sdk.ZeroInt() + } + if pool.SponsorshipAmount.IsNil() { + pool.SponsorshipAmount = sdk.ZeroInt() + } + if pool.AvailablePrizePool.IsNil() { + pool.AvailablePrizePool = sdk.NewCoin(pool.Denom, sdk.ZeroInt()) + } + if pool.State == millionstypes.PoolState_Unspecified { + pool.State = millionstypes.PoolState_Ready + } + if pool.CreatedAt.IsZero() { + pool.CreatedAt = suite.ctx.BlockTime() + } + if pool.UpdatedAt.IsZero() { + pool.UpdatedAt = suite.ctx.BlockTime() + } + if pool.IcaDepositPortId == "" { + pool.IcaDepositPortId = icatypes.ControllerPortPrefix + string(millionstypes.NewPoolName(pool.GetPoolId(), millionstypes.ICATypeDeposit)) + } + if pool.IcaPrizepoolPortId == "" { + pool.IcaPrizepoolPortId = icatypes.ControllerPortPrefix + string(millionstypes.NewPoolName(pool.GetPoolId(), millionstypes.ICATypePrizePool)) + } + return &pool +} + +func (suite *StoreMigrationTestSuite) SetupTest() { + app := apptypes.SetupForTesting(false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + // Setup the default application + suite.app = app + suite.ctx = ctx.WithChainID("lum-network-devnet").WithBlockTime(time.Now().UTC()) + + // Setup test account addresses + suite.addrs = apptesting.AddTestAddrsWithDenom(app, ctx, 6, sdk.NewInt(10_000_000_000), app.StakingKeeper.BondDenom(ctx)) + for i := 0; i < 6; i++ { + poolAddress := millionstypes.NewPoolAddress(uint64(i+1), "unused-in-test") + apptesting.AddTestModuleAccount(app, ctx, poolAddress) + suite.moduleAddrs = append(suite.moduleAddrs, poolAddress) + } + + // Setup vals for pools + vals := app.StakingKeeper.GetAllValidators(ctx) + suite.valAddrs = []sdk.ValAddress{} + for _, v := range vals { + addr, err := sdk.ValAddressFromBech32(v.OperatorAddress) + suite.Require().NoError(err) + suite.valAddrs = append(suite.valAddrs, addr) + } + + // Setup test params + suite.app.MillionsKeeper.SetParams(ctx, millionstypes.Params{ + MinDepositAmount: sdk.NewInt(millionstypes.MinAcceptableDepositAmount), + MaxPrizeStrategyBatches: 1_000, + MaxPrizeBatchQuantity: 1_000_000, + MinDrawScheduleDelta: 1 * time.Hour, + MaxDrawScheduleDelta: 366 * 24 * time.Hour, + PrizeExpirationDelta: 30 * 24 * time.Hour, + FeesStakers: sdk.ZeroDec(), + MinDepositDrawDelta: millionstypes.MinAcceptableDepositDrawDelta, + }) +} + +func (suite *StoreMigrationTestSuite) TestMigrateAutoCompoundDeposits() { + poolID := suite.app.MillionsKeeper.GetNextPoolIDAndIncrement(suite.ctx) + suite.app.MillionsKeeper.AddPool(suite.ctx, newValidPool(suite, millionstypes.Pool{PoolId: poolID})) + + // Grab our pool entity + pool, err := suite.app.MillionsKeeper.GetPool(suite.ctx, poolID) + suite.Require().NoError(err) + + for i := 0; i < 5; i++ { + suite.app.MillionsKeeper.AddDeposit(suite.ctx, &millionstypes.Deposit{ + PoolId: pool.PoolId, + DepositorAddress: suite.addrs[i].String(), + WinnerAddress: suite.addrs[i].String(), + State: millionstypes.DepositState_IbcTransfer, + Amount: sdk.NewCoin("ulum", sdk.NewInt(1_000_0)), + Origin: millionstypes.DepositOrigin_Autocompound, + }) + } + + // Run the migration operation + err = v161.MigrateAutoCompoundDeposits(suite.ctx, *suite.app.MillionsKeeper) + suite.Require().NoError(err) + + deposits := suite.app.MillionsKeeper.ListDeposits(suite.ctx) + for _, d := range deposits { + suite.Require().Equal(millionstypes.DepositOrigin_Direct, d.Origin) + } + +} + +func TestKeeperSuite(t *testing.T) { + suite.Run(t, new(StoreMigrationTestSuite)) +} diff --git a/x/millions/module.go b/x/millions/module.go index ff166fbf..ca47fb99 100644 --- a/x/millions/module.go +++ b/x/millions/module.go @@ -140,6 +140,11 @@ func (a AppModule) RegisterServices(cfg module.Configurator) { if err != nil { panic(err) } + + err = cfg.RegisterMigration(types.ModuleName, 4, migrator.Migrate4To5) + if err != nil { + panic(err) + } } func (a AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { diff --git a/x/millions/types/deposit.go b/x/millions/types/deposit.go index 5880632f..4132bdcf 100644 --- a/x/millions/types/deposit.go +++ b/x/millions/types/deposit.go @@ -17,6 +17,9 @@ func (deposit *Deposit) ValidateBasic() error { if deposit.State == DepositState_Unspecified { return errorsmod.Wrapf(ErrInvalidDepositState, "no state specified") } + if deposit.Origin == DepositOrigin_Unspecified { + return errorsmod.Wrapf(ErrInvalidDepositOriginState, "no state specified") + } if _, err := sdk.AccAddressFromBech32(deposit.DepositorAddress); err != nil { return errorsmod.Wrapf(ErrInvalidDepositorAddress, err.Error()) } diff --git a/x/millions/types/deposit.pb.go b/x/millions/types/deposit.pb.go index 0979d879..51df9300 100644 --- a/x/millions/types/deposit.pb.go +++ b/x/millions/types/deposit.pb.go @@ -64,19 +64,48 @@ func (DepositState) EnumDescriptor() ([]byte, []int) { return fileDescriptor_5252614e94b18a0e, []int{0} } +type DepositOrigin int32 + +const ( + DepositOrigin_Unspecified DepositOrigin = 0 + DepositOrigin_Direct DepositOrigin = 1 + DepositOrigin_Autocompound DepositOrigin = 2 +) + +var DepositOrigin_name = map[int32]string{ + 0: "DEPOSIT_ORIGIN_UNSPECIFIED", + 1: "DEPOSIT_ORIGIN_DIRECT", + 2: "DEPOSIT_ORIGIN_AUTOCOMPOUND", +} + +var DepositOrigin_value = map[string]int32{ + "DEPOSIT_ORIGIN_UNSPECIFIED": 0, + "DEPOSIT_ORIGIN_DIRECT": 1, + "DEPOSIT_ORIGIN_AUTOCOMPOUND": 2, +} + +func (x DepositOrigin) String() string { + return proto.EnumName(DepositOrigin_name, int32(x)) +} + +func (DepositOrigin) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_5252614e94b18a0e, []int{1} +} + type Deposit struct { - PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` - DepositId uint64 `protobuf:"varint,2,opt,name=deposit_id,json=depositId,proto3" json:"deposit_id,omitempty"` - State DepositState `protobuf:"varint,3,opt,name=state,proto3,enum=lum.network.millions.DepositState" json:"state,omitempty"` - ErrorState DepositState `protobuf:"varint,4,opt,name=error_state,json=errorState,proto3,enum=lum.network.millions.DepositState" json:"error_state,omitempty"` - DepositorAddress string `protobuf:"bytes,5,opt,name=depositor_address,json=depositorAddress,proto3" json:"depositor_address,omitempty"` - Amount types.Coin `protobuf:"bytes,6,opt,name=amount,proto3" json:"amount"` - WinnerAddress string `protobuf:"bytes,7,opt,name=winner_address,json=winnerAddress,proto3" json:"winner_address,omitempty"` - IsSponsor bool `protobuf:"varint,8,opt,name=is_sponsor,json=isSponsor,proto3" json:"is_sponsor,omitempty"` - CreatedAtHeight int64 `protobuf:"varint,10,opt,name=created_at_height,json=createdAtHeight,proto3" json:"created_at_height,omitempty"` - UpdatedAtHeight int64 `protobuf:"varint,11,opt,name=updated_at_height,json=updatedAtHeight,proto3" json:"updated_at_height,omitempty"` - CreatedAt time.Time `protobuf:"bytes,12,opt,name=created_at,json=createdAt,proto3,stdtime" json:"created_at"` - UpdatedAt time.Time `protobuf:"bytes,13,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at"` + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + DepositId uint64 `protobuf:"varint,2,opt,name=deposit_id,json=depositId,proto3" json:"deposit_id,omitempty"` + State DepositState `protobuf:"varint,3,opt,name=state,proto3,enum=lum.network.millions.DepositState" json:"state,omitempty"` + ErrorState DepositState `protobuf:"varint,4,opt,name=error_state,json=errorState,proto3,enum=lum.network.millions.DepositState" json:"error_state,omitempty"` + DepositorAddress string `protobuf:"bytes,5,opt,name=depositor_address,json=depositorAddress,proto3" json:"depositor_address,omitempty"` + Amount types.Coin `protobuf:"bytes,6,opt,name=amount,proto3" json:"amount"` + WinnerAddress string `protobuf:"bytes,7,opt,name=winner_address,json=winnerAddress,proto3" json:"winner_address,omitempty"` + IsSponsor bool `protobuf:"varint,8,opt,name=is_sponsor,json=isSponsor,proto3" json:"is_sponsor,omitempty"` + Origin DepositOrigin `protobuf:"varint,9,opt,name=origin,proto3,enum=lum.network.millions.DepositOrigin" json:"origin,omitempty"` + CreatedAtHeight int64 `protobuf:"varint,10,opt,name=created_at_height,json=createdAtHeight,proto3" json:"created_at_height,omitempty"` + UpdatedAtHeight int64 `protobuf:"varint,11,opt,name=updated_at_height,json=updatedAtHeight,proto3" json:"updated_at_height,omitempty"` + CreatedAt time.Time `protobuf:"bytes,12,opt,name=created_at,json=createdAt,proto3,stdtime" json:"created_at"` + UpdatedAt time.Time `protobuf:"bytes,13,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at"` } func (m *Deposit) Reset() { *m = Deposit{} } @@ -168,6 +197,13 @@ func (m *Deposit) GetIsSponsor() bool { return false } +func (m *Deposit) GetOrigin() DepositOrigin { + if m != nil { + return m.Origin + } + return DepositOrigin_Unspecified +} + func (m *Deposit) GetCreatedAtHeight() int64 { if m != nil { return m.CreatedAtHeight @@ -198,6 +234,7 @@ func (m *Deposit) GetUpdatedAt() time.Time { func init() { proto.RegisterEnum("lum.network.millions.DepositState", DepositState_name, DepositState_value) + proto.RegisterEnum("lum.network.millions.DepositOrigin", DepositOrigin_name, DepositOrigin_value) proto.RegisterType((*Deposit)(nil), "lum.network.millions.Deposit") } @@ -206,49 +243,55 @@ func init() { } var fileDescriptor_5252614e94b18a0e = []byte{ - // 661 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xcf, 0x6e, 0xd3, 0x30, - 0x1c, 0xc7, 0x9b, 0xad, 0xeb, 0x1f, 0x77, 0x7f, 0xba, 0x68, 0x88, 0xac, 0xd2, 0xb2, 0x68, 0x07, - 0x54, 0x4d, 0x5a, 0xa2, 0x8d, 0x03, 0xdc, 0x50, 0x9b, 0xa6, 0x23, 0x68, 0x1a, 0x53, 0x92, 0x5e, - 0xb8, 0x44, 0x69, 0xe2, 0xa5, 0x16, 0x49, 0x1c, 0xc5, 0x0e, 0x83, 0x37, 0x98, 0x76, 0xda, 0x0b, - 0xec, 0xc4, 0x2b, 0xf0, 0x10, 0x3b, 0x4e, 0x9c, 0x38, 0x01, 0xda, 0xde, 0x81, 0x33, 0x4a, 0xec, - 0xb6, 0x0c, 0x26, 0x01, 0x37, 0xfb, 0xf7, 0xfd, 0x7c, 0x7f, 0x7f, 0x6c, 0xcb, 0x60, 0x27, 0xca, - 0x63, 0x2d, 0x81, 0xf4, 0x0c, 0x67, 0x6f, 0xb5, 0x18, 0x45, 0x11, 0xc2, 0x09, 0xd1, 0x02, 0x98, - 0x62, 0x82, 0xa8, 0x9a, 0x66, 0x98, 0x62, 0x71, 0x23, 0xca, 0x63, 0x95, 0x33, 0xea, 0x94, 0xe9, - 0x6c, 0x84, 0x38, 0xc4, 0x25, 0xa0, 0x15, 0x2b, 0xc6, 0x76, 0xb6, 0x43, 0x8c, 0xc3, 0x08, 0x6a, - 0xe5, 0x6e, 0x9c, 0x9f, 0x6a, 0x14, 0xc5, 0x90, 0x50, 0x2f, 0x4e, 0x39, 0x20, 0xfb, 0x98, 0xc4, - 0x98, 0x68, 0x63, 0x8f, 0x40, 0xed, 0xdd, 0xfe, 0x18, 0x52, 0x6f, 0x5f, 0x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, 0x0b, 0xdc, 0xe0, 0x7b, 0x03, 0x18, 0xc1, 0xb0, - 0xe8, 0xe8, 0x09, 0x78, 0x74, 0xdf, 0x60, 0x8f, 0x74, 0xdd, 0xb0, 0xed, 0xf6, 0x62, 0xa7, 0x75, - 0x71, 0xa5, 0xd4, 0xed, 0xdc, 0xf7, 0x8b, 0x1b, 0xfd, 0x83, 0x1b, 0xf6, 0xcc, 0xa3, 0x91, 0x65, - 0xb4, 0xab, 0x8c, 0x1b, 0x7a, 0x28, 0xca, 0x33, 0xd8, 0xa9, 0x9e, 0x7f, 0x94, 0x85, 0xfe, 0xe1, - 0xf5, 0xad, 0x2c, 0xdc, 0xdc, 0xca, 0xc2, 0xf7, 0x5b, 0x59, 0xb8, 0xbc, 0x93, 0x2b, 0x37, 0x77, - 0x72, 0xe5, 0xcb, 0x9d, 0x5c, 0x79, 0xb3, 0x17, 0x22, 0x3a, 0xc9, 0xc7, 0xaa, 0x8f, 0x63, 0x2d, - 0xca, 0xe3, 0xbd, 0xe9, 0xa7, 0xe2, 0x4f, 0x3c, 0x94, 0x68, 0xef, 0xe7, 0x9f, 0x0b, 0xfd, 0x90, - 0x42, 0x32, 0xae, 0x95, 0x07, 0xfe, 0xf4, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe6, 0xbc, 0x5f, - 0x24, 0x81, 0x04, 0x00, 0x00, + // 756 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x41, 0x6f, 0xe3, 0x44, + 0x14, 0xc7, 0x33, 0x6d, 0x9a, 0x36, 0x93, 0x76, 0xd7, 0x6b, 0x15, 0xe1, 0x1a, 0xad, 0x6b, 0x15, + 0x81, 0xa2, 0x4a, 0xb5, 0xd5, 0xe5, 0x00, 0x12, 0x07, 0xe4, 0xd8, 0x6e, 0xb1, 0xb4, 0x34, 0x95, + 0xed, 0x5c, 0xb8, 0x58, 0x8e, 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 0x99, 0xef, 0x4a, 0x7d, 0xce, 0x9d, 0xc5, 0x38, 0x6f, 0x6a, 0xa4, + 0xf6, 0x7f, 0xf8, 0x49, 0x03, 0xc7, 0x3f, 0x02, 0xb8, 0x77, 0xef, 0xa7, 0xbf, 0xd9, 0xd8, 0xd4, + 0xf7, 0xce, 0xbd, 0x8b, 0x87, 0xae, 0xfe, 0xd1, 0xba, 0xa0, 0x30, 0x38, 0x9e, 0xef, 0xda, 0xa1, + 0x04, 0x54, 0x78, 0xb3, 0xd0, 0x07, 0x0e, 0xae, 0x51, 0xc2, 0xe4, 0x53, 0xf8, 0xc1, 0x5b, 0x98, + 0x35, 0x0b, 0xa7, 0xf6, 0xf4, 0xab, 0xcb, 0xe9, 0xec, 0xc2, 0x91, 0x36, 0x54, 0xe9, 0x66, 0xa1, + 0xef, 0x5a, 0x0d, 0x23, 0x09, 0x29, 0x2a, 0xd2, 0x94, 0x29, 0x6f, 0x71, 0x72, 0xfe, 0xea, 0x56, + 0x03, 0xaf, 0x6f, 0x35, 0xf0, 0xe7, 0xad, 0x06, 0x5e, 0xde, 0x69, 0xbd, 0xd7, 0x77, 0x5a, 0xef, + 0xb7, 0x3b, 0xad, 0xf7, 0xf5, 0x49, 0x86, 0xd9, 0x75, 0x33, 0x37, 0x12, 0x52, 0x98, 0x79, 0x53, + 0x9c, 0x2c, 0x9f, 0xcb, 0xe4, 0x3a, 0xc6, 0xa5, 0xf9, 0xdd, 0xfa, 0xd9, 0x64, 0xdf, 0x57, 0x88, + 0xce, 0x07, 0xdd, 0x36, 0x7c, 0xf2, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xda, 0xd6, 0x3d, 0xdf, + 0x5b, 0x05, 0x00, 0x00, } func (m *Deposit) Marshal() (dAtA []byte, err error) { @@ -297,6 +340,11 @@ func (m *Deposit) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x50 } + if m.Origin != 0 { + i = encodeVarintDeposit(dAtA, i, uint64(m.Origin)) + i-- + dAtA[i] = 0x48 + } if m.IsSponsor { i-- if m.IsSponsor { @@ -396,6 +444,9 @@ func (m *Deposit) Size() (n int) { if m.IsSponsor { n += 2 } + if m.Origin != 0 { + n += 1 + sovDeposit(uint64(m.Origin)) + } if m.CreatedAtHeight != 0 { n += 1 + sovDeposit(uint64(m.CreatedAtHeight)) } @@ -637,6 +688,25 @@ func (m *Deposit) Unmarshal(dAtA []byte) error { } } m.IsSponsor = bool(v != 0) + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Origin", wireType) + } + m.Origin = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDeposit + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Origin |= DepositOrigin(b&0x7F) << shift + if b < 0x80 { + break + } + } case 10: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field CreatedAtHeight", wireType) diff --git a/x/millions/types/errors.go b/x/millions/types/errors.go index 5e84290f..595e6e8d 100644 --- a/x/millions/types/errors.go +++ b/x/millions/types/errors.go @@ -36,6 +36,8 @@ var ( ErrInvalidDepositState = errorsmod.Register(ModuleName, 1208, "Deposit is in an invalid state") ErrInvalidPoolAccountAddress = errorsmod.Register(ModuleName, 1209, "Invalid pool module account address") ErrInvalidRestorerAddress = errorsmod.Register(ModuleName, 1210, "Invalid restorer address") + ErrInvalidAutoCompoundSponsorCombo = errorsmod.Register(ModuleName, 1211, "Only winners that auto compounds can sponsor a deposit through a claim process") + ErrInvalidDepositOriginState = errorsmod.Register(ModuleName, 1212, "Deposit origin is in an invalid state") ErrPoolDrawNotFound = errorsmod.Register(ModuleName, 1300, "Pool draw not found") ErrPoolDrawNotDone = errorsmod.Register(ModuleName, 1301, "Cannot launch a new draw until the previous one is done") ErrInvalidDrawState = errorsmod.Register(ModuleName, 1302, "Invalid draw state") diff --git a/x/millions/types/events.go b/x/millions/types/events.go index 177f97a7..cfc44aa3 100644 --- a/x/millions/types/events.go +++ b/x/millions/types/events.go @@ -33,4 +33,6 @@ const ( AttributeKeySponsor = "sponsor" AttributeKeyEpochID = "epoch_id" AttributeSeed = "seed" + AttributeKeyOrigin = "origin" + AttributeKeyAutoCompound = "auto_compound" ) diff --git a/x/millions/types/keys.go b/x/millions/types/keys.go index 54f7856e..cc9a3e4e 100644 --- a/x/millions/types/keys.go +++ b/x/millions/types/keys.go @@ -14,7 +14,7 @@ import ( const ( ModuleName = "millions" - ModuleVersion = 4 + ModuleVersion = 5 StoreKey = ModuleName diff --git a/x/millions/types/message_claim_prize.go b/x/millions/types/message_claim_prize.go index d4d1928d..1381138f 100644 --- a/x/millions/types/message_claim_prize.go +++ b/x/millions/types/message_claim_prize.go @@ -44,5 +44,9 @@ func (msg *MsgClaimPrize) ValidateBasic() error { return ErrInvalidID } + if !msg.GetIsAutoCompound() && msg.GetIsSponsor() { + return ErrInvalidAutoCompoundSponsorCombo + } + return nil } diff --git a/x/millions/types/tx.pb.go b/x/millions/types/tx.pb.go index 41c5f825..f9a5cd35 100644 --- a/x/millions/types/tx.pb.go +++ b/x/millions/types/tx.pb.go @@ -755,10 +755,12 @@ func (m *MsgDepositRetryResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgDepositRetryResponse proto.InternalMessageInfo type MsgClaimPrize struct { - PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` - DrawId uint64 `protobuf:"varint,2,opt,name=draw_id,json=drawId,proto3" json:"draw_id,omitempty"` - PrizeId uint64 `protobuf:"varint,3,opt,name=prize_id,json=prizeId,proto3" json:"prize_id,omitempty"` - WinnerAddress string `protobuf:"bytes,4,opt,name=winner_address,json=winnerAddress,proto3" json:"winner_address,omitempty"` + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + DrawId uint64 `protobuf:"varint,2,opt,name=draw_id,json=drawId,proto3" json:"draw_id,omitempty"` + PrizeId uint64 `protobuf:"varint,3,opt,name=prize_id,json=prizeId,proto3" json:"prize_id,omitempty"` + WinnerAddress string `protobuf:"bytes,4,opt,name=winner_address,json=winnerAddress,proto3" json:"winner_address,omitempty"` + IsAutoCompound bool `protobuf:"varint,5,opt,name=is_auto_compound,json=isAutoCompound,proto3" json:"is_auto_compound,omitempty"` + IsSponsor bool `protobuf:"varint,6,opt,name=is_sponsor,json=isSponsor,proto3" json:"is_sponsor,omitempty"` } func (m *MsgClaimPrize) Reset() { *m = MsgClaimPrize{} } @@ -822,6 +824,20 @@ func (m *MsgClaimPrize) GetWinnerAddress() string { return "" } +func (m *MsgClaimPrize) GetIsAutoCompound() bool { + if m != nil { + return m.IsAutoCompound + } + return false +} + +func (m *MsgClaimPrize) GetIsSponsor() bool { + if m != nil { + return m.IsSponsor + } + return false +} + type MsgClaimPrizeResponse struct { } @@ -1368,99 +1384,101 @@ func init() { func init() { proto.RegisterFile("lum/network/millions/tx.proto", fileDescriptor_13b6da814e999511) } var fileDescriptor_13b6da814e999511 = []byte{ - // 1461 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0x4f, 0x6f, 0xdb, 0xc6, - 0x12, 0x37, 0x25, 0x59, 0xb6, 0xc6, 0xff, 0xf2, 0x18, 0xc5, 0x96, 0x85, 0x17, 0xd9, 0x91, 0xf3, - 0x02, 0xbf, 0xb6, 0x92, 0x1a, 0x1b, 0x45, 0xd0, 0x5e, 0x0a, 0x39, 0x4e, 0x03, 0x1d, 0x0c, 0x38, - 0x34, 0x92, 0xa6, 0x69, 0x51, 0x62, 0x45, 0x6e, 0x64, 0xc2, 0x24, 0x57, 0xd9, 0x5d, 0x59, 0x72, - 0x91, 0x6b, 0x81, 0x02, 0xb9, 0xe4, 0xd8, 0x4b, 0xfb, 0x29, 0xfa, 0x0d, 0x7a, 0xc9, 0xa1, 0x87, - 0xa0, 0x87, 0xa2,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, 0x39, 0xe3, 0xdb, 0x70, 0x89, 0x4a, 0xaf, 0x3e, - 0x89, 0xa9, 0x31, 0x69, 0xad, 0x84, 0x1e, 0x61, 0x56, 0x37, 0xe0, 0xfa, 0x45, 0xd1, 0xa3, 0x2c, - 0x1f, 0x8a, 0x61, 0x7d, 0x17, 0xfb, 0x38, 0xb8, 0x57, 0x8f, 0x30, 0x16, 0x55, 0xa4, 0xf8, 0x49, - 0x07, 0xb3, 0xf8, 0xdd, 0xaa, 0x8d, 0xe3, 0x25, 0x72, 0x09, 0x33, 0xa8, 0x08, 0x95, 0xc5, 0x91, - 0x23, 0x99, 0xea, 0x90, 0x61, 0x18, 0xcb, 0x73, 0xa7, 0x0d, 0xf1, 0xfb, 0xce, 0xcf, 0x73, 0x90, - 0x3e, 0x60, 0x2d, 0xfd, 0x3e, 0xcc, 0x85, 0x3d, 0xba, 0x39, 0xfa, 0x71, 0xd0, 0x1f, 0x51, 0xc5, - 0xed, 0x71, 0x16, 0x51, 0x48, 0x1b, 0x16, 0x07, 0x84, 0xfe, 0xbf, 0xf1, 0x9e, 0x9c, 0x9e, 0x15, - 0x2b, 0x13, 0x99, 0x45, 0x51, 0x10, 0x2c, 0xc4, 0x2f, 0x99, 0xeb, 0xe3, 0xbc, 0x03, 0xab, 0xe2, - 0x07, 0x93, 0x58, 0x45, 0x21, 0xbe, 0x06, 0x88, 0x0d, 0xe1, 0xad, 0x44, 0xdf, 0xbe, 0x51, 0xf1, - 0xfd, 0x09, 0x8c, 0x22, 0x7c, 0x0f, 0x56, 0xce, 0xcf, 0xca, 0x64, 0x96, 0xcf, 0x59, 0x16, 0x3f, - 0x9c, 0xd4, 0x32, 0x0a, 0xf7, 0x14, 0xf2, 0x23, 0x07, 0x51, 0x65, 0x72, 0xa4, 0xa0, 0x4e, 0x1f, - 0x4d, 0x65, 0x1e, 0x45, 0xff, 0x12, 0x72, 0xfd, 0x11, 0x52, 0x4e, 0xae, 0x43, 0x68, 0x53, 0x7c, - 0x6f, 0xbc, 0x4d, 0x04, 0xfe, 0x4c, 0x83, 0xf5, 0xe4, 0xf6, 0xdf, 0x49, 0x44, 0x4a, 0xf4, 0x29, - 0x7e, 0x32, 0xbd, 0x4f, 0xbc, 0x01, 0x06, 0xba, 0x3c, 0xb9, 0x01, 0xe2, 0x66, 0x17, 0x34, 0xc0, - 0xa8, 0xce, 0xde, 0xbb, 0xfb, 0xe2, 0x75, 0x49, 0x7b, 0xf9, 0xba, 0xa4, 0xfd, 0xf5, 0xba, 0xa4, - 0x3d, 0x7f, 0x53, 0x9a, 0x79, 0xf9, 0xa6, 0x34, 0xf3, 0xfb, 0x9b, 0xd2, 0xcc, 0xa3, 0x4a, 0xec, - 0x4f, 0x11, 0xb7, 0xe3, 0x55, 0xc2, 0x7f, 0x94, 0x89, 0x6c, 0x6b, 0xbd, 0xd8, 0x3f, 0x08, 0x83, - 0xbf, 0x4a, 0x9a, 0x59, 0xf1, 0x14, 0xda, 0xfd, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x9c, 0x2c, 0xc8, - 0x41, 0x45, 0x14, 0x00, 0x00, + // 1492 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0x4d, 0x6f, 0xdb, 0x46, + 0x13, 0x36, 0x25, 0x59, 0xb6, 0xc6, 0x9f, 0x2f, 0xe3, 0xd8, 0xb2, 0xf0, 0x46, 0x76, 0xe4, 0xbc, + 0x81, 0xdf, 0xb6, 0x96, 0x1a, 0x1b, 0x45, 0xd0, 0x5e, 0x0a, 0xd9, 0x4e, 0x03, 0x1f, 0x0c, 0x38, + 0x34, 0x92, 0xa6, 0x69, 0x51, 0x62, 0x4d, 0x6e, 0xe4, 0x85, 0x49, 0xae, 0xc2, 0x5d, 0x5a, 0x72, + 0x91, 0x6b, 0x81, 0x02, 0xb9, 0xe4, 0xd8, 0x53, 0x7f, 0x45, 0xff, 0x41, 0x2f, 0x39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0x96, 0x7b, 0x2c, 0x4b, 0x1f, 0x8e, 0x6a, + 0x19, 0x87, 0x7b, 0x0a, 0x4b, 0x03, 0x07, 0xd1, 0xd6, 0xe8, 0x48, 0x61, 0x9d, 0x3e, 0x1a, 0xcb, + 0x3c, 0x8e, 0xfe, 0x25, 0x14, 0x3a, 0x23, 0xa4, 0x92, 0x5e, 0x87, 0xc8, 0xa6, 0xf4, 0xde, 0x70, + 0x9b, 0x18, 0xfc, 0x99, 0x06, 0xab, 0xe9, 0xed, 0xbf, 0x9d, 0x8a, 0x94, 0xea, 0x53, 0xfa, 0x64, + 0x7c, 0x9f, 0x64, 0x03, 0x74, 0x75, 0x79, 0x7a, 0x03, 0x24, 0xcd, 0x2e, 0x69, 0x80, 0x41, 0x9d, + 0xbd, 0x7b, 0xf7, 0xc5, 0xeb, 0xb2, 0xf6, 0xf2, 0x75, 0x59, 0xfb, 0xf3, 0x75, 0x59, 0x7b, 0xfe, + 0xa6, 0x3c, 0xf1, 0xf2, 0x4d, 0x79, 0xe2, 0xb7, 0x37, 0xe5, 0x89, 0x47, 0x5b, 0x89, 0xbf, 0x69, + 0x9c, 0xc0, 0xdd, 0x8a, 0xfe, 0xe3, 0x26, 0xb2, 0xad, 0xb5, 0x13, 0xff, 0x69, 0x0c, 0xff, 0xbc, + 0x39, 0xc9, 0x8b, 0x37, 0xd5, 0xce, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xea, 0x31, 0xf6, 0x77, + 0x8e, 0x14, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2469,6 +2487,26 @@ func (m *MsgClaimPrize) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.IsSponsor { + i-- + if m.IsSponsor { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } + if m.IsAutoCompound { + i-- + if m.IsAutoCompound { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } if len(m.WinnerAddress) > 0 { i -= len(m.WinnerAddress) copy(dAtA[i:], m.WinnerAddress) @@ -3123,6 +3161,12 @@ func (m *MsgClaimPrize) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + if m.IsAutoCompound { + n += 2 + } + if m.IsSponsor { + n += 2 + } return n } @@ -5249,6 +5293,46 @@ func (m *MsgClaimPrize) Unmarshal(dAtA []byte) error { } m.WinnerAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsAutoCompound", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsAutoCompound = bool(v != 0) + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsSponsor", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsSponsor = bool(v != 0) default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:])