diff --git a/go.mod b/go.mod index a205b75d35..c11bb0b3a2 100644 --- a/go.mod +++ b/go.mod @@ -269,7 +269,7 @@ require ( replace ( github.com/CosmWasm/wasmd => github.com/sei-protocol/sei-wasmd v0.0.1 github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.2.13 + github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.2.14 github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.1.3 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 diff --git a/go.sum b/go.sum index 6944d070a1..41a56af6d4 100644 --- a/go.sum +++ b/go.sum @@ -1067,8 +1067,8 @@ github.com/seccomp/libseccomp-golang v0.9.2-0.20210429002308-3879420cc921/go.mod github.com/securego/gosec/v2 v2.11.0 h1:+PDkpzR41OI2jrw1q6AdXZCbsNGNGT7pQjal0H0cArI= github.com/securego/gosec/v2 v2.11.0/go.mod h1:SX8bptShuG8reGC0XS09+a4H2BoWSJi+fscA+Pulbpo= github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY= -github.com/sei-protocol/sei-cosmos v0.2.13 h1:legDUxrbj+hfGbXFk0ivziO8NfwmP9GkER9yqOL0VOw= -github.com/sei-protocol/sei-cosmos v0.2.13/go.mod h1:CYMdG9mBiQ9Dfw3Wd+JCF+ph7NpySllMAnMA3qNG5ro= +github.com/sei-protocol/sei-cosmos v0.2.14 h1:UHdTI9QKI02VFlnBCyAUsOQQlBuNH3p70TGUW6qr5aQ= +github.com/sei-protocol/sei-cosmos v0.2.14/go.mod h1:CYMdG9mBiQ9Dfw3Wd+JCF+ph7NpySllMAnMA3qNG5ro= github.com/sei-protocol/sei-iavl v0.1.3 h1:0hvW1NtmBlZ7ZkerQcM/n+2tFKg0vUlYWK8q/OeuCgw= github.com/sei-protocol/sei-iavl v0.1.3/go.mod h1:7PfkEVT5dcoQE+s/9KWdoXJ8VVVP1QpYYPLdxlkSXFk= github.com/sei-protocol/sei-tendermint v0.2.2 h1:lwzqgMIF8XyLE7r3VGRv0t6nLxLLDmoOUDcnKw+whNE= diff --git a/x/dex/keeper/abci/end_block_deposit.go b/x/dex/keeper/abci/end_block_deposit.go index 8cb544c608..3eb5a348a2 100644 --- a/x/dex/keeper/abci/end_block_deposit.go +++ b/x/dex/keeper/abci/end_block_deposit.go @@ -42,7 +42,7 @@ func (w KeeperWrapper) GetDepositSudoMsg(ctx sdk.Context, typedContractAddr type ) escrowed := sdk.NewCoins() for _, deposit := range depositMemState { - escrowed.Add(sdk.NewCoin(deposit.Denom, deposit.Amount.TruncateInt())) + escrowed = escrowed.Add(sdk.NewCoin(deposit.Denom, deposit.Amount.TruncateInt())) } contractAddr, err := sdk.AccAddressFromBech32(string(typedContractAddr)) if err != nil { diff --git a/x/dex/keeper/abci/end_block_place_orders_test.go b/x/dex/keeper/abci/end_block_place_orders_test.go index 43fe291564..0ffc6fe8ef 100644 --- a/x/dex/keeper/abci/end_block_place_orders_test.go +++ b/x/dex/keeper/abci/end_block_place_orders_test.go @@ -9,8 +9,10 @@ import ( dexcache "github.com/sei-protocol/sei-chain/x/dex/cache" "github.com/sei-protocol/sei-chain/x/dex/keeper/abci" "github.com/sei-protocol/sei-chain/x/dex/types" + dextypes "github.com/sei-protocol/sei-chain/x/dex/types" typesutils "github.com/sei-protocol/sei-chain/x/dex/types/utils" dexutils "github.com/sei-protocol/sei-chain/x/dex/utils" + minttypes "github.com/sei-protocol/sei-chain/x/mint/types" "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) @@ -41,6 +43,13 @@ func TestGetDepositSudoMsg(t *testing.T) { ctx = ctx.WithContext(context.WithValue(ctx.Context(), dexutils.DexMemStateContextKey, dexcache.NewMemState(testApp.GetKey(types.StoreKey)))) testAccount, _ := sdk.AccAddressFromBech32("sei1yezq49upxhunjjhudql2fnj5dgvcwjj87pn2wx") amounts := sdk.NewCoins(sdk.NewCoin("usei", sdk.NewInt(1000000))) + bankkeeper := testApp.BankKeeper + bankkeeper.MintCoins(ctx, minttypes.ModuleName, amounts) + err := bankkeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, testAccount, amounts) + require.Nil(t, err) + // this send would happen in msg server + err = bankkeeper.SendCoinsFromAccountToModule(ctx, testAccount, dextypes.ModuleName, amounts) + require.Nil(t, err) keeper := testApp.DexKeeper dexutils.GetMemState(ctx.Context()).GetDepositInfo(ctx, keepertest.TestContract).Add( &types.DepositInfoEntry{ @@ -52,4 +61,8 @@ func TestGetDepositSudoMsg(t *testing.T) { wrapper := abci.KeeperWrapper{Keeper: &keeper} msgs := wrapper.GetDepositSudoMsg(ctx, keepertest.TestContract) require.Equal(t, 1, len(msgs.OrderPlacements.Deposits)) + + contractAddr, _ := sdk.AccAddressFromBech32(keepertest.TestContract) + contractBalance := testApp.BankKeeper.GetBalance(ctx, contractAddr, "usei") + require.Equal(t, contractBalance.Amount.Int64(), int64(1000000)) } diff --git a/x/dex/module_test.go b/x/dex/module_test.go index 473b7d3cac..759c89ed79 100644 --- a/x/dex/module_test.go +++ b/x/dex/module_test.go @@ -57,6 +57,8 @@ func TestEndBlockMarketOrder(t *testing.T) { bankkeeper := testApp.BankKeeper bankkeeper.MintCoins(ctx, minttypes.ModuleName, amounts) bankkeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, testAccount, amounts) + dexAmounts := sdk.NewCoins(sdk.NewCoin("usei", sdk.NewInt(5000000)), sdk.NewCoin("uusdc", sdk.NewInt(10000000))) + bankkeeper.SendCoinsFromAccountToModule(ctx, testAccount, types.ModuleName, dexAmounts) wasm, err := ioutil.ReadFile("./testdata/mars.wasm") if err != nil { panic(err) @@ -187,6 +189,8 @@ func TestEndBlockLimitOrder(t *testing.T) { bankkeeper := testApp.BankKeeper bankkeeper.MintCoins(ctx, minttypes.ModuleName, amounts) bankkeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, testAccount, amounts) + dexAmounts := sdk.NewCoins(sdk.NewCoin("usei", sdk.NewInt(5000000)), sdk.NewCoin("uusdc", sdk.NewInt(10000000))) + bankkeeper.SendCoinsFromAccountToModule(ctx, testAccount, types.ModuleName, dexAmounts) wasm, err := ioutil.ReadFile("./testdata/mars.wasm") if err != nil { panic(err) @@ -402,6 +406,8 @@ func TestEndBlockPartialRollback(t *testing.T) { bankkeeper := testApp.BankKeeper bankkeeper.MintCoins(ctx, minttypes.ModuleName, amounts) bankkeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, testAccount, amounts) + dexAmounts := sdk.NewCoins(sdk.NewCoin("usei", sdk.NewInt(500000)), sdk.NewCoin("uusdc", sdk.NewInt(1000000))) + bankkeeper.SendCoinsFromAccountToModule(ctx, testAccount, types.ModuleName, dexAmounts) wasm, err := ioutil.ReadFile("./testdata/mars.wasm") if err != nil { panic(err) @@ -502,6 +508,8 @@ func TestEndBlockPanicHandling(t *testing.T) { bankkeeper := testApp.BankKeeper bankkeeper.MintCoins(ctx, minttypes.ModuleName, amounts) bankkeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, testAccount, amounts) + dexAmounts := sdk.NewCoins(sdk.NewCoin("usei", sdk.NewInt(5000000))) + bankkeeper.SendCoinsFromAccountToModule(ctx, testAccount, types.ModuleName, dexAmounts) wasm, err := ioutil.ReadFile("./testdata/mars.wasm") if err != nil { panic(err) @@ -559,6 +567,8 @@ func TestEndBlockRollbackWithRentCharge(t *testing.T) { bankkeeper := testApp.BankKeeper bankkeeper.MintCoins(ctx, minttypes.ModuleName, amounts) bankkeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, testAccount, amounts) + dexAmounts := sdk.NewCoins(sdk.NewCoin("usei", sdk.NewInt(500000)), sdk.NewCoin("uusdc", sdk.NewInt(1000000))) + bankkeeper.SendCoinsFromAccountToModule(ctx, testAccount, types.ModuleName, dexAmounts) wasm, err := ioutil.ReadFile("./testdata/mars.wasm") if err != nil { panic(err)