feegrant

package
v0.45.26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2022 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package feegrant provides functionality for authorizing the payment of transaction fees from one account (key) to another account (key).

Effectively, this allows for a user to pay fees using the balance of an account different from their own. Example use cases would be allowing a key on a device to pay for fees using a master wallet, or a third party service allowing users to pay for transactions without ever really holding their own tokens. This package provides ways for specifying fee allowances such that authorizing fee payment to another account can be done with clear and safe restrictions.

A user would authorize granting fee payment to another user using MsgGrantAllowance and revoke that delegation using MsgRevokeAllowance. In both cases, Granter is the one who is authorizing fee payment and Grantee is the one who is receiving the fee payment authorization. So grantee would correspond to the one who is signing a transaction and the granter would be the address that pays the fees.

The fee allowance that a grantee receives is specified by an implementation of the FeeAllowance interface. Two FeeAllowance implementations are provided in this package: BasicAllowance and PeriodicAllowance.

Package feegrant is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	EventTypeUseFeeGrant    = "use_feegrant"
	EventTypeRevokeFeeGrant = "revoke_feegrant"
	EventTypeSetFeeGrant    = "set_feegrant"

	AttributeKeyGranter = "granter"
	AttributeKeyGrantee = "grantee"

	AttributeValueCategory = ModuleName
)

evidence module events

View Source
const (
	// ModuleName is the module name constant used in many places
	ModuleName = "feegrant"

	// StoreKey is the store key string for supply
	StoreKey = ModuleName

	// RouterKey is the message route for supply
	RouterKey = ModuleName

	// QuerierRoute is the querier route for supply
	QuerierRoute = ModuleName
)
View Source
const (
	DefaultCodespace = ModuleName
)

Codes for governance errors

Variables

View Source
var (
	// ErrFeeLimitExceeded error if there are not enough allowance to cover the fees
	ErrFeeLimitExceeded = sdkerrors.Register(DefaultCodespace, 2, "fee limit exceeded")
	// ErrFeeLimitExpired error if the allowance has expired
	ErrFeeLimitExpired = sdkerrors.Register(DefaultCodespace, 3, "fee allowance expired")
	// ErrInvalidDuration error if the Duration is invalid or doesn't match the expiration
	ErrInvalidDuration = sdkerrors.Register(DefaultCodespace, 4, "invalid duration")
	// ErrNoAllowance error if there is no allowance for that pair
	ErrNoAllowance = sdkerrors.Register(DefaultCodespace, 5, "no allowance")
	// ErrNoMessages error if there is no message
	ErrNoMessages = sdkerrors.Register(DefaultCodespace, 6, "allowed messages are empty")
	// ErrMessageNotAllowed error if message is not allowed
	ErrMessageNotAllowed = sdkerrors.Register(DefaultCodespace, 7, "message not allowed")
)
View Source
var (
	ErrInvalidLengthFeegrant        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowFeegrant          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupFeegrant = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthGenesis        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowGenesis          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthQuery        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowQuery          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthTx        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowTx          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	// FeeAllowanceKeyPrefix is the set of the kvstore for fee allowance data
	FeeAllowanceKeyPrefix = []byte{0x00}
)

Functions

func FeeAllowanceKey

func FeeAllowanceKey(granter sdk.AccAddress, grantee sdk.AccAddress) []byte

FeeAllowanceKey is the canonical key to store a grant from granter to grantee We store by grantee first to allow searching by everyone who granted to you

func FeeAllowancePrefixByGrantee

func FeeAllowancePrefixByGrantee(grantee sdk.AccAddress) []byte

FeeAllowancePrefixByGrantee returns a prefix to scan for all grants to this given address.

func RegisterInterfaces

func RegisterInterfaces(registry types.InterfaceRegistry)

RegisterInterfaces registers the interfaces types with the interface registry

func RegisterMsgServer

func RegisterMsgServer(s grpc1.Server, srv MsgServer)

func RegisterQueryHandler

func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterQueryHandler registers the http handlers for service Query to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterQueryHandlerClient

func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error

RegisterQueryHandlerClient registers the http handlers for service Query to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "QueryClient" to call the correct interceptors.

func RegisterQueryHandlerFromEndpoint

func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterQueryHandlerServer

func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error

RegisterQueryHandlerServer registers the http handlers for service Query to "mux". UnaryRPC :call QueryServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.

func RegisterQueryServer

func RegisterQueryServer(s grpc1.Server, srv QueryServer)

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis ensures all grants in the genesis state are valid

Types

type AccountKeeper

type AccountKeeper interface {
	GetModuleAddress(moduleName string) sdk.AccAddress
	GetModuleAccount(ctx sdk.Context, moduleName string) auth.ModuleAccountI

	NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) auth.AccountI
	GetAccount(ctx sdk.Context, addr sdk.AccAddress) auth.AccountI
	SetAccount(ctx sdk.Context, acc auth.AccountI)
}

AccountKeeper defines the expected auth Account Keeper (noalias)

type AllowedMsgAllowance

type AllowedMsgAllowance struct {
	// allowance can be any of basic and filtered fee allowance.
	Allowance *types1.Any `protobuf:"bytes,1,opt,name=allowance,proto3" json:"allowance,omitempty"`
	// allowed_messages are the messages for which the grantee has the access.
	AllowedMessages []string `protobuf:"bytes,2,rep,name=allowed_messages,json=allowedMessages,proto3" json:"allowed_messages,omitempty"`
}

AllowedMsgAllowance creates allowance only for specified message types.

func NewAllowedMsgAllowance

