-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
feat(types): add MustValAddressFromBech32 function #18768
Changes from 1 commit
2be11ed
0c1a63c
92610b1
2ce4ed2
66ad9a7
dc06287
d9a0772
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -362,6 +362,16 @@ func ValAddressFromBech32(address string) (addr ValAddress, err error) { | |||||
return ValAddress(bz), nil | ||||||
} | ||||||
|
||||||
// MustValAddressFromBech32 calls MustValAddressFromBech32 and panics on error. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment on line 365 incorrectly references - // MustValAddressFromBech32 calls MustValAddressFromBech32 and panics on error.
+ // MustValAddressFromBech32 calls ValAddressFromBech32 and panics on error. Committable suggestion
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks rabbit. I fix it. |
||||||
func MustValAddressFromBech32(address string) ValAddress { | ||||||
addr, err := ValAddressFromBech32(address) | ||||||
if err != nil { | ||||||
panic(err) | ||||||
} | ||||||
|
||||||
return addr | ||||||
} | ||||||
|
||||||
// Returns boolean for whether two ValAddresses are Equal | ||||||
func (va ValAddress) Equals(va2 Address) bool { | ||||||
if va.Empty() && va2.Empty() { | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -567,3 +567,13 @@ func (s *addressTestSuite) TestGetFromBech32() { | |
s.Require().Error(err) | ||
s.Require().Equal("invalid Bech32 prefix; expected x, got cosmos", err.Error()) | ||
} | ||
|
||
func (s *addressTestSuite) TestMustAccAddressFromBech32() { | ||
julienrbrt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
address := "cosmosvaloper1780p20ce3quhzqxdq0xfeqtnzrjgdraz0kwwjp" | ||
valAddress1, err := types.ValAddressFromBech32(address) | ||
s.Require().Nil(err) | ||
|
||
valAddress2 := types.MustValAddressFromBech32(address) | ||
|
||
s.Require().Equal(valAddress1, valAddress2) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test case provided for |
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.
nit: types
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.
done