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

feat: add ordering at ica account creation #276

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions proto/initia/intertx/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "amino/amino.proto";
import "cosmos/msg/v1/msg.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "ibc/core/channel/v1/channel.proto";

option go_package = "github.com/initia-labs/initia/x/intertx/types";

Expand All @@ -30,6 +31,7 @@ message MsgRegisterAccount {
string owner = 1;
string connection_id = 2 [(gogoproto.moretags) = "yaml:\"connection_id\""];
string version = 3;
ibc.core.channel.v1.Order ordering = 4;
}

// MsgRegisterAccountResponse defines the response for Msg/RegisterAccount
Expand Down
4 changes: 4 additions & 0 deletions x/intertx/client/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ const (
FlagConnectionID = "connection-id"
// The controller chain channel version
FlagVersion = "version"
// Set the ordering of the channel to ordered
FlagOrdered = "ordered"
)

// common flagsets to add to various functions
var (
fsConnectionID = flag.NewFlagSet("", flag.ContinueOnError)
fsVersion = flag.NewFlagSet("", flag.ContinueOnError)
fsOrdered = flag.NewFlagSet("", flag.ContinueOnError)
)

func init() {
fsConnectionID.String(FlagConnectionID, "", "Connection ID")
fsVersion.String(FlagVersion, "", "Version")
fsOrdered.Bool(FlagOrdered, false, "Set the ordering of the channel to ordered")
}
8 changes: 8 additions & 0 deletions x/intertx/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"

channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
)

// GetTxCmd creates and returns the intertx tx command
Expand Down Expand Up @@ -55,6 +57,11 @@
viper.GetString(FlagVersion),
)

ordered := viper.GetBool(FlagOrdered)
if ordered {
msg.Ordering = channeltypes.ORDERED
}

Check warning on line 63 in x/intertx/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/intertx/client/cli/tx.go#L60-L63

Added lines #L60 - L63 were not covered by tests

if err := msg.Validate(ac); err != nil {
return err
}
Expand All @@ -65,6 +72,7 @@

cmd.Flags().AddFlagSet(fsConnectionID)
cmd.Flags().AddFlagSet(fsVersion)
cmd.Flags().AddFlagSet(fsOrdered)

Check warning on line 75 in x/intertx/client/cli/tx.go

View check run for this annotation

Codecov / codecov/patch

x/intertx/client/cli/tx.go#L75

Added line #L75 was not covered by tests
_ = cmd.MarkFlagRequired(FlagConnectionID)

flags.AddTxFlagsToCmd(cmd)
Expand Down
2 changes: 2 additions & 0 deletions x/intertx/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ func (k msgServer) RegisterAccount(goCtx context.Context, msg *types.MsgRegister
ctx := sdk.UnwrapSDKContext(goCtx)

icaMsg := icacontrollertypes.NewMsgRegisterInterchainAccount(msg.ConnectionId, msg.Owner, msg.Version)
icaMsg.Ordering = msg.Ordering

if _, err := k.icaControllerMsgServer.RegisterInterchainAccount(ctx, icaMsg); err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions x/intertx/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (suite *KeeperTestSuite) TestRegisterInterchainAccount() {

msgSrv := keeper.NewMsgServerImpl(*GetICAApp(suite.chainA).GetICAAuthKeeper())
msg := types.NewMsgRegisterAccount(owner, path.EndpointA.ConnectionID, path.EndpointA.ChannelConfig.Version)
msg.Ordering = channeltypes.ORDERED

res, err := msgSrv.RegisterAccount(sdk.WrapSDKContext(suite.chainA.GetContext()), msg)

Expand Down
106 changes: 69 additions & 37 deletions x/intertx/types/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading