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

[v18] FeeShare: Allow authz exec to count towards feeshare payouts #833

Merged
merged 3 commits into from
Sep 20, 2023

Conversation

Reecepbcups
Copy link
Contributor

@Reecepbcups Reecepbcups commented Sep 10, 2023

Thanks to Aleem from Vitwit for pointing this out :)

summary

Allows feeshare authz executes to pay the wasm contract its % of feeshare rewards.
(Reuses logic from past decorator in v14.0.0)

@Reecepbcups Reecepbcups marked this pull request as ready for review September 19, 2023 22:43
@Reecepbcups Reecepbcups merged commit b03500a into main Sep 20, 2023
20 checks passed
@Reecepbcups Reecepbcups deleted the reece/allow-feeshare-auth-executes branch September 20, 2023 22:14
@@ -62,29 +63,63 @@ type FeeSharePayoutEventOutput struct {
FeesPaid sdk.Coins `json:"fees_paid"`
}

func addNewFeeSharePayoutsForMsg(ctx sdk.Context, fsk FeeShareKeeper, toPay *[]sdk.AccAddress, m sdk.Msg) error {
if msg, ok := m.(*wasmtypes.MsgExecuteContract); ok {

Choose a reason for hiding this comment

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

If the message contains another authz.MsgExec this logic doesn't work. You should add additional case for authz.MsgExec, and if it contains another authz.MsgExec message, call the function recursively.

validAuthz := func(execMsg *authz.MsgExec) error {
for _, v := range execMsg.Msgs {
var innerMsg sdk.Msg
if err := json.Unmarshal(v.Value, &innerMsg); err != nil {

Choose a reason for hiding this comment

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

I think this is always going to fail. You should use SDK codec to correctly unmarshal any type to an interface.

Copy link
Contributor

Choose a reason for hiding this comment

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

To add on to what aleem is saying, It turns out authz.MsgExec has a built in function called "GetMessages()" which returns an arrray of sdk.Msg. Way easier than looping through and trying to unmarshal.

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.

4 participants