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

Stargate msg and query #435

Merged
merged 7 commits into from
Mar 4, 2021
Merged

Stargate msg and query #435

merged 7 commits into from
Mar 4, 2021

Conversation

ethanfrey
Copy link
Member

@ethanfrey ethanfrey commented Mar 4, 2021

Closes #388

  • Implement StargateMsgEncoder
  • Implement StargateQueryHandler
  • Test message encoder
  • Test query handler

@codecov
Copy link

codecov bot commented Mar 4, 2021

Codecov Report

Merging #435 (cec6dcd) into master (b09a925) will decrease coverage by 0.06%.
The diff coverage is 75.51%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #435      +/-   ##
==========================================
- Coverage   55.42%   55.36%   -0.07%     
==========================================
  Files          39       39              
  Lines        4043     4073      +30     
==========================================
+ Hits         2241     2255      +14     
- Misses       1619     1627       +8     
- Partials      183      191       +8     
Impacted Files Coverage Δ
x/wasm/internal/keeper/query_plugins.go 73.51% <70.00%> (-1.05%) ⬇️
x/wasm/internal/keeper/handler_plugin.go 74.32% <76.00%> (-3.94%) ⬇️
app/app.go 87.74% <100.00%> (ø)
x/wasm/internal/keeper/keeper.go 87.92% <100.00%> (+0.49%) ⬆️

@@ -20,8 +22,8 @@ type DefaultMessageHandler struct {
encoders MessageEncoders
}

func NewDefaultMessageHandler(router sdk.Router, channelKeeper types.ChannelKeeper, capabilityKeeper types.CapabilityKeeper, customEncoders *MessageEncoders) DefaultMessageHandler {
encoders := DefaultEncoders(channelKeeper, capabilityKeeper).Merge(customEncoders)
func NewDefaultMessageHandler(router sdk.Router, channelKeeper types.ChannelKeeper, capabilityKeeper types.CapabilityKeeper, unpacker codectypes.AnyUnpacker, customEncoders *MessageEncoders) DefaultMessageHandler {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good use of the minimal interface

x/wasm/internal/keeper/handler_plugin.go Show resolved Hide resolved
@ethanfrey ethanfrey marked this pull request as ready for review March 4, 2021 15:55
Copy link
Member Author

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alpe this should be ready now. I'd like a review, especially on the proto part and how I wire it with the app

@@ -276,6 +288,27 @@ func TestEncoding(t *testing.T) {
},
},
},
// TODO: alpe? can you add an example with sub-interfaces (where the UnpackInterfaces call would be needed)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure how to create such a case. (I also think we only have bank, staking, and distribution registered here in the tests).

If you could add such a test to trigger this that would be great. Or if it is a pain, please open up an issue on it and explain more or less what is needed. I can put that down lower on the priority list

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found Any types in sdk (master).

  • MsgGrantAuthorizationRequest
  • MsgGrantFeeAllowance
  • MsgSubmitProposal
  • MsgCreateValidator
    I guess MsgSubmitProposal would be a good candidate. I can add a test.

Copy link
Member

@alpe alpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work. This will add a very valuable feature to the system. 🚀

@@ -276,6 +288,27 @@ func TestEncoding(t *testing.T) {
},
},
},
// TODO: alpe? can you add an example with sub-interfaces (where the UnpackInterfaces call would be needed)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found Any types in sdk (master).

  • MsgGrantAuthorizationRequest
  • MsgGrantFeeAllowance
  • MsgSubmitProposal
  • MsgCreateValidator
    I guess MsgSubmitProposal would be a good candidate. I can add a test.

protoQuery := banktypes.QueryAllBalancesRequest{
Address: creator.String(),
}
protoQueryBin, err := proto.Marshal(&protoQuery)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever to test with a different golang protobuf marshaller. 🌻

var simpleBalance wasmvmtypes.AllBalancesResponse
mustParse(t, simpleChain.Data, &simpleBalance)
require.Equal(t, len(expectedBalance), len(simpleBalance.Amount))
assert.Equal(t, simpleBalance.Amount[0].Amount, expectedBalance[0].Amount.String())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need to change: wrong order of arguments. Here and others (t, expect, got) (to be fair it is not consistent within testify like assert.Len(t, got, exp)` )

@ethanfrey
Copy link
Member Author

Thanks. If you could add a follow up pr sometime with submit proposal, that would be great

Now contracts can vote

@ethanfrey ethanfrey merged commit b98353e into master Mar 4, 2021
@ethanfrey ethanfrey deleted the stargate-msg-and-query branch March 4, 2021 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Stargate CosmosMsg/QueryRequest
2 participants