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

msg.ValidateBasic() does not return sdk.Result type #666

Open
truted opened this issue Jun 25, 2019 · 0 comments
Open

msg.ValidateBasic() does not return sdk.Result type #666

truted opened this issue Jun 25, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@truted
Copy link
Contributor

truted commented Jun 25, 2019

msg handlers return an sdk.Result type to the API with one exception: if msg.ValidateBasic() fails, it returns something else. This is because msg.ValidateBasic() is run by the cosmos framework before the msg is processed by the registered handler.

This results in the following two formats being returned by the API, the first is what ValidateBasic() returns and the second is what the handler returns if an error occurs:

"{\"codespace\":\"claim\",\"code\":101,\"message\":\"Invalid claim body, too short: \"}"
"[{"msg_index":0,"success":false,"log":"{\"codespace\":\"claim\",\"code\":102,\"message\":\"Invalid claim body, too long\"}"}]"

Bonus: we can remove this code from modules:

	// if err := msg.ValidateBasic(); err != nil {
	// 	return err.Result()
	// }
@truted truted added the enhancement New feature or request label Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant