-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
refactor(feegrant): remove bech32 global #15347
Merged
Merged
Changes from 22 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
539b6fe
feegrant bech32 removal
tac0turtle 683e1f2
remove some global bech32 items in feegrant
tac0turtle e72f015
few more changes
tac0turtle d31093a
Merge branch 'main' into marko/bech32_global_feegrant
tac0turtle fb97ad9
Merge branch 'main' into marko/bech32_global_feegrant
tac0turtle 1144aef
remove global codec
tac0turtle 90e0cac
remove usage of accaddressfrombech32
tac0turtle 2d56e2a
remove failing tests
tac0turtle cde3607
Merge branch 'main' into marko/bech32_global_feegrant
tac0turtle f16b0fd
Merge branch 'main' into marko/bech32_global_feegrant
tac0turtle 4285a67
address feedback
tac0turtle 979697e
Merge branch 'main' into marko/bech32_global_feegrant
tac0turtle 523c839
Merge branch 'main' into marko/bech32_global_feegrant
tac0turtle 11f2150
Merge branch 'main' into marko/bech32_global_feegrant
tac0turtle 232c6f4
move to address/codec
tac0turtle ca828f5
depend on core
tac0turtle 5063def
remove types codec
tac0turtle 96b3845
fix imports
tac0turtle c9fdbdb
fix imports
tac0turtle 8cea31f
move bech32 back to auth and wrap methods
tac0turtle 600915c
Merge branch 'main' into marko/bech32_global_feegrant
tac0turtle 6a0784e
changelog
tac0turtle d09177a
fix build
tac0turtle 536d268
mock expect
tac0turtle aece29f
stuck
tac0turtle c50474d
Merge branch 'main' into marko/bech32_global_feegrant
tac0turtle 698ec45
fix tests
tac0turtle dc2ebf1
some fixes
tac0turtle f41cb66
move higher
tac0turtle 028444b
fix genesis test
julienrbrt 4f7a171
fix all tests
julienrbrt 6d297e1
Merge branch 'main' into marko/bech32_global_feegrant
julienrbrt 0176e31
go mod tidy
julienrbrt 764bd17
remove replace
julienrbrt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package address | ||
|
||
import ( | ||
"cosmossdk.io/core/address" | ||
errorsmod "cosmossdk.io/errors" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/bech32" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
) | ||
|
||
type Bech32Codec struct { | ||
Bech32Prefix string | ||
} | ||
|
||
var _ address.Codec = &Bech32Codec{} | ||
|
||
func NewBech32Codec(prefix string) address.Codec { | ||
return Bech32Codec{prefix} | ||
} | ||
|
||
// StringToBytes encodes text to bytes | ||
func (bc Bech32Codec) StringToBytes(text string) ([]byte, error) { | ||
hrp, bz, err := bech32.DecodeAndConvert(text) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if hrp != bc.Bech32Prefix { | ||
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "hrp does not match bech32Prefix") | ||
} | ||
|
||
if err := sdk.VerifyAddressFormat(bz); err != nil { | ||
return nil, err | ||
} | ||
|
||
return bz, nil | ||
} | ||
|
||
// BytesToString decodes bytes to text | ||
func (bc Bech32Codec) BytesToString(bz []byte) (string, error) { | ||
text, err := bech32.ConvertAndEncode(bc.Bech32Prefix, bz) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return text, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Putting the Bech32Codec has one small disadvantage: it will make it harder to refactor auth into a go.mod, since it will depend on the root sdk. But maybe it's fine for now, other go-modded sdk modules also depend on root.