diff --git a/.gitignore b/.gitignore index 8c806e68..d94fc81d 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ # ignore visual studio code dev container config .devcontainer + +# ignore build dir +build \ No newline at end of file diff --git a/app/upgrades/v3/consts.go b/app/upgrades/v3/consts.go index 13388a3b..9b8b8fe8 100644 --- a/app/upgrades/v3/consts.go +++ b/app/upgrades/v3/consts.go @@ -1,7 +1,9 @@ package v3 import ( + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sge-network/sge/app/upgrades" ) @@ -11,7 +13,7 @@ const UpgradeName = "v1.2.0" // Expedite governance params var ( // DefaultMinExpeditedDepositTokens is the default minimum deposit required for expedited proposals. - DefaultMinExpeditedDepositTokens = sdk.NewInt(50000000000) + DefaultMinExpeditedDepositTokens = sdkmath.NewInt(50000000000) // DefaultExpeditedQuorum is the default quorum percentage required for expedited proposals. DefaultExpeditedQuorum = sdk.NewDecWithPrec(750, 3) // DefaultExpeditedThreshold is the default voting threshold percentage required for expedited proposals. diff --git a/app/upgrades/v8/consts.go b/app/upgrades/v8/consts.go index 6c28f595..686ccb5f 100644 --- a/app/upgrades/v8/consts.go +++ b/app/upgrades/v8/consts.go @@ -6,8 +6,8 @@ import ( "github.com/sge-network/sge/app/upgrades" ) -// UpgradeName defines the on-chain upgrade name for the v1.6.1 upgrade. -const UpgradeName = "v1.6.1" +// UpgradeName defines the on-chain upgrade name for the v1.6.2 upgrade. +const UpgradeName = "v1.6.2" var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, diff --git a/app/upgrades/v8/upgrades.go b/app/upgrades/v8/upgrades.go index c6bbbb93..c9b38084 100644 --- a/app/upgrades/v8/upgrades.go +++ b/app/upgrades/v8/upgrades.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/sge-network/sge/app/keepers" "github.com/sge-network/sge/x/reward/types" ) @@ -17,42 +18,52 @@ func CreateUpgradeHandler( k *keepers.AppKeepers, ) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - allCampaigns := k.RewardKeeper.GetAllCampaign(ctx) - promoters := make(map[string]struct{}) - for _, c := range allCampaigns { - c.CapCount = 0 // infinite cap for all campaigns - c.Pool.Withdrawn = sdkmath.ZeroInt() - k.RewardKeeper.SetCampaign(ctx, c) - promoters[c.Promoter] = struct{}{} - } + allPromoters := k.RewardKeeper.GetAllPromoter(ctx) + promoterUID := "f0630627-9e4e-48f3-8cd5-1422b46d2175" + if len(allPromoters) == 0 { + allCampaigns := k.RewardKeeper.GetAllCampaign(ctx) + promoters := make(map[string]struct{}) + for _, c := range allCampaigns { + c.CapCount = 0 // infinite cap for all campaigns + c.Pool.Withdrawn = sdkmath.ZeroInt() + k.RewardKeeper.SetCampaign(ctx, c) + promoters[c.Promoter] = struct{}{} + } - promoterAddresses := []string{} - for addr := range promoters { - promoterAddresses = append(promoterAddresses, addr) - } - sort.Strings(promoterAddresses) - - if len(promoterAddresses) > 0 { - promoterUID := "f0630627-9e4e-48f3-8cd5-1422b46d2175" - k.RewardKeeper.SetPromoter(ctx, types.Promoter{ - Creator: promoterAddresses[0], - UID: promoterUID, - Addresses: promoterAddresses, - Conf: types.PromoterConf{ - CategoryCap: []types.CategoryCap{ - {Category: types.RewardCategory_REWARD_CATEGORY_SIGNUP, CapPerAcc: 1}, - }, - }, - }) + promoterAddresses := []string{} + for addr := range promoters { + promoterAddresses = append(promoterAddresses, addr) + } + sort.Strings(promoterAddresses) - for _, addr := range promoterAddresses { - k.RewardKeeper.SetPromoterByAddress(ctx, types.PromoterByAddress{ - PromoterUID: promoterUID, - Address: addr, + if len(promoterAddresses) > 0 { + promoterUID := promoterUID + k.RewardKeeper.SetPromoter(ctx, types.Promoter{ + Creator: promoterAddresses[0], + UID: promoterUID, + Addresses: promoterAddresses, + Conf: types.PromoterConf{ + CategoryCap: []types.CategoryCap{ + {Category: types.RewardCategory_REWARD_CATEGORY_SIGNUP, CapPerAcc: 1}, + }, + }, }) + + for _, addr := range promoterAddresses { + k.RewardKeeper.SetPromoterByAddress(ctx, types.PromoterByAddress{ + PromoterUID: promoterUID, + Address: addr, + }) + } } } + allByCat := k.RewardKeeper.GetAllRewardsOfReceiverByPromoterAndCategory(ctx) + for _, rc := range allByCat { + k.RewardKeeper.RemoveRewardOfReceiverByPromoterAndCategory(ctx, "", rc) + k.RewardKeeper.SetRewardOfReceiverByPromoterAndCategory(ctx, promoterUID, rc) + } + return mm.RunMigrations(ctx, configurator, fromVM) } } diff --git a/go.mod b/go.mod index b02fcfba..cba6b055 100644 --- a/go.mod +++ b/go.mod @@ -318,7 +318,7 @@ replace ( // use cosmos fork of keyring github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 - github.com/cosmos/cosmos-sdk => github.com/sge-network/cosmos-sdk v0.46.17-0.20240223100624-2a2661276cb4 + github.com/cosmos/cosmos-sdk => github.com/sge-network/cosmos-sdk v0.46.17-0.20240430064306-1b044d03d56c github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2 github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0 // use cosmos-compatible protobufs diff --git a/go.sum b/go.sum index de7910cc..157c58a7 100644 --- a/go.sum +++ b/go.sum @@ -1317,8 +1317,8 @@ github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KR github.com/segmentio/kafka-go v0.1.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= github.com/segmentio/kafka-go v0.2.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/sge-network/cosmos-sdk v0.46.17-0.20240223100624-2a2661276cb4 h1:HaHBgOxHd0mvl9Y07qujdnwtjcRweJsktbNPPy6LlwQ= -github.com/sge-network/cosmos-sdk v0.46.17-0.20240223100624-2a2661276cb4/go.mod h1:05U50tAsOzQ8JOAePshJCbJQw5ib1YJR6IXcqyVI1Xg= +github.com/sge-network/cosmos-sdk v0.46.17-0.20240430064306-1b044d03d56c h1:cnMnb+CR81vB2ula0qQqMIkfYREVUpUTpqHtu34zLGQ= +github.com/sge-network/cosmos-sdk v0.46.17-0.20240430064306-1b044d03d56c/go.mod h1:05U50tAsOzQ8JOAePshJCbJQw5ib1YJR6IXcqyVI1Xg= github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c h1:W65qqJCIOVP4jpqPQ0YvHYKwcMEMVWIzWC5iNQQfBTU= github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c/go.mod h1:/PevMnwAxekIXwN8qQyfc5gl2NlkB3CQlkizAbOkeBs= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= diff --git a/x/bet/keeper/settle_test.go b/x/bet/keeper/settle_test.go index 703492de..a6bf6801 100644 --- a/x/bet/keeper/settle_test.go +++ b/x/bet/keeper/settle_test.go @@ -52,7 +52,7 @@ func TestSettleBet(t *testing.T) { bet: &types.Bet{ MarketUID: testMarketUID, OddsValue: "10", - Amount: sdk.NewInt(1000000), + Amount: sdkmath.NewInt(1000000), Creator: testCreator, OddsUID: testOddsUID1, Status: types.Bet_STATUS_SETTLED, @@ -73,7 +73,7 @@ func TestSettleBet(t *testing.T) { bet: &types.Bet{ MarketUID: testMarketUID, OddsValue: "10", - Amount: sdk.NewInt(1000000), + Amount: sdkmath.NewInt(1000000), Creator: testCreator, OddsUID: testOddsUID1, }, @@ -92,7 +92,7 @@ func TestSettleBet(t *testing.T) { bet: &types.Bet{ MarketUID: testMarketUID, OddsValue: "10", - Amount: sdk.NewInt(1000000), + Amount: sdkmath.NewInt(1000000), Creator: testCreator, OddsUID: testOddsUID1, }, @@ -111,7 +111,7 @@ func TestSettleBet(t *testing.T) { bet: &types.Bet{ MarketUID: testMarketUID, OddsValue: "10", - Amount: sdk.NewInt(1000000), + Amount: sdkmath.NewInt(1000000), Creator: testCreator, OddsUID: testOddsUID1, }, @@ -131,7 +131,7 @@ func TestSettleBet(t *testing.T) { bet: &types.Bet{ MarketUID: testMarketUID, OddsValue: "10", - Amount: sdk.NewInt(1000000), + Amount: sdkmath.NewInt(1000000), Creator: testCreator, OddsUID: testOddsUID1, diff --git a/x/bet/types/params.go b/x/bet/types/params.go index c85b69d6..2fd04c27 100644 --- a/x/bet/types/params.go +++ b/x/bet/types/params.go @@ -6,7 +6,6 @@ import ( "gopkg.in/yaml.v2" sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) @@ -134,11 +133,11 @@ func validateConstraints(i interface{}) error { return fmt.Errorf("%s: %T", ErrTextInvalidParamType, i) } - if v.MinAmount.LTE(sdk.OneInt()) { + if v.MinAmount.LTE(sdkmath.OneInt()) { return fmt.Errorf("minimum bet amount must be more than one: %d", v.MinAmount.Int64()) } - if v.Fee.LT(sdk.ZeroInt()) { + if v.Fee.LT(sdkmath.ZeroInt()) { return fmt.Errorf("minimum bet fee must be positive: %d", v.Fee.Int64()) } diff --git a/x/house/keeper/deposit.go b/x/house/keeper/deposit.go index 28246c99..7fbdbf27 100644 --- a/x/house/keeper/deposit.go +++ b/x/house/keeper/deposit.go @@ -58,7 +58,7 @@ func (k Keeper) Deposit(ctx sdk.Context, creator, depositor string, marketUID string, amount sdkmath.Int, ) (participationIndex uint64, feeAmount sdkmath.Int, err error) { // Create the deposit object - deposit := types.NewDeposit(creator, depositor, marketUID, amount, sdk.ZeroInt(), 0) + deposit := types.NewDeposit(creator, depositor, marketUID, amount, sdkmath.ZeroInt(), 0) feeAmount = deposit.CalcHouseParticipationFeeAmount(k.GetHouseParticipationFee(ctx)) diff --git a/x/house/types/deposit_authorizaton.go b/x/house/types/deposit_authorizaton.go index f67e413b..5944b592 100644 --- a/x/house/types/deposit_authorizaton.go +++ b/x/house/types/deposit_authorizaton.go @@ -50,7 +50,7 @@ func (a DepositAuthorization) ValidateBasic() error { if a.SpendLimit.IsNil() { return sdkerrtypes.ErrInvalidCoins.Wrap("spend limit cannot be nil") } - if a.SpendLimit.LTE(sdk.ZeroInt()) { + if a.SpendLimit.LTE(sdkmath.ZeroInt()) { return sdkerrtypes.ErrInvalidCoins.Wrap("spend limit cannot be less than or equal to zero") } if a.SpendLimit.LT(minDepositGrant) { diff --git a/x/house/types/message_deposit_test.go b/x/house/types/message_deposit_test.go index ea1e5aef..b5604ea9 100644 --- a/x/house/types/message_deposit_test.go +++ b/x/house/types/message_deposit_test.go @@ -7,7 +7,6 @@ import ( "github.com/stretchr/testify/require" sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrtypes "github.com/cosmos/cosmos-sdk/types/errors" "github.com/sge-network/sge/testutil/sample" @@ -49,7 +48,7 @@ func TestMsgDepositValidateBasic(t *testing.T) { msg: types.MsgDeposit{ Creator: sample.AccAddress(), MarketUID: uuid.NewString(), - Amount: sdk.ZeroInt(), + Amount: sdkmath.ZeroInt(), Ticket: "Ticket", }, err: sdkerrtypes.ErrInvalidRequest, @@ -76,7 +75,7 @@ func TestNewDeposit(t *testing.T) { Amount: sdkmath.NewInt(100), ParticipationIndex: 0, WithdrawalCount: 0, - TotalWithdrawalAmount: sdk.ZeroInt(), + TotalWithdrawalAmount: sdkmath.ZeroInt(), } res := types.NewDeposit( expected.Creator, diff --git a/x/house/types/params.go b/x/house/types/params.go index b09a916d..13af8dd0 100644 --- a/x/house/types/params.go +++ b/x/house/types/params.go @@ -97,7 +97,7 @@ func validateMinimumDeposit(i interface{}) error { return fmt.Errorf("invalid parameter type: %T", i) } - if v.LTE(sdk.OneInt()) { + if v.LTE(sdkmath.OneInt()) { return fmt.Errorf("minimum deposit must be positive and more than one: %d", v) } diff --git a/x/house/types/withdraw_authorizaton.go b/x/house/types/withdraw_authorizaton.go index 0fb4d5ac..2cfc7f67 100644 --- a/x/house/types/withdraw_authorizaton.go +++ b/x/house/types/withdraw_authorizaton.go @@ -50,7 +50,7 @@ func (a WithdrawAuthorization) ValidateBasic() error { if a.WithdrawLimit.IsNil() { return sdkerrtypes.ErrInvalidCoins.Wrap("withdraw limit cannot be nil") } - if a.WithdrawLimit.LTE(sdk.ZeroInt()) { + if a.WithdrawLimit.LTE(sdkmath.ZeroInt()) { return sdkerrtypes.ErrInvalidCoins.Wrap("withdraw limit cannot be less than or equal to zero") } if a.WithdrawLimit.GT(maxWithdrawGrant) { diff --git a/x/mint/simulation/genesis_test.go b/x/mint/simulation/genesis_test.go index 61bd123d..5cb12aa9 100644 --- a/x/mint/simulation/genesis_test.go +++ b/x/mint/simulation/genesis_test.go @@ -11,7 +11,6 @@ import ( sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -57,7 +56,7 @@ func TestRandomizedGenState(t *testing.T) { require.Equal( t, "0.000000000000000000", - mintGenesis.Minter.NextPhaseProvisions(sdk.OneInt(), types.DefaultExcludeAmount, types.NonePhase()). + mintGenesis.Minter.NextPhaseProvisions(sdkmath.OneInt(), types.DefaultExcludeAmount, types.NonePhase()). String(), ) require.Equal(t, "0.229787234042553191", params.GetPhaseAtStep(1).Inflation.String()) diff --git a/x/mint/types/params.go b/x/mint/types/params.go index 2d0a546f..2fac608d 100644 --- a/x/mint/types/params.go +++ b/x/mint/types/params.go @@ -245,7 +245,7 @@ func validateExcludeAmount(i interface{}) error { return fmt.Errorf(ErrTextInvalidParamType, i) } - if v.LT(sdk.ZeroInt()) { + if v.LT(sdkmath.ZeroInt()) { return fmt.Errorf(ErrTextExcludeAmountMustBePositive, v) } diff --git a/x/orderbook/keeper/bet_wager.go b/x/orderbook/keeper/bet_wager.go index a287e83f..195a9928 100644 --- a/x/orderbook/keeper/bet_wager.go +++ b/x/orderbook/keeper/bet_wager.go @@ -84,7 +84,7 @@ func (k Keeper) fulfillBetByParticipationQueue( // the decimal amount that is being lost in the bet amount calculation from payout profit truncatedBetAmount := sdk.NewDec(0) - requeThreshold := sdk.NewIntFromUint64(k.GetRequeueThreshold(ctx)) + requeThreshold := sdkmath.NewIntFromUint64(k.GetRequeueThreshold(ctx)) // continue until updatedFulfillmentQueue gets empty for fInfo.hasUnfulfilledQueueItem() { var err error @@ -464,7 +464,7 @@ func (fInfo *fulfillmentInfo) checkFullfillmentForOtherOdds(requeThreshold sdkma // availableLiquidity is the available amount of tokens to be used from the participation exposure fInfo.secondaryProcessItem.setAvailableLiquidity(betOdd.MaxLossMultiplier) - if fInfo.secondaryProcessItem.isLiquidityLessThanThreshold(requeThreshold, sdk.ZeroInt()) { + if fInfo.secondaryProcessItem.isLiquidityLessThanThreshold(requeThreshold, sdkmath.ZeroInt()) { fInfo.inProcessItem.setFulfilledSecondary(&fInfo.secondaryProcessItem) eUpdate = append(eUpdate, fInfo.secondaryProcessItem.participationExposure) } @@ -513,7 +513,7 @@ func (fItem *fulfillmentItem) isLiquidityLessThanThreshold(threshold, adjAmount } func (fItem *fulfillmentItem) noLiquidityAvailable() bool { - return fItem.availableLiquidity.LTE(sdk.ZeroInt()) + return fItem.availableLiquidity.LTE(sdkmath.ZeroInt()) } func (fItem *fulfillmentItem) setFulfilled() { diff --git a/x/orderbook/keeper/bet_wager_test.go b/x/orderbook/keeper/bet_wager_test.go index 68b6d80d..562619bb 100644 --- a/x/orderbook/keeper/bet_wager_test.go +++ b/x/orderbook/keeper/bet_wager_test.go @@ -465,7 +465,7 @@ func (ts *testBetSuite) bulkDepositPlaceBetsAndTest() { OddsUID: ts.market.Odds[1].UID, OddsValue: "4.415", Amount: betAmount, - Fee: sdk.ZeroInt(), + Fee: sdkmath.ZeroInt(), Status: bettypes.Bet_STATUS_PENDING, Creator: bettorAddr.String(), CreatedAt: cast.ToInt64(ts.ctx.BlockTime().Unix()), diff --git a/x/orderbook/keeper/exposure_odds.go b/x/orderbook/keeper/exposure_odds.go index 9feff83f..afa2c48b 100644 --- a/x/orderbook/keeper/exposure_odds.go +++ b/x/orderbook/keeper/exposure_odds.go @@ -1,6 +1,7 @@ package keeper import ( + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sge-network/sge/x/orderbook/types" @@ -92,8 +93,8 @@ func (k Keeper) initParticipationExposures( pe := types.NewParticipationExposure( orderBookUID, boe.OddsUID, - sdk.ZeroInt(), - sdk.ZeroInt(), + sdkmath.ZeroInt(), + sdkmath.ZeroInt(), participationIndex, 1, false, diff --git a/x/orderbook/keeper/participation.go b/x/orderbook/keeper/participation.go index 310f2d5c..94278b98 100644 --- a/x/orderbook/keeper/participation.go +++ b/x/orderbook/keeper/participation.go @@ -132,7 +132,7 @@ func (k Keeper) InitiateOrderBookParticipation( index, book.UID, addr.String(), book.OddsCount, // all odds need to be filled in the next steps liquidity, feeAmount, liquidity, // int the start, liquidity and current round liquidity are the same - sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroInt(), sdkmath.Int{}, "", sdk.ZeroInt(), + sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkmath.ZeroInt(), sdkmath.Int{}, "", sdkmath.ZeroInt(), ) // fund order book liquidity pool from participant's account. diff --git a/x/orderbook/keeper/participation_test.go b/x/orderbook/keeper/participation_test.go index 62166488..bbe6f345 100644 --- a/x/orderbook/keeper/participation_test.go +++ b/x/orderbook/keeper/participation_test.go @@ -217,7 +217,7 @@ func TestWithdrawOrderBookParticipation(t *testing.T) { { desc: "no participation", depositorAddr: simapp.TestParamUsers["user1"].Address, - depositAmount: sdk.ZeroInt(), + depositAmount: sdkmath.ZeroInt(), withdrawMode: housetypes.WithdrawalMode_WITHDRAWAL_MODE_FULL, err: types.ErrOrderBookParticipationNotFound, }, @@ -266,7 +266,7 @@ func TestWithdrawOrderBookParticipation(t *testing.T) { marketUID, participationIndex, tc.withdrawMode, - sdk.ZeroInt(), + sdkmath.ZeroInt(), tc.depositAmount, ) diff --git a/x/orderbook/types/exposure.go b/x/orderbook/types/exposure.go index 1ab973f9..24c2a000 100644 --- a/x/orderbook/types/exposure.go +++ b/x/orderbook/types/exposure.go @@ -4,7 +4,6 @@ import ( yaml "gopkg.in/yaml.v2" sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" ) // NewOrderBookOddsExposure creates a new book odds exposure object @@ -55,8 +54,8 @@ func (pe ParticipationExposure) NextRound() ParticipationExposure { return NewParticipationExposure( pe.OrderBookUID, pe.OddsUID, - sdk.ZeroInt(), - sdk.ZeroInt(), + sdkmath.ZeroInt(), + sdkmath.ZeroInt(), pe.ParticipationIndex, pe.Round+1, false, diff --git a/x/orderbook/types/participation.go b/x/orderbook/types/participation.go index 14a2dffe..04b97d34 100644 --- a/x/orderbook/types/participation.go +++ b/x/orderbook/types/participation.go @@ -78,7 +78,7 @@ func (p *OrderBookParticipation) ValidateWithdraw( // maxWithdrawalAmount returns the max withdrawal amount of a participation. func (p *OrderBookParticipation) maxWithdrawalAmount() sdkmath.Int { - if p.CurrentRoundMaxLoss.LT(sdk.ZeroInt()) { + if p.CurrentRoundMaxLoss.LT(sdkmath.ZeroInt()) { return p.CurrentRoundLiquidity } return p.CurrentRoundLiquidity.Sub(p.CurrentRoundMaxLoss) @@ -86,7 +86,7 @@ func (p *OrderBookParticipation) maxWithdrawalAmount() sdkmath.Int { // IsLiquidityInCurrentRound determines if the participation has liquidity in current round. func (p *OrderBookParticipation) IsLiquidityInCurrentRound() bool { - return p.CurrentRoundLiquidity.GT(sdk.ZeroInt()) + return p.CurrentRoundLiquidity.GT(sdkmath.ZeroInt()) } // WithdrawableAmount returns the withdrawal amount according to the withdrawal mode and max withdrawable amount. @@ -100,7 +100,7 @@ func (p *OrderBookParticipation) WithdrawableAmount( var withdrawalAmt sdkmath.Int switch mode { case housetypes.WithdrawalMode_WITHDRAWAL_MODE_FULL: - if maxTransferableAmount.LTE(sdk.ZeroInt()) { + if maxTransferableAmount.LTE(sdkmath.ZeroInt()) { return sdkmath.Int{}, sdkerrors.Wrapf( ErrMaxWithdrawableAmountIsZero, "%d, %d", @@ -135,25 +135,25 @@ func (p *OrderBookParticipation) SetLiquidityAfterWithdrawal(withdrawalAmt sdkma // NotParticipatedInBetFulfillment determines if the participation has // participated in the bet fulfillment. func (p *OrderBookParticipation) NotParticipatedInBetFulfillment() bool { - return p.TotalBetAmount.Equal(sdk.ZeroInt()) + return p.TotalBetAmount.Equal(sdkmath.ZeroInt()) } // IsEligibleForNextRound determines if the participation has enough // liquidity to be used in the next round or not func (p *OrderBookParticipation) IsEligibleForNextRound() bool { - return p.CurrentRoundLiquidity.GT(sdk.ZeroInt()) + return p.CurrentRoundLiquidity.GT(sdkmath.ZeroInt()) } // IsEligibleForNextRound determines if the participation has enough // liquidity to be used in the next round or not func (p *OrderBookParticipation) IsEligibleForNextRoundPreLiquidityReduction() bool { - maxLoss := sdk.MaxInt(sdk.ZeroInt(), p.CurrentRoundMaxLoss) - return p.CurrentRoundLiquidity.Sub(maxLoss).GT(sdk.ZeroInt()) + maxLoss := sdk.MaxInt(sdkmath.ZeroInt(), p.CurrentRoundMaxLoss) + return p.CurrentRoundLiquidity.Sub(maxLoss).GT(sdkmath.ZeroInt()) } // TrimCurrentRoundLiquidity subtracts the max loss from the current round liquidity. func (p *OrderBookParticipation) TrimCurrentRoundLiquidity() { - maxLoss := sdk.MaxInt(sdk.ZeroInt(), p.CurrentRoundMaxLoss) + maxLoss := sdk.MaxInt(sdkmath.ZeroInt(), p.CurrentRoundMaxLoss) p.CurrentRoundLiquidity = p.CurrentRoundLiquidity.Sub(maxLoss) } @@ -163,8 +163,8 @@ func (p *OrderBookParticipation) ResetForNextRound(notFilledExposures uint64) { // prepare participation for the next round p.ExposuresNotFilled = notFilledExposures p.MaxLoss = p.MaxLoss.Add(p.CurrentRoundMaxLoss) - p.CurrentRoundTotalBetAmount = sdk.ZeroInt() - p.CurrentRoundMaxLoss = sdk.ZeroInt() + p.CurrentRoundTotalBetAmount = sdkmath.ZeroInt() + p.CurrentRoundMaxLoss = sdkmath.ZeroInt() } // SetCurrentRound sets the current round total bet amount and max loss. diff --git a/x/reward/keeper/campaign_test.go b/x/reward/keeper/campaign_test.go index 12b5926b..075b811c 100644 --- a/x/reward/keeper/campaign_test.go +++ b/x/reward/keeper/campaign_test.go @@ -33,7 +33,7 @@ func createNCampaign(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.Camp items[i].RewardAmountType = types.RewardAmountType_REWARD_AMOUNT_TYPE_FIXED items[i].IsActive = true items[i].Meta = "campaign " + items[i].UID - items[i].Pool = types.Pool{Spent: sdk.ZeroInt(), Withdrawn: sdk.ZeroInt(), Total: sdkmath.NewInt(100)} + items[i].Pool = types.Pool{Spent: sdkmath.ZeroInt(), Withdrawn: sdkmath.ZeroInt(), Total: sdkmath.NewInt(100)} keeper.SetCampaign(ctx, items[i]) } diff --git a/x/reward/keeper/distribution.go b/x/reward/keeper/distribution.go index e61d1360..3010401e 100644 --- a/x/reward/keeper/distribution.go +++ b/x/reward/keeper/distribution.go @@ -2,6 +2,7 @@ package keeper import ( sdkerrors "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/cast" @@ -12,7 +13,7 @@ import ( // DistributeRewards distributes the rewards according to the input distribution list. func (k Keeper) DistributeRewards(ctx sdk.Context, receiver types.Receiver) (uint64, error) { unlockTS := uint64(0) - if receiver.RewardAmount.SubaccountAmount.GT(sdk.ZeroInt()) { + if receiver.RewardAmount.SubaccountAmount.GT(sdkmath.ZeroInt()) { moduleAccAddr := types.RewardPoolFunder{}.GetModuleAcc() unlockTS = cast.ToUint64(ctx.BlockTime().Unix()) + receiver.RewardAmount.UnlockPeriod if _, err := k.subaccountKeeper.TopUp(ctx, k.accountKeeper.GetModuleAddress(moduleAccAddr).String(), receiver.MainAccountAddr, @@ -25,7 +26,7 @@ func (k Keeper) DistributeRewards(ctx sdk.Context, receiver types.Receiver) (uin return unlockTS, sdkerrors.Wrapf(types.ErrSubaccountRewardTopUp, "subaccount address %s, %s", receiver.SubaccountAddr, err) } } - if receiver.RewardAmount.MainAccountAmount.GT(sdk.ZeroInt()) { + if receiver.RewardAmount.MainAccountAmount.GT(sdkmath.ZeroInt()) { if err := k.modFunder.Refund( types.RewardPoolFunder{}, ctx, sdk.MustAccAddressFromBech32(receiver.MainAccountAddr), diff --git a/x/reward/keeper/msg_server_reward_test.go b/x/reward/keeper/msg_server_reward_test.go index f2e4a398..36630b4a 100644 --- a/x/reward/keeper/msg_server_reward_test.go +++ b/x/reward/keeper/msg_server_reward_test.go @@ -88,7 +88,7 @@ func TestMsgApplySignupReward(t *testing.T) { _, err := tApp.SubaccountKeeper.CreateSubaccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ { - Amount: sdk.ZeroInt(), + Amount: sdkmath.ZeroInt(), UnlockTS: uint64(ctx.BlockTime().Add(60 * time.Minute).Unix()), }, }) @@ -165,7 +165,7 @@ func TestMsgApplySignupRewardWithCap(t *testing.T) { _, err := tApp.SubaccountKeeper.CreateSubaccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ { - Amount: sdk.ZeroInt(), + Amount: sdkmath.ZeroInt(), UnlockTS: uint64(ctx.BlockTime().Add(60 * time.Minute).Unix()), }, }) @@ -223,7 +223,7 @@ func TestMsgApplySignupRefereeReward(t *testing.T) { _, err := tApp.SubaccountKeeper.CreateSubaccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ { - Amount: sdk.ZeroInt(), + Amount: sdkmath.ZeroInt(), UnlockTS: uint64(ctx.BlockTime().Add(60 * time.Minute).Unix()), }, }) @@ -316,7 +316,7 @@ func TestMsgApplySignupReferrerReward(t *testing.T) { _, err := tApp.SubaccountKeeper.CreateSubaccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ { - Amount: sdk.ZeroInt(), + Amount: sdkmath.ZeroInt(), UnlockTS: uint64(ctx.BlockTime().Add(60 * time.Minute).Unix()), }, }) @@ -455,7 +455,7 @@ func TestMsgApplySignupAffiliateReward(t *testing.T) { _, err := tApp.SubaccountKeeper.CreateSubaccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ { - Amount: sdk.ZeroInt(), + Amount: sdkmath.ZeroInt(), UnlockTS: uint64(ctx.BlockTime().Add(60 * time.Minute).Unix()), }, }) @@ -548,7 +548,7 @@ func TestMsgApplySignupAffiliateeReward(t *testing.T) { _, err := tApp.SubaccountKeeper.CreateSubaccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ { - Amount: sdk.ZeroInt(), + Amount: sdkmath.ZeroInt(), UnlockTS: uint64(ctx.BlockTime().Add(60 * time.Minute).Unix()), }, }) @@ -698,7 +698,7 @@ func TestMsgApplyBetBonus(t *testing.T) { _, err := tApp.SubaccountKeeper.CreateSubaccount(ctx, bettor, bettor, []subaccounttypes.LockedBalance{ { - Amount: sdk.ZeroInt(), + Amount: sdkmath.ZeroInt(), UnlockTS: uint64(ctx.BlockTime().Add(60 * time.Minute).Unix()), }, }) @@ -839,7 +839,7 @@ func TestMsgApplySignupRewardSubaccount(t *testing.T) { _, err := tApp.SubaccountKeeper.CreateSubaccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ { - Amount: sdk.ZeroInt(), + Amount: sdkmath.ZeroInt(), UnlockTS: uint64(ctx.BlockTime().Add(60 * time.Minute).Unix()), }, }) diff --git a/x/reward/keeper/reward.go b/x/reward/keeper/reward.go index 28473a72..2eee883a 100644 --- a/x/reward/keeper/reward.go +++ b/x/reward/keeper/reward.go @@ -54,12 +54,33 @@ func (k Keeper) GetAllRewards(ctx sdk.Context) (list []types.Reward) { return } +// GetAllRewardsOfReceiverByPromoterAndCategory returns all reward by promoter and category +func (k Keeper) GetAllRewardsOfReceiverByPromoterAndCategory(ctx sdk.Context) (list []types.RewardByCategory) { + store := k.getRewardByReceiverAndCategoryStore(ctx) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.RewardByCategory + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + func (k Keeper) SetRewardOfReceiverByPromoterAndCategory(ctx sdk.Context, promoterUID string, rByCategory types.RewardByCategory) { store := k.getRewardByReceiverAndCategoryStore(ctx) b := k.cdc.MustMarshal(&rByCategory) store.Set(types.GetRewardsOfReceiverByPromoterAndCategoryKey(promoterUID, rByCategory.Addr, rByCategory.RewardCategory, rByCategory.UID), b) } +func (k Keeper) RemoveRewardOfReceiverByPromoterAndCategory(ctx sdk.Context, promoterUID string, rByCategory types.RewardByCategory) { + store := k.getRewardByReceiverAndCategoryStore(ctx) + store.Delete(types.GetRewardsOfReceiverByPromoterAndCategoryKey(promoterUID, rByCategory.Addr, rByCategory.RewardCategory, rByCategory.UID)) +} + // GetRewardsOfReceiverByPromoterAndCategory returns all rewards by address and category. func (k Keeper) GetRewardsOfReceiverByPromoterAndCategory( ctx sdk.Context, diff --git a/x/reward/types/campaign_authorizaton.go b/x/reward/types/campaign_authorizaton.go index e3c47a19..c7743b4b 100644 --- a/x/reward/types/campaign_authorizaton.go +++ b/x/reward/types/campaign_authorizaton.go @@ -54,7 +54,7 @@ func (a CreateCampaignAuthorization) ValidateBasic() error { if a.SpendLimit.IsNil() { return sdkerrtypes.ErrInvalidCoins.Wrap("spend limit cannot be nil") } - if a.SpendLimit.LTE(sdk.ZeroInt()) { + if a.SpendLimit.LTE(sdkmath.ZeroInt()) { return sdkerrtypes.ErrInvalidCoins.Wrap("spend limit cannot be less than or equal to zero") } @@ -110,7 +110,7 @@ func (a UpdateCampaignAuthorization) ValidateBasic() error { if a.SpendLimit.IsNil() { return sdkerrtypes.ErrInvalidCoins.Wrap("spend limit cannot be nil") } - if a.SpendLimit.LTE(sdk.ZeroInt()) { + if a.SpendLimit.LTE(sdkmath.ZeroInt()) { return sdkerrtypes.ErrInvalidCoins.Wrap("spend limit cannot be less than or equal to zero") } @@ -164,7 +164,7 @@ func (a WithdrawCampaignAuthorization) ValidateBasic() error { if a.WithdrawLimit.IsNil() { return sdkerrtypes.ErrInvalidCoins.Wrap("withdraw limit cannot be nil") } - if a.WithdrawLimit.LTE(sdk.ZeroInt()) { + if a.WithdrawLimit.LTE(sdkmath.ZeroInt()) { return sdkerrtypes.ErrInvalidCoins.Wrap("withdraw limit cannot be less than or equal to zero") } if a.WithdrawLimit.GT(maxWithdrawGrant) { diff --git a/x/subaccount/genesis_test.go b/x/subaccount/genesis_test.go index 66e64e02..79b4fc17 100644 --- a/x/subaccount/genesis_test.go +++ b/x/subaccount/genesis_test.go @@ -7,7 +7,6 @@ import ( "github.com/stretchr/testify/require" sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sge-network/sge/testutil/sample" "github.com/sge-network/sge/testutil/simapp" @@ -36,9 +35,9 @@ func TestGenesis(t *testing.T) { Owner: subAccOwner.String(), Balance: types.AccountSummary{ DepositedAmount: subAccFunds, - SpentAmount: sdk.ZeroInt(), - WithdrawnAmount: sdk.ZeroInt(), - LostAmount: sdk.ZeroInt(), + SpentAmount: sdkmath.ZeroInt(), + WithdrawnAmount: sdkmath.ZeroInt(), + LostAmount: sdkmath.ZeroInt(), }, LockedBalances: []types.LockedBalance{ { diff --git a/x/subaccount/keeper/msg_server_bet_test.go b/x/subaccount/keeper/msg_server_bet_test.go index e3b75b1f..26db5ebf 100644 --- a/x/subaccount/keeper/msg_server_bet_test.go +++ b/x/subaccount/keeper/msg_server_bet_test.go @@ -165,8 +165,8 @@ func TestMsgServer_Bet(t *testing.T) { // now we check the subaccount balance balance, exists := k.GetAccountSummary(ctx, subAccAddr) require.True(t, exists) - require.Equal(t, sdk.ZeroInt(), balance.SpentAmount) - require.Equal(t, sdk.ZeroInt(), balance.LostAmount) + require.Equal(t, sdkmath.ZeroInt(), balance.SpentAmount) + require.Equal(t, sdkmath.ZeroInt(), balance.LostAmount) require.Equal(t, halfBetAmt, balance.WithdrawnAmount) // the owner has no balances ownerBalance := app.BankKeeper.GetBalance(ctx, subAccOwner, params.DefaultBondDenom).Amount @@ -190,7 +190,7 @@ func TestMsgServer_Bet(t *testing.T) { // now we check the subaccount balance balance, exists := k.GetAccountSummary(ctx, subAccAddr) require.True(t, exists) - require.Equal(t, balance.SpentAmount, sdk.ZeroInt()) + require.Equal(t, balance.SpentAmount, sdkmath.ZeroInt()) ownerBalance := app.BankKeeper.GetBalance(ctx, subAccOwner, params.DefaultBondDenom).Amount diff --git a/x/subaccount/keeper/msg_server_house_test.go b/x/subaccount/keeper/msg_server_house_test.go index 1623c88f..88091c7d 100644 --- a/x/subaccount/keeper/msg_server_house_test.go +++ b/x/subaccount/keeper/msg_server_house_test.go @@ -109,7 +109,7 @@ func TestMsgServer(t *testing.T) { require.True(t, exists) require.NoError(t, err) - require.Equal(t, subBalance.SpentAmount.String(), sdk.ZeroInt().Add(participateFee).String()) + require.Equal(t, subBalance.SpentAmount.String(), sdkmath.ZeroInt().Add(participateFee).String()) // check profits were forwarded to subacc owner ownerBalance := app.BankKeeper.GetAllBalances(ctx, subAccOwner) require.Equal(t, @@ -134,11 +134,11 @@ func TestMsgServer(t *testing.T) { require.True(t, exists) require.NoError(t, err) - require.Equal(t, subBalance.SpentAmount.String(), sdk.ZeroInt().Add(participateFee).String()) + require.Equal(t, subBalance.SpentAmount.String(), sdkmath.ZeroInt().Add(participateFee).String()) require.Equal(t, subBalance.LostAmount, sdk.NewDecFromInt(bettor1Funds.Sub(bettorFee)).Mul(sdk.MustNewDecFromStr("3.2")).TruncateInt()) // check profits were forwarded to subacc owner ownerBalance := app.BankKeeper.GetAllBalances(ctx, subAccOwner) - require.Equal(t, ownerBalance.AmountOf(params.DefaultBondDenom), sdk.ZeroInt()) + require.Equal(t, ownerBalance.AmountOf(params.DefaultBondDenom), sdkmath.ZeroInt()) }) t.Run("house refund", func(t *testing.T) { ctx, _ := ctx.CacheContext() @@ -157,11 +157,11 @@ func TestMsgServer(t *testing.T) { require.True(t, exists) require.NoError(t, err) - require.Equal(t, subBalance.SpentAmount, sdk.ZeroInt()) - require.Equal(t, subBalance.LostAmount, sdk.ZeroInt()) + require.Equal(t, subBalance.SpentAmount, sdkmath.ZeroInt()) + require.Equal(t, subBalance.LostAmount, sdkmath.ZeroInt()) // check profits were forwarded to subacc owner ownerBalance := app.BankKeeper.GetAllBalances(ctx, subAccOwner) - require.Equal(t, ownerBalance.AmountOf(params.DefaultBondDenom), sdk.ZeroInt()) + require.Equal(t, ownerBalance.AmountOf(params.DefaultBondDenom), sdkmath.ZeroInt()) }) // TODO: not participated in bet fulfillment. @@ -176,7 +176,7 @@ func TestMsgServer(t *testing.T) { require.True(t, exists) require.Equal(t, subBalance.SpentAmount.String(), sdkmath.NewInt(131999680).String()) // NOTE: there was a match in the bet + participate fee - require.Equal(t, subBalance.LostAmount.String(), sdk.ZeroInt().String()) + require.Equal(t, subBalance.LostAmount.String(), sdkmath.ZeroInt().String()) }) t.Run("withdrawal and market refund with bet fulfillment", func(t *testing.T) { @@ -200,11 +200,11 @@ func TestMsgServer(t *testing.T) { require.True(t, exists) require.NoError(t, err) - require.Equal(t, subBalance.SpentAmount, sdk.ZeroInt()) - require.Equal(t, subBalance.LostAmount, sdk.ZeroInt()) + require.Equal(t, subBalance.SpentAmount, sdkmath.ZeroInt()) + require.Equal(t, subBalance.LostAmount, sdkmath.ZeroInt()) // check profits were forwarded to subacc owner ownerBalance := app.BankKeeper.GetAllBalances(ctx, subAccOwner) - require.Equal(t, ownerBalance.AmountOf(params.DefaultBondDenom), sdk.ZeroInt()) + require.Equal(t, ownerBalance.AmountOf(params.DefaultBondDenom), sdkmath.ZeroInt()) }) } @@ -271,7 +271,7 @@ func TestHouseWithdrawal_MarketRefund(t *testing.T) { subBalance, exists = k.GetAccountSummary(ctx, subAccAddr) require.True(t, exists) require.Equal(t, subBalance.SpentAmount, sdkmath.NewInt(100).Mul(micro)) // all minus participation fee - require.Equal(t, subBalance.LostAmount, sdk.ZeroInt()) + require.Equal(t, subBalance.LostAmount, sdkmath.ZeroInt()) require.Equal(t, subBalance.DepositedAmount, subAccFunds) subBankBalance := app.BankKeeper.GetAllBalances(ctx, subAccAddr) require.Equal(t, subBankBalance.AmountOf(params.DefaultBondDenom), subAccFunds.Sub(sdkmath.NewInt(100).Mul(micro))) // original funds - fee @@ -292,13 +292,13 @@ func TestHouseWithdrawal_MarketRefund(t *testing.T) { require.True(t, exists) require.NoError(t, err) - require.Equal(t, subBalance.SpentAmount, sdk.ZeroInt()) - require.Equal(t, subBalance.LostAmount, sdk.ZeroInt()) + require.Equal(t, subBalance.SpentAmount, sdkmath.ZeroInt()) + require.Equal(t, subBalance.LostAmount, sdkmath.ZeroInt()) subBankBalance = app.BankKeeper.GetAllBalances(ctx, subAccAddr) require.Equal(t, subBankBalance.AmountOf(params.DefaultBondDenom), subAccFunds) // original funds - fee was refunded // check profits were not forwarded to subacc owner ownerBalance := app.BankKeeper.GetAllBalances(ctx, subAccOwner) - require.Equal(t, ownerBalance.AmountOf(params.DefaultBondDenom), sdk.ZeroInt()) + require.Equal(t, ownerBalance.AmountOf(params.DefaultBondDenom), sdkmath.ZeroInt()) } func houseWithdrawMsg(t testing.TB, owner sdk.AccAddress, amt sdkmath.Int, partecipationIndex uint64) *housetypes.MsgWithdraw { diff --git a/x/subaccount/keeper/msg_server_subaccount_test.go b/x/subaccount/keeper/msg_server_subaccount_test.go index 244d24ad..41858487 100644 --- a/x/subaccount/keeper/msg_server_subaccount_test.go +++ b/x/subaccount/keeper/msg_server_subaccount_test.go @@ -64,9 +64,9 @@ func TestMsgServer_Create(t *testing.T) { // get the balance of the account subaccountBalance, exists := app.SubaccountKeeper.GetAccountSummary(ctx, types.NewAddressFromSubaccount(1)) require.True(t, exists) - require.Equal(t, sdk.ZeroInt(), subaccountBalance.SpentAmount) - require.Equal(t, sdk.ZeroInt(), subaccountBalance.LostAmount) - require.Equal(t, sdk.ZeroInt(), subaccountBalance.WithdrawnAmount) + require.Equal(t, sdkmath.ZeroInt(), subaccountBalance.SpentAmount) + require.Equal(t, sdkmath.ZeroInt(), subaccountBalance.LostAmount) + require.Equal(t, sdkmath.ZeroInt(), subaccountBalance.WithdrawnAmount) require.Equal(t, sdkmath.NewInt(123), subaccountBalance.DepositedAmount) } diff --git a/x/subaccount/keeper/query_server_test.go b/x/subaccount/keeper/query_server_test.go index bdaa16f4..118b577f 100644 --- a/x/subaccount/keeper/query_server_test.go +++ b/x/subaccount/keeper/query_server_test.go @@ -4,6 +4,7 @@ import ( "testing" "time" + sdkmath "cosmossdk.io/math" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" @@ -62,9 +63,9 @@ func TestQueryServer(t *testing.T) { require.Equal(t, subAccAddr.String(), gotSubaccount.Address) require.Equal(t, types.AccountSummary{ DepositedAmount: subAccFunds, - SpentAmount: sdk.ZeroInt(), - WithdrawnAmount: sdk.ZeroInt(), - LostAmount: sdk.ZeroInt(), + SpentAmount: sdkmath.ZeroInt(), + WithdrawnAmount: sdkmath.ZeroInt(), + LostAmount: sdkmath.ZeroInt(), }, gotSubaccount.Balance) require.Len(t, gotSubaccount.LockedBalance, 1) require.Equal(t, subAccFunds, gotSubaccount.LockedBalance[0].Amount) diff --git a/x/subaccount/keeper/subaccount.go b/x/subaccount/keeper/subaccount.go index a863261c..0df03653 100644 --- a/x/subaccount/keeper/subaccount.go +++ b/x/subaccount/keeper/subaccount.go @@ -123,9 +123,9 @@ func (k Keeper) CreateSubaccount(ctx sdk.Context, creator, owner string, k.SetLockedBalances(ctx, subAccAddr, lockedBalances) k.SetAccountSummary(ctx, subAccAddr, types.AccountSummary{ DepositedAmount: lockedBalance, - SpentAmount: sdk.ZeroInt(), - WithdrawnAmount: sdk.ZeroInt(), - LostAmount: sdk.ZeroInt(), + SpentAmount: sdkmath.ZeroInt(), + WithdrawnAmount: sdkmath.ZeroInt(), + LostAmount: sdkmath.ZeroInt(), }) return subAccAddr.String(), nil } diff --git a/x/subaccount/keeper/subaccount_test.go b/x/subaccount/keeper/subaccount_test.go index 7c670367..73900e66 100644 --- a/x/subaccount/keeper/subaccount_test.go +++ b/x/subaccount/keeper/subaccount_test.go @@ -7,7 +7,6 @@ import ( "github.com/stretchr/testify/require" sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sge-network/sge/testutil/sample" "github.com/sge-network/sge/x/subaccount/types" @@ -93,10 +92,10 @@ func TestSetBalances(t *testing.T) { _, k, ctx := setupKeeperAndApp(t) balance := types.AccountSummary{ - DepositedAmount: sdk.ZeroInt(), - SpentAmount: sdk.ZeroInt(), - WithdrawnAmount: sdk.ZeroInt(), - LostAmount: sdk.OneInt(), + DepositedAmount: sdkmath.ZeroInt(), + SpentAmount: sdkmath.ZeroInt(), + WithdrawnAmount: sdkmath.ZeroInt(), + LostAmount: sdkmath.OneInt(), } subAccAddr := types.NewAddressFromSubaccount(1)