func NewAllowedMsgAllowance(allowance FeeAllowanceI, allowedMsgs []string) (*AllowedMsgAllowance, error)

NewAllowedMsgFeeAllowance creates new filtered fee allowance.

func (*AllowedMsgAllowance) Accept

func (a *AllowedMsgAllowance) Accept(ctx sdk.Context, fee sdk.Coins, msgs []sdk.Msg) (bool, error)

Accept method checks for the filtered messages has valid expiry

func (*AllowedMsgAllowance) Descriptor

func (*AllowedMsgAllowance) Descriptor() ([]byte, []int)

func (*AllowedMsgAllowance) GetAllowance

func (a *AllowedMsgAllowance) GetAllowance() (FeeAllowanceI, error)

GetAllowance returns allowed fee allowance.

func (*AllowedMsgAllowance) Marshal

func (m *AllowedMsgAllowance) Marshal() (dAtA []byte, err error)

func (*AllowedMsgAllowance) MarshalTo

func (m *AllowedMsgAllowance) MarshalTo(dAtA []byte) (int, error)

func (*AllowedMsgAllowance) MarshalToSizedBuffer

func (m *AllowedMsgAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*AllowedMsgAllowance) ProtoMessage

func (*AllowedMsgAllowance) ProtoMessage()

func (*AllowedMsgAllowance) Reset

func (m *AllowedMsgAllowance) Reset()

func (*AllowedMsgAllowance) Size

func (m *AllowedMsgAllowance) Size() (n int)

func (*AllowedMsgAllowance) String

func (m *AllowedMsgAllowance) String() string

func (*AllowedMsgAllowance) Unmarshal

func (m *AllowedMsgAllowance) Unmarshal(dAtA []byte) error

func (*AllowedMsgAllowance) UnpackInterfaces

func (a *AllowedMsgAllowance) UnpackInterfaces(unpacker types.AnyUnpacker) error

UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces

func (*AllowedMsgAllowance) ValidateBasic

func (a *AllowedMsgAllowance) ValidateBasic() error

ValidateBasic implements FeeAllowance and enforces basic sanity checks

func (*AllowedMsgAllowance) XXX_DiscardUnknown

func (m *AllowedMsgAllowance) XXX_DiscardUnknown()

func (*AllowedMsgAllowance) XXX_Marshal

func (m *AllowedMsgAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AllowedMsgAllowance) XXX_Merge

func (m *AllowedMsgAllowance) XXX_Merge(src proto.Message)

func (*AllowedMsgAllowance) XXX_Size

func (m *AllowedMsgAllowance) XXX_Size() int

func (*AllowedMsgAllowance) XXX_Unmarshal

func (m *AllowedMsgAllowance) XXX_Unmarshal(b []byte) error

type BankKeeper

type BankKeeper interface {
	SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
	SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
}

BankKeeper defines the expected supply Keeper (noalias)

type BasicAllowance

type BasicAllowance struct {
	// spend_limit specifies the maximum amount of tokens that can be spent
	// by this allowance and will be updated as tokens are spent. If it is
	// empty, there is no spend limit and any amount of coins can be spent.
	SpendLimit github_com_cosmos_cosmos_sdk_types.Coins `` /* 136-byte string literal not displayed */
	// expiration specifies an optional time when this allowance expires
	Expiration *time.Time `protobuf:"bytes,2,opt,name=expiration,proto3,stdtime" json:"expiration,omitempty"`
}

BasicAllowance implements Allowance with a one-time grant of tokens that optionally expires. The grantee can use up to SpendLimit to cover fees.

func (*BasicAllowance) Accept

func (a *BasicAllowance) Accept(ctx sdk.Context, fee sdk.Coins, _ []sdk.Msg) (bool, error)

Accept can use fee payment requested as well as timestamp of the current block to determine whether or not to process this. This is checked in Keeper.UseGrantedFees and the return values should match how it is handled there.

If it returns an error, the fee payment is rejected, otherwise it is accepted. The FeeAllowance implementation is expected to update it's internal state and will be saved again after an acceptance.

If remove is true (regardless of the error), the FeeAllowance will be deleted from storage (eg. when it is used up). (See call to RevokeAllowance in Keeper.UseGrantedFees)

func (*BasicAllowance) Descriptor

func (*BasicAllowance) Descriptor() ([]byte, []int)

func (*BasicAllowance) GetExpiration

func (m *BasicAllowance) GetExpiration() *time.Time

func (*BasicAllowance) GetSpendLimit

func (*BasicAllowance) Marshal

func (m *BasicAllowance) Marshal() (dAtA []byte, err error)

func (*BasicAllowance) MarshalTo

func (m *BasicAllowance) MarshalTo(dAtA []byte) (int, error)

func (*BasicAllowance) MarshalToSizedBuffer

func (m *BasicAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*BasicAllowance) ProtoMessage

func (*BasicAllowance) ProtoMessage()

func (*BasicAllowance) Reset

func (m *BasicAllowance) Reset()

func (*BasicAllowance) Size

func (m *BasicAllowance) Size() (n int)

func (*BasicAllowance) String

func (m *BasicAllowance) String() string

func (*BasicAllowance) Unmarshal

func (m *BasicAllowance) Unmarshal(dAtA []byte) error

func (BasicAllowance) ValidateBasic

func (a BasicAllowance) ValidateBasic() error

ValidateBasic implements FeeAllowance and enforces basic sanity checks

func (*BasicAllowance) XXX_DiscardUnknown

func (m *BasicAllowance) XXX_DiscardUnknown()

func (*BasicAllowance) XXX_Marshal

