rbac

package
v0.0.1-test-release Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultAdminRole = 0x00

	ErrorAccessControlUnauthorizedAccount = 90
	ErrorAccessControlBadConfirmation     = 91
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	// Roles mapping
	Roles *cell.Dictionary `tlb:"dict 32"` // map<uint32, RoleData>
}

AccessControl data struct, auto-serialized to/from cell.

type GrantRole

type GrantRole struct {

	// Query ID of the change request.
	QueryID uint64 `tlb:"## 64"`

	Role    *big.Int         `tlb:"## 256"` // Role definition.
	Account *address.Address `tlb:"addr"`   // New account to add.
	// contains filtered or unexported fields
}

@dev Grants `role` to `account`.

If `account` had not been already granted `role`, emits a {AccessControl_RoleGranted} event.

Requirements:

- the caller must have `role`'s admin role.

May emit a {AccessControl_RoleGranted} event.

type RenounceRole

type RenounceRole struct {

	// Query ID of the change request.
	QueryID uint64 `tlb:"## 64"`

	Role               *big.Int         `tlb:"## 256"` // Role definition.
	CallerConfirmation *address.Address `tlb:"addr"`   // Account to revoke.
	// contains filtered or unexported fields
}

@dev Revokes `role` from the calling account.

Roles are often managed via {AccessControl_GrantRole} and {AccessControl_RevokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced).

If `account` had been granted `role`, emits a {AccessControl_RoleRevoked} event.

Requirements:

- the caller must be `callerConfirmation`.

May emit a {AccessControl_RoleRevoked} event.

type RevokeRole

type RevokeRole struct {

	// Query ID of the change request.
	QueryID uint64 `tlb:"## 64"`

	Role    *big.Int         `tlb:"## 256"` // Role definition.
	Account *address.Address `tlb:"addr"`   // Account to revoke.
	// contains filtered or unexported fields
}

@dev Revokes `role` from `account`.

If `account` had been granted `role`, emits a {AccessControl_RoleRevoked} event.

Requirements:

- the caller must have `role`'s admin role.

May emit a {AccessControl_RoleRevoked} event.

type RoleAdminChanged

type RoleAdminChanged struct {

	// Query ID of the change request.
	QueryID uint64 `tlb:"## 64"`

	Role              *big.Int `tlb:"## 256"` // Role definition.
	PreviousAdminRole *big.Int `tlb:"## 256"` // Previous admin role of the specific role.
	NewAdminRole      *big.Int `tlb:"## 256"` // New admin role of the specific role.
	// contains filtered or unexported fields
}

@dev Emitted when `newAdminRole` is set as “role“'s admin role, replacing `previousAdminRole`

`DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {AccessControl_RoleAdminChanged} not being emitted to signal this.

type RoleData

type RoleData struct {
	AdminRole *big.Int `tlb:"## 256"`
	// Number of members in the role
	MembersLen uint64 `tlb:"## 64"`
	// Members of the role, indexed by their address hash.
	HasRole *cell.Dictionary `tlb:"dict 267"` // map<address, slice>
}

Internal storage struct for role data

Each role has a mapping of accounts that have been granted that role, and an admin role that can manage that role.

type RoleGranted

type RoleGranted struct {

	// Query ID of the change request.
	QueryID uint64 `tlb:"## 64"`

	Role    *big.Int         `tlb:"## 256"` // Role definition.
	Account *address.Address `tlb:"addr"`   // New account added.
	Sender  *address.Address `tlb:"addr"`   // Account that requested the change.
	// contains filtered or unexported fields
}

@dev Emitted when `account` is granted `role`.

`sender` is the account that originated the contract call. This account bears the admin role (for the granted role). Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.

type RoleRevoked

type RoleRevoked struct {

	// Query ID of the change request.
	QueryID uint64 `tlb:"## 64"`

	Role    *big.Int         `tlb:"## 256"` // Role definition.
	Account *address.Address `tlb:"addr"`   // Account revoked.
	Sender  *address.Address `tlb:"addr"`   // Account that requested the change.
	// contains filtered or unexported fields
}

@dev Emitted when `account` is revoked `role`.

`sender` is the account that originated the contract call:

  • if using `revokeRole`, it is the admin role bearer

- if using `renounceRole`, it is the role bearer (i.e. `account`)

Jump to

Keyboard shortcuts

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