action_gateway

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionGateConfig

type ActionGateConfig struct {
	FreeActionsAllowance uint64 `yaml:"free_actions_allowance"`
	IncreasePerLevel     uint64 `yaml:"increase_per_level"`
}

type ActionGateway

type ActionGateway struct {
	// contains filtered or unexported fields
}

func NewActionGateway

func NewActionGateway(cfg ActionLimitConfig) (*ActionGateway, error)

func NewActionGatewayFromYaml

func NewActionGatewayFromYaml(configDirPath string) (*ActionGateway, error)

func (*ActionGateway) AllowAction

func (a *ActionGateway) AllowAction(tx Store, userAddress string, gatedAction core.GatedAction) error

func (*ActionGateway) AllowAppRegistration

func (v *ActionGateway) AllowAppRegistration(tx Store, userAddress string) error

func (*ActionGateway) GetUserAllowances

func (a *ActionGateway) GetUserAllowances(tx Store, userAddress string) ([]core.ActionAllowance, error)

GetUserAllowances returns user allowance for every gated action.

type ActionLimitConfig

type ActionLimitConfig struct {
	LevelStepTokens decimal.Decimal                       `yaml:"level_step_tokens"`
	AppCost         decimal.Decimal                       `yaml:"app_cost"`
	ActionGates     map[core.GatedAction]ActionGateConfig `yaml:"action_gates"`
}

type Store

type Store interface {
	// GetAppCount returns the total number of applications owned by a specific wallet.
	GetAppCount(ownerWallet string) (uint64, error)

	// GetTotalUserStaked returns the total staked amount for a user across all blockchains.
	GetTotalUserStaked(wallet string) (decimal.Decimal, error)

	// RecordAction inserts a new action log entry for a user.
	RecordAction(wallet string, gatedAction core.GatedAction) error

	// GetUserActionCount returns the number of actions matching the given wallet and gated action
	// within the specified time window (counting backwards from now).
	GetUserActionCount(wallet string, gatedAction core.GatedAction, window time.Duration) (uint64, error)

	// GetUserActionCounts returns a map of gated actions to their respective counts for a user within the specified time window.
	GetUserActionCounts(userWallet string, window time.Duration) (map[core.GatedAction]uint64, error)
}

Jump to

Keyboard shortcuts

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