func (m *BasicAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*BasicAllowance) XXX_Merge

func (m *BasicAllowance) XXX_Merge(src proto.Message)

func (*BasicAllowance) XXX_Size

func (m *BasicAllowance) XXX_Size() int

func (*BasicAllowance) XXX_Unmarshal

func (m *BasicAllowance) XXX_Unmarshal(b []byte) error

type FeeAllowanceI

type FeeAllowanceI interface {
	// Accept can use fee payment requested as well as timestamp of the current block
	// to determine whether or not to process this. This is checked in
	// Keeper.UseGrantedFees and the return values should match how it is handled there.
	//
	// If it returns an error, the fee payment is rejected, otherwise it is accepted.
	// The FeeAllowance implementation is expected to update it's internal state
	// and will be saved again after an acceptance.
	//
	// If remove is true (regardless of the error), the FeeAllowance will be deleted from storage
	// (eg. when it is used up). (See call to RevokeAllowance in Keeper.UseGrantedFees)
	Accept(ctx sdk.Context, fee sdk.Coins, msgs []sdk.Msg) (remove bool, err error)

	// ValidateBasic should evaluate this FeeAllowance for internal consistency.
	// Don't allow negative amounts, or negative periods for example.
	ValidateBasic() error
}

FeeAllowance implementations are tied to a given fee delegator and delegatee, and are used to enforce fee grant limits.

type GenesisState

type GenesisState struct {
	Allowances []Grant `protobuf:"bytes,1,rep,name=allowances,proto3" json:"allowances"`
}

GenesisState contains a set of fee allowances, persisted from the store

func DefaultGenesisState

func DefaultGenesisState() *GenesisState

DefaultGenesisState returns default state for feegrant module.

func NewGenesisState

func NewGenesisState(entries []Grant) *GenesisState

NewGenesisState creates new GenesisState object

func (*GenesisState) Descriptor

func (*GenesisState) Descriptor() ([]byte, []int)

func (*GenesisState) GetAllowances

func (m *GenesisState) GetAllowances() []Grant

func (*GenesisState) Marshal

func (m *GenesisState) Marshal() (dAtA []byte, err error)

func (*GenesisState) MarshalTo

func (m *GenesisState) MarshalTo(dAtA []byte) (int, error)

func (*GenesisState) MarshalToSizedBuffer

func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*GenesisState) ProtoMessage

func (*GenesisState) ProtoMessage()

func (*GenesisState) Reset

func (m *GenesisState) Reset()

func (*GenesisState) Size

func (m *GenesisState) Size() (n int)

func (*GenesisState) String

func (m *GenesisState) String() string

func (*GenesisState) Unmarshal

func (m *GenesisState) Unmarshal(dAtA []byte) error

func (GenesisState) UnpackInterfaces

func (data GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error

UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces

func (*GenesisState) XXX_DiscardUnknown

func (m *GenesisState) XXX_DiscardUnknown()

func (*GenesisState) XXX_Marshal

func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GenesisState) XXX_Merge

func (m *GenesisState) XXX_Merge(src proto.Message)

func (*GenesisState) XXX_Size

func (m *GenesisState) XXX_Size() int

func (*GenesisState) XXX_Unmarshal

func (m *GenesisState) XXX_Unmarshal(b []byte) error

type Grant

type Grant struct {
	// granter is the address of the user granting an allowance of their funds.
	Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"`
	// grantee is the address of the user being granted an allowance of another user's funds.
	Grantee string `protobuf:"bytes,2,opt,name=grantee,proto3" json:"grantee,omitempty"`
	// allowance can be any of basic and filtered fee allowance.
	Allowance *types1.Any `protobuf:"bytes,3,opt,name=allowance,proto3" json:"allowance,omitempty"`
}

Grant is stored in the KVStore to record a grant with full context

func NewGrant

func NewGrant(granter, grantee sdk.AccAddress, feeAllowance FeeAllowanceI) (Grant, error)

NewGrant creates a new FeeAllowanceGrant.

func (*Grant) Descriptor

func (*Grant) Descriptor() ([]byte, []int)

func (*Grant) GetAllowance

func (m *Grant) GetAllowance() *types1.Any

func (Grant) GetGrant

func (a Grant) GetGrant() (FeeAllowanceI, error)

GetGrant unpacks allowance

func (*Grant) GetGrantee

func (m *Grant) GetGrantee() string

func (*Grant) GetGranter

func (m *Grant) GetGranter() string

func (*Grant) Marshal

func (m *Grant) Marshal() (dAtA []byte, err error)

func (*Grant) MarshalTo

func (m *Grant) MarshalTo(dAtA []byte) (int, error)

func (*Grant) MarshalToSizedBuffer

func (m *Grant) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Grant) ProtoMessage

func (*Grant) ProtoMessage()

func (*Grant) Reset

func (m *Grant) Reset()

func (*Grant) Size

func (m *Grant) Size() (n int)

func (*Grant) String

func (m *Grant) String() string

func (*Grant) Unmarshal

func (m *Grant) Unmarshal(dAtA []byte) error

func (Grant) UnpackInterfaces

func (a Grant) UnpackInterfaces(unpacker types.AnyUnpacker) error

UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces

func (Grant) ValidateBasic

func (a Grant) ValidateBasic() error

ValidateBasic performs basic validation on FeeAllowanceGrant

func (*Grant) XXX_DiscardUnknown

func (m *Grant) XXX_DiscardUnknown()

func (*Grant) XXX_Marshal

func (m *Grant) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Grant) XXX_Merge

func (m *Grant) XXX_Merge(src proto.Message)

