This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
forked from b-harvest/Canto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from b-harvest/abci1.0/remove-not-core-modules
refactor!: remove not core modules
- Loading branch information
Showing
237 changed files
with
10,386 additions
and
58,876 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package cosmos | ||
|
||
import ( | ||
"fmt" | ||
|
||
errorsmod "cosmossdk.io/errors" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
errortypes "github.com/cosmos/cosmos-sdk/types/errors" | ||
) | ||
|
||
// DisabledMsgsDecorator blocks certain msg types from being granted or executed | ||
// within the authorization module. | ||
type DisabledMsgsDecorator struct { | ||
// disabledMsgTypes is the type urls of the msgs to block. | ||
disabledMsgTypes []string | ||
} | ||
|
||
// NewDisabledMsgDecorator creates a decorator to block certain msg types | ||
func NewDisabledMsgDecorator(disabledMsgTypes ...string) DisabledMsgsDecorator { | ||
return DisabledMsgsDecorator{ | ||
disabledMsgTypes: disabledMsgTypes, | ||
} | ||
} | ||
|
||
func (ald DisabledMsgsDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { | ||
if err := ald.checkDisabledMsgs(tx.GetMsgs()); err != nil { | ||
return ctx, errorsmod.Wrapf(errortypes.ErrUnauthorized, err.Error()) | ||
} | ||
return next(ctx, tx, simulate) | ||
} | ||
|
||
// checkDisabledMsgs iterates through the msgs and returns an error if it finds any unauthorized msgs. | ||
func (ald DisabledMsgsDecorator) checkDisabledMsgs(msgs []sdk.Msg) error { | ||
for _, msg := range msgs { | ||
url := sdk.MsgTypeURL(msg) | ||
if ald.isDisabledMsg(url) { | ||
return fmt.Errorf("found disabled msg type: %s", url) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// isDisabledMsg returns true if the given message is in the list of restricted | ||
// messages from the AnteHandler. | ||
func (ald DisabledMsgsDecorator) isDisabledMsg(msgTypeURL string) bool { | ||
for _, disabledType := range ald.disabledMsgTypes { | ||
if msgTypeURL == disabledType { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.