testnet
GitHub

keeper.GlobalPolicyValidate

GlobalPolicyValidate(ctx sdk.Context, msgs []sdk.Msg) error

Validates a slice of Cosmos SDK messages against the globally configured PCL policies. This function is the core integration point for the PclAnteDecorator, which runs on every transaction to enforce network-wide compliance rules.

Parameters

Name Type Required Description
ctx sdk.Context The current blockchain context, providing access to the store, block time, etc.
msgs []sdk.Msg The slice of messages contained within the transaction to be validated.

Returns

Type: error

Returns nil if all global policies pass. Otherwise, it returns a specific error indicating which policy was violated (e.g., ErrorInDenylist, ErrorVolumeAboveMaxLimit).

Errors

Code Name Description
ErrorInDenylist ErrorInDenylist The message sender is on the active global denylist.
ErrorEasAttestationRequired ErrorEasAttestationRequired A global EAS policy is active and the sender does not have the required attestation.

Examples

Usage within an AnteDecorator

This code snippet, taken from `ante.go`, shows the canonical usage. The decorator calls `GlobalPolicyValidate` and rejects the transaction if an error is returned.

func (pd PclAnteDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
    // The core logic of the PCL ante handler.
    err := pd.pclKeeper.GlobalPolicyValidate(ctx, tx.GetMsgs())
    if err != nil {
        // If validation fails, reject the transaction.
        return ctx, err
    }

    // If validation succeeds, proceed to the next handler in the chain.
    return next(ctx, tx, simulate)
}
ESC
Type to search