func (*Grant) XXX_Size

func (m *Grant) XXX_Size() int

func (*Grant) XXX_Unmarshal

func (m *Grant) XXX_Unmarshal(b []byte) error

type MsgClient

type MsgClient interface {
	// GrantAllowance grants fee allowance to the grantee on the granter's
	// account with the provided expiration time.
	GrantAllowance(ctx context.Context, in *MsgGrantAllowance, opts ...grpc.CallOption) (*MsgGrantAllowanceResponse, error)
	// RevokeAllowance revokes any fee allowance of granter's account that
	// has been granted to the grantee.
	RevokeAllowance(ctx context.Context, in *MsgRevokeAllowance, opts ...grpc.CallOption) (*MsgRevokeAllowanceResponse, error)
}

MsgClient is the client API for Msg service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewMsgClient

func NewMsgClient(cc grpc1.ClientConn) MsgClient

type MsgGrantAllowance

type MsgGrantAllowance struct {
	// granter is the address of the user granting an allowance of their funds.
	Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"`
	// grantee is the address of the user being granted an allowance of another user's funds.
	Grantee string `protobuf:"bytes,2,opt,name=grantee,proto3" json:"grantee,omitempty"`
	// allowance can be any of basic and filtered fee allowance.
	Allowance *types.Any `protobuf:"bytes,3,opt,name=allowance,proto3" json:"allowance,omitempty"`
}

MsgGrantAllowance adds permission for Grantee to spend up to Allowance of fees from the account of Granter.

func NewMsgGrantAllowance

func NewMsgGrantAllowance(feeAllowance FeeAllowanceI, granter, grantee sdk.AccAddress) (*MsgGrantAllowance, error)

NewMsgGrantAllowance creates a new MsgGrantAllowance.

func (*MsgGrantAllowance) Descriptor

func (*MsgGrantAllowance) Descriptor() ([]byte, []int)

func (*MsgGrantAllowance) GetAllowance

func (m *MsgGrantAllowance) GetAllowance() *types.Any

func (MsgGrantAllowance) GetFeeAllowanceI

func (msg MsgGrantAllowance) GetFeeAllowanceI() (FeeAllowanceI, error)

GetFeeAllowanceI returns unpacked FeeAllowance

func (*MsgGrantAllowance) GetGrantee

func (m *MsgGrantAllowance) GetGrantee() string

func (*MsgGrantAllowance) GetGranter

func (m *MsgGrantAllowance) GetGranter() string

func (MsgGrantAllowance) GetSignBytes

func (msg MsgGrantAllowance) GetSignBytes() []byte

GetSignBytes implements the LegacyMsg.GetSignBytes method.

func (MsgGrantAllowance) GetSigners

func (msg MsgGrantAllowance) GetSigners() []sdk.AccAddress

GetSigners gets the granter account associated with an allowance

func (*MsgGrantAllowance) Marshal

func (m *MsgGrantAllowance) Marshal() (dAtA []byte, err error)

func (*MsgGrantAllowance) MarshalTo

func (m *MsgGrantAllowance) MarshalTo(dAtA []byte) (int, error)

func (*MsgGrantAllowance) MarshalToSizedBuffer

func (m *MsgGrantAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*MsgGrantAllowance) ProtoMessage

func (*MsgGrantAllowance) ProtoMessage()

func (*MsgGrantAllowance) Reset

func (m *MsgGrantAllowance) Reset()

func (MsgGrantAllowance) Route

func (msg MsgGrantAllowance) Route() string

Route implements the LegacyMsg.Route method.

func (*MsgGrantAllowance) Size

func (m *MsgGrantAllowance) Size() (n int)

func (*MsgGrantAllowance) String

func (m *MsgGrantAllowance) String() string

func (MsgGrantAllowance) Type

func (msg MsgGrantAllowance) Type() string

Type implements the LegacyMsg.Type method.

func (*MsgGrantAllowance) Unmarshal

func (m *MsgGrantAllowance) Unmarshal(dAtA []byte) error

func (MsgGrantAllowance) UnpackInterfaces

func (msg MsgGrantAllowance) UnpackInterfaces(unpacker types.AnyUnpacker) error

UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces

func (MsgGrantAllowance) ValidateBasic

func (msg MsgGrantAllowance) ValidateBasic() error

ValidateBasic implements the sdk.Msg interface.

func (*MsgGrantAllowance) XXX_DiscardUnknown

func (m *MsgGrantAllowance) XXX_DiscardUnknown()

func (*MsgGrantAllowance) XXX_Marshal

func (m *MsgGrantAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*MsgGrantAllowance) XXX_Merge

func (m *MsgGrantAllowance) XXX_Merge(src proto.Message)

func (*MsgGrantAllowance) XXX_Size

func (m *MsgGrantAllowance) XXX_Size() int

func (*MsgGrantAllowance) XXX_Unmarshal

func (m *MsgGrantAllowance) XXX_Unmarshal(b []byte) error

type MsgGrantAllowanceResponse

type MsgGrantAllowanceResponse struct {
}

MsgGrantAllowanceResponse defines the Msg/GrantAllowanceResponse response type.

func (*MsgGrantAllowanceResponse) Descriptor

func (*MsgGrantAllowanceResponse) Descriptor() ([]byte, []int)

func (*MsgGrantAllowanceResponse) Marshal

func (m *MsgGrantAllowanceResponse) Marshal() (dAtA []byte, err error)

func (*MsgGrantAllowanceResponse) MarshalTo

func (m *MsgGrantAllowanceResponse) MarshalTo(dAtA []byte) (int, error)

