-
Notifications
You must be signed in to change notification settings - Fork 95
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
Conversation
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;
Codecov Report
@@ 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
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
x/rewards/wasmbinding/msg_plugin.go
Outdated
|
||
// Skip non module-related sub-message | ||
if customMsg.Rewards == nil { | ||
return p.wrappedMessenger.DispatchMsg(ctx, contractAddr, contractIBCPortID, msg) |
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.
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.
x/rewards/wasmbinding/msg_plugin.go
Outdated
return p.withdrawContractRewards(ctx, contractAddr, *customMsg.Rewards.WithdrawRewards) | ||
} | ||
|
||
return nil, nil, sdkErrors.Wrap(rewardsTypes.ErrInvalidRequest, "unknown x/rewards custom message") |
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.
I'd put this in a default:
, just personal opinion I think it makes code more readable.
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.
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;
1c760ca
to
8848e1d
Compare
…or all modules unlike multiple nested decorators and dispatchers)