github.com/MetalBlockchain/subnet-evm@v0.4.9/precompile/allow_list_role.go (about)

     1  // (c) 2019-2020, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package precompile
     5  
     6  import "github.com/ethereum/go-ethereum/common"
     7  
     8  // Enum constants for valid AllowListRole
     9  type AllowListRole common.Hash
    10  
    11  // Valid returns true iff [s] represents a valid role.
    12  func (s AllowListRole) Valid() bool {
    13  	switch s {
    14  	case AllowListNoRole, AllowListEnabled, AllowListAdmin:
    15  		return true
    16  	default:
    17  		return false
    18  	}
    19  }
    20  
    21  // IsNoRole returns true if [s] indicates no specific role.
    22  func (s AllowListRole) IsNoRole() bool {
    23  	switch s {
    24  	case AllowListNoRole:
    25  		return true
    26  	default:
    27  		return false
    28  	}
    29  }
    30  
    31  // IsAdmin returns true if [s] indicates the permission to modify the allow list.
    32  func (s AllowListRole) IsAdmin() bool {
    33  	switch s {
    34  	case AllowListAdmin:
    35  		return true
    36  	default:
    37  		return false
    38  	}
    39  }
    40  
    41  // IsEnabled returns true if [s] indicates that it has permission to access the resource.
    42  func (s AllowListRole) IsEnabled() bool {
    43  	switch s {
    44  	case AllowListAdmin, AllowListEnabled:
    45  		return true
    46  	default:
    47  		return false
    48  	}
    49  }