func (*MsgGrantAllowanceResponse) MarshalToSizedBuffer

func (m *MsgGrantAllowanceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*MsgGrantAllowanceResponse) ProtoMessage

func (*MsgGrantAllowanceResponse) ProtoMessage()

func (*MsgGrantAllowanceResponse) Reset

func (m *MsgGrantAllowanceResponse) Reset()

func (*MsgGrantAllowanceResponse) Size

func (m *MsgGrantAllowanceResponse) Size() (n int)

func (*MsgGrantAllowanceResponse) String

func (m *MsgGrantAllowanceResponse) String() string

func (*MsgGrantAllowanceResponse) Unmarshal

func (m *MsgGrantAllowanceResponse) Unmarshal(dAtA []byte) error

func (*MsgGrantAllowanceResponse) XXX_DiscardUnknown

func (m *MsgGrantAllowanceResponse) XXX_DiscardUnknown()

func (*MsgGrantAllowanceResponse) XXX_Marshal

func (m *MsgGrantAllowanceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*MsgGrantAllowanceResponse) XXX_Merge

func (m *MsgGrantAllowanceResponse) XXX_Merge(src proto.Message)

func (*MsgGrantAllowanceResponse) XXX_Size

func (m *MsgGrantAllowanceResponse) XXX_Size() int

func (*MsgGrantAllowanceResponse) XXX_Unmarshal

func (m *MsgGrantAllowanceResponse) XXX_Unmarshal(b []byte) error

type MsgRevokeAllowance

type MsgRevokeAllowance struct {
	// granter is the address of the user granting an allowance of their funds.
	Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"`
	// grantee is the address of the user being granted an allowance of another user's funds.
	Grantee string `protobuf:"bytes,2,opt,name=grantee,proto3" json:"grantee,omitempty"`
}

MsgRevokeAllowance removes any existing Allowance from Granter to Grantee.

func NewMsgRevokeAllowance

func NewMsgRevokeAllowance(granter sdk.AccAddress, grantee sdk.AccAddress) MsgRevokeAllowance

NewMsgRevokeAllowance returns a message to revoke a fee allowance for a given granter and grantee

func (*MsgRevokeAllowance) Descriptor

func (*MsgRevokeAllowance) Descriptor() ([]byte, []int)

func (*MsgRevokeAllowance) GetGrantee

func (m *MsgRevokeAllowance) GetGrantee() string

func (*MsgRevokeAllowance) GetGranter

func (m *MsgRevokeAllowance) GetGranter() string

func (MsgRevokeAllowance) GetSignBytes

func (msg MsgRevokeAllowance) GetSignBytes() []byte

GetSignBytes implements the LegacyMsg.GetSignBytes method.

func (MsgRevokeAllowance) GetSigners

func (msg MsgRevokeAllowance) GetSigners() []sdk.AccAddress

GetSigners gets the granter address associated with an Allowance to revoke.

func (*MsgRevokeAllowance) Marshal

func (m *MsgRevokeAllowance) Marshal() (dAtA []byte, err error)

func (*MsgRevokeAllowance) MarshalTo

func (m *MsgRevokeAllowance) MarshalTo(dAtA []byte) (int, error)

func (*MsgRevokeAllowance) MarshalToSizedBuffer

func (m *MsgRevokeAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*MsgRevokeAllowance) ProtoMessage

func (*MsgRevokeAllowance) ProtoMessage()

func (*MsgRevokeAllowance) Reset

func (m *MsgRevokeAllowance) Reset()

func (MsgRevokeAllowance) Route

func (msg MsgRevokeAllowance) Route() string

Route implements the LegacyMsg.Route method.

func (*MsgRevokeAllowance) Size

func (m *MsgRevokeAllowance) Size() (n int)

func (*MsgRevokeAllowance) String

func (m *MsgRevokeAllowance) String() string

func (MsgRevokeAllowance) Type

func (msg MsgRevokeAllowance) Type() string

Type implements the LegacyMsg.Type method.

func (*MsgRevokeAllowance) Unmarshal

func (m *MsgRevokeAllowance) Unmarshal(dAtA []byte) error

func (MsgRevokeAllowance) ValidateBasic

func (msg MsgRevokeAllowance) ValidateBasic() error

ValidateBasic implements the sdk.Msg interface.

func (*MsgRevokeAllowance) XXX_DiscardUnknown

func (m *MsgRevokeAllowance) XXX_DiscardUnknown()

func (*MsgRevokeAllowance) XXX_Marshal

func (m *MsgRevokeAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*MsgRevokeAllowance) XXX_Merge

func (m *MsgRevokeAllowance) XXX_Merge(src proto.Message)

func (*MsgRevokeAllowance) XXX_Size

func (m *MsgRevokeAllowance) XXX_Size() int

func (*MsgRevokeAllowance) XXX_Unmarshal

func (m *MsgRevokeAllowance) XXX_Unmarshal(b []byte) error

type MsgRevokeAllowanceResponse

type MsgRevokeAllowanceResponse struct {
}

MsgRevokeAllowanceResponse defines the Msg/RevokeAllowanceResponse response type.

func (*MsgRevokeAllowanceResponse) Descriptor

func (*MsgRevokeAllowanceResponse) Descriptor() ([]byte, []int)

func (*MsgRevokeAllowanceResponse) Marshal

func (m *MsgRevokeAllowanceResponse) Marshal() (dAtA []byte, err error)

func (*MsgRevokeAllowanceResponse) MarshalTo

func (m *MsgRevokeAllowanceResponse) MarshalTo(dAtA []byte) (int, error)

