Skip to content

Commit

Permalink
refactor(api)!: remove unnecessary channel getter functions (cosmos#5705
Browse files Browse the repository at this point in the history
)

* refactor: remove unnecessary channelI interface

* rm: unused GetChannel function

* rm: channel.GetVersion() function

* rm: channel.GetCounterparty()

* rm: channel.GetOrdering()

* rm: channel.GetConnectionHops()

* lint

* update v9 migration docs

* rm: GetConnectinoHops() usage in e2es

---------

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
  • Loading branch information
colin-axner and crodriguezvega committed Jan 25, 2024
1 parent c62d15b commit 310a4bd
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 41 deletions.
2 changes: 2 additions & 0 deletions docs/docs/05-migrations/13-v8-to-v9.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ There are four sections based on the four potential user groups of this document

The `exported.ChannelI` interface has been removed. Please use the concrete type.

The functions `GetState()`, `GetOrdering()`, `GetCounterparty()`, `GetConnectionHops()`, `GetVersion()` of the `Channel` type have been removed.

### API deprecation notice

The testing package functions `coordinator.Setup`, `coordinator.SetupClients`, `coordinator.SetupConnections`, `coordinator.CreateConnections`, and `coordinator.CreateChannels` have been deprecated and will be removed in v10.
Expand Down
6 changes: 3 additions & 3 deletions e2e/tests/interchain_accounts/localhost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_Localhost(
s.Require().NoError(err)
s.Require().NotNil(channelEndB)

s.Require().Equal(channelEndA.GetConnectionHops(), channelEndB.GetConnectionHops())
s.Require().Equal(channelEndA.ConnectionHops, channelEndB.ConnectionHops)
})

t.Run("verify interchain account registration and deposit funds", func(t *testing.T) {
Expand Down Expand Up @@ -271,7 +271,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan
s.Require().NoError(err)
s.Require().NotNil(channelEndB)

s.Require().Equal(channelEndA.GetConnectionHops(), channelEndB.GetConnectionHops())
s.Require().Equal(channelEndA.ConnectionHops, channelEndB.ConnectionHops)
})

t.Run("verify interchain account registration and deposit funds", func(t *testing.T) {
Expand Down Expand Up @@ -401,7 +401,7 @@ func (s *LocalhostInterchainAccountsTestSuite) TestInterchainAccounts_ReopenChan
s.Require().NoError(err)
s.Require().NotNil(channelEndB)

s.Require().Equal(channelEndA.GetConnectionHops(), channelEndB.GetConnectionHops())
s.Require().Equal(channelEndA.ConnectionHops, channelEndB.ConnectionHops)
})

t.Run("verify interchain account and existing balance", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/transfer/localhost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (s *LocalhostTransferTestSuite) TestMsgTransfer_Localhost() {
s.Require().NoError(err)
s.Require().NotNil(channelEndB)

s.Require().Equal(channelEndA.GetConnectionHops(), channelEndB.GetConnectionHops())
s.Require().Equal(channelEndA.ConnectionHops, channelEndB.ConnectionHops)
})

t.Run("send packet localhost ibc transfer", func(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() {
cbs = controller.NewIBCMiddleware(nil, suite.chainA.GetSimApp().ICAControllerKeeper)
}

version, err := cbs.OnChanOpenInit(suite.chainA.GetContext(), channel.Ordering, channel.GetConnectionHops(),
path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, chanCap, channel.Counterparty, channel.GetVersion(),
version, err := cbs.OnChanOpenInit(suite.chainA.GetContext(), channel.Ordering, channel.ConnectionHops,
path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, chanCap, channel.Counterparty, channel.Version,
)

if tc.expPass {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenInit() {

tc.malleate() // malleate mutates test data

version, err := suite.chainA.GetSimApp().ICAControllerKeeper.OnChanOpenInit(suite.chainA.GetContext(), channel.Ordering, channel.GetConnectionHops(),
version, err := suite.chainA.GetSimApp().ICAControllerKeeper.OnChanOpenInit(suite.chainA.GetContext(), channel.Ordering, channel.ConnectionHops,
path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, chanCap, channel.Counterparty, channel.Version,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenTry() {
cbs, ok := suite.chainB.App.GetIBCKeeper().Router.GetRoute(module)
suite.Require().True(ok)

version, err := cbs.OnChanOpenTry(suite.chainB.GetContext(), channel.Ordering, channel.GetConnectionHops(),
version, err := cbs.OnChanOpenTry(suite.chainB.GetContext(), channel.Ordering, channel.ConnectionHops,
path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, chanCap, channel.Counterparty, path.EndpointA.ChannelConfig.Version,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func (suite *KeeperTestSuite) TestOnChanOpenTry() {

tc.malleate() // malleate mutates test data

version, err := suite.chainB.GetSimApp().ICAHostKeeper.OnChanOpenTry(suite.chainB.GetContext(), channel.Ordering, channel.GetConnectionHops(),
version, err := suite.chainB.GetSimApp().ICAHostKeeper.OnChanOpenTry(suite.chainB.GetContext(), channel.Ordering, channel.ConnectionHops,
path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, chanCap, channel.Counterparty, path.EndpointA.ChannelConfig.Version,
)

Expand Down
4 changes: 2 additions & 2 deletions modules/apps/29-fee/ibc_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (suite *FeeTestSuite) TestOnChanOpenInit() {
cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module)
suite.Require().True(ok)

version, err := cbs.OnChanOpenInit(suite.chainA.GetContext(), channel.Ordering, channel.GetConnectionHops(),
version, err := cbs.OnChanOpenInit(suite.chainA.GetContext(), channel.Ordering, channel.ConnectionHops,
suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, chanCap, counterparty, channel.Version)

if tc.expPass {
Expand Down Expand Up @@ -215,7 +215,7 @@ func (suite *FeeTestSuite) TestOnChanOpenTry() {
cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module)
suite.Require().True(ok)

_, err = cbs.OnChanOpenTry(suite.chainA.GetContext(), channel.Ordering, channel.GetConnectionHops(),
_, err = cbs.OnChanOpenTry(suite.chainA.GetContext(), channel.Ordering, channel.ConnectionHops,
suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, chanCap, counterparty, tc.cpVersion)

if tc.expPass {
Expand Down
6 changes: 3 additions & 3 deletions modules/apps/transfer/ibc_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func (suite *TransferTestSuite) TestOnChanOpenInit() {
tc.malleate() // explicitly change fields in channel and testChannel

transferModule := transfer.NewIBCModule(suite.chainA.GetSimApp().TransferKeeper)
version, err := transferModule.OnChanOpenInit(suite.chainA.GetContext(), channel.Ordering, channel.GetConnectionHops(),
path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, chanCap, counterparty, channel.GetVersion(),
version, err := transferModule.OnChanOpenInit(suite.chainA.GetContext(), channel.Ordering, channel.ConnectionHops,
path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, chanCap, counterparty, channel.Version,
)

if tc.expPass {
Expand Down Expand Up @@ -188,7 +188,7 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() {

tc.malleate() // explicitly change fields in channel and testChannel

version, err := cbs.OnChanOpenTry(suite.chainA.GetContext(), channel.Ordering, channel.GetConnectionHops(),
version, err := cbs.OnChanOpenTry(suite.chainA.GetContext(), channel.Ordering, channel.ConnectionHops,
path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, chanCap, channel.Counterparty, counterpartyVersion,
)

Expand Down
4 changes: 2 additions & 2 deletions modules/apps/transfer/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func (k Keeper) sendTransfer(
return 0, errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", sourcePort, sourceChannel)
}

destinationPort := channel.GetCounterparty().GetPortID()
destinationChannel := channel.GetCounterparty().GetChannelID()
destinationPort := channel.Counterparty.GetPortID()
destinationChannel := channel.Counterparty.GetChannelID()

// begin createOutgoingPacket logic
// See spec for this logic: https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transfer#packet-relay
Expand Down
25 changes: 0 additions & 25 deletions modules/core/04-channel/types/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,6 @@ func NewChannel(
}
}

// GetState implements Channel interface.
func (ch Channel) GetState() int32 {
return int32(ch.State)
}

// GetOrdering implements Channel interface.
func (ch Channel) GetOrdering() int32 {
return int32(ch.Ordering)
}

// GetCounterparty implements Channel interface.
func (ch Channel) GetCounterparty() exported.CounterpartyChannelI {
return ch.Counterparty
}

// GetConnectionHops implements Channel interface.
func (ch Channel) GetConnectionHops() []string {
return ch.ConnectionHops
}

// GetVersion implements Channel interface.
func (ch Channel) GetVersion() string {
return ch.Version
}

// ValidateBasic performs a basic validation of the channel fields
func (ch Channel) ValidateBasic() error {
if ch.State == UNINITIALIZED {
Expand Down

0 comments on commit 310a4bd

Please sign in to comment.