Skip to content

Commit

Permalink
fix(sequencer): use AccAddress for operator address
Browse files Browse the repository at this point in the history
  • Loading branch information
keruch committed Nov 7, 2024
1 parent 8493c65 commit 15b05fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
4 changes: 2 additions & 2 deletions x/sequencer/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func CmdUpdateRewardAddress() *cobra.Command {
}

msg := &types.MsgUpdateRewardAddress{
Creator: sdk.ValAddress(ctx.GetFromAddress()).String(),
Creator: ctx.GetFromAddress().String(),
RewardAddr: args[0],
}

Expand All @@ -186,7 +186,7 @@ func CmdUpdateWhitelistedRelayers() *cobra.Command {
}

msg := &types.MsgUpdateWhitelistedRelayers{
Creator: sdk.ValAddress(ctx.GetFromAddress()).String(),
Creator: ctx.GetFromAddress().String(),
Relayers: strings.Split(args[0], ","),
}

Expand Down
14 changes: 2 additions & 12 deletions x/sequencer/types/msg_update_whitelisted_relayers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/bech32"
"github.com/dymensionxyz/gerr-cosmos/gerrc"
"github.com/dymensionxyz/sdk-utils/utils/uaddr"
)

const maxWhitelistedRelayers = 10
Expand Down Expand Up @@ -37,7 +37,7 @@ func ValidateWhitelistedRelayers(wr []string) error {
}
relayers[r] = struct{}{}

relayer, err := Bech32ToAddr[sdk.AccAddress](r)
relayer, err := uaddr.FromBech32[sdk.AccAddress](r)
if err != nil {
return fmt.Errorf("convert bech32 to relayer address: %s: %w", r, err)
}
Expand All @@ -49,16 +49,6 @@ func ValidateWhitelistedRelayers(wr []string) error {
return nil
}

// Bech32ToAddr casts an arbitrary-prefixed bech32 string to either sdk.AccAddress or sdk.ValAddress.
// TODO: move to sdk-utils.
func Bech32ToAddr[T sdk.AccAddress | sdk.ValAddress](addr string) (T, error) {
_, bytes, err := bech32.DecodeAndConvert(addr)
if err != nil {
return nil, fmt.Errorf("decoding bech32 addr: %w", err)
}
return T(bytes), nil
}

func (m *MsgUpdateWhitelistedRelayers) GetSigners() []sdk.AccAddress {
addr, _ := sdk.AccAddressFromBech32(m.Creator)
return []sdk.AccAddress{addr}
Expand Down

0 comments on commit 15b05fb

Please sign in to comment.