func (*MsgRevokeAllowanceResponse) MarshalToSizedBuffer

func (m *MsgRevokeAllowanceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*MsgRevokeAllowanceResponse) ProtoMessage

func (*MsgRevokeAllowanceResponse) ProtoMessage()

func (*MsgRevokeAllowanceResponse) Reset

func (m *MsgRevokeAllowanceResponse) Reset()

func (*MsgRevokeAllowanceResponse) Size

func (m *MsgRevokeAllowanceResponse) Size() (n int)

func (*MsgRevokeAllowanceResponse) String

func (m *MsgRevokeAllowanceResponse) String() string

func (*MsgRevokeAllowanceResponse) Unmarshal

func (m *MsgRevokeAllowanceResponse) Unmarshal(dAtA []byte) error

func (*MsgRevokeAllowanceResponse) XXX_DiscardUnknown

func (m *MsgRevokeAllowanceResponse) XXX_DiscardUnknown()

func (*MsgRevokeAllowanceResponse) XXX_Marshal

func (m *MsgRevokeAllowanceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*MsgRevokeAllowanceResponse) XXX_Merge

func (m *MsgRevokeAllowanceResponse) XXX_Merge(src proto.Message)

func (*MsgRevokeAllowanceResponse) XXX_Size

func (m *MsgRevokeAllowanceResponse) XXX_Size() int

func (*MsgRevokeAllowanceResponse) XXX_Unmarshal

func (m *MsgRevokeAllowanceResponse) XXX_Unmarshal(b []byte) error

type MsgServer

type MsgServer interface {
	// GrantAllowance grants fee allowance to the grantee on the granter's
	// account with the provided expiration time.
	GrantAllowance(context.Context, *MsgGrantAllowance) (*MsgGrantAllowanceResponse, error)
	// RevokeAllowance revokes any fee allowance of granter's account that
	// has been granted to the grantee.
	RevokeAllowance(context.Context, *MsgRevokeAllowance) (*MsgRevokeAllowanceResponse, error)
}

MsgServer is the server API for Msg service.

type PeriodicAllowance

type PeriodicAllowance struct {
	// basic specifies a struct of `BasicAllowance`
	Basic BasicAllowance `protobuf:"bytes,1,opt,name=basic,proto3" json:"basic"`
	// period specifies the time duration in which period_spend_limit coins can
	// be spent before that allowance is reset
	Period time.Duration `protobuf:"bytes,2,opt,name=period,proto3,stdduration" json:"period"`
	// period_spend_limit specifies the maximum number of coins that can be spent
	// in the period
	PeriodSpendLimit github_com_cosmos_cosmos_sdk_types.Coins `` /* 156-byte string literal not displayed */
	// period_can_spend is the number of coins left to be spent before the period_reset time
	PeriodCanSpend github_com_cosmos_cosmos_sdk_types.Coins `` /* 150-byte string literal not displayed */
	// period_reset is the time at which this period resets and a new one begins,
	// it is calculated from the start time of the first transaction after the
	// last period ended
	PeriodReset time.Time `protobuf:"bytes,5,opt,name=period_reset,json=periodReset,proto3,stdtime" json:"period_reset"`
}

PeriodicAllowance extends Allowance to allow for both a maximum cap, as well as a limit per time period.

func (*PeriodicAllowance) Accept

func (a *PeriodicAllowance) Accept(ctx sdk.Context, fee sdk.Coins, _ []sdk.Msg) (bool, error)

Accept can use fee payment requested as well as timestamp of the current block to determine whether or not to process this. This is checked in Keeper.UseGrantedFees and the return values should match how it is handled there.

If it returns an error, the fee payment is rejected, otherwise it is accepted. The FeeAllowance implementation is expected to update it's internal state and will be saved again after an acceptance.

If remove is true (regardless of the error), the FeeAllowance will be deleted from storage (eg. when it is used up). (See call to RevokeAllowance in Keeper.UseGrantedFees)

func (*PeriodicAllowance) Descriptor

func (*PeriodicAllowance) Descriptor() ([]byte, []int)

func (*PeriodicAllowance) GetBasic

func (m *PeriodicAllowance) GetBasic() BasicAllowance

func (*PeriodicAllowance) GetPeriod

func (m *PeriodicAllowance) GetPeriod() time.Duration

func (*PeriodicAllowance) GetPeriodCanSpend

func (*PeriodicAllowance) GetPeriodReset

func (m *PeriodicAllowance) GetPeriodReset() time.Time

func (*PeriodicAllowance) GetPeriodSpendLimit

func (*PeriodicAllowance) Marshal

func (m *PeriodicAllowance) Marshal() (dAtA []byte, err error)

func (*PeriodicAllowance) MarshalTo

func (m *PeriodicAllowance) MarshalTo(dAtA []byte) (int, error)

func (*PeriodicAllowance) MarshalToSizedBuffer

func (m *PeriodicAllowance) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*PeriodicAllowance) ProtoMessage

func (*PeriodicAllowance) ProtoMessage()

func (*PeriodicAllowance) Reset

func (m *PeriodicAllowance) Reset()

func (*PeriodicAllowance) Size

func (m *PeriodicAllowance) Size() (n int)

func (*PeriodicAllowance) String

func (m *PeriodicAllowance) String() string

func (*PeriodicAllowance) Unmarshal

func (m *PeriodicAllowance) Unmarshal(dAtA []byte) error

func (PeriodicAllowance) ValidateBasic

func (a PeriodicAllowance) ValidateBasic() error

ValidateBasic implements FeeAllowance and enforces basic sanity checks

