Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: remove GetPrefixedDenom #6440

Merged
merged 6 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (core) [\#6138](https://github.com/cosmos/ibc-go/pull/6138) Remove `Router` reference from IBC core keeper and use instead the router on the existing `PortKeeper` reference.
* (core/04-channel) [\#6023](https://github.com/cosmos/ibc-go/pull/6023) Remove emission of non-hexlified event attributes `packet_data` and `packet_ack`.
* (core) [\#6320](https://github.com/cosmos/ibc-go/pull/6320) Remove unnecessary `Proof` interface from `exported` package.
* (core/05-port) [\#6341](https://github.com/cosmos/ibc-go/pull/6341) Modify `UnmarshalPacketData` interface to take in the context, portID, and channelID. This allows for packet data's to be unmarshaled based on the channel version.
* (core/05-port) [\#6341](https://github.com/cosmos/ibc-go/pull/6341) Modify `UnmarshalPacketData` interface to take in the context, portID, and channelID. This allows for packet data's to be unmarshaled based on the channel version.
* (apps/transfer) [\#6440](https://github.com/cosmos/ibc-go/pull/6440) Remove `GetPrefixedDenom`.

### State Machine Breaking

Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/wasm/grandpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ func (s *GrandpaTestSuite) TestMsgTransfer_Succeeds_GrandpaContract() {
s.Require().True(cosmosUserStakeBal.Equal(finalStakeBal))

// Verify cosmos user's final "unit" balance
unitDenomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", "UNIT"))
cosmosUserUnitBal, err := cosmosChain.GetBalance(ctx, cosmosUser.FormattedAddress(), unitDenomTrace.IBCDenom())
denom := transfertypes.NewDenom("UNIT", transfertypes.NewTrace("transfer", "channel-0"))
cosmosUserUnitBal, err := cosmosChain.GetBalance(ctx, cosmosUser.FormattedAddress(), denom.IBCDenom())
s.Require().NoError(err)
s.Require().True(cosmosUserUnitBal.Equal(amountUnits))

Expand Down
14 changes: 7 additions & 7 deletions modules/apps/callbacks/replay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ func (s *CallbacksTestSuite) TestTransferRecvPacketReplayProtection() {
}

// save initial balance of receiver
voucherDenomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom(s.path.EndpointB.ChannelConfig.PortID, s.path.EndpointB.ChannelID, sdk.DefaultBondDenom))
initialBalance := GetSimApp(s.chainB).BankKeeper.GetBalance(s.chainB.GetContext(), s.chainB.SenderAccount.GetAddress(), voucherDenomTrace.IBCDenom())
voucherDenom := transfertypes.NewDenom(sdk.DefaultBondDenom, transfertypes.NewTrace(s.path.EndpointB.ChannelConfig.PortID, s.path.EndpointB.ChannelID))
initialBalance := GetSimApp(s.chainB).BankKeeper.GetBalance(s.chainB.GetContext(), s.chainB.SenderAccount.GetAddress(), voucherDenom.IBCDenom())

// execute the transfer
s.ExecuteTransfer(tc.transferMemo)
Expand All @@ -296,9 +296,9 @@ func (s *CallbacksTestSuite) TestTransferRecvPacketReplayProtection() {
s.Require().Equal(1, callbackCount)

// expected is not a malicious amount
expBalance := initialBalance.Add(sdk.NewCoin(voucherDenomTrace.IBCDenom(), ibctesting.TestCoin.Amount))
expBalance := initialBalance.Add(sdk.NewCoin(voucherDenom.IBCDenom(), ibctesting.TestCoin.Amount))

afterBalance := GetSimApp(s.chainB).BankKeeper.GetBalance(s.chainB.GetContext(), s.chainB.SenderAccount.GetAddress(), voucherDenomTrace.IBCDenom())
afterBalance := GetSimApp(s.chainB).BankKeeper.GetBalance(s.chainB.GetContext(), s.chainB.SenderAccount.GetAddress(), voucherDenom.IBCDenom())

s.Require().Equal(expBalance.Amount, afterBalance.Amount)
})
Expand All @@ -319,8 +319,8 @@ func (s *CallbacksTestSuite) ExecuteFailedTransfer(memo string) {
// record the balance of the escrow address before the transfer
escrowBalance := GetSimApp(s.chainA).BankKeeper.GetBalance(s.chainA.GetContext(), escrowAddress, sdk.DefaultBondDenom)
// record the balance of the receiving address before the transfer
voucherDenomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom(s.path.EndpointB.ChannelConfig.PortID, s.path.EndpointB.ChannelID, sdk.DefaultBondDenom))
receiverBalance := GetSimApp(s.chainB).BankKeeper.GetBalance(s.chainB.GetContext(), s.chainB.SenderAccount.GetAddress(), voucherDenomTrace.IBCDenom())
voucherDenom := transfertypes.NewDenom(sdk.DefaultBondDenom, transfertypes.NewTrace(s.path.EndpointB.ChannelConfig.PortID, s.path.EndpointB.ChannelID))
receiverBalance := GetSimApp(s.chainB).BankKeeper.GetBalance(s.chainB.GetContext(), s.chainB.SenderAccount.GetAddress(), voucherDenom.IBCDenom())

amount := ibctesting.TestCoin
msg := transfertypes.NewMsgTransfer(
Expand All @@ -347,5 +347,5 @@ func (s *CallbacksTestSuite) ExecuteFailedTransfer(memo string) {
// check that the escrow address balance hasn't changed
s.Require().Equal(escrowBalance, GetSimApp(s.chainA).BankKeeper.GetBalance(s.chainA.GetContext(), escrowAddress, sdk.DefaultBondDenom))
// check that the receiving address balance hasn't changed
s.Require().Equal(receiverBalance, GetSimApp(s.chainB).BankKeeper.GetBalance(s.chainB.GetContext(), s.chainB.SenderAccount.GetAddress(), voucherDenomTrace.IBCDenom()))
s.Require().Equal(receiverBalance, GetSimApp(s.chainB).BankKeeper.GetBalance(s.chainB.GetContext(), s.chainB.SenderAccount.GetAddress(), voucherDenom.IBCDenom()))
}
6 changes: 3 additions & 3 deletions modules/apps/callbacks/transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ func (s *CallbacksTestSuite) ExecuteTransfer(memo string) {
// record the balance of the escrow address before the transfer
escrowBalance := GetSimApp(s.chainA).BankKeeper.GetBalance(s.chainA.GetContext(), escrowAddress, sdk.DefaultBondDenom)
// record the balance of the receiving address before the transfer
voucherDenomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom(s.path.EndpointB.ChannelConfig.PortID, s.path.EndpointB.ChannelID, sdk.DefaultBondDenom))
receiverBalance := GetSimApp(s.chainB).BankKeeper.GetBalance(s.chainB.GetContext(), s.chainB.SenderAccount.GetAddress(), voucherDenomTrace.IBCDenom())
voucherDenom := transfertypes.NewDenom(sdk.DefaultBondDenom, transfertypes.NewTrace(s.path.EndpointB.ChannelConfig.PortID, s.path.EndpointB.ChannelID))
receiverBalance := GetSimApp(s.chainB).BankKeeper.GetBalance(s.chainB.GetContext(), s.chainB.SenderAccount.GetAddress(), voucherDenom.IBCDenom())

amount := ibctesting.TestCoin
msg := transfertypes.NewMsgTransfer(
Expand All @@ -210,7 +210,7 @@ func (s *CallbacksTestSuite) ExecuteTransfer(memo string) {
// check that the escrow address balance increased by 100
s.Require().Equal(escrowBalance.Add(amount), GetSimApp(s.chainA).BankKeeper.GetBalance(s.chainA.GetContext(), escrowAddress, sdk.DefaultBondDenom))
// check that the receiving address balance increased by 100
s.Require().Equal(receiverBalance.AddAmount(sdkmath.NewInt(100)), GetSimApp(s.chainB).BankKeeper.GetBalance(s.chainB.GetContext(), s.chainB.SenderAccount.GetAddress(), voucherDenomTrace.IBCDenom()))
s.Require().Equal(receiverBalance.AddAmount(sdkmath.NewInt(100)), GetSimApp(s.chainB).BankKeeper.GetBalance(s.chainB.GetContext(), s.chainB.SenderAccount.GetAddress(), voucherDenom.IBCDenom()))
}

// ExecuteTransferTimeout executes a transfer message on chainA for 100 denom.
Expand Down
3 changes: 2 additions & 1 deletion modules/apps/transfer/keeper/migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ func (suite *KeeperTestSuite) TestMigrateTotalEscrowForDenom() {
"success: valid ibc denom escrowed in one channel",
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))
voucherDenom := transfertypes.NewDenom(sdk.DefaultBondDenom, transfertypes.NewTrace(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID))
trace := transfertypes.ParseDenomTrace(voucherDenom.FullPath())
coin := sdk.NewCoin(trace.IBCDenom(), sdkmath.NewInt(100))
denom = trace.IBCDenom()

Expand Down
Loading
Loading