Skip to content

Commit

Permalink
fix: allow base denom with trailing slash (#6148)
Browse files Browse the repository at this point in the history
  • Loading branch information
crodriguezvega committed Apr 15, 2024
1 parent 034f472 commit 4cc6a85
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions modules/apps/transfer/types/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@ func ValidatePrefixedDenom(denom string) error {
return nil
}

if strings.TrimSpace(denomSplit[len(denomSplit)-1]) == "" {
path, baseDenom := extractPathAndBaseFromFullDenom(denomSplit)
if strings.TrimSpace(baseDenom) == "" {
return errorsmod.Wrap(ErrInvalidDenomForTransfer, "base denomination cannot be blank")
}

path, _ := extractPathAndBaseFromFullDenom(denomSplit)
if path == "" {
// NOTE: base denom contains slashes, so no base denomination validation
return nil
Expand Down
3 changes: 2 additions & 1 deletion modules/apps/transfer/types/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,16 @@ func TestValidatePrefixedDenom(t *testing.T) {
expError bool
}{
{"prefixed denom", "transfer/channel-1/uatom", false},
{"prefixed denom with base denom with leading slash", "transfer/channel-1/uatom/", false},
{"prefixed denom with '/'", "transfer/channel-1/gamm/pool/1", false},
{"empty prefix", "/uatom", false},
{"empty identifiers", "//uatom", false},
{"base denom", "uatom", false},
{"base denom with single '/'", "erc20/0x85bcBCd7e79Ec36f4fBBDc54F90C643d921151AA", false},
{"base denom with multiple '/'s", "gamm/pool/1", false},
{"single trace identifier", "transfer/", false},
{"invalid port ID", "(transfer)/channel-1/uatom", true},
{"empty denom", "", true},
{"single trace identifier", "transfer/", true},
}

for _, tc := range testCases {
Expand Down

0 comments on commit 4cc6a85

Please sign in to comment.