func (*PeriodicAllowance) XXX_DiscardUnknown

func (m *PeriodicAllowance) XXX_DiscardUnknown()

func (*PeriodicAllowance) XXX_Marshal

func (m *PeriodicAllowance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PeriodicAllowance) XXX_Merge

func (m *PeriodicAllowance) XXX_Merge(src proto.Message)

func (*PeriodicAllowance) XXX_Size

func (m *PeriodicAllowance) XXX_Size() int

func (*PeriodicAllowance) XXX_Unmarshal

func (m *PeriodicAllowance) XXX_Unmarshal(b []byte) error

type QueryAllowanceRequest

type QueryAllowanceRequest struct {
	// granter is the address of the user granting an allowance of their funds.
	Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"`
	// grantee is the address of the user being granted an allowance of another user's funds.
	Grantee string `protobuf:"bytes,2,opt,name=grantee,proto3" json:"grantee,omitempty"`
}

QueryAllowanceRequest is the request type for the Query/Allowance RPC method.

func (*QueryAllowanceRequest) Descriptor

func (*QueryAllowanceRequest) Descriptor() ([]byte, []int)

func (*QueryAllowanceRequest) GetGrantee

func (m *QueryAllowanceRequest) GetGrantee() string

func (*QueryAllowanceRequest) GetGranter

func (m *QueryAllowanceRequest) GetGranter() string

func (*QueryAllowanceRequest) Marshal

func (m *QueryAllowanceRequest) Marshal() (dAtA []byte, err error)

func (*QueryAllowanceRequest) MarshalTo

func (m *QueryAllowanceRequest) MarshalTo(dAtA []byte) (int, error)

func (*QueryAllowanceRequest) MarshalToSizedBuffer

func (m *QueryAllowanceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryAllowanceRequest) ProtoMessage

func (*QueryAllowanceRequest) ProtoMessage()

func (*QueryAllowanceRequest) Reset

func (m *QueryAllowanceRequest) Reset()

func (*QueryAllowanceRequest) Size

func (m *QueryAllowanceRequest) Size() (n int)

func (*QueryAllowanceRequest) String

func (m *QueryAllowanceRequest) String() string

func (*QueryAllowanceRequest) Unmarshal

func (m *QueryAllowanceRequest) Unmarshal(dAtA []byte) error

func (*QueryAllowanceRequest) XXX_DiscardUnknown

func (m *QueryAllowanceRequest) XXX_DiscardUnknown()

func (*QueryAllowanceRequest) XXX_Marshal

func (m *QueryAllowanceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryAllowanceRequest) XXX_Merge

func (m *QueryAllowanceRequest) XXX_Merge(src proto.Message)

func (*QueryAllowanceRequest) XXX_Size

func (m *QueryAllowanceRequest) XXX_Size() int

func (*QueryAllowanceRequest) XXX_Unmarshal

func (m *QueryAllowanceRequest) XXX_Unmarshal(b []byte) error

type QueryAllowanceResponse

type QueryAllowanceResponse struct {
	// allowance is a allowance granted for grantee by granter.
	Allowance *Grant `protobuf:"bytes,1,opt,name=allowance,proto3" json:"allowance,omitempty"`
}

QueryAllowanceResponse is the response type for the Query/Allowance RPC method.

func (*QueryAllowanceResponse) Descriptor

func (*QueryAllowanceResponse) Descriptor() ([]byte, []int)

func (*QueryAllowanceResponse) GetAllowance

func (m *QueryAllowanceResponse) GetAllowance() *Grant

func (*QueryAllowanceResponse) Marshal

func (m *QueryAllowanceResponse) Marshal() (dAtA []byte, err error)

func (*QueryAllowanceResponse) MarshalTo

func (m *QueryAllowanceResponse) MarshalTo(dAtA []byte) (int, error)

func (*QueryAllowanceResponse) MarshalToSizedBuffer

func (m *QueryAllowanceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryAllowanceResponse) ProtoMessage

func (*QueryAllowanceResponse) ProtoMessage()

func (*QueryAllowanceResponse) Reset

func (m *QueryAllowanceResponse) Reset()

func (*QueryAllowanceResponse) Size

func (m *QueryAllowanceResponse) Size() (n int)

func (*QueryAllowanceResponse) String

func (m *QueryAllowanceResponse) String() string

func (*QueryAllowanceResponse) Unmarshal

func (m *QueryAllowanceResponse) Unmarshal(dAtA []byte) error

func (*QueryAllowanceResponse) XXX_DiscardUnknown

func (m *QueryAllowanceResponse) XXX_DiscardUnknown()

func (*QueryAllowanceResponse) XXX_Marshal

func (m *QueryAllowanceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryAllowanceResponse) XXX_Merge

func (m *QueryAllowanceResponse) XXX_Merge(src proto.Message)

func (*QueryAllowanceResponse) XXX_Size

func (m *QueryAllowanceResponse) XXX_Size() int

func (*QueryAllowanceResponse) XXX_Unmarshal

func (m *QueryAllowanceResponse) XXX_Unmarshal(b []byte) error

type QueryAllowancesRequest

type QueryAllowancesRequest struct {
	Grantee string `protobuf:"bytes,1,opt,name=grantee,proto3" json:"grantee,omitempty"`
	// pagination defines an pagination for the request.
	Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
}

QueryAllowancesRequest is the request type for the Query/Allowances RPC method.

func (*QueryAllowancesRequest) Descriptor

func (*QueryAllowancesRequest) Descriptor() ([]byte, []int)

func (*QueryAllowancesRequest) GetGrantee

