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

fix: allow base denom with trailing slash #6148

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
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
Loading