From eab9fb51f0d1cc7e4443737b47b24ec5f8e3e69b Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Fri, 16 Jun 2023 14:48:38 +0800 Subject: [PATCH] begin math lib transition (#3835) * begin math lib transition * adopt sdk math * remove depguard * remove duplicate imports * missing import --------- Co-authored-by: Carlos Rodriguez --- .golangci.yml | 2 +- e2e/tests/transfer/authz_test.go | 13 +++++----- e2e/tests/transfer/base_test.go | 4 +-- e2e/testvalues/values.go | 9 ++++--- .../controller/keeper/msg_server_test.go | 3 ++- .../controller/keeper/relay_test.go | 10 ++++--- .../host/ibc_module_test.go | 7 ++--- .../host/keeper/handshake_test.go | 3 ++- .../host/keeper/relay_test.go | 21 ++++++++------- .../types/codec_test.go | 11 ++++---- modules/apps/29-fee/ibc_middleware_test.go | 9 ++++--- modules/apps/29-fee/ica_test.go | 5 ++-- modules/apps/29-fee/keeper/escrow_test.go | 5 ++-- modules/apps/29-fee/keeper/events_test.go | 3 ++- modules/apps/29-fee/keeper/grpc_query_test.go | 7 ++--- modules/apps/29-fee/keeper/keeper_test.go | 9 ++++--- modules/apps/29-fee/keeper/msg_server_test.go | 6 +++-- modules/apps/29-fee/types/fee_test.go | 11 ++++---- .../apps/transfer/keeper/grpc_query_test.go | 2 +- modules/apps/transfer/keeper/keeper.go | 3 ++- .../apps/transfer/keeper/mbt_relay_test.go | 4 +-- .../apps/transfer/keeper/migrations_test.go | 10 +++---- .../apps/transfer/keeper/msg_server_test.go | 3 ++- modules/apps/transfer/keeper/relay.go | 5 ++-- modules/apps/transfer/keeper/relay_test.go | 26 +++++++++---------- modules/apps/transfer/transfer_test.go | 3 ++- modules/apps/transfer/types/msgs_test.go | 11 ++++---- modules/apps/transfer/types/packet.go | 3 ++- .../transfer/types/transfer_authorization.go | 2 +- .../types/transfer_authorization_test.go | 25 +++++++++--------- modules/core/02-client/keeper/keeper_test.go | 3 ++- .../core/02-client/proposal_handler_test.go | 3 ++- testing/app.go | 10 +++---- testing/chain.go | 3 ++- testing/chain_test.go | 6 ++--- testing/simapp/state.go | 2 +- testing/simapp/test_helpers.go | 9 ++++--- testing/solomachine.go | 3 ++- testing/values.go | 3 ++- 39 files changed, 154 insertions(+), 123 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 98e1babadbe..4a0022ce9df 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -63,4 +63,4 @@ linters-settings: revive: rules: - name: if-return - disabled: true \ No newline at end of file + disabled: true diff --git a/e2e/tests/transfer/authz_test.go b/e2e/tests/transfer/authz_test.go index b27b0a98518..3e8fe322bc0 100644 --- a/e2e/tests/transfer/authz_test.go +++ b/e2e/tests/transfer/authz_test.go @@ -4,6 +4,7 @@ import ( "context" "testing" + sdkmath "cosmossdk.io/math" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -54,7 +55,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_MsgTransfer_Succeeds() { { SourcePort: channelA.PortID, SourceChannel: channelA.ChannelID, - SpendLimit: sdk.NewCoins(sdk.NewCoin(chainADenom, sdk.NewInt(testvalues.StartingTokenAmount))), + SpendLimit: sdk.NewCoins(sdk.NewCoin(chainADenom, sdkmath.NewInt(testvalues.StartingTokenAmount))), AllowList: []string{receiverWalletAddress}, }, }, @@ -88,7 +89,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_MsgTransfer_Succeeds() { grantAuthorization := grantAuths[0] transferAuth := suite.extractTransferAuthorizationFromGrantAuthorization(grantAuthorization) - expectedSpendLimit := sdk.NewCoins(sdk.NewCoin(chainADenom, sdk.NewInt(expectedLimit))) + expectedSpendLimit := sdk.NewCoins(sdk.NewCoin(chainADenom, sdkmath.NewInt(expectedLimit))) suite.Require().Equal(expectedSpendLimit, transferAuth.Allocations[0].SpendLimit) } } @@ -205,7 +206,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_InvalidTransferAuthorizations() { { SourcePort: channelA.PortID, SourceChannel: channelA.ChannelID, - SpendLimit: sdk.NewCoins(sdk.NewCoin(chainADenom, sdk.NewInt(spendLimit))), + SpendLimit: sdk.NewCoins(sdk.NewCoin(chainADenom, sdkmath.NewInt(spendLimit))), AllowList: []string{receiverWalletAddress}, }, }, @@ -235,7 +236,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_InvalidTransferAuthorizations() { transferMsg := transfertypes.MsgTransfer{ SourcePort: channelA.PortID, SourceChannel: channelA.ChannelID, - Token: sdk.Coin{Denom: chainADenom, Amount: sdk.NewInt(invalidSpendAmount)}, + Token: sdk.Coin{Denom: chainADenom, Amount: sdkmath.NewInt(invalidSpendAmount)}, Sender: granterAddress, Receiver: receiverWalletAddress, TimeoutHeight: suite.GetTimeoutHeight(ctx, chainB), @@ -278,7 +279,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_InvalidTransferAuthorizations() { grantAuthorization := grantAuths[0] transferAuth := suite.extractTransferAuthorizationFromGrantAuthorization(grantAuthorization) - expectedSpendLimit := sdk.NewCoins(sdk.NewCoin(chainADenom, sdk.NewInt(spendLimit))) + expectedSpendLimit := sdk.NewCoins(sdk.NewCoin(chainADenom, sdkmath.NewInt(spendLimit))) suite.Require().Equal(expectedSpendLimit, transferAuth.Allocations[0].SpendLimit) }) }) @@ -291,7 +292,7 @@ func (suite *AuthzTransferTestSuite) TestAuthz_InvalidTransferAuthorizations() { transferMsg := transfertypes.MsgTransfer{ SourcePort: channelA.PortID, SourceChannel: channelA.ChannelID, - Token: sdk.Coin{Denom: chainADenom, Amount: sdk.NewInt(spendLimit)}, + Token: sdk.Coin{Denom: chainADenom, Amount: sdkmath.NewInt(spendLimit)}, Sender: granterAddress, Receiver: invalidWalletAddress, TimeoutHeight: suite.GetTimeoutHeight(ctx, chainB), diff --git a/e2e/tests/transfer/base_test.go b/e2e/tests/transfer/base_test.go index 37a957221a3..a94867084ea 100644 --- a/e2e/tests/transfer/base_test.go +++ b/e2e/tests/transfer/base_test.go @@ -110,7 +110,7 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() { if testvalues.TotalEscrowFeatureReleases.IsSupported(chainBVersion) { actualTotalEscrow, err := s.QueryTotalEscrowForDenom(ctx, chainB, chainBIBCToken.IBCDenom()) s.Require().NoError(err) - s.Require().Equal(sdk.NewCoin(chainBIBCToken.IBCDenom(), sdk.NewInt(0)), actualTotalEscrow) // total escrow is zero because sending chain is not source for tokens + s.Require().Equal(sdk.NewCoin(chainBIBCToken.IBCDenom(), sdkmath.NewInt(0)), actualTotalEscrow) // total escrow is zero because sending chain is not source for tokens } }) @@ -130,7 +130,7 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() { t.Run("tokens are un-escrowed", func(t *testing.T) { actualTotalEscrow, err := s.QueryTotalEscrowForDenom(ctx, chainA, chainADenom) s.Require().NoError(err) - s.Require().Equal(sdk.NewCoin(chainADenom, sdk.NewInt(0)), actualTotalEscrow) // total escrow is zero because tokens have come back + s.Require().Equal(sdk.NewCoin(chainADenom, sdkmath.NewInt(0)), actualTotalEscrow) // total escrow is zero because tokens have come back }) } } diff --git a/e2e/testvalues/values.go b/e2e/testvalues/values.go index b1dc183363a..03a7a207386 100644 --- a/e2e/testvalues/values.go +++ b/e2e/testvalues/values.go @@ -4,6 +4,7 @@ import ( "fmt" "time" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/strangelove-ventures/interchaintest/v7/ibc" @@ -27,14 +28,14 @@ func ImmediatelyTimeout() *ibc.IBCTimeout { func DefaultFee(denom string) feetypes.Fee { return feetypes.Fee{ - RecvFee: sdk.NewCoins(sdk.NewCoin(denom, sdk.NewInt(50))), - AckFee: sdk.NewCoins(sdk.NewCoin(denom, sdk.NewInt(25))), - TimeoutFee: sdk.NewCoins(sdk.NewCoin(denom, sdk.NewInt(10))), + RecvFee: sdk.NewCoins(sdk.NewCoin(denom, sdkmath.NewInt(50))), + AckFee: sdk.NewCoins(sdk.NewCoin(denom, sdkmath.NewInt(25))), + TimeoutFee: sdk.NewCoins(sdk.NewCoin(denom, sdkmath.NewInt(10))), } } func DefaultTransferAmount(denom string) sdk.Coin { - return sdk.Coin{Denom: denom, Amount: sdk.NewInt(IBCTransferAmount)} + return sdk.Coin{Denom: denom, Amount: sdkmath.NewInt(IBCTransferAmount)} } func TendermintClientID(id int) string { diff --git a/modules/apps/27-interchain-accounts/controller/keeper/msg_server_test.go b/modules/apps/27-interchain-accounts/controller/keeper/msg_server_test.go index 47a05f4679e..f929a74a55a 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/msg_server_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/msg_server_test.go @@ -3,6 +3,7 @@ package keeper_test import ( "time" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/gogoproto/proto" @@ -165,7 +166,7 @@ func (suite *KeeperTestSuite) TestSubmitTx() { icaMsg := &banktypes.MsgSend{ FromAddress: interchainAccountAddr, ToAddress: suite.chainB.SenderAccount.GetAddress().String(), - Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100))), } data, err := icatypes.SerializeCosmosTx(suite.chainA.Codec, []proto.Message{icaMsg}) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go b/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go index c16af788923..d5deeb41d19 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/relay_test.go @@ -1,7 +1,9 @@ package keeper_test import ( + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/gogoproto/proto" @@ -32,7 +34,7 @@ func (suite *KeeperTestSuite) TestSendTx() { msg := &banktypes.MsgSend{ FromAddress: interchainAccountAddr, ToAddress: suite.chainB.SenderAccount.GetAddress().String(), - Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100))), } data, err := icatypes.SerializeCosmosTx(suite.chainB.GetSimApp().AppCodec(), []proto.Message{msg}) @@ -55,12 +57,12 @@ func (suite *KeeperTestSuite) TestSendTx() { &banktypes.MsgSend{ FromAddress: interchainAccountAddr, ToAddress: suite.chainB.SenderAccount.GetAddress().String(), - Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100))), }, &banktypes.MsgSend{ FromAddress: interchainAccountAddr, ToAddress: suite.chainB.SenderAccount.GetAddress().String(), - Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100))), }, } @@ -119,7 +121,7 @@ func (suite *KeeperTestSuite) TestSendTx() { msg := &banktypes.MsgSend{ FromAddress: interchainAccountAddr, ToAddress: suite.chainB.SenderAccount.GetAddress().String(), - Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100))), } data, err := icatypes.SerializeCosmosTx(suite.chainB.GetSimApp().AppCodec(), []proto.Message{msg}) diff --git a/modules/apps/27-interchain-accounts/host/ibc_module_test.go b/modules/apps/27-interchain-accounts/host/ibc_module_test.go index f8737c300a2..4428d453f59 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -4,6 +4,7 @@ import ( "fmt" "testing" + sdkmath "cosmossdk.io/math" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -141,7 +142,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenTry() { { "account address generation is block dependent", func() { icaHostAccount := icatypes.GenerateAddress(suite.chainB.GetContext(), path.EndpointB.ConnectionID, path.EndpointA.ChannelConfig.PortID) - err := suite.chainB.GetSimApp().BankKeeper.SendCoins(suite.chainB.GetContext(), suite.chainB.SenderAccount.GetAddress(), icaHostAccount, sdk.Coins{sdk.NewCoin("stake", sdk.NewInt(1))}) + err := suite.chainB.GetSimApp().BankKeeper.SendCoins(suite.chainB.GetContext(), suite.chainB.SenderAccount.GetAddress(), icaHostAccount, sdk.Coins{sdk.NewCoin("stake", sdkmath.NewInt(1))}) suite.Require().NoError(err) suite.Require().True(suite.chainB.GetSimApp().AccountKeeper.HasAccount(suite.chainB.GetContext(), icaHostAccount)) @@ -635,8 +636,8 @@ func (suite *InterchainAccountsTestSuite) TestControlAccountAfterChannelClose() // two sends will be performed, one after initial creation of the account and one after channel closure and reopening var ( - startingBal = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000))) - tokenAmt = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000))) + startingBal = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000))) + tokenAmt = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(5000))) expBalAfterFirstSend = startingBal.Sub(tokenAmt...) expBalAfterSecondSend = expBalAfterFirstSend.Sub(tokenAmt...) ) diff --git a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go index 4712aac2c5a..7f31c3bcb31 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/handshake_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" @@ -130,7 +131,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() { "account already exists", func() { interchainAccAddr := icatypes.GenerateAddress(suite.chainB.GetContext(), path.EndpointB.ConnectionID, path.EndpointA.ChannelConfig.PortID) - err := suite.chainB.GetSimApp().BankKeeper.SendCoins(suite.chainB.GetContext(), suite.chainB.SenderAccount.GetAddress(), interchainAccAddr, sdk.Coins{sdk.NewCoin("stake", sdk.NewInt(1))}) + err := suite.chainB.GetSimApp().BankKeeper.SendCoins(suite.chainB.GetContext(), suite.chainB.SenderAccount.GetAddress(), interchainAccAddr, sdk.Coins{sdk.NewCoin("stake", sdkmath.NewInt(1))}) suite.Require().NoError(err) suite.Require().True(suite.chainB.GetSimApp().AccountKeeper.HasAccount(suite.chainB.GetContext(), interchainAccAddr)) }, diff --git a/modules/apps/27-interchain-accounts/host/keeper/relay_test.go b/modules/apps/27-interchain-accounts/host/keeper/relay_test.go index 6e07e58715f..7f0f298c452 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/relay_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/relay_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + sdkmath "cosmossdk.io/math" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -80,7 +81,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { msg := &banktypes.MsgSend{ FromAddress: interchainAccountAddr, ToAddress: suite.chainB.SenderAccount.GetAddress().String(), - Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100))), } data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []proto.Message{msg}) @@ -108,7 +109,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { msg := &stakingtypes.MsgDelegate{ DelegatorAddress: interchainAccountAddr, ValidatorAddress: validatorAddr.String(), - Amount: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000)), + Amount: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(5000)), } data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []proto.Message{msg}) @@ -136,13 +137,13 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { msgDelegate := &stakingtypes.MsgDelegate{ DelegatorAddress: interchainAccountAddr, ValidatorAddress: validatorAddr.String(), - Amount: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000)), + Amount: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(5000)), } msgUndelegate := &stakingtypes.MsgUndelegate{ DelegatorAddress: interchainAccountAddr, ValidatorAddress: validatorAddr.String(), - Amount: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000)), + Amount: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(5000)), } data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []proto.Message{msgDelegate, msgUndelegate}) @@ -176,7 +177,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { msg := &govtypes.MsgSubmitProposal{ Content: protoAny, - InitialDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000))), + InitialDeposit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(5000))), Proposer: interchainAccountAddr, } @@ -244,7 +245,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { suite.Require().True(found) msg := &disttypes.MsgFundCommunityPool{ - Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000))), + Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(5000))), Depositor: interchainAccountAddr, } @@ -306,7 +307,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { msg := &transfertypes.MsgTransfer{ SourcePort: transferPath.EndpointA.ChannelConfig.PortID, SourceChannel: transferPath.EndpointA.ChannelID, - Token: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), + Token: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)), Sender: interchainAccountAddr, Receiver: suite.chainA.SenderAccount.GetAddress().String(), TimeoutHeight: clienttypes.NewHeight(1, 100), @@ -407,7 +408,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { msg := &banktypes.MsgSend{ FromAddress: suite.chainB.SenderAccount.GetAddress().String(), ToAddress: suite.chainB.SenderAccount.GetAddress().String(), - Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100))), } data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []proto.Message{msg}) @@ -428,7 +429,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { msg := &banktypes.MsgSend{ FromAddress: suite.chainB.SenderAccount.GetAddress().String(), // unexpected signer ToAddress: suite.chainB.SenderAccount.GetAddress().String(), - Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100))), } data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []proto.Message{msg}) @@ -474,7 +475,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { interchainAccount := suite.chainB.GetSimApp().AccountKeeper.GetAccount(suite.chainB.GetContext(), icaAddr) suite.Require().Equal(interchainAccount.GetAddress().String(), storedAddr) - suite.fundICAWallet(suite.chainB.GetContext(), path.EndpointA.ChannelConfig.PortID, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000)))) + suite.fundICAWallet(suite.chainB.GetContext(), path.EndpointA.ChannelConfig.PortID, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(10000)))) tc.malleate() // malleate mutates test data diff --git a/modules/apps/27-interchain-accounts/types/codec_test.go b/modules/apps/27-interchain-accounts/types/codec_test.go index 1df2dd4d66a..08db0f6d0e7 100644 --- a/modules/apps/27-interchain-accounts/types/codec_test.go +++ b/modules/apps/27-interchain-accounts/types/codec_test.go @@ -1,6 +1,7 @@ package types_test import ( + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -49,7 +50,7 @@ func (suite *TypesTestSuite) TestSerializeAndDeserializeCosmosTx() { &banktypes.MsgSend{ FromAddress: TestOwnerAddress, ToAddress: TestOwnerAddress, - Amount: sdk.NewCoins(sdk.NewCoin("bananas", sdk.NewInt(100))), + Amount: sdk.NewCoins(sdk.NewCoin("bananas", sdkmath.NewInt(100))), }, }, true, @@ -60,12 +61,12 @@ func (suite *TypesTestSuite) TestSerializeAndDeserializeCosmosTx() { &banktypes.MsgSend{ FromAddress: TestOwnerAddress, ToAddress: TestOwnerAddress, - Amount: sdk.NewCoins(sdk.NewCoin("bananas", sdk.NewInt(100))), + Amount: sdk.NewCoins(sdk.NewCoin("bananas", sdkmath.NewInt(100))), }, &banktypes.MsgSend{ FromAddress: TestOwnerAddress, ToAddress: TestOwnerAddress, - Amount: sdk.NewCoins(sdk.NewCoin("bananas", sdk.NewInt(200))), + Amount: sdk.NewCoins(sdk.NewCoin("bananas", sdkmath.NewInt(200))), }, }, true, @@ -76,10 +77,10 @@ func (suite *TypesTestSuite) TestSerializeAndDeserializeCosmosTx() { &banktypes.MsgSend{ FromAddress: TestOwnerAddress, ToAddress: TestOwnerAddress, - Amount: sdk.NewCoins(sdk.NewCoin("bananas", sdk.NewInt(100))), + Amount: sdk.NewCoins(sdk.NewCoin("bananas", sdkmath.NewInt(100))), }, &govtypes.MsgSubmitProposal{ - InitialDeposit: sdk.NewCoins(sdk.NewCoin("bananas", sdk.NewInt(100))), + InitialDeposit: sdk.NewCoins(sdk.NewCoin("bananas", sdkmath.NewInt(100))), Proposer: TestOwnerAddress, }, }, diff --git a/modules/apps/29-fee/ibc_middleware_test.go b/modules/apps/29-fee/ibc_middleware_test.go index 6ed745304de..11302063364 100644 --- a/modules/apps/29-fee/ibc_middleware_test.go +++ b/modules/apps/29-fee/ibc_middleware_test.go @@ -3,6 +3,7 @@ package fee_test import ( "fmt" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" @@ -17,10 +18,10 @@ import ( ) var ( - defaultRecvFee = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}} - defaultAckFee = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(200)}} - defaultTimeoutFee = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(300)}} - smallAmount = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(50)}} + defaultRecvFee = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdkmath.NewInt(100)}} + defaultAckFee = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdkmath.NewInt(200)}} + defaultTimeoutFee = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdkmath.NewInt(300)}} + smallAmount = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdkmath.NewInt(50)}} ) // Tests OnChanOpenInit on ChainA diff --git a/modules/apps/29-fee/ica_test.go b/modules/apps/29-fee/ica_test.go index 090533cb875..396e25cb00a 100644 --- a/modules/apps/29-fee/ica_test.go +++ b/modules/apps/29-fee/ica_test.go @@ -1,6 +1,7 @@ package fee_test import ( + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -124,7 +125,7 @@ func (suite *FeeTestSuite) TestFeeInterchainAccounts() { suite.Require().True(found) // fund the interchain account on chainB - coins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000))) + coins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000))) msgBankSend := &banktypes.MsgSend{ FromAddress: suite.chainB.SenderAccount.GetAddress().String(), ToAddress: interchainAccountAddr, @@ -140,7 +141,7 @@ func (suite *FeeTestSuite) TestFeeInterchainAccounts() { msgDelegate := &stakingtypes.MsgDelegate{ DelegatorAddress: interchainAccountAddr, ValidatorAddress: validatorAddr.String(), - Amount: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000)), + Amount: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(5000)), } data, err := icatypes.SerializeCosmosTx(suite.chainA.GetSimApp().AppCodec(), []proto.Message{msgDelegate}) diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index bcb6c473596..71a1f9e5a44 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + sdkmath "cosmossdk.io/math" "github.com/cometbft/cometbft/crypto/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" @@ -59,7 +60,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() { // check the module acc wallet is now empty balance = suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.DefaultBondDenom) - suite.Require().Equal(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(0)), balance) + suite.Require().Equal(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(0)), balance) }, }, { @@ -229,7 +230,7 @@ func (suite *KeeperTestSuite) TestDistributePacketFeesOnTimeout() { // check the module acc wallet is now empty balance = suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.DefaultBondDenom) - suite.Require().Equal(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(0)), balance) + suite.Require().Equal(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(0)), balance) }, }, { diff --git a/modules/apps/29-fee/keeper/events_test.go b/modules/apps/29-fee/keeper/events_test.go index 1f7726fea00..7c8b917f49e 100644 --- a/modules/apps/29-fee/keeper/events_test.go +++ b/modules/apps/29-fee/keeper/events_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + sdkmath "cosmossdk.io/math" abcitypes "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -110,7 +111,7 @@ func (suite *KeeperTestSuite) TestDistributeFeeEvent() { msgTransfer := transfertypes.NewMsgTransfer( path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, - sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), + sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), clienttypes.NewHeight(1, 100), 0, "", ) diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index ef60976fca6..707980d9bb2 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -3,6 +3,7 @@ package keeper_test import ( "fmt" + sdkmath "cosmossdk.io/math" "github.com/cometbft/cometbft/crypto/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" @@ -160,9 +161,9 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketsForChannel() { ) fee := types.Fee{ - AckFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, - RecvFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, - TimeoutFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, + AckFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdkmath.NewInt(100)}}, + RecvFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdkmath.NewInt(100)}}, + TimeoutFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdkmath.NewInt(100)}}, } testCases := []struct { diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index 26a573042b7..d82f09eea5e 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -4,6 +4,7 @@ import ( "fmt" "testing" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" @@ -14,10 +15,10 @@ import ( ) var ( - defaultRecvFee = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}} - defaultAckFee = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(200)}} - defaultTimeoutFee = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(300)}} - invalidCoins = sdk.Coins{sdk.Coin{Denom: "invalidDenom", Amount: sdk.NewInt(100)}} + defaultRecvFee = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdkmath.NewInt(100)}} + defaultAckFee = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdkmath.NewInt(200)}} + defaultTimeoutFee = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdkmath.NewInt(300)}} + invalidCoins = sdk.Coins{sdk.Coin{Denom: "invalidDenom", Amount: sdkmath.NewInt(100)}} ) type KeeperTestSuite struct { diff --git a/modules/apps/29-fee/keeper/msg_server_test.go b/modules/apps/29-fee/keeper/msg_server_test.go index 4c7269931ad..40a24c5225d 100644 --- a/modules/apps/29-fee/keeper/msg_server_test.go +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -1,7 +1,9 @@ package keeper_test import ( + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" @@ -330,7 +332,7 @@ func (suite *KeeperTestSuite) TestPayPacketFee() { suite.Require().Error(err) escrowBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.DefaultBondDenom) - suite.Require().Equal(sdk.NewInt(0), escrowBalance.Amount) + suite.Require().Equal(sdkmath.NewInt(0), escrowBalance.Amount) } }) } @@ -543,7 +545,7 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() { suite.Require().Error(err) escrowBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.DefaultBondDenom) - suite.Require().Equal(sdk.NewInt(0), escrowBalance.Amount) + suite.Require().Equal(sdkmath.NewInt(0), escrowBalance.Amount) } }) } diff --git a/modules/apps/29-fee/types/fee_test.go b/modules/apps/29-fee/types/fee_test.go index 5c8800f2913..0ff42efb41a 100644 --- a/modules/apps/29-fee/types/fee_test.go +++ b/modules/apps/29-fee/types/fee_test.go @@ -3,6 +3,7 @@ package types_test import ( "testing" + sdkmath "cosmossdk.io/math" "github.com/cometbft/cometbft/crypto/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -12,16 +13,16 @@ import ( var ( // defaultRecvFee is the default packet receive fee used for testing purposes - defaultRecvFee = sdk.NewCoins(sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}) + defaultRecvFee = sdk.NewCoins(sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdkmath.NewInt(100)}) // defaultAckFee is the default packet acknowledgement fee used for testing purposes - defaultAckFee = sdk.NewCoins(sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(200)}) + defaultAckFee = sdk.NewCoins(sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdkmath.NewInt(200)}) // defaultTimeoutFee is the default packet timeout fee used for testing purposes - defaultTimeoutFee = sdk.NewCoins(sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(300)}) + defaultTimeoutFee = sdk.NewCoins(sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdkmath.NewInt(300)}) // invalidFee is an invalid coin set used to trigger error cases for testing purposes - invalidFee = sdk.Coins{sdk.Coin{Denom: "invalid-denom", Amount: sdk.NewInt(-2)}} + invalidFee = sdk.Coins{sdk.Coin{Denom: "invalid-denom", Amount: sdkmath.NewInt(-2)}} // defaultAccAddress is the default account used for testing purposes defaultAccAddress = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() @@ -33,7 +34,7 @@ func TestFeeTotal(t *testing.T) { fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee) total := fee.Total() - require.Equal(t, sdk.NewInt(600), total.AmountOf(sdk.DefaultBondDenom)) + require.Equal(t, sdkmath.NewInt(600), total.AmountOf(sdk.DefaultBondDenom)) } func TestPacketFeeValidation(t *testing.T) { diff --git a/modules/apps/transfer/keeper/grpc_query_test.go b/modules/apps/transfer/keeper/grpc_query_test.go index 24bc271d110..ae741a9b714 100644 --- a/modules/apps/transfer/keeper/grpc_query_test.go +++ b/modules/apps/transfer/keeper/grpc_query_test.go @@ -343,7 +343,7 @@ func (suite *KeeperTestSuite) TestTotalEscrowForDenom() { suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset - expEscrowAmount = sdk.ZeroInt() + expEscrowAmount = sdkmath.ZeroInt() tc.malleate() ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) diff --git a/modules/apps/transfer/keeper/keeper.go b/modules/apps/transfer/keeper/keeper.go index 7c5e2af0ba4..4e5760cbf5b 100644 --- a/modules/apps/transfer/keeper/keeper.go +++ b/modules/apps/transfer/keeper/keeper.go @@ -4,6 +4,7 @@ import ( "fmt" "strings" + sdkmath "cosmossdk.io/math" tmbytes "github.com/cometbft/cometbft/libs/bytes" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" @@ -189,7 +190,7 @@ func (k Keeper) GetTotalEscrowForDenom(ctx sdk.Context, denom string) sdk.Coin { store := ctx.KVStore(k.storeKey) bz := store.Get(types.TotalEscrowForDenomKey(denom)) if len(bz) == 0 { - return sdk.NewCoin(denom, sdk.ZeroInt()) + return sdk.NewCoin(denom, sdkmath.ZeroInt()) } amount := sdk.IntProto{} diff --git a/modules/apps/transfer/keeper/mbt_relay_test.go b/modules/apps/transfer/keeper/mbt_relay_test.go index 59a369cd191..80a99eada08 100644 --- a/modules/apps/transfer/keeper/mbt_relay_test.go +++ b/modules/apps/transfer/keeper/mbt_relay_test.go @@ -127,7 +127,7 @@ func BalanceFromTla(balance TlaBalance) Balance { ID: AddressFromTla(balance.Address), Address: AddressFromString(AddressFromTla(balance.Address)), Denom: DenomFromTla(balance.Denom), - Amount: sdk.NewInt(balance.Amount), + Amount: sdkmath.NewInt(balance.Amount), } } @@ -338,7 +338,7 @@ func (suite *KeeperTestSuite) TestModelBasedRelay() { denom := denomTrace.IBCDenom() err = sdk.ValidateDenom(denom) if err == nil { - amount, ok := sdk.NewIntFromString(tc.packet.Data.Amount) + amount, ok := sdkmath.NewIntFromString(tc.packet.Data.Amount) if !ok { panic("MBT failed to parse amount from string") } diff --git a/modules/apps/transfer/keeper/migrations_test.go b/modules/apps/transfer/keeper/migrations_test.go index a86a1f4f9f6..577fe8d2ba6 100644 --- a/modules/apps/transfer/keeper/migrations_test.go +++ b/modules/apps/transfer/keeper/migrations_test.go @@ -174,7 +174,7 @@ func (suite *KeeperTestSuite) TestMigrateTotalEscrowForDenom() { func() { denom = sdk.DefaultBondDenom escrowAddress := transfertypes.GetEscrowAddress(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) - coin := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) + coin := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)) // funds the escrow account to have balance suite.Require().NoError(banktestutil.FundAccount(suite.chainA.GetSimApp().BankKeeper, suite.chainA.GetContext(), escrowAddress, sdk.NewCoins(coin))) @@ -190,8 +190,8 @@ func (suite *KeeperTestSuite) TestMigrateTotalEscrowForDenom() { escrowAddress1 := transfertypes.GetEscrowAddress(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) escrowAddress2 := transfertypes.GetEscrowAddress(extraPath.EndpointA.ChannelConfig.PortID, extraPath.EndpointA.ChannelID) - coin1 := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) - coin2 := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) + coin1 := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)) + coin2 := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)) // funds the escrow accounts to have balance suite.Require().NoError(banktestutil.FundAccount(suite.chainA.GetSimApp().BankKeeper, suite.chainA.GetContext(), escrowAddress1, sdk.NewCoins(coin1))) @@ -204,7 +204,7 @@ func (suite *KeeperTestSuite) TestMigrateTotalEscrowForDenom() { func() { escrowAddress := transfertypes.GetEscrowAddress(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) trace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.DefaultBondDenom)) - coin := sdk.NewCoin(trace.IBCDenom(), sdk.NewInt(100)) + coin := sdk.NewCoin(trace.IBCDenom(), sdkmath.NewInt(100)) denom = trace.IBCDenom() suite.chainA.GetSimApp().TransferKeeper.SetDenomTrace(suite.chainA.GetContext(), trace) @@ -212,7 +212,7 @@ func (suite *KeeperTestSuite) TestMigrateTotalEscrowForDenom() { // funds the escrow account to have balance suite.Require().NoError(banktestutil.FundAccount(suite.chainA.GetSimApp().BankKeeper, suite.chainA.GetContext(), escrowAddress, sdk.NewCoins(coin))) }, - sdk.NewInt(100), + sdkmath.NewInt(100), }, } diff --git a/modules/apps/transfer/keeper/msg_server_test.go b/modules/apps/transfer/keeper/msg_server_test.go index 39d4e458ebc..73c94bc0ca3 100644 --- a/modules/apps/transfer/keeper/msg_server_test.go +++ b/modules/apps/transfer/keeper/msg_server_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ibctesting "github.com/cosmos/ibc-go/v7/testing" @@ -87,7 +88,7 @@ func (suite *KeeperTestSuite) TestMsgTransfer() { path := NewTransferPath(suite.chainA, suite.chainB) suite.coordinator.Setup(path) - coin := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) + coin := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)) msg = types.NewMsgTransfer( path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, diff --git a/modules/apps/transfer/keeper/relay.go b/modules/apps/transfer/keeper/relay.go index 723be454d4e..0bef4fa81f9 100644 --- a/modules/apps/transfer/keeper/relay.go +++ b/modules/apps/transfer/keeper/relay.go @@ -5,6 +5,7 @@ import ( "strings" errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" metrics "github.com/armon/go-metrics" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" @@ -177,7 +178,7 @@ func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, data t } // parse the transfer amount - transferAmount, ok := sdk.NewIntFromString(data.Amount) + transferAmount, ok := sdkmath.NewIntFromString(data.Amount) if !ok { return errorsmod.Wrapf(types.ErrInvalidAmount, "unable to parse transfer amount: %s", data.Amount) } @@ -334,7 +335,7 @@ func (k Keeper) refundPacketToken(ctx sdk.Context, packet channeltypes.Packet, d trace := types.ParseDenomTrace(data.Denom) // parse the transfer amount - transferAmount, ok := sdk.NewIntFromString(data.Amount) + transferAmount, ok := sdkmath.NewIntFromString(data.Amount) if !ok { return errorsmod.Wrapf(types.ErrInvalidAmount, "unable to parse transfer amount (%s) into math.Int", data.Amount) } diff --git a/modules/apps/transfer/keeper/relay_test.go b/modules/apps/transfer/keeper/relay_test.go index 2adab9b070d..57f594d4711 100644 --- a/modules/apps/transfer/keeper/relay_test.go +++ b/modules/apps/transfer/keeper/relay_test.go @@ -74,7 +74,7 @@ func (suite *KeeperTestSuite) TestSendTransfer() { { "send coin failed", func() { - coin = sdk.NewCoin("randomdenom", sdk.NewInt(100)) + coin = sdk.NewCoin("randomdenom", sdkmath.NewInt(100)) }, false, }, { @@ -86,7 +86,7 @@ func (suite *KeeperTestSuite) TestSendTransfer() { { "send from module account failed, insufficient balance", func() { - coin = types.GetTransferCoin(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, coin.Denom, coin.Amount.Add(sdk.NewInt(1))) + coin = types.GetTransferCoin(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, coin.Denom, coin.Amount.Add(sdkmath.NewInt(1))) }, false, }, { @@ -114,7 +114,7 @@ func (suite *KeeperTestSuite) TestSendTransfer() { path = NewTransferPath(suite.chainA, suite.chainB) suite.coordinator.Setup(path) - coin = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) + coin = sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)) sender = suite.chainA.SenderAccount.GetAddress() memo = "" timeoutHeight = suite.chainB.GetTimeoutHeight() @@ -197,7 +197,7 @@ func (suite *KeeperTestSuite) TestSendTransferSetsTotalEscrowAmountForSourceIBCT suite.coordinator.Setup(path2) // create IBC token on chain B with denom trace "transfer/channel-0/stake" - coin := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) + coin := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)) transferMsg := types.NewMsgTransfer( path1.EndpointA.ChannelConfig.PortID, path1.EndpointA.ChannelID, @@ -217,7 +217,7 @@ func (suite *KeeperTestSuite) TestSendTransferSetsTotalEscrowAmountForSourceIBCT // execute trace := types.ParseDenomTrace(types.GetPrefixedDenom(path1.EndpointB.ChannelConfig.PortID, path1.EndpointB.ChannelID, sdk.DefaultBondDenom)) - coin = sdk.NewCoin(trace.IBCDenom(), sdk.NewInt(100)) + coin = sdk.NewCoin(trace.IBCDenom(), sdkmath.NewInt(100)) msg := types.NewMsgTransfer( path2.EndpointB.ChannelConfig.PortID, path2.EndpointB.ChannelID, @@ -286,7 +286,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { "empty coin", func() { trace = types.DenomTrace{} - amount = sdk.ZeroInt() + amount = sdkmath.ZeroInt() expEscrowAmount = sdkmath.NewInt(100) }, true, false, }, @@ -303,7 +303,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { { "failure: mint zero coin", func() { - amount = sdk.ZeroInt() + amount = sdkmath.ZeroInt() }, false, false, }, @@ -311,7 +311,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { { "tries to unescrow more tokens than allowed", func() { - amount = sdk.NewInt(1000000) + amount = sdkmath.NewInt(1000000) expEscrowAmount = sdkmath.NewInt(100) }, true, false, }, @@ -345,13 +345,13 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { receiver = suite.chainB.SenderAccount.GetAddress().String() // must be explicitly changed in malleate memo = "" // can be explicitly changed in malleate - amount = sdk.NewInt(100) // must be explicitly changed in malleate + amount = sdkmath.NewInt(100) // must be explicitly changed in malleate expEscrowAmount = sdkmath.ZeroInt() // total amount in escrow of voucher denom on receiving chain seq := uint64(1) if tc.recvIsSource { // send coin from chainB to chainA, receive them, acknowledge them, and send back to chainB - coinFromBToA := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) + coinFromBToA := sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)) transferMsg := types.NewMsgTransfer(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, coinFromBToA, suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), clienttypes.NewHeight(1, 110), 0, memo) res, err := suite.chainB.SendMsgs(transferMsg) suite.Require().NoError(err) // message committed @@ -571,7 +571,7 @@ func (suite *KeeperTestSuite) TestOnAcknowledgementPacket() { suite.SetupTest() // reset path = NewTransferPath(suite.chainA, suite.chainB) suite.coordinator.Setup(path) - amount = sdk.NewInt(100) // must be explicitly changed + amount = sdkmath.NewInt(100) // must be explicitly changed expEscrowAmount = sdkmath.ZeroInt() tc.malleate() @@ -757,7 +757,7 @@ func (suite *KeeperTestSuite) TestOnTimeoutPacket() { "mint failed", func() { trace = types.ParseDenomTrace(types.GetPrefixedDenom(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, sdk.DefaultBondDenom)) - amount = sdk.OneInt() + amount = sdkmath.OneInt() sender = "invalid address" }, false, }, @@ -771,7 +771,7 @@ func (suite *KeeperTestSuite) TestOnTimeoutPacket() { path = NewTransferPath(suite.chainA, suite.chainB) suite.coordinator.Setup(path) - amount = sdk.NewInt(100) // must be explicitly changed + amount = sdkmath.NewInt(100) // must be explicitly changed sender = suite.chainA.SenderAccount.GetAddress().String() expEscrowAmount = sdkmath.ZeroInt() diff --git a/modules/apps/transfer/transfer_test.go b/modules/apps/transfer/transfer_test.go index b934cf44c03..eec87eb60cd 100644 --- a/modules/apps/transfer/transfer_test.go +++ b/modules/apps/transfer/transfer_test.go @@ -3,6 +3,7 @@ package transfer_test import ( "testing" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" @@ -54,7 +55,7 @@ func (suite *TransferTestSuite) TestHandleMsgTransfer() { originalBalance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom) timeoutHeight := clienttypes.NewHeight(1, 110) - amount, ok := sdk.NewIntFromString("9223372036854775808") // 2^63 (one above int64) + amount, ok := sdkmath.NewIntFromString("9223372036854775808") // 2^63 (one above int64) suite.Require().True(ok) coinToSendToB := sdk.NewCoin(sdk.DefaultBondDenom, amount) diff --git a/modules/apps/transfer/types/msgs_test.go b/modules/apps/transfer/types/msgs_test.go index 7b722f0249c..22423d403f9 100644 --- a/modules/apps/transfer/types/msgs_test.go +++ b/modules/apps/transfer/types/msgs_test.go @@ -4,6 +4,7 @@ import ( "fmt" "testing" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -34,11 +35,11 @@ var ( receiver = sdk.AccAddress("testaddr2").String() emptyAddr string - coin = sdk.NewCoin("atom", sdk.NewInt(100)) - ibcCoin = sdk.NewCoin("ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", sdk.NewInt(100)) - invalidIBCCoin = sdk.NewCoin("ibc/7F1D3FCF4AE79E1554", sdk.NewInt(100)) - invalidDenomCoin = sdk.Coin{Denom: "0atom", Amount: sdk.NewInt(100)} - zeroCoin = sdk.Coin{Denom: "atoms", Amount: sdk.NewInt(0)} + coin = sdk.NewCoin("atom", sdkmath.NewInt(100)) + ibcCoin = sdk.NewCoin("ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", sdkmath.NewInt(100)) + invalidIBCCoin = sdk.NewCoin("ibc/7F1D3FCF4AE79E1554", sdkmath.NewInt(100)) + invalidDenomCoin = sdk.Coin{Denom: "0atom", Amount: sdkmath.NewInt(100)} + zeroCoin = sdk.Coin{Denom: "atoms", Amount: sdkmath.NewInt(0)} timeoutHeight = clienttypes.NewHeight(0, 10) ) diff --git a/modules/apps/transfer/types/packet.go b/modules/apps/transfer/types/packet.go index 98bb327298c..92e60a646ea 100644 --- a/modules/apps/transfer/types/packet.go +++ b/modules/apps/transfer/types/packet.go @@ -5,6 +5,7 @@ import ( "time" errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" ibcerrors "github.com/cosmos/ibc-go/v7/modules/core/errors" @@ -42,7 +43,7 @@ func NewFungibleTokenPacketData( // NOTE: The addresses formats are not validated as the sender and recipient can have different // formats defined by their corresponding chains that are not known to IBC. func (ftpd FungibleTokenPacketData) ValidateBasic() error { - amount, ok := sdk.NewIntFromString(ftpd.Amount) + amount, ok := sdkmath.NewIntFromString(ftpd.Amount) if !ok { return errorsmod.Wrapf(ErrInvalidAmount, "unable to parse transfer amount (%s) into math.Int", ftpd.Amount) } diff --git a/modules/apps/transfer/types/transfer_authorization.go b/modules/apps/transfer/types/transfer_authorization.go index 597e3fa9f6b..119b148e8cb 100644 --- a/modules/apps/transfer/types/transfer_authorization.go +++ b/modules/apps/transfer/types/transfer_authorization.go @@ -147,5 +147,5 @@ func isAllowedAddress(ctx sdk.Context, receiver string, allowedAddrs []string) b // will be granted the privilege to do ICS20 token transfers for the total amount // of the denomination available at the granter's account. func UnboundedSpendLimit() sdkmath.Int { - return sdk.NewIntFromBigInt(maxUint256) + return sdkmath.NewIntFromBigInt(maxUint256) } diff --git a/modules/apps/transfer/types/transfer_authorization_test.go b/modules/apps/transfer/types/transfer_authorization_test.go index a549bce954e..eb50f2e5f8a 100644 --- a/modules/apps/transfer/types/transfer_authorization_test.go +++ b/modules/apps/transfer/types/transfer_authorization_test.go @@ -1,6 +1,7 @@ package types_test import ( + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/authz" "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" @@ -33,7 +34,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { { "success: with spend limit updated", func() { - msgTransfer.Token = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(50)) + msgTransfer.Token = sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(50)) }, func(res authz.AcceptResponse, err error) { suite.Require().NoError(err) @@ -44,7 +45,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { updatedAuthz, ok := res.Updated.(*types.TransferAuthorization) suite.Require().True(ok) - isEqual := updatedAuthz.Allocations[0].SpendLimit.IsEqual(sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(50)))) + isEqual := updatedAuthz.Allocations[0].SpendLimit.IsEqual(sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(50)))) suite.Require().True(isEqual) }, }, @@ -103,11 +104,11 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { func() { transferAuthz.Allocations[0].SpendLimit = transferAuthz.Allocations[0].SpendLimit.Add( sdk.NewCoins( - sdk.NewCoin("test-denom", sdk.NewInt(100)), - sdk.NewCoin("test-denom2", sdk.NewInt(100)), + sdk.NewCoin("test-denom", sdkmath.NewInt(100)), + sdk.NewCoin("test-denom2", sdkmath.NewInt(100)), )..., ) - msgTransfer.Token = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(50)) + msgTransfer.Token = sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(50)) }, func(res authz.AcceptResponse, err error) { suite.Require().NoError(err) @@ -116,13 +117,13 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { suite.Require().True(ok) remainder := updatedTransferAuthz.Allocations[0].SpendLimit.AmountOf(sdk.DefaultBondDenom) - suite.Require().True(sdk.NewInt(50).Equal(remainder)) + suite.Require().True(sdkmath.NewInt(50).Equal(remainder)) remainder = updatedTransferAuthz.Allocations[0].SpendLimit.AmountOf("test-denom") - suite.Require().True(sdk.NewInt(100).Equal(remainder)) + suite.Require().True(sdkmath.NewInt(100).Equal(remainder)) remainder = updatedTransferAuthz.Allocations[0].SpendLimit.AmountOf("test-denom2") - suite.Require().True(sdk.NewInt(100).Equal(remainder)) + suite.Require().True(sdkmath.NewInt(100).Equal(remainder)) }, }, { @@ -138,7 +139,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationAccept() { { "requested transfer amount is more than the spend limit", func() { - msgTransfer.Token = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000)) + msgTransfer.Token = sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(1000)) }, func(res authz.AcceptResponse, err error) { suite.Require().Error(err) @@ -221,7 +222,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationValidateBasic() { allocation := types.Allocation{ SourcePort: types.PortID, SourceChannel: "channel-1", - SpendLimit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + SpendLimit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100))), AllowList: []string{}, } @@ -291,7 +292,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationValidateBasic() { allocation := types.Allocation{ SourcePort: mock.PortID, SourceChannel: transferAuthz.Allocations[0].SourceChannel, - SpendLimit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + SpendLimit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100))), AllowList: []string{ibctesting.TestAccAddress}, } @@ -308,7 +309,7 @@ func (suite *TypesTestSuite) TestTransferAuthorizationValidateBasic() { { SourcePort: mock.PortID, SourceChannel: ibctesting.FirstChannelID, - SpendLimit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + SpendLimit: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100))), AllowList: []string{ibctesting.TestAccAddress}, }, }, diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index eb6a5b82d11..50d6fedc23e 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -5,6 +5,7 @@ import ( "testing" "time" + sdkmath "cosmossdk.io/math" tmbytes "github.com/cometbft/cometbft/libs/bytes" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" tmtypes "github.com/cometbft/cometbft/types" @@ -110,7 +111,7 @@ func (suite *KeeperTestSuite) SetupTest() { suite.Require().NoError(err) val.Status = stakingtypes.Bonded - val.Tokens = sdk.NewInt(rand.Int63()) + val.Tokens = sdkmath.NewInt(rand.Int63()) validators = append(validators, val) hi := stakingtypes.NewHistoricalInfo(suite.ctx.BlockHeader(), validators, sdk.DefaultPowerReduction) diff --git a/modules/core/02-client/proposal_handler_test.go b/modules/core/02-client/proposal_handler_test.go index 3a417197f71..a4914f282cf 100644 --- a/modules/core/02-client/proposal_handler_test.go +++ b/modules/core/02-client/proposal_handler_test.go @@ -1,6 +1,7 @@ package client_test import ( + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" @@ -64,7 +65,7 @@ func (suite *ClientTestSuite) TestNewClientUpdateProposalHandler() { Title: ibctesting.Title, Description: ibctesting.Description, Recipient: suite.chainA.SenderAccount.GetAddress().String(), - Amount: sdk.NewCoins(sdk.NewCoin("communityfunds", sdk.NewInt(10))), + Amount: sdk.NewCoins(sdk.NewCoin("communityfunds", sdkmath.NewInt(10))), } }, false, }, diff --git a/testing/app.go b/testing/app.go index d219c34d323..2f188d2770a 100644 --- a/testing/app.go +++ b/testing/app.go @@ -88,16 +88,16 @@ func SetupWithGenesisValSet(tb testing.TB, valSet *tmtypes.ValidatorSet, genAccs Jailed: false, Status: stakingtypes.Bonded, Tokens: bondAmt, - DelegatorShares: sdk.OneDec(), + DelegatorShares: sdkmath.LegacyOneDec(), Description: stakingtypes.Description{}, UnbondingHeight: int64(0), UnbondingTime: time.Unix(0, 0).UTC(), - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), - MinSelfDelegation: sdk.ZeroInt(), + Commission: stakingtypes.NewCommission(sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec()), + MinSelfDelegation: sdkmath.ZeroInt(), } validators = append(validators, validator) - delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) + delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdkmath.LegacyOneDec())) } // set validators and delegations @@ -109,7 +109,7 @@ func SetupWithGenesisValSet(tb testing.TB, valSet *tmtypes.ValidatorSet, genAccs // add bonded amount to bonded pool module account balances = append(balances, banktypes.Balance{ Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(), - Coins: sdk.Coins{sdk.NewCoin(bondDenom, bondAmt.Mul(sdk.NewInt(int64(len(valSet.Validators)))))}, + Coins: sdk.Coins{sdk.NewCoin(bondDenom, bondAmt.Mul(sdkmath.NewInt(int64(len(valSet.Validators)))))}, }) // set validators and delegations diff --git a/testing/chain.go b/testing/chain.go index ac70d9dcc1c..13ce21a8ec4 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -6,6 +6,7 @@ import ( "time" errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/crypto/tmhash" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" @@ -105,7 +106,7 @@ func NewTestChainWithValSet(tb testing.TB, coord *Coordinator, chainID string, v for i := 0; i < MaxAccounts; i++ { senderPrivKey := secp256k1.GenPrivKey() acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), uint64(i), 0) - amount, ok := sdk.NewIntFromString("10000000000000000000") + amount, ok := sdkmath.NewIntFromString("10000000000000000000") require.True(tb, ok) // add sender account diff --git a/testing/chain_test.go b/testing/chain_test.go index 4f1f4e4a118..e0a97795e38 100644 --- a/testing/chain_test.go +++ b/testing/chain_test.go @@ -3,7 +3,7 @@ package ibctesting_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/stretchr/testify/require" @@ -18,9 +18,9 @@ func TestChangeValSet(t *testing.T) { path := ibctesting.NewPath(chainA, chainB) coord.Setup(path) - amount, ok := sdk.NewIntFromString("10000000000000000000") + amount, ok := sdkmath.NewIntFromString("10000000000000000000") require.True(t, ok) - amount2, ok := sdk.NewIntFromString("30000000000000000000") + amount2, ok := sdkmath.NewIntFromString("30000000000000000000") require.True(t, ok) val := chainA.GetSimApp().StakingKeeper.GetValidators(chainA.GetContext(), 4) diff --git a/testing/simapp/state.go b/testing/simapp/state.go index b83a5877d6b..fb69deb7512 100644 --- a/testing/simapp/state.go +++ b/testing/simapp/state.go @@ -88,7 +88,7 @@ func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simty panic(err) } // compute not bonded balance - notBondedTokens := sdk.ZeroInt() + notBondedTokens := sdkmath.ZeroInt() for _, val := range stakingState.Validators { if val.Status != stakingtypes.Unbonded { continue diff --git a/testing/simapp/test_helpers.go b/testing/simapp/test_helpers.go index 683cd2e07e7..64226ae9d74 100644 --- a/testing/simapp/test_helpers.go +++ b/testing/simapp/test_helpers.go @@ -6,6 +6,7 @@ import ( "testing" "time" + sdkmath "cosmossdk.io/math" dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/log" @@ -70,7 +71,7 @@ func Setup(isCheckTx bool) *SimApp { acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) balance := banktypes.Balance{ Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))), } app := SetupWithGenesisValSet(valSet, []authtypes.GenesisAccount{acc}, balance) @@ -131,12 +132,12 @@ func genesisStateWithValSet(app *SimApp, genesisState GenesisState, Jailed: false, Status: stakingtypes.Bonded, Tokens: bondAmt, - DelegatorShares: sdk.OneDec(), + DelegatorShares: sdkmath.LegacyOneDec(), Description: stakingtypes.Description{}, UnbondingHeight: int64(0), UnbondingTime: time.Unix(0, 0).UTC(), - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), - MinSelfDelegation: sdk.ZeroInt(), + Commission: stakingtypes.NewCommission(sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec(), sdkmath.LegacyZeroDec()), + MinSelfDelegation: sdkmath.ZeroInt(), } validators = append(validators, validator) delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) diff --git a/testing/solomachine.go b/testing/solomachine.go index 4385c270fe4..313e93de696 100644 --- a/testing/solomachine.go +++ b/testing/solomachine.go @@ -4,6 +4,7 @@ import ( "testing" "time" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" @@ -369,7 +370,7 @@ func (solo *Solomachine) SendTransfer(chain *TestChain, portID, channelID string msgTransfer := transfertypes.MsgTransfer{ SourcePort: portID, SourceChannel: channelID, - Token: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), + Token: sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)), Sender: chain.SenderAccount.GetAddress().String(), Receiver: chain.SenderAccount.GetAddress().String(), TimeoutHeight: clienttypes.ZeroHeight(), diff --git a/testing/values.go b/testing/values.go index fa69c502069..0251e40bc81 100644 --- a/testing/values.go +++ b/testing/values.go @@ -7,6 +7,7 @@ package ibctesting import ( "time" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" @@ -50,7 +51,7 @@ var ( DefaultTrustLevel = ibctm.DefaultTrustLevel TestAccAddress = "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs" - TestCoin = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) + TestCoin = sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)) TestCoins = sdk.NewCoins(TestCoin) UpgradePath = []string{"upgrade", "upgradedIBCState"}