func (m *QueryAllowancesRequest) GetGrantee() string

func (*QueryAllowancesRequest) GetPagination

func (m *QueryAllowancesRequest) GetPagination() *query.PageRequest

func (*QueryAllowancesRequest) Marshal

func (m *QueryAllowancesRequest) Marshal() (dAtA []byte, err error)

func (*QueryAllowancesRequest) MarshalTo

func (m *QueryAllowancesRequest) MarshalTo(dAtA []byte) (int, error)

func (*QueryAllowancesRequest) MarshalToSizedBuffer

func (m *QueryAllowancesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryAllowancesRequest) ProtoMessage

func (*QueryAllowancesRequest) ProtoMessage()

func (*QueryAllowancesRequest) Reset

func (m *QueryAllowancesRequest) Reset()

func (*QueryAllowancesRequest) Size

func (m *QueryAllowancesRequest) Size() (n int)

func (*QueryAllowancesRequest) String

func (m *QueryAllowancesRequest) String() string

func (*QueryAllowancesRequest) Unmarshal

func (m *QueryAllowancesRequest) Unmarshal(dAtA []byte) error

func (*QueryAllowancesRequest) XXX_DiscardUnknown

func (m *QueryAllowancesRequest) XXX_DiscardUnknown()

func (*QueryAllowancesRequest) XXX_Marshal

func (m *QueryAllowancesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryAllowancesRequest) XXX_Merge

func (m *QueryAllowancesRequest) XXX_Merge(src proto.Message)

func (*QueryAllowancesRequest) XXX_Size

func (m *QueryAllowancesRequest) XXX_Size() int

func (*QueryAllowancesRequest) XXX_Unmarshal

func (m *QueryAllowancesRequest) XXX_Unmarshal(b []byte) error

type QueryAllowancesResponse

type QueryAllowancesResponse struct {
	// allowances are allowance's granted for grantee by granter.
	Allowances []*Grant `protobuf:"bytes,1,rep,name=allowances,proto3" json:"allowances,omitempty"`
	// pagination defines an pagination for the response.
	Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
}

QueryAllowancesResponse is the response type for the Query/Allowances RPC method.

func (*QueryAllowancesResponse) Descriptor

func (*QueryAllowancesResponse) Descriptor() ([]byte, []int)

func (*QueryAllowancesResponse) GetAllowances

func (m *QueryAllowancesResponse) GetAllowances() []*Grant

func (*QueryAllowancesResponse) GetPagination

func (m *QueryAllowancesResponse) GetPagination() *query.PageResponse

func (*QueryAllowancesResponse) Marshal

func (m *QueryAllowancesResponse) Marshal() (dAtA []byte, err error)

func (*QueryAllowancesResponse) MarshalTo

func (m *QueryAllowancesResponse) MarshalTo(dAtA []byte) (int, error)

func (*QueryAllowancesResponse) MarshalToSizedBuffer

func (m *QueryAllowancesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryAllowancesResponse) ProtoMessage

func (*QueryAllowancesResponse) ProtoMessage()

func (*QueryAllowancesResponse) Reset

func (m *QueryAllowancesResponse) Reset()

func (*QueryAllowancesResponse) Size

func (m *QueryAllowancesResponse) Size() (n int)

func (*QueryAllowancesResponse) String

func (m *QueryAllowancesResponse) String() string

func (*QueryAllowancesResponse) Unmarshal

func (m *QueryAllowancesResponse) Unmarshal(dAtA []byte) error

func (*QueryAllowancesResponse) XXX_DiscardUnknown

func (m *QueryAllowancesResponse) XXX_DiscardUnknown()

func (*QueryAllowancesResponse) XXX_Marshal

func (m *QueryAllowancesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryAllowancesResponse) XXX_Merge

func (m *QueryAllowancesResponse) XXX_Merge(src proto.Message)

func (*QueryAllowancesResponse) XXX_Size

func (m *QueryAllowancesResponse) XXX_Size() int

func (*QueryAllowancesResponse) XXX_Unmarshal

func (m *QueryAllowancesResponse) XXX_Unmarshal(b []byte) error

type QueryClient

type QueryClient interface {
	// Allowance returns fee granted to the grantee by the granter.
	Allowance(ctx context.Context, in *QueryAllowanceRequest, opts ...grpc.CallOption) (*QueryAllowanceResponse, error)
	// Allowances returns all the grants for address.
	Allowances(ctx context.Context, in *QueryAllowancesRequest, opts ...grpc.CallOption) (*QueryAllowancesResponse, error)
}

QueryClient is the client API for Query service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewQueryClient

func NewQueryClient(cc grpc1.ClientConn) QueryClient

type QueryServer

type QueryServer interface {
	// Allowance returns fee granted to the grantee by the granter.
	Allowance(context.Context, *QueryAllowanceRequest) (*QueryAllowanceResponse, error)
	// Allowances returns all the grants for address.
	Allowances(context.Context, *QueryAllowancesRequest) (*QueryAllowancesResponse, error)
}

QueryServer is the server API for Query service.

type UnimplementedMsgServer

type UnimplementedMsgServer struct {
}

UnimplementedMsgServer can be embedded to have forward compatible implementations.

func (*UnimplementedMsgServer) GrantAllowance

func (*UnimplementedMsgServer) RevokeAllowance

type UnimplementedQueryServer

type UnimplementedQueryServer struct {
}

UnimplementedQueryServer can be embedded to have forward compatible implementations.

func (*UnimplementedQueryServer) Allowance

func (*UnimplementedQueryServer) Allowances

Directories

Path Synopsis
client
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL