Documentation
¶
Index ¶
- Constants
- type DatabaseWalletAllowLister
- func (d *DatabaseWalletAllowLister) Allow(ctx context.Context, walletAddress string) error
- func (d *DatabaseWalletAllowLister) Apply(ctx context.Context, walletAddress string, permission Permission) error
- func (d *DatabaseWalletAllowLister) Deny(ctx context.Context, walletAddress string) error
- func (d *DatabaseWalletAllowLister) GetPermissions(walletAddress string) Permission
- func (d *DatabaseWalletAllowLister) IsAllowListed(walletAddress string) bool
- func (d *DatabaseWalletAllowLister) IsDenyListed(walletAddress string) bool
- func (d *DatabaseWalletAllowLister) Start(ctx context.Context) error
- func (d *DatabaseWalletAllowLister) Stop()
- type Permission
- type WalletAddress
- type WalletAllowLister
Constants ¶
View Source
const REFRESH_INTERVAL_SECONDS = 5
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DatabaseWalletAllowLister ¶
type DatabaseWalletAllowLister struct {
// contains filtered or unexported fields
}
DatabaseWalletAllowLister implements database backed allow list.
func NewDatabaseWalletAllowLister ¶
func NewDatabaseWalletAllowLister(db *bun.DB, log *zap.Logger) *DatabaseWalletAllowLister
func (*DatabaseWalletAllowLister) Allow ¶
func (d *DatabaseWalletAllowLister) Allow(ctx context.Context, walletAddress string) error
Add an address to the allow list.
func (*DatabaseWalletAllowLister) Apply ¶
func (d *DatabaseWalletAllowLister) Apply(ctx context.Context, walletAddress string, permission Permission) error
func (*DatabaseWalletAllowLister) Deny ¶
func (d *DatabaseWalletAllowLister) Deny(ctx context.Context, walletAddress string) error
Add an address to the deny list.
func (*DatabaseWalletAllowLister) GetPermissions ¶
func (d *DatabaseWalletAllowLister) GetPermissions(walletAddress string) Permission
Get the permissions for a wallet address
func (*DatabaseWalletAllowLister) IsAllowListed ¶
func (d *DatabaseWalletAllowLister) IsAllowListed(walletAddress string) bool
Check if the wallet address is explicitly allow listed
func (*DatabaseWalletAllowLister) IsDenyListed ¶
func (d *DatabaseWalletAllowLister) IsDenyListed(walletAddress string) bool
Check if the wallet address is explicitly deny listed
func (*DatabaseWalletAllowLister) Start ¶
func (d *DatabaseWalletAllowLister) Start(ctx context.Context) error
Load the permissions and start listening
func (*DatabaseWalletAllowLister) Stop ¶
func (d *DatabaseWalletAllowLister) Stop()
type Permission ¶
type Permission int64
const ( Allowed Permission = 0 Denied Permission = 1 Unspecified Permission = 2 )
func (Permission) String ¶
func (p Permission) String() string
Add a string function to use for logging
type WalletAddress ¶
type WalletAddress struct { bun.BaseModel `bun:"table:authz_addresses"` ID int64 `bun:",pk,autoincrement"` WalletAddress string `bun:"wallet_address,notnull"` CreatedAt time.Time `bun:"created_at"` DeletedAt *time.Time `bun:"deleted_at"` Permission string `bun:"permission"` Comment string `bun:"comment"` }
type WalletAllowLister ¶
type WalletAllowLister interface { Start(ctx context.Context) error Stop() IsAllowListed(walletAddress string) bool IsDenyListed(walletAddress string) bool GetPermissions(walletAddress string) Permission Deny(ctx context.Context, WalletAddress string) error Allow(ctx context.Context, WalletAddress string) error }
WalletAllowLister maintains an allow list for wallets.
Click to show internal directories.
Click to hide internal directories.