-
Notifications
You must be signed in to change notification settings - Fork 35
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
feat: Add TrackBeforeSend
, BlockBeforeSend
hooks. Deprecate BeforeSend
hook
#421
Conversation
TrackBeforeSend
, BlockBeforeSend
hooks. Deprecate BeforeSend
hookTrackBeforeSend
, BlockBeforeSend
hooks. Deprecate BeforeSend
hook
@@ -237,12 +238,14 @@ func (k BaseKeeper) UndelegateCoins(ctx sdk.Context, moduleAccAddr, delegatorAdd | |||
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, amt.String()) | |||
} | |||
|
|||
// call the BeforeSend hooks | |||
err := k.BeforeSend(ctx, moduleAccAddr, delegatorAddr, amt) | |||
// call the TrackBeforeSend hooks and the BlockBeforeSend hooks |
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.
Q unrelated to this PR: Do we know why Delegate/UndelegateCoins manages the coins directly instead of using SendCoins under the hood? Seems like it would be a better abstraction and the hooks could just be in SendCoins
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.
potentially because of security issue, I have no ide. Good point tho
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.
left some minor comments, but this LGTM. I'm not a fan of the imperative in the function names here ("track", "block") as it seems like we're doing the action when that gets called, but couldn't come up with good alternatives. My best idea is "tracking" and "blocking" but still not great
Co-authored-by: Nicolas Lara <[email protected]>
…oreSend` hook (#421) * Add separated hooks for bank send * Update x/bank/keeper/hooks.go Co-authored-by: Nicolas Lara <[email protected]> --------- Co-authored-by: Nicolas Lara <[email protected]>
…oreSend` hook (#421) * Add separated hooks for bank send * Update x/bank/keeper/hooks.go Co-authored-by: Nicolas Lara <[email protected]> --------- Co-authored-by: Nicolas Lara <[email protected]>
…oreSend` hook (#421) * Add separated hooks for bank send * Update x/bank/keeper/hooks.go Co-authored-by: Nicolas Lara <[email protected]> --------- Co-authored-by: Nicolas Lara <[email protected]>
…oreSend` hook (#421) * Add separated hooks for bank send * Update x/bank/keeper/hooks.go Co-authored-by: Nicolas Lara <[email protected]> --------- Co-authored-by: Nicolas Lara <[email protected]>
…oreSend` hook (#421) * Add separated hooks for bank send * Update x/bank/keeper/hooks.go Co-authored-by: Nicolas Lara <[email protected]> --------- Co-authored-by: Nicolas Lara <[email protected]>
What is the purpose of the change
This PR adds
TrackBeforeSend
hook andBlockBeforeSend
hook, and deprecatesBeforeSend
hook.Each hook, respectively would call the hook that has been registered from a different module.
The difference between the two new hooks being introduced is that
TrackBeforesend
hook does not have the ability to cause any effect, as it does not emit errors. Meanwhile,BlockBeforeSend
does emit errors, allowing connected hooks to stop and block the send.Additional method
SendCoinsWithoutBlockHook
has also been added along with the two hooks, as for module <> module transfers, we want to ensure it does not get blocked by external hooks.Brief Changelog
Add
TrackBeforeSend
,BlockBeforeSend
hooks. DeprecateBeforeSend
hookTesting and Verifying
This change adds tests
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? (yes / no)x/<module>/spec/
) / Osmosis docs repo / not documented)