ObjectAuthorization

Git Source

Inherits: IObjectAuthorization, OmniRegistryErrors, Initializable

Manages directional authorization rules for object relations. Grants define who can initiate a relation (from or to) based on various criteria, such as ownership, token holding, delegation, or external contract verification.

State Variables

OBJECTAUTHORIZATION_STORAGE_LOCATION

Deterministic storage slot per ERC-7201

bytes32 private constant OBJECTAUTHORIZATION_STORAGE_LOCATION =
    0x66533e6d1966c5548931afa2a923bcafa00e1e6794f41ca0f03bbc3ab865ab00;

Functions

_getObjectAuthorizationStorage

function _getObjectAuthorizationStorage() private pure returns (ObjectAuthorizationStorage storage $);

__ObjectAuthorization_init

function __ObjectAuthorization_init() internal onlyInitializing;

grantFrom

Issues a grant to allow initiating relations from a tail object

function grantFrom(uint128 tail, RelationGrant memory grant) external;

Parameters

NameTypeDescription
tailuint128Tail object ID
grantRelationGrantGrant details

revokeFrom

Revokes a previously issued from grant

function revokeFrom(uint128 tail, uint32 grantId) external;

Parameters

NameTypeDescription
tailuint128Tail object ID
grantIduint32Grant ID to revoke

grantTo

Issues a grant to allow accepting relations to a head object

function grantTo(uint128 head, RelationGrant memory grant) external;

Parameters

NameTypeDescription
headuint128Head object ID
grantRelationGrantGrant details

revokeTo

Revokes a previously issued to grant

function revokeTo(uint128 head, uint32 grantId) external;

Parameters

NameTypeDescription
headuint128Head object ID
grantIduint32Grant ID to revoke

allowFrom

Checks whether a sender is authorized to initiate a relation from a tail object

function allowFrom(uint32 grantId, address sender, uint128 tail, uint64 rel, uint64 headKind, uint64 headSet)
    external
    view
    returns (bool allow);

Parameters

NameTypeDescription
grantIduint32Grant ID to check
senderaddressAddress attempting the action
tailuint128Tail object ID
reluint64Relation ID
headKinduint64Kind ID of the target (head) object
headSetuint64Set ID of the target (head) object

Returns

NameTypeDescription
allowboolallowed True if authorized

allowTo

Checks whether a sender is authorized to accept a relation to a head object

function allowTo(uint32 grantId, address sender, uint128 head, uint64 rel, uint64 tailKind, uint64 tailSet)
    external
    view
    returns (bool);

Parameters

NameTypeDescription
grantIduint32Grant ID to check
senderaddressAddress attempting the action
headuint128Head object ID
reluint64Relation ID
tailKinduint64Kind ID of the source (tail) object
tailSetuint64Set ID of the source (tail) object

Returns

NameTypeDescription
<none>boolallowed True if authorized

_objectInfo

function _objectInfo(uint64 set, uint64 id)
    internal
    view
    virtual
    returns (Descriptor memory meta, address setContract, address owner);

_objectInfo

function _objectInfo(uint128 sid)
    private
    view
    returns (uint64 id, Descriptor memory meta, address setContract, address owner);

_validateHolder

function _validateHolder(address holder, bytes32 holding) internal view virtual returns (bool);

_validateGrantSpec

function _validateGrantSpec(RelationGrant memory grant) private view;

_validateGrant

function _validateGrant(RelationGrant memory grant, address sender, uint128 sid, uint64 rel, uint64 kind, uint64 set)
    private
    view
    returns (bool);

_grantKey

function _grantKey(uint8 direction, uint128 sid, uint32 grantId) private pure returns (uint256);

_pointerKey

function _pointerKey(uint8 direction, uint128 sid) private pure returns (uint256);

Structs

GrantPointer

struct GrantPointer {
    uint32 lastId;
    uint32 minValidId;
}

ObjectAuthorizationStorage

Note: storage-location: erc7201:every.storage.ObjectAuthorization

struct ObjectAuthorizationStorage {
    mapping(uint256 => GrantPointer) pointers;
    mapping(uint256 => RelationGrant) grants;
}

Enums

Direction

enum Direction {
    None,
    From,
    To
}

GrantStatus

enum GrantStatus {
    None,
    Granted,
    Revoked
}