-
Notifications
You must be signed in to change notification settings - Fork 147
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 chain not found error #3481
Fix chain not found error #3481
Conversation
fix: Chain lookup done even when network prefix in chain ID is wrong
@@ -65,7 +65,7 @@ func (c *Controller) getChainInfo(e echo.Context) error { | |||
} | |||
|
|||
chainInfo, err := c.chainService.GetChainInfoByChainID(chainID, e.QueryParam(params.ParamBlockIndexOrTrieRoot)) | |||
if errors.Is(err, interfaces.ErrChainNotFound) { | |||
if errors.As(err, &interfaces.ChainNotFoundError{}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jorgemmsilva please note style of usage of ChainNotFoundError.
errors.Is
replaced with errors.As
. There was another option - to add separate wrapper in addition to ErrChainNotFound, which will return it through Unwrap()
. That would allow to keep errors.Is
as it is now. But that would also split error into two separate parts, which we thought is not a nice thing to have.
Head branch was pushed to by a user without write access
packages/isc/chainid.go
Outdated
@@ -121,6 +127,10 @@ func (id ChainID) ShortString() string { | |||
|
|||
// String human-readable form (bech32) | |||
func (id ChainID) String() string { | |||
if id.Empty() { | |||
return "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably breaks the invariant:
ChainIDFromString(chainID.String()) == chainID
Maybe it's better to panic if the chainID is "empty"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just return the bech32 as before. Why is the check needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, thanks, actually I reverted it. It was accidentally pushed
packages/isc/chainid.go
Outdated
@@ -121,6 +127,10 @@ func (id ChainID) ShortString() string { | |||
|
|||
// String human-readable form (bech32) | |||
func (id ChainID) String() string { | |||
if id.Empty() { | |||
return "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just return the bech32 as before. Why is the check needed?
Fix api error message if chainID not found
Fix api error message if network prefix is incorrect