Skip to content

Commit

Permalink
remove --app-address flag from subcommands
Browse files Browse the repository at this point in the history
Signed-off-by: Masanori Yoshida <[email protected]>
  • Loading branch information
siburu committed Aug 22, 2024
1 parent acea618 commit 4e04d54
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 27 deletions.
25 changes: 1 addition & 24 deletions pkg/relay/ethereum/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
chantypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
"github.com/datachainlab/ethereum-ibc-relay-chain/pkg/contract/iibcchannelupgradablemodule"
"github.com/ethereum/go-ethereum/common"
"github.com/hyperledger-labs/yui-relayer/config"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
Expand Down Expand Up @@ -43,7 +42,6 @@ func channelUpgradeCmd(ctx *config.Context) *cobra.Command {

func proposeUpgradeCmd(ctx *config.Context) *cobra.Command {
const (
flagAppAddress = "app-address"
flagOrdering = "ordering"
flagConnectionHops = "connection-hops"
flagVersion = "version"
Expand All @@ -52,21 +50,13 @@ func proposeUpgradeCmd(ctx *config.Context) *cobra.Command {
)

cmd := cobra.Command{
Use: "propose-init",
Use: "propose-upgrade",
Aliases: []string{"propose"},
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
pathName := args[0]
chainID := args[1]

// get app address from flags
var appAddr common.Address
if appAddrHex, err := cmd.Flags().GetString(flagAppAddress); err != nil {
return err
} else {
appAddr = common.HexToAddress(appAddrHex)
}

// get ordering from flags
ordering, err := getOrderFromFlags(cmd.Flags(), flagOrdering)
if err != nil {
Expand Down Expand Up @@ -112,7 +102,6 @@ func proposeUpgradeCmd(ctx *config.Context) *cobra.Command {

return ethChain.ProposeUpgrade(
cmd.Context(),
appAddr,
ethChain.pathEnd.PortID,
ethChain.pathEnd.ChannelID,
iibcchannelupgradablemodule.UpgradeFieldsData{
Expand All @@ -128,7 +117,6 @@ func proposeUpgradeCmd(ctx *config.Context) *cobra.Command {
},
}

cmd.Flags().String(flagAppAddress, "", "IBC app module address")
cmd.Flags().String(flagOrdering, "", "channel ordering applied for the new channel")
cmd.Flags().StringSlice(flagConnectionHops, []string{}, "connection hops applied for the new channel")
cmd.Flags().String(flagVersion, "", "channel version applied for the new channel")
Expand All @@ -140,7 +128,6 @@ func proposeUpgradeCmd(ctx *config.Context) *cobra.Command {

func allowTransitionToFlushCompleteCmd(ctx *config.Context) *cobra.Command {
const (
flagAppAddress = "app-address"
flagUpgradeSequence = "upgrade-sequence"
)

Expand All @@ -152,14 +139,6 @@ func allowTransitionToFlushCompleteCmd(ctx *config.Context) *cobra.Command {
pathName := args[0]
chainID := args[1]

// get app address from flags
var appAddr common.Address
if appAddrHex, err := cmd.Flags().GetString(flagAppAddress); err != nil {
return err
} else {
appAddr = common.HexToAddress(appAddrHex)
}

// get upgrade sequence from flags
upgradeSequence, err := cmd.Flags().GetUint64(flagUpgradeSequence)
if err != nil {
Expand All @@ -177,15 +156,13 @@ func allowTransitionToFlushCompleteCmd(ctx *config.Context) *cobra.Command {

return ethChain.AllowTransitionToFlushComplete(
cmd.Context(),
appAddr,
ethChain.pathEnd.PortID,
ethChain.pathEnd.ChannelID,
upgradeSequence,
)
},
}

cmd.Flags().String(flagAppAddress, "", "IBC app module address")
cmd.Flags().Uint64(flagUpgradeSequence, 0, "upgrade sequence")

return &cmd
Expand Down
13 changes: 10 additions & 3 deletions pkg/relay/ethereum/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ import (
"fmt"

"github.com/datachainlab/ethereum-ibc-relay-chain/pkg/contract/iibcchannelupgradablemodule"
"github.com/ethereum/go-ethereum/common"
gethtypes "github.com/ethereum/go-ethereum/core/types"
)

func (c *Chain) ProposeUpgrade(
ctx context.Context,
appAddr common.Address,
portID string,
channelID string,
upgradeFields iibcchannelupgradablemodule.UpgradeFieldsData,
timeout iibcchannelupgradablemodule.TimeoutData,
) error {
appAddr, err := c.ibcHandler.GetIBCModuleByChannel(c.CallOpts(ctx, 0), portID, channelID)
if err != nil {
return err
}

mockApp, err := iibcchannelupgradablemodule.NewIibcchannelupgradablemodule(
appAddr,
c.client.Client,
Expand Down Expand Up @@ -52,11 +55,15 @@ func (c *Chain) ProposeUpgrade(

func (c *Chain) AllowTransitionToFlushComplete(
ctx context.Context,
appAddr common.Address,
portID string,
channelID string,
upgradeSequence uint64,
) error {
appAddr, err := c.ibcHandler.GetIBCModuleByChannel(c.CallOpts(ctx, 0), portID, channelID)
if err != nil {
return err
}

mockApp, err := iibcchannelupgradablemodule.NewIibcchannelupgradablemodule(
appAddr,
c.client.Client,
Expand Down

0 comments on commit 4e04d54

Please sign in to comment.