-
Notifications
You must be signed in to change notification settings - Fork 573
refactor(templates)!: remove ValidateBasic() and use address codec #4058
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e592423
refactor(templates)!: remove ValidateBasic() and use address codec
julienrbrt 914e2f9
fixes
julienrbrt 6db469f
updates
julienrbrt c1d7048
Merge branch 'main' into julien/del-validate-basic-codec
julienrbrt e569bde
typo
julienrbrt b15269e
typo (2)
julienrbrt a6016de
Merge branch 'main' into julien/del-validate-basic-codec
julienrbrt 3caf828
Merge branch 'main' into julien/del-validate-basic-codec
julienrbrt 86a0fa5
Apply suggestions from code review
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 hidden or 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 hidden or 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 hidden or 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
8 changes: 0 additions & 8 deletions
8
...emplates/ibc/files/packet/component/x/{{moduleName}}/types/packet_{{packetName}}.go.plush
This file contains hidden or 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 hidden or 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 hidden or 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
84 changes: 84 additions & 0 deletions
84
...ibc/files/packet/messages/x/{{moduleName}}/keeper/msg_server_{{packetName}}_test.go.plush
This file contains hidden or 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,84 @@ | ||
| package keeper_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
|
|
||
| sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
| channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" | ||
|
|
||
| keepertest "<%= ModulePath %>/testutil/keeper" | ||
| "<%= ModulePath %>/x/<%= moduleName %>/keeper" | ||
| "<%= ModulePath %>/x/<%= moduleName %>/types" | ||
| ) | ||
|
|
||
| func TestMsgServerSend<%= packetName.UpperCamel %>(t *testing.T) { | ||
| k, ctx, addressCodec := keepertest.<%= title(moduleName) %>Keeper(t) | ||
| <%= MsgSigner.LowerCamel %>, err := addressCodec.BytesToString([]byte("signerAddr__________________")) | ||
| require.NoError(t, err) | ||
| srv := keeper.NewMsgServerImpl(k) | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| msg types.MsgSend<%= packetName.UpperCamel %> | ||
| err error | ||
| }{ | ||
| { | ||
| name: "invalid address", | ||
| msg: types.MsgSend<%= packetName.UpperCamel %>{ | ||
| <%= MsgSigner.UpperCamel %>: "invalid address", | ||
| Port: "port", | ||
| ChannelID: "channel-0", | ||
| TimeoutTimestamp: 100, | ||
| }, | ||
| err: sdkerrors.ErrInvalidAddress, | ||
| }, { | ||
| name: "invalid port", | ||
| msg: types.MsgSend<%= packetName.UpperCamel %>{ | ||
| <%= MsgSigner.UpperCamel %>: <%= MsgSigner.LowerCamel %>, | ||
| Port: "", | ||
| ChannelID: "channel-0", | ||
| TimeoutTimestamp: 100, | ||
| }, | ||
| err: sdkerrors.ErrInvalidRequest, | ||
| }, { | ||
| name: "invalid channel", | ||
| msg: types.MsgSend<%= packetName.UpperCamel %>{ | ||
| <%= MsgSigner.UpperCamel %>: <%= MsgSigner.LowerCamel %>, | ||
| Port: "port", | ||
| ChannelID: "", | ||
| TimeoutTimestamp: 100, | ||
| }, | ||
| err: sdkerrors.ErrInvalidRequest, | ||
| }, { | ||
| name: "invalid timeout", | ||
| msg: types.MsgSend<%= packetName.UpperCamel %>{ | ||
| <%= MsgSigner.UpperCamel %>: <%= MsgSigner.LowerCamel %>, | ||
| Port: "port", | ||
| ChannelID: "channel-0", | ||
| TimeoutTimestamp: 0, | ||
| }, | ||
| err: sdkerrors.ErrInvalidRequest, | ||
| }, { | ||
| name: "valid message", | ||
| msg: types.MsgSend<%= packetName.UpperCamel %>{ | ||
| <%= MsgSigner.UpperCamel %>: <%= MsgSigner.LowerCamel %>, | ||
| Port: "port", | ||
| ChannelID: "channel-0", | ||
| TimeoutTimestamp: 100, | ||
| }, | ||
| err: channeltypes.ErrChannelCapabilityNotFound, | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| _, err = srv.Send<%= packetName.UpperCamel %>(ctx, &tt.msg) | ||
| if tt.err != nil { | ||
| require.ErrorContains(t, err, tt.err.Error()) | ||
| return | ||
| } | ||
| require.NoError(t, err) | ||
| }) | ||
| } | ||
| } |
This file contains hidden or 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
73 changes: 0 additions & 73 deletions
73
...es/ibc/files/packet/messages/x/{{moduleName}}/types/messages_{{packetName}}_test.go.plush
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
19 changes: 1 addition & 18 deletions
19
ignite/templates/message/files/message/x/{{moduleName}}/types/message_{{msgName}}.go.plush
This file contains hidden or 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 |
|---|---|---|
| @@ -1,25 +1,8 @@ | ||
| package types | ||
|
|
||
| import ( | ||
| errorsmod "cosmossdk.io/errors" | ||
| sdk "github.com/cosmos/cosmos-sdk/types" | ||
| sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
| ) | ||
|
|
||
| var _ sdk.Msg = &Msg<%= MsgName.UpperCamel %>{} | ||
|
|
||
| func NewMsg<%= MsgName.UpperCamel %>(<%= MsgSigner.LowerCamel %> string<%= for (field) in Fields { %>, <%= field.Name.LowerCamel %> <%= field.DataType() %><% } %>) *Msg<%= MsgName.UpperCamel %> { | ||
| return &Msg<%= MsgName.UpperCamel %>{ | ||
| <%= MsgSigner.UpperCamel %>: <%= MsgSigner.LowerCamel %>,<%= for (field) in Fields { %> | ||
| <%= field.Name.UpperCamel %>: <%= field.Name.LowerCamel %>,<% } %> | ||
| } | ||
| } | ||
|
|
||
| func (msg *Msg<%= MsgName.UpperCamel %>) ValidateBasic() error { | ||
| _, err := sdk.AccAddressFromBech32(msg.<%= MsgSigner.UpperCamel %>) | ||
| if err != nil { | ||
| return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid <%= MsgSigner.LowerCamel %> address (%s)", err) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| } |
40 changes: 0 additions & 40 deletions
40
.../templates/message/files/message/x/{{moduleName}}/types/message_{{msgName}}_test.go.plush
This file was deleted.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.