Skip to content

Commit

Permalink
Revert introducing a common Type proto message
Browse files Browse the repository at this point in the history
  • Loading branch information
zale144 committed May 27, 2024
1 parent 8ffd74e commit e46f5f2
Show file tree
Hide file tree
Showing 19 changed files with 188 additions and 239 deletions.
7 changes: 6 additions & 1 deletion proto/dymension/common/rollapp_packet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package dymensionxyz.dymension.common;
import "gogoproto/gogo.proto";
import "ibc/core/channel/v1/channel.proto";
import "dymension/common/status.proto";
import "dymension/common/type.proto";

option go_package = "github.com/dymensionxyz/dymension/v3/x/common/types";

Expand All @@ -15,6 +14,12 @@ message RollappPacket {
Status status = 4;
uint64 ProofHeight = 5;
bytes relayer = 6;
enum Type {
ON_RECV = 0;
ON_ACK = 1;
ON_TIMEOUT = 2;
UNDEFINED = -1;
}
Type type = 7;
// stores the result of onAck, onTimeout or onRecv/writeAck
string error = 8;
Expand Down
13 changes: 0 additions & 13 deletions proto/dymension/common/type.proto

This file was deleted.

3 changes: 1 addition & 2 deletions proto/dymension/delayedack/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "dymension/delayedack/params.proto";
import "dymension/common/status.proto";
import "dymension/common/type.proto";
import "dymension/common/rollapp_packet.proto";

option go_package = "github.com/dymensionxyz/dymension/v3/x/delayedack/types";
Expand Down Expand Up @@ -36,7 +35,7 @@ message QueryParamsResponse {
message QueryRollappPacketsRequest {
string rollappId = 1;
common.Status status = 2;
common.Type type = 3;
common.RollappPacket.Type type = 3;
cosmos.base.query.v1beta1.PageRequest pagination = 4;
}

Expand Down
4 changes: 2 additions & 2 deletions x/common/types/packet_uid.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import "fmt"

// PacketUID is a unique identifier for an Rollapp IBC packet on the hub
type PacketUID struct {
Type Type
Type RollappPacket_Type
RollappHubPort string
RollappHubChannel string
Sequence uint64
}

// NewPacketUID creates a new PacketUID with the provided details.
func NewPacketUID(packetType Type, hubPort string, hubChannel string, sequence uint64) PacketUID {
func NewPacketUID(packetType RollappPacket_Type, hubPort string, hubChannel string, sequence uint64) PacketUID {
return PacketUID{
Type: packetType,
RollappHubPort: hubPort,
Expand Down
4 changes: 2 additions & 2 deletions x/common/types/rollapp_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ func (r RollappPacket) RestoreOriginalTransferTarget() (RollappPacket, error) {
}
if r.OriginalTransferTarget != "" { // It can be empty if the eibc order was never fulfilled
switch r.Type {
case Type_ON_RECV:
case RollappPacket_ON_RECV:
transferPacketData.Receiver = r.OriginalTransferTarget
case Type_ON_ACK, Type_ON_TIMEOUT:
case RollappPacket_ON_ACK, RollappPacket_ON_TIMEOUT:
transferPacketData.Sender = r.OriginalTransferTarget
}
r.Packet.Data = transferPacketData.GetBytes()
Expand Down
110 changes: 73 additions & 37 deletions x/common/types/rollapp_packet.pb.go

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

76 changes: 0 additions & 76 deletions x/common/types/type.pb.go

This file was deleted.

18 changes: 9 additions & 9 deletions x/delayedack/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ func CmdGetPacketsByRollapp() *cobra.Command {

req := &types.QueryRollappPacketsRequest{
RollappId: rollappId,
Status: commontypes.Status_PENDING, // get pending packets by default
Type: commontypes.Type_UNDEFINED, // must specify, as '0' is a valid type
Status: commontypes.Status_PENDING, // get pending packets by default
Type: commontypes.RollappPacket_UNDEFINED, // must specify, as '0' is a valid type
}

if len(args) > 1 {
Expand All @@ -97,12 +97,12 @@ func CmdGetPacketsByRollapp() *cobra.Command {
if !strings.HasPrefix(typeStr, "ON_") {
typeStr = "ON_" + typeStr
}
dtype, ok := commontypes.Type_value[typeStr]
dtype, ok := commontypes.RollappPacket_Type_value[typeStr]
if !ok {
// Handle error: typeStr is not a valid commontypes.Type
return fmt.Errorf("invalid type: %s", typeStr)
}
req.Type = commontypes.Type(dtype)
req.Type = commontypes.RollappPacket_Type(dtype)
}

res, err := queryClient.GetPackets(cmd.Context(), req)
Expand Down Expand Up @@ -140,19 +140,19 @@ func CmdGetPacketsByStatus() *cobra.Command {

req := &types.QueryRollappPacketsRequest{
Status: commontypes.Status(status),
Type: commontypes.Type_UNDEFINED, // must specify, as '0' is a valid type
Type: commontypes.RollappPacket_UNDEFINED, // must specify, as '0' is a valid type
}

if len(args) > 1 {
typeStr := strings.ToUpper(args[1])
if !strings.HasPrefix(typeStr, "ON_") {
typeStr = "ON_" + typeStr
}
dtype, ok := commontypes.Type_value[typeStr]
dtype, ok := commontypes.RollappPacket_Type_value[typeStr]
if !ok {
return fmt.Errorf("invalid type: %s", typeStr)
}
req.Type = commontypes.Type(dtype)
req.Type = commontypes.RollappPacket_Type(dtype)
}

res, err := queryClient.GetPackets(cmd.Context(), req)
Expand Down Expand Up @@ -188,13 +188,13 @@ func CmdGetPacketsByType() *cobra.Command {
typeStr = "ON_" + typeStr
}

dtype, ok := commontypes.Type_value[typeStr]
dtype, ok := commontypes.RollappPacket_Type_value[typeStr]
if !ok {
return fmt.Errorf("invalid type: %s", typeStr)
}

req := &types.QueryRollappPacketsRequest{
Type: commontypes.Type(dtype),
Type: commontypes.RollappPacket_Type(dtype),
Status: commontypes.Status_PENDING, // get pending packets by default
}

Expand Down
Loading

0 comments on commit e46f5f2

Please sign in to comment.