Skip to content

Commit

Permalink
Merge branch 'master-tunnel' into tunnel-ibc
Browse files Browse the repository at this point in the history
  • Loading branch information
satawatnack committed Nov 25, 2024
2 parents fb9f8fc + fe0ff59 commit be53449
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
34 changes: 16 additions & 18 deletions x/tunnel/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,20 @@ var (
ErrIntervalOutOfRange = errorsmod.Register(ModuleName, 4, "interval out of range")
ErrDeviationOutOfRange = errorsmod.Register(ModuleName, 5, "deviation out of range")
ErrTunnelNotFound = errorsmod.Register(ModuleName, 6, "tunnel not found")
ErrNoRoute = errorsmod.Register(ModuleName, 7, "no route")
ErrNoReceipt = errorsmod.Register(ModuleName, 8, "no receipt")
ErrLatestPricesNotFound = errorsmod.Register(ModuleName, 9, "latest prices not found")
ErrPacketNotFound = errorsmod.Register(ModuleName, 10, "packet not found")
ErrNoPacketReceipt = errorsmod.Register(ModuleName, 11, "no packet receipt")
ErrInvalidTunnelCreator = errorsmod.Register(ModuleName, 12, "invalid creator of the tunnel")
ErrAccountAlreadyExist = errorsmod.Register(ModuleName, 13, "account already exist")
ErrInvalidRoute = errorsmod.Register(ModuleName, 14, "invalid tunnel route")
ErrInactiveTunnel = errorsmod.Register(ModuleName, 15, "inactive tunnel")
ErrAlreadyActive = errorsmod.Register(ModuleName, 16, "already active")
ErrAlreadyInactive = errorsmod.Register(ModuleName, 17, "already inactive")
ErrInvalidDepositDenom = errorsmod.Register(ModuleName, 18, "invalid deposit denom")
ErrDepositNotFound = errorsmod.Register(ModuleName, 19, "deposit not found")
ErrInsufficientDeposit = errorsmod.Register(ModuleName, 20, "insufficient deposit")
ErrInsufficientFund = errorsmod.Register(ModuleName, 21, "insufficient fund")
ErrDeviationNotFound = errorsmod.Register(ModuleName, 22, "deviation not found")
ErrInvalidVersion = errorsmod.Register(ModuleName, 23, "invalid ICS20 version")
ErrChannelCapabilityNotFound = errorsmod.Register(ModuleName, 24, "channel capability not found")
ErrLatestPricesNotFound = errorsmod.Register(ModuleName, 7, "latest prices not found")
ErrPacketNotFound = errorsmod.Register(ModuleName, 8, "packet not found")
ErrNoPacketReceipt = errorsmod.Register(ModuleName, 9, "no packet receipt")
ErrInvalidTunnelCreator = errorsmod.Register(ModuleName, 10, "invalid creator of the tunnel")
ErrAccountAlreadyExist = errorsmod.Register(ModuleName, 11, "account already exist")
ErrInvalidRoute = errorsmod.Register(ModuleName, 12, "invalid tunnel route")
ErrInactiveTunnel = errorsmod.Register(ModuleName, 13, "inactive tunnel")
ErrAlreadyActive = errorsmod.Register(ModuleName, 14, "already active")
ErrAlreadyInactive = errorsmod.Register(ModuleName, 15, "already inactive")
ErrInvalidDepositDenom = errorsmod.Register(ModuleName, 16, "invalid deposit denom")
ErrDepositNotFound = errorsmod.Register(ModuleName, 17, "deposit not found")
ErrInsufficientDeposit = errorsmod.Register(ModuleName, 18, "insufficient deposit")
ErrInsufficientFund = errorsmod.Register(ModuleName, 19, "insufficient fund")
ErrDeviationNotFound = errorsmod.Register(ModuleName, 20, "deviation not found")
ErrInvalidVersion = errorsmod.Register(ModuleName, 21, "invalid ICS20 version")
ErrChannelCapabilityNotFound = errorsmod.Register(ModuleName, 22, "channel capability not found")
)
2 changes: 1 addition & 1 deletion x/tunnel/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func NewMsgCreateIBCTunnel(
func (m MsgCreateTunnel) GetRouteValue() (RouteI, error) {
r, ok := m.Route.GetCachedValue().(RouteI)
if !ok {
return nil, ErrNoRoute.Wrap("failed to get route")
return nil, sdkerrors.ErrInvalidType.Wrapf("expected %T, got %T", (RouteI)(nil), m.Route.GetCachedValue())
}
return r, nil
}
Expand Down
6 changes: 5 additions & 1 deletion x/tunnel/types/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ func (p *Packet) SetReceipt(receipt PacketReceiptI) error {
func (p Packet) GetReceiptValue() (PacketReceiptI, error) {
r, ok := p.Receipt.GetCachedValue().(PacketReceiptI)
if !ok {
return nil, sdkerrors.ErrPackAny.Wrapf("cannot unpack route")
return nil, sdkerrors.ErrInvalidType.Wrapf(
"expected %T, got %T",
(PacketReceiptI)(nil),
p.Receipt.GetCachedValue(),
)
}

return r, nil
Expand Down
7 changes: 6 additions & 1 deletion x/tunnel/types/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types"
)
Expand Down Expand Up @@ -77,7 +78,11 @@ func (t *Tunnel) SetRoute(route RouteI) error {
func (t Tunnel) GetRouteValue() (RouteI, error) {
r, ok := t.Route.GetCachedValue().(RouteI)
if !ok {
return nil, ErrNoRoute.Wrap("failed to get route")
return nil, sdkerrors.ErrInvalidType.Wrapf(
"expected %T, got %T",
(RouteI)(nil),
t.Route.GetCachedValue(),
)
}

return r, nil
Expand Down

0 comments on commit be53449

Please sign in to comment.