Documentation ¶
Index ¶
- Constants
- Variables
- func ConcatBz(bz1, bz2 []byte) []byte
- func CreateParamKey(name string) []byte
- func CreateProposalTempIndexKey(govPropID uint64, addr sdk.AccAddress) []byte
- func CreateProposalTempIndexPrefix(govPropID *uint64) []byte
- func CreateSanctionedAddrKey(addr sdk.AccAddress) []byte
- func CreateTemporaryAddrPrefix(addr sdk.AccAddress) []byte
- func CreateTemporaryKey(addr sdk.AccAddress, govPropID uint64) []byte
- func IsSanctionBz(bz []byte) bool
- func IsUnsanctionBz(bz []byte) bool
- func NewTempEvent(typeVal byte, addr sdk.AccAddress) proto.Message
- func ParseLengthPrefixedBz(bz []byte) ([]byte, []byte)
- func ParseParamKey(bz []byte) string
- func ParseProposalTempIndexKey(key []byte) (uint64, sdk.AccAddress)
- func ParseSanctionedAddrKey(key []byte) sdk.AccAddress
- func ParseTemporaryKey(key []byte) (sdk.AccAddress, uint64)
- func ToTempStatus(bz []byte) sanction.TempStatus
- type Keeper
- func (k Keeper) AddTemporarySanction(ctx sdk.Context, govPropID uint64, addrs ...sdk.AccAddress) error
- func (k Keeper) AddTemporaryUnsanction(ctx sdk.Context, govPropID uint64, addrs ...sdk.AccAddress) error
- func (k Keeper) AfterProposalDeposit(ctx context.Context, proposalID uint64, _ sdk.AccAddress) error
- func (k Keeper) AfterProposalFailedMinDeposit(ctx context.Context, proposalID uint64) error
- func (k Keeper) AfterProposalSubmission(ctx context.Context, proposalID uint64) error
- func (k Keeper) AfterProposalVote(_ context.Context, _ uint64, _ sdk.AccAddress) error
- func (k Keeper) AfterProposalVotingPeriodEnded(ctx context.Context, proposalID uint64) error
- func (k Keeper) DeleteAddrTempEntries(ctx sdk.Context, addrs ...sdk.AccAddress)
- func (k Keeper) DeleteGovPropTempEntries(ctx sdk.Context, govPropID uint64)
- func (k Keeper) ExportGenesis(ctx sdk.Context) *sanction.GenesisState
- func (k Keeper) GetAllSanctionedAddresses(ctx sdk.Context) []string
- func (k Keeper) GetAllTemporaryEntries(ctx sdk.Context) []*sanction.TemporaryEntry
- func (k Keeper) GetAuthority() string
- func (k Keeper) GetImmediateSanctionMinDeposit(ctx sdk.Context) sdk.Coins
- func (k Keeper) GetImmediateUnsanctionMinDeposit(ctx sdk.Context) sdk.Coins
- func (k Keeper) GetParams(ctx sdk.Context) *sanction.Params
- func (k Keeper) InitGenesis(origCtx sdk.Context, genState *sanction.GenesisState)
- func (k Keeper) IsAddrThatCannotBeSanctioned(addr sdk.AccAddress) bool
- func (k Keeper) IsSanctioned(goCtx context.Context, req *sanction.QueryIsSanctionedRequest) (*sanction.QueryIsSanctionedResponse, error)
- func (k Keeper) IsSanctionedAddr(goCtx context.Context, addr sdk.AccAddress) bool
- func (k Keeper) IterateParams(ctx sdk.Context, cb func(name, value string) (stop bool))
- func (k Keeper) IterateProposalIndexEntries(ctx sdk.Context, govPropID *uint64, ...)
- func (k Keeper) IterateSanctionedAddresses(ctx sdk.Context, cb func(addr sdk.AccAddress) (stop bool))
- func (k Keeper) IterateTemporaryEntries(ctx sdk.Context, addr sdk.AccAddress, ...)
- func (k Keeper) Params(goCtx context.Context, _ *sanction.QueryParamsRequest) (*sanction.QueryParamsResponse, error)
- func (k Keeper) Sanction(goCtx context.Context, req *sanction.MsgSanction) (*sanction.MsgSanctionResponse, error)
- func (k Keeper) SanctionAddresses(ctx sdk.Context, addrs ...sdk.AccAddress) error
- func (k Keeper) SanctionedAddresses(goCtx context.Context, req *sanction.QuerySanctionedAddressesRequest) (*sanction.QuerySanctionedAddressesResponse, error)
- func (k Keeper) SendRestrictionFn(ctx context.Context, fromAddr, toAddr sdk.AccAddress, _ sdk.Coins) (sdk.AccAddress, error)
- func (k Keeper) SetParams(ctx sdk.Context, params *sanction.Params) error
- func (k Keeper) TemporaryEntries(goCtx context.Context, req *sanction.QueryTemporaryEntriesRequest) (*sanction.QueryTemporaryEntriesResponse, error)
- func (k Keeper) Unsanction(goCtx context.Context, req *sanction.MsgUnsanction) (*sanction.MsgUnsanctionResponse, error)
- func (k Keeper) UnsanctionAddresses(ctx sdk.Context, addrs ...sdk.AccAddress) error
- func (k Keeper) UpdateParams(goCtx context.Context, req *sanction.MsgUpdateParams) (*sanction.MsgUpdateParamsResponse, error)
- type WrappedGovKeeper
Constants ¶
const ( ParamNameImmediateSanctionMinDeposit = "immediate_sanction_min_deposit" ParamNameImmediateUnsanctionMinDeposit = "immediate_unsanction_min_deposit" )
const ( // SanctionB is a byte representing a sanction (either temporary or permanent). SanctionB = 0x01 // UnsanctionB is a byte representing an unsanction (probably temporary). UnsanctionB = 0x00 )
Variables ¶
var ( ParamsPrefix = []byte{0x00} SanctionedPrefix = []byte{0x01} TemporaryPrefix = []byte{0x02} ProposalIndexPrefix = []byte{0x03} )
Keys for store prefixes Items are stored with the following keys:
Params entry: - 0x00<name> -> <value> Sanctioned addresses: - 0x01<addr len (1 byte)><addr> -> 0x01 Temporarily sanctioned or unsanctioned addresses: - 0x02<addr len (1 byte)><addr><gov prop id (8 bytes)> -> 0x01 or 0x00 Proposal id temp sanction index: - 0x03<proposal id (8 bytes)><addr len (1 byte)><addr> -> 0x00 or 0x01
Functions ¶
func ConcatBz ¶
ConcatBz creates a single byte slice consisting of the two provided byte slices. Like append() but always returns a new slice with its own underlying array.
func CreateParamKey ¶
CreateParamKey creates the key to use for a param with the given name.
- 0x00<name> -> <value>
func CreateProposalTempIndexKey ¶
func CreateProposalTempIndexKey(govPropID uint64, addr sdk.AccAddress) []byte
CreateProposalTempIndexKey creates a key for a proposal id + addr temporary index entry.
0x03<proposal id (8 bytes)><addr len (1 byte)><addr>
func CreateProposalTempIndexPrefix ¶
CreateProposalTempIndexPrefix creates a key prefix for a proposal temporary index key.
If a govPropID is provided: - 0x03<proposal id (8 bytes)> If a govPropID isn't provided: - 0x03
func CreateSanctionedAddrKey ¶
func CreateSanctionedAddrKey(addr sdk.AccAddress) []byte
CreateSanctionedAddrKey creates the sanctioned address key for the provided address.
- 0x01<addr len (1 byte)><addr>
func CreateTemporaryAddrPrefix ¶
func CreateTemporaryAddrPrefix(addr sdk.AccAddress) []byte
CreateTemporaryAddrPrefix creates a key prefix for a temporarily sanctioned/unsanctioned address.
If an address is provided: - 0x02<addr len(1 byte)><addr> If an address isn't provided: - 0x02
func CreateTemporaryKey ¶
func CreateTemporaryKey(addr sdk.AccAddress, govPropID uint64) []byte
CreateTemporaryKey creates a key for a temporarily sanctioned/unsanctioned address associated with the given governance proposal id.
- 0x02<addr len (1 byte)><addr><gov prop id (8 bytes)>
func IsSanctionBz ¶
IsSanctionBz returns true if the provided byte slice indicates a temporary sanction.
func IsUnsanctionBz ¶
IsUnsanctionBz returns true if the provided byte slice indicates a temporary unsanction.
func NewTempEvent ¶
func NewTempEvent(typeVal byte, addr sdk.AccAddress) proto.Message
NewTempEvent creates the temp event for the given type val (e.g. SanctionB or UnsanctionB) with the given address.
func ParseLengthPrefixedBz ¶
ParseLengthPrefixedBz parses a length-prefixed byte slice into those bytes and any leftover bytes.
func ParseParamKey ¶
ParseParamKey extracts the param name from the provided key.
func ParseProposalTempIndexKey ¶
func ParseProposalTempIndexKey(key []byte) (uint64, sdk.AccAddress)
ParseProposalTempIndexKey extracts the gov prop id and address from the provided proposal temp index key.
func ParseSanctionedAddrKey ¶
func ParseSanctionedAddrKey(key []byte) sdk.AccAddress
ParseSanctionedAddrKey extracts the address from the provided sanctioned address key.
func ParseTemporaryKey ¶
func ParseTemporaryKey(key []byte) (sdk.AccAddress, uint64)
ParseTemporaryKey extracts the address and gov prop id from the provided temporary key.
func ToTempStatus ¶
func ToTempStatus(bz []byte) sanction.TempStatus
ToTempStatus converts a temporary entry value byte slice into a TempStatus value.
Types ¶
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
func NewKeeper ¶
func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, bankKeeper sanction.BankKeeper, govKeeper *govkeeper.Keeper, authority string, unsanctionableAddrs []sdk.AccAddress, ) Keeper
func (Keeper) AddTemporarySanction ¶
func (k Keeper) AddTemporarySanction(ctx sdk.Context, govPropID uint64, addrs ...sdk.AccAddress) error
AddTemporarySanction adds a temporary sanction with the given gov prop id for each of the provided addresses.
func (Keeper) AddTemporaryUnsanction ¶
func (k Keeper) AddTemporaryUnsanction(ctx sdk.Context, govPropID uint64, addrs ...sdk.AccAddress) error
AddTemporaryUnsanction adds a temporary unsanction with the given gov prop id for each of the provided addresses.
func (Keeper) AfterProposalDeposit ¶
func (k Keeper) AfterProposalDeposit(ctx context.Context, proposalID uint64, _ sdk.AccAddress) error
AfterProposalDeposit is called after a deposit is made. If there's enough deposit, temporary entries are created.
func (Keeper) AfterProposalFailedMinDeposit ¶
AfterProposalFailedMinDeposit is called when proposal fails to reach min deposit. Cleans up any possible temporary entries.
func (Keeper) AfterProposalSubmission ¶
AfterProposalSubmission is called after proposal is submitted. If there's enough deposit, temporary entries are created.
func (Keeper) AfterProposalVote ¶
AfterProposalVote is called after a vote on a proposal is cast. This one does nothing.
func (Keeper) AfterProposalVotingPeriodEnded ¶
AfterProposalVotingPeriodEnded is called when proposal's finishes it's voting period. Cleans up temporary entries.
func (Keeper) DeleteAddrTempEntries ¶
func (k Keeper) DeleteAddrTempEntries(ctx sdk.Context, addrs ...sdk.AccAddress)
DeleteAddrTempEntries deletes all temporary entries for each given address.
func (Keeper) DeleteGovPropTempEntries ¶
DeleteGovPropTempEntries deletes the temporary entries for the given proposal id.
func (Keeper) ExportGenesis ¶
func (k Keeper) ExportGenesis(ctx sdk.Context) *sanction.GenesisState
ExportGenesis reads this keeper's entire state and returns it as a GenesisState.
func (Keeper) GetAllSanctionedAddresses ¶
GetAllSanctionedAddresses gets the bech32 string of every account that is sanctioned. This is designed for use with ExportGenesis. See also IterateSanctionedAddresses.
func (Keeper) GetAllTemporaryEntries ¶
func (k Keeper) GetAllTemporaryEntries(ctx sdk.Context) []*sanction.TemporaryEntry
GetAllTemporaryEntries gets all the Temporary entries. This is designed for use with ExportGenesis. See also IterateTemporaryEntries.
func (Keeper) GetAuthority ¶
GetAuthority returns this module's authority string.
func (Keeper) GetImmediateSanctionMinDeposit ¶
GetImmediateSanctionMinDeposit gets the minimum deposit for a sanction to happen immediately.
func (Keeper) GetImmediateUnsanctionMinDeposit ¶
GetImmediateUnsanctionMinDeposit gets the minimum deposit for an unsanction to happen immediately.
func (Keeper) GetParams ¶
GetParams gets the sanction module's params. If there isn't anything set in state, the defaults are returned.
func (Keeper) InitGenesis ¶
func (k Keeper) InitGenesis(origCtx sdk.Context, genState *sanction.GenesisState)
InitGenesis updates this keeper's store using the provided GenesisState.
func (Keeper) IsAddrThatCannotBeSanctioned ¶
func (k Keeper) IsAddrThatCannotBeSanctioned(addr sdk.AccAddress) bool
IsAddrThatCannotBeSanctioned returns true if the provided address is one of the ones that cannot be sanctioned. Returns false if the addr can be sanctioned.
func (Keeper) IsSanctioned ¶
func (k Keeper) IsSanctioned(goCtx context.Context, req *sanction.QueryIsSanctionedRequest) (*sanction.QueryIsSanctionedResponse, error)
func (Keeper) IsSanctionedAddr ¶
IsSanctionedAddr returns true if the provided address is currently sanctioned (either permanently or temporarily).
func (Keeper) IterateParams ¶
IterateParams iterates over all params entries. The callback takes in the name and value, and should return whether to stop iteration (true = stop, false = keep going).
func (Keeper) IterateProposalIndexEntries ¶
func (k Keeper) IterateProposalIndexEntries(ctx sdk.Context, govPropID *uint64, cb func(govPropID uint64, addr sdk.AccAddress) (stop bool))
IterateProposalIndexEntries iterates over all of the index entries for temp entries. The callback takes in the gov prop id and address. The callback should return whether to stop iteration (true = stop, false = keep going).
func (Keeper) IterateSanctionedAddresses ¶
func (k Keeper) IterateSanctionedAddresses(ctx sdk.Context, cb func(addr sdk.AccAddress) (stop bool))
IterateSanctionedAddresses iterates over all of the permanently sanctioned addresses. The callback takes in the sanctioned address and should return whether to stop iteration (true = stop, false = keep going).
func (Keeper) IterateTemporaryEntries ¶
func (k Keeper) IterateTemporaryEntries(ctx sdk.Context, addr sdk.AccAddress, cb func(addr sdk.AccAddress, govPropID uint64, isSanction bool) (stop bool))
IterateTemporaryEntries iterates over each of the temporary entries. If an address is provided, only the temporary entries for that address are iterated, otherwise all entries are iterated. The callback takes in the address in question, the governance proposal associated with it, and whether it's a sanction (true) or unsanction (false). The callback should return whether to stop iteration (true = stop, false = keep going).
func (Keeper) Params ¶
func (k Keeper) Params(goCtx context.Context, _ *sanction.QueryParamsRequest) (*sanction.QueryParamsResponse, error)
func (Keeper) Sanction ¶
func (k Keeper) Sanction(goCtx context.Context, req *sanction.MsgSanction) (*sanction.MsgSanctionResponse, error)
func (Keeper) SanctionAddresses ¶
SanctionAddresses creates permanent sanctioned address entries for each of the provided addresses. Also deletes any temporary entries for each address.
func (Keeper) SanctionedAddresses ¶
func (k Keeper) SanctionedAddresses(goCtx context.Context, req *sanction.QuerySanctionedAddressesRequest) (*sanction.QuerySanctionedAddressesResponse, error)
func (Keeper) SendRestrictionFn ¶
func (k Keeper) SendRestrictionFn(ctx context.Context, fromAddr, toAddr sdk.AccAddress, _ sdk.Coins) (sdk.AccAddress, error)
func (Keeper) SetParams ¶
SetParams sets the sanction module's params. Providing a nil params will cause all params to be deleted (so that defaults are used).
func (Keeper) TemporaryEntries ¶
func (k Keeper) TemporaryEntries(goCtx context.Context, req *sanction.QueryTemporaryEntriesRequest) (*sanction.QueryTemporaryEntriesResponse, error)
func (Keeper) Unsanction ¶
func (k Keeper) Unsanction(goCtx context.Context, req *sanction.MsgUnsanction) (*sanction.MsgUnsanctionResponse, error)
func (Keeper) UnsanctionAddresses ¶
UnsanctionAddresses deletes any sanctioned address entries for each provided address. Also deletes any temporary entries for each address.
func (Keeper) UpdateParams ¶
func (k Keeper) UpdateParams(goCtx context.Context, req *sanction.MsgUpdateParams) (*sanction.MsgUpdateParamsResponse, error)
type WrappedGovKeeper ¶
A WrappedGovKeeper implements the sanction.GovKeeper interface, allowing for mocking of some of the stuff that the gov keeper keeps in fields now.
func WrapGovKeeper ¶
func WrapGovKeeper(keeper *govkeeper.Keeper) *WrappedGovKeeper
WrapGovKeeper creates a new WrappedGovKeeper around the provided keeper.