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

WASM bindings refactoring #210

Merged
merged 2 commits into from
Aug 23, 2022
Merged

WASM bindings refactoring #210

merged 2 commits into from
Aug 23, 2022

Conversation

iTiky
Copy link
Contributor

@iTiky iTiky commented Aug 22, 2022

  • "rewards" embedded struct added for custom x/rewards query and msg handling (in case there would be other modules supporting WASM bindings, API won't change);
  • CosmWasm custom queries dispatcher added for a future support of other modules with custom WASM bindings queries;
  • E2E tests updated to test unknown custom msg and query;

@iTiky iTiky requested a review from fdymylja August 22, 2022 16:17
@codecov
Copy link

codecov bot commented Aug 22, 2022

Codecov Report

Merging #210 (831e49d) into main (88880ca) will increase coverage by 0.54%.
The diff coverage is 68.55%.

@@            Coverage Diff             @@
##             main     #210      +/-   ##
==========================================
+ Coverage   63.75%   64.30%   +0.54%     
==========================================
  Files          52       59       +7     
  Lines        2337     2353      +16     
==========================================
+ Hits         1490     1513      +23     
+ Misses        779      775       -4     
+ Partials       68       65       -3     
Impacted Files Coverage Δ
wasmbinding/rewards/types/query_metadata.go 30.00% <30.00%> (ø)
wasmbinding/query_plugin.go 35.00% <35.00%> (ø)
wasmbinding/rewards/types/query_records.go 9.67% <40.00%> (ø)
wasmbinding/rewards/types/msg_metadata.go 44.44% <44.44%> (ø)
wasmbinding/msg_plugin.go 66.66% <66.66%> (ø)
wasmbinding/rewards/query_handler.go 68.96% <68.96%> (ø)
wasmbinding/rewards/types/msg_withdraw.go 75.00% <75.00%> (ø)
wasmbinding/rewards/msg_handler.go 77.77% <77.77%> (ø)
app/app.go 91.05% <100.00%> (ø)
wasmbinding/plugin.go 100.00% <100.00%> (ø)
... and 5 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.


// Skip non module-related sub-message
if customMsg.Rewards == nil {
return p.wrappedMessenger.DispatchMsg(ctx, contractAddr, contractIBCPortID, msg)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should return an error.

Because, if we are in customMsg.Rewards, and msg.Custom != nil, then it means:

  • Either the user set msg.Custom && msg.SomethingElse -- which is incorrect by enum definition.
  • Or it left msg.Custom empty (ex: {}), which is incorrect

I think here we should return an error.

return p.withdrawContractRewards(ctx, contractAddr, *customMsg.Rewards.WithdrawRewards)
}

return nil, nil, sdkErrors.Wrap(rewardsTypes.ErrInvalidRequest, "unknown x/rewards custom message")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd put this in a default: , just personal opinion I think it makes code more readable.

Copy link
Contributor

@fdymylja fdymylja left a comment

Choose a reason for hiding this comment

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

LGTM, would move wasmbinding out of rewards and to the repo root.

* "rewards" embedded struct added for custom x/rewards query and msg handling (in case there would be other modules supporting WASM bindings, API won't change);
* CosmWasm custom queries dispatcher added for a future support of other modules with custom WASM bindings queries;
* E2E tests updated to test unknown custom msg and query;
…or all modules unlike multiple nested decorators and dispatchers)
@iTiky iTiky merged commit f19ba7d into main Aug 23, 2022
@iTiky iTiky deleted the wasmb_refactoring branch August 23, 2022 13:12
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.

None yet

2 participants