diff --git a/modules/apps/transfer/types/trace.go b/modules/apps/transfer/types/trace.go index 93aa7ee14bf..ee7b3c2ad50 100644 --- a/modules/apps/transfer/types/trace.go +++ b/modules/apps/transfer/types/trace.go @@ -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 diff --git a/modules/apps/transfer/types/trace_test.go b/modules/apps/transfer/types/trace_test.go index 49623ed1dec..f7634a7a3b0 100644 --- a/modules/apps/transfer/types/trace_test.go +++ b/modules/apps/transfer/types/trace_test.go